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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PRINTIA(a,n) REP(i,n){printf("%d ", *((a)+i));}putchar('\n');
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back

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

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
void PI() {putchar('\n');}
template<typename... T>
void PI(const int head, T... tail ) {
    printf("%d ", head);
    PI(tail...);
}

#define MAX_N 100005

multiset<int> G[MAX_N];
set<int> supp;

void delete_edge(int s, int to) {
    G[s].erase(G[s].find(to));
    G[to].erase(G[to].find(s));
    if(G[s].size() == 0) {
        supp.erase(s);
    }
    if(G[to].size() == 0) {
        supp.erase(to);
    }
}

int main()
{
    int N, M;
    RI(N, M);
    REP(i, M) {
        int a, b;
        RI(a, b);
        G[a].insert(b);
        G[b].insert(a);
    }

    REP(i, 1, N+1) {
        if(G[i].size() > 0) {
            supp.insert(i);
        }
    }

    while(!supp.empty()) {
        int s = *(supp.cbegin());
        int to = *(G[s].cbegin());
        delete_edge(s, to);
        while(to != s) {
            if(G[to].size() == 0) {
                printf("NO\n");
                return 0;
            }
            int v = *(G[to].cbegin());
            delete_edge(to, v);
            to = v;
        }
    }
    printf("YES\n");
    return 0;
}


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

using namespace std;

int main() {
    int K, X;
    cin >> K >> X;

    for (int i = X - K + 1; i <= X + K - 1; ++i) {
        cout << i;
        if (i != X + K - 1) {
            cout << ' ';
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

int inverse(int a){
	return power(a, p - 2);
}

int *fact, *fact_inv;

int comb(int N, int k){
	if(k < 0 || N < k || N < 0){
		return 0;
	}
	else{
		return MOD(fact[N] * MOD(fact_inv[k] * fact_inv[N - k]));
	}
}

int E(int A, int B, int C, int a, int b, int c, int N, int M){
//	printf("(N, M) = (%lld, %lld)\n", N, M);
	int k, l, ans = 0;
	for(k = 0; k <= N; k++){
		for(l = 0; l <= M; l++){
			if((k + l) % 2 == 0){
				ans = MOD(ans + MOD(comb(N, k) * comb(M, l)) * power(MOD(power(b, N - k) + power(a, M - l) - 1), C));
			}
			else{
				ans = MOD(ans - MOD(comb(N, k) * comb(M, l)) * power(MOD(power(b, N - k) + power(a, M - l) - 1), C));
			}
		}
	}
	ans = MOD(ans * MOD((power(c, (A - N) * (B - M)) - 1) * a * b * c));
	return ans;
}

signed main(){
	int a, b, c, A, B, C, i, j;
	scanf("%lld%lld%lld%lld%lld%lld", &a, &b, &c, &A, &B, &C);
	if(A % a != 0 || B % b != 0 || C % c != 0){
		printf("0\n");
		return 0;
	}
//	swap(A, C);
//	swap(a, c);
	A /= a;
	B /= b;
	C /= c;
	fact = new int[A + B];
	fact[0] = 1;
	for(i = 1; i < A + B; i++){
		fact[i] = MOD(fact[i - 1] * i);
	}
	fact_inv = new int[A + B];
	for(i = 0; i < A + B; i++){
		fact_inv[i] = inverse(fact[i]);
	}
	int ans = 0;
	if(a > 1 && b > 1 && c > 1){
		for(i = 1; i < A; i++){
			for(j = 1; j < B; j++){
				ans = MOD(ans + MOD(MOD(comb(A, i) * comb(B, j)) * E(A, B, C, a, b, c, i, j)));
			}
		}
	}
//	printf("ans = %lld\n", ans);
	ans = MOD(ans + a * power(MOD(b * c * (power(b, C - 1) + power(c, B - 1) - 1)), A));
	ans = MOD(ans + b * power(MOD(c * a * (power(c, A - 1) + power(a, C - 1) - 1)), B));
	ans = MOD(ans + c * power(MOD(a * b * (power(a, B - 1) + power(b, A - 1) - 1)), C));
	ans = MOD(ans - a * b * power(c, A * B));
	ans = MOD(ans - b * c * power(a, B * C));
	ans = MOD(ans - c * a * power(b, C * A));
	ans = MOD(ans + a * b * c);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		100000									// 最大配列数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数
static int si1GcdL[D_ARRAY_MAX];								// 最大公約数[0からの範囲]
static int si1GcdR[D_ARRAY_MAX];								// 最大公約数[siACnt-1からの範囲]

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 最大公約数 - 取得
int
fGetGcd(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	int liWork;

	// ユークリッドの互除法
	if (piVal1 < piVal2) {
		liWork = piVal1;
		piVal1 = piVal2;
		piVal2 = liWork;
	}
	while (piVal2 > 0) {
		liWork = piVal1 % piVal2;
		piVal1 = piVal2;
		piVal2 = liWork;
	}

	return piVal1;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列 - 取得
	for (i = 0; i < siACnt; i++) {
		fscanf(szpFpI, "%d", &si1Array[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 最大公約数 - セット
	si1GcdL[0] = si1Array[0];
	for (i = 1; i < siACnt - 1; i++) {
		si1GcdL[i] = fGetGcd(si1GcdL[i - 1], si1Array[i]);
	}
	si1GcdR[siACnt - 1] = si1Array[siACnt - 1];
	for (i = siACnt - 2; i >= 1; i--) {
		si1GcdR[i] = fGetGcd(si1GcdR[i + 1], si1Array[i]);
	}

	// 最大値 - 取得 - 片側のみ
	int liMax = si1GcdL[siACnt - 2];
	if (liMax < si1GcdR[1]) {
		liMax = si1GcdR[1];
	}

	// 最大値 - 取得 - 両側
	for (i = 0; i < siACnt - 2; i++) {
		int liGcd = fGetGcd(si1GcdL[i], si1GcdR[i + 2]);
		if (liMax < liGcd) {
			liMax = liGcd;
		}
	}

	return liMax;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1Array, 0, sizeof(si1Array));						// 配列

																// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1280
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()
val A = sc.nextInt()
val B = sc.nextInt()

fun main(args: Array<String>) {
    (1..N).filter {
        sumOfDigits(it) in A..B
    }.sum().let(::println)
}

fun sumOfDigits(n0: Int): Int {
    var n = n0
    var result = 0
    while (n != 0) {
        result += n % 10
        n /= 10
    }
    return result
}


Measured memory_bytes: 29984
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let N = parseInt(input[0][0], 10);
	let M = parseInt(input[0][1], 10);
	let arr_AB = [];
	for (let i = 0; i < M; i++){
		arr_AB.push(input[i + 1].map(e => parseInt(e, 10)));
	}
	let uf = new UnionFind(N);
	for (let i = 0; i < M; i++){
		uf.union(arr_AB[i][0] - 1, arr_AB[i][1] - 1);
	}
	let ans = 0;
	for (let i = 0; i <N; i++){
		ans = Math.max(ans, uf.size(i));
	}
	console.log(ans);
}

function UnionFind (n) {
    this.parents = [];
    for (let i = 0; i < n; i++) {
        this.parents.push(-1);
    }
}
UnionFind.prototype.find = function (x) {
    if (this.parents[x] < 0) return x;
    return this.parents[x] = this.find(this.parents[x]);    
}


UnionFind.prototype.union = function (x, y) {
    x = this.find(x);
    y = this.find(y);
    if (x === y) return;
    if (this.parents[x] > this.parents[y]) [x, y] = [y, x];
    
    this.parents[x] += this.parents[y];
    this.parents[y] = x;
}


UnionFind.prototype.size = function (x) {
    x = this.find(x);
    while (x >= 0) {
        x = this.parents[x];
    }
    return x * -1;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 117200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n; cin>>n; ll arr[n];
	for(int i = 0; i < n; i++){
		cin>>arr[i];
	}
	ll cost = 0;
	ll best = 10000000;
	for(int avg = -200; avg < 200; avg++){
		cost = 0;
		for(int i = 0; i < n; i++){
			cost += (arr[i] - avg) * (arr[i] - avg);
		}
		best = min(best,cost);
	}
	cout<<best<<"\n";
}

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

long long int dp[51][2502][52];
int flag[2502][52];
int a[50];
int n;
int A;

long long int rec(int i,int j,int cnt){
    if(i==n)return 0;
    long long int ret1,ret2,ret;
    if(dp[i+1][j+a[i+1]][cnt+1]==-1)ret1=rec(i+1,j+a[i+1],cnt+1);
    else ret1=dp[i+1][j+a[i+1]][cnt+1];
    if(dp[i+1][j][cnt]==-1)ret2=rec(i+1,j,cnt);
    else ret2=dp[i+1][j][cnt];
    ret=ret1+ret2;
    if(cnt!=0&&(j/cnt)==A&&(j%cnt)==0&&!flag[j][cnt]){
        ret++;
        flag[j][cnt]=1;
    }
    return (dp[i][j][cnt]=ret);
}

int main(){
    cin>>n>>A;
    for(int i=0; i<51; i++){
        for(int j=0; j<2502; j++){
            for(int k=0; k<52; k++)dp[i][j][k]=-1;
        }
    }
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    cout<<rec(0,a[0],1)+rec(0,0,0)<<endl;
    return 0;
}


Measured memory_bytes: 52224
N,W = map(int,input().split())
WV = [[0,0]] + [list(map(int,input().split())) for _ in range(N)]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1,N+1):
  tmpw, tmpv = WV[i]
  for w in range(W+1):
    if 0<=w-tmpw:
      dp[i][w] = max(dp[i-1][w], dp[i-1][w-tmpw]+tmpv)
    else:
      dp[i][w] = dp[i-1][w]
print(max(dp[-1]))

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

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

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

    while(K>0){
        if(A>=B){
            B *= 2;
            K--;
        }else if(B>=C){
            C *= 2;
            K--;
        }
        if(A<B && B<C){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

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

using namespace std;

const int N = 19;

char a[N];
char b[N];
char c[N];

int main() {
  int na, nb;
  scanf("%s%s%d%d%s", a, b, &na, &nb, c);
  if (string(a) == string(c)) {
    --na;
  } else {
    --nb;
  }
  printf("%d %d\n", na, nb);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<string>
#include<list>
using namespace std;
typedef list<string>L;
typedef L::iterator I;
int main()
{
	char str[256];
	L l;
	while(fgets(str,256,stdin),strcmp(str,"END_OF_TEXT\n"))
	{
		str[strlen(str)-1]=0;
		l.push_back(str);
	}
	I row=l.begin(),t;
	string::iterator col=row->begin();
	string buf;
	while(fgets(str,256,stdin),*str-'-')
	{
		switch(*str)
		{
		case'a':col=row->begin();break;
		case'e':col=row->end();break;
		case'p':
			if(row!=l.begin())--row;
			col=row->begin();
			break;
		case'n':if(t=l.end(), row!=--t)++row;
			col=row->begin();
			break;
		case'f':
			if(col!=row->end())++col;
			else if(t=l.end(),row!=--t)++row,col=row->begin();
			break;
		case'b':
			if(col!=row->begin())--col;
			else if(row!=l.begin())--row,col=row->end();
			break;
		case'd':
			if(col!=row->end())col=row->erase(col);
			else if(t=l.end(),row!=--t)
			{
				t=row;
				int s=row->size();
				if(++t!=l.end())
				{
					*row+=*t;
					l.erase(t);
				}
				col=row->begin()+s;
			}
			break;
		case'k':
			if(col!=row->end())
			{
				buf=row->substr(col-row->begin());
				col=row->erase(col,row->end());
			}
			else
			{
				buf="\n";
				t=row;
				int s=row->size();
				if(++t!=l.end())
				{
					*row+=*t;
					l.erase(t);
				}
				col=row->begin()+s;
			}
			break;
		case'y':
			if(buf=="\n")
			{
				t=row;
				++t;
				string s(row->substr(col-row->begin()));
				l.insert(t,s);
				row->erase(col,row->end());
				row=--t;
				col=row->begin();
			}
			else if(!buf.empty())
			{
				int s=col-row->begin()+buf.size();
				row->insert(col-row->begin(),buf);
				col=row->begin()+s;
			}
			break;
		}
	}
	for(t=l.begin();t!=l.end();++t)printf("%s\n",t->c_str());
	return 0;
}

Measured memory_bytes: 0
/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int[][] value = new int[3][N]; // store happiness for each activity for each day
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                value[j][i] = sc.nextInt();
            }
        }

        int[][] dp = new int[3][N];
        // dp[x][i] stores the max happiness by this day, having done activity x on the ith day
        for (int activity = 0; activity < 3; activity++) {
            dp[activity][0] = value[activity][0];
        }
        for (int day = 1; day < N; day++) {
            // For each daily activity,
            for (int curr = 0; curr < 3; curr++) {
                // pick an activity different from today,
                for (int prev = 0; prev < 3; prev++) {
                    if (prev == curr) continue;
                    // and maximize the happiness to reach the state of this day and this activity
                    dp[curr][day] = Math.max(dp[curr][day], value[curr][day] + dp[prev][day - 1]);
                }
//                System.out.println("Day: " + day + " Curr: " + curr + Arrays.toString(dp[curr]));
            }
        }
        int best = 0;
        for (int activity = 0; activity < 3; activity++) {
            best = Math.max(best, dp[activity][N - 1]);
        }
        out.println(best);
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException { return br.readLine(); }

        double nextDouble() throws IOException { return Double.parseDouble(next()); }

        int nextInt() throws IOException { return Integer.parseInt(next()); }

        long nextLong() throws IOException { return Long.parseLong(next()); }
    }
}

Measured memory_bytes: 45276
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
ll n, k;
const int Div = 1e9 + 7;
int main() {
    cin >> n >> k;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];

    int in = 0, between = 0;
    rep(i,n) rep(j,n) {
      if (v[i] > v[j]) {
        between++;
        if (i < j) in++;
      }
    } 
    ll ans = 0;
    ans += (in*k) % Div;
    ans += (k*(k-1)/2%Div) * between;
    ans %= Div;
    cout << ans << endl;
    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

const ll MOD = 998244353;

typedef vector<vi> mat;

int get_rank(mat A) //mod 2
{
	const int n = A.size(), m = A[0].size();
	int r = 0;
	for (int i = 0; r < n && i < m; ++i) {
		int pivot = r;
		for (int j = r+1; j < n; ++j) {
			if (A[j][i]) {
				pivot = j;
				break;
			}
		}
		swap(A[pivot], A[r]);
		if (A[r][i] == 0) continue;
		for (int j = r+1; j < n; ++j) {
			if (A[j][i]) {
				for (int k = i; k < m; ++k) {
					A[j][k] ^= A[r][k];
				}       
			}
		}
		++r;
	}
	return r;
}

int main() {
	int N, M;
	cin >> N >> M;
	mat A(N, vi(M));

	rep(i, N) {
		rep(j, M) {
			cin >> A[i][j];
		}
	}

	int r = get_rank(A);

	ll all = 1, dec = 1;
	rep(i, N+M-1) all = all * 2 % MOD;
	rep(i, N+M-r-1) dec = dec * 2 % MOD;
	cout << (all - dec + MOD) % MOD << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//const ll MOD=(ll)1e9+7;
const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};


void solve(int ca){
    ll N; cin>>N;
    string ans="";
    bool f= true;
    if(N==1){
        cout<<'a'<<endl;
        return;
    }
    if(N==2){
        cout<<'b'<<endl;
        return;
    }
    while(N>0){
        //cout<<N<<endl;
        char tmp='a'+((N-1)%26);

        /*
        if(f){
            ans+=tmp;
            f= false;
        }
        else {
            if(tmp=='a') tmp='z';
            else tmp--;
            //tmp--;
            ans+=tmp;
        }
         */
        ans+=tmp;
        N=(N-1)/26;
    }
    reverse(ans.begin(),ans.end());
    //if(ans.length()>1&& ans)
        cout<<ans<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<double,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

char s[401][401];

int main(){
    int h,w,k;cin >> h >> w >> k;
    int cnt = 0;
    vector<vector<int>> ans(h,vector<int> (w,0));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
            if(s[i][j]=='#'){
                cnt++;
                ans[i][j] = cnt;
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w-1; j++) {
            if(ans[i][j+1] == 0){
                ans[i][j+1] = ans[i][j];
            }
        }
        for (int j = w-1; j >= 1; j--) {
            if(ans[i][j-1] == 0){
                ans[i][j-1] = ans[i][j];
            }
        }
    }
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h-1; j++) {
            if(ans[j+1][i] == 0){
                ans[j+1][i] = ans[j][i];
            }
        }
        for (int j = h-1; j >= 1; j--) {
            if(ans[j-1][i] == 0){
                ans[j-1][i] = ans[j][i];
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ans[i][j] << (j==w-1?"\n":" ");
        }
    }
    return 0;
}


Measured memory_bytes: 1280
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
s=is1()
ss=is1()
n=len(s)
count=0
for i in range(n):
    if s[i]!=ss[i]:
        count+=1
print(count)



Measured memory_bytes: 9680
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = n-1; i > 0; i--)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n,k;cin>>n>>k;
  cout<<(n-1+k-2)/(k-1)<<endl;
  return false;
}


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    long array[] = new long[num];
    for(int i = 0;i < num;i++){
      array[i] = sc.nextLong();
    }
    long count = 0;
    for(int i = 0;i < num - 2;i++){
      for(int j = i + 1;j < num - 1;j++){
        for(int k = j + 1;k < num;k++){
          long a = array[i];
          long b = array[j];
          long c = array[k];
          long sum = a + b + c;
          if(a != b && b != c && c != a){
            long max = Math.max(a,Math.max(b,c));
            if(max < sum - max){
              count++;
            }
          }
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 36588
#include <stdio.h>
int main(void) {
long long int a,b,c,d,e,f,g,h,z;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
e=a*c;
f=a*d;
g=b*c;
h=b*d;
z=e;
if(z<f)
z=f;
if(z<g)
z=g;
if(z<h)
z=h;
printf("%lld",z);
return 0;
}


Measured memory_bytes: 1732
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a_s = [0] * (len(A)+1)
b_s = [0] * (len(B)+1)
for i in range(len(A)):
    a_s[i+1] = a_s[i] + A[i]
for i in range(len(B)):
    b_s[i + 1] = b_s[i] + B[i]

ans = 0
j = M
for i in range(len(a_s)):
    if a_s[i] > K:
        break
    while b_s[j] + a_s[i] > K:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cout << 6- in() - in() << "\n";
}

Measured memory_bytes: 256
// C - Chocolate Bar
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);++i)

ll check1(int Y, int X){//"||||"
	ll s1,s2,s3;
	ll minDiff = LLONG_MAX;
	ll e = (X+3-1)/3;
	for(ll x1=1; x1<=e; ++x1){
		ll x2 = (X-x1)/2;
		ll x3 = X - x1 - (X-x1)/2;
		s1 = Y * x1;
		s2 = Y * x2;
		s3 = Y * x3;
		ll diff = max({s1, s2, s3}) - min({s1, s2, s3});
		minDiff = min(minDiff, diff);
	}
	return minDiff;
}

ll check2(int Y, int X){//"T"
	ll s1,s2,s3;
	ll minDiff = LLONG_MAX;
	for(ll y1=1; y1<=Y-1; ++y1){
		ll y2 = Y-y1;
		ll x1 = X;
		ll x2 = X/2;
		ll x3 = X-x2;
		s1 = y1 * x1;
		s2 = y2 * x2;
		s3 = y2 * x3;
		ll diff = max({s1, s2, s3}) - min({s1, s2, s3});
		minDiff = min(minDiff, diff);
	}
	return minDiff;
}

int main(){
	int H,W; cin>>H>>W;
	ll ans = LLONG_MAX;
	ans = min({ans, check1(H, W), check1(W, H)});
	ans = min({ans, check2(H, W), check2(W, H)});
	cout<< ans <<endl;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  map<pair<int, int>, int> m;
  int64_t ans = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    int64_t a = stoi(s);
    int64_t b = 1;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == '.') {
        for (int j = i + 1; j < s.size(); ++j) {
          b = b * 10;
          a = a * 10 + s[j] - '0';
        }
        break;
      }
    }
    while (a % 2 == 0 && b % 2 == 0) a /= 2, b /= 2;
    while (a % 5 == 0 && b % 5 == 0) a /= 5, b /= 5;

    int x = 0, y = 0;
    while (a % 2 == 0) x++, a /= 2;
    while (a % 5 == 0) y++, a /= 5;
    while (b % 2 == 0) x--, b /= 2;
    while (b % 5 == 0) y--, b /= 5;

    for (auto &it : m) {
      if (x + it.first.first >= 0 && y + it.first.second >= 0) ans += it.second;
    }
    m[{x, y}]++;
  }
  cout << ans << endl;
  return 0;
}



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

const long long INF = 1LL<<60;

long long dp[100010];

int main() {
    int n,k;
    cin >> n >> k;
    vector<long long> h(n);
    for(int i = 0; i < n; i++)
    {
        cin >> h.at(i);
    }
    for(int i = 0; i < 100010; i++)
    {
        dp[i] = INF;
    }
    
    dp[0] = 0;
    for(int i = 1; i < n; i++)
    {
        for (int j = 1; j <= min(i, k); j++) {
            dp[i] = min(dp[i], (dp[i - j] + abs(h.at(i - j) - h.at(i))));
        }
    }

    cout << dp[n - 1] << endl;
}

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
        ll a, b, c, n; cin >> a >> b >> c >> n;
        if (n % 2 == 0)
        {
                cout << a - b << endl;
        }
        else
        {
                cout << -(a - b) << endl;
        }
        
}

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


Measured memory_bytes: 3596
#include <iostream>

int main(){
    long long a,b,c;
    std::cin >> a >> b >> c;
    long long x = c - a - b;
    if(x < 0){
        std::cout << "No";
        return 0;
    }
    std::cout << (4 * a * b < x * x?"Yes":"No");
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(all(p));
  reverse(all(p));
  int ans = p[0] / 2;
  for(int i = 1; i < n; i++) ans += p[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 21, mod = 1000000007;

template <class T1, class T2> inline void addMod(T1& a, T2 b)	{   a = (a + b) % mod;  }
template <class T1, class T2> inline void multMod(T1& a, T2 b)	{   a = a * b % mod;    }

long long qpow(long long a, long long b)
{
    long long res0 = 1;
    for (; b!=0; b>>=1)
    {
        if (b & 1)  multMod(res0, a);
        multMod(a, a);
    }
    return res0;
}

int apd[maxN], ile[maxN];
long long F[maxN];
vector <int> bezkw;

void sito()
{
	FOR(i, 2, maxN)
		apd[i] = i;
	for (int i=2; i*i<maxN; i++)
		if (apd[i] == i)
			for (int j=i*i; j<maxN; j+=i)
				apd[j] = i;
				
	FOR(i, 2, maxN)
	{
		int p = apd[i], j = i / p;
		if (j % p == 0 or ile[j] == -1)
			ile[i] = -1;
		else
			ile[i] = ile[j]+1, bezkw.pb(i);
	}
}

void solve()
{
	sito();
	int n, k;
	scanf ("%d%d", &n, &k);
	long long res = 0;
	
	FOR(g, 1, k+1)
		F[g] = qpow(k / g, n);
	
	FOR(g, 1, k+1)
	{
		long long temp = F[g];
		for (int v : bezkw)
		{
			if (1ll * g * v > k)
				break;
			
			addMod(temp, F[v * g] * (ile[v] % 2 == 1 ? -1 : 1));
		}
		
		multMod(temp, g);
		addMod(res, temp);
	}
	
	printf("%lld\n", res);
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}



Measured memory_bytes: 26452
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int i = Integer.parseInt(in.next() + in.next());
        for (int j = 0; j < 1000; j++) {
            if (j*j > i) {
                out.println("No");
                return;
            }
            if (j*j == i) {
                out.println("Yes");
                return;
            }
        }
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

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



int main(void) {
	int  a, b, aplace, bplace, fvalue = 100000000;
	int64_t num;
	cin >> num;

	for (int i = 1; i <= sqrt(num); i++) {
		if (num % i == 0) {
			a = i; b = num / i;
			aplace = 0; bplace = 0;
			while (a) { a /= 10; aplace++; }
			while (b) { b /= 10; bplace++; }
			if (aplace < bplace) { if (bplace < fvalue) fvalue = bplace; }
			else { if (aplace < fvalue) fvalue = aplace; }
		}
	}

	cout << fvalue << endl;
	return 0;

}


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

int dp[10][10];

void warshall() {
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
}

int main() {
    int H, W; cin >> H >> W;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> dp[i][j];
        }
    }
    warshall();
    int ans = 0;
    for (int i = 0; i < H*W; i++) {
        int x; cin >> x;
        if (x == -1) {
            continue;
        } else {
            ans += dp[x][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

int main(){
    ll a,b;
    ll ans;
    cin>>a>>b;
    b=min(b,a+2019);
    ans=2018;
    for(ll i=a;i<b;i++){
        for(ll k=i+1;k<=b;k++){
            ans=min(ans,i*k%2019);
        }
    }
   cout<<ans<<endl;
}


Measured memory_bytes: 3616
# import sys
# import math
import itertools
from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007


def bfs(s, N, edge):
    d = [-1 for _ in range(N)]
    d[s] = 0
    q = deque()
    q.append(s)

    while q:
        v = q.popleft()
        edgelist = edge[v]
        for e in edgelist:
            if d[e] == -1:
                d[e] = d[v] + 1
                q.append(e)

    return d


def main():

    N, X, Y = map(int, input().split())

    edge = [[] for _ in range(N)]
    for i in range(N - 1):
        edge[i].append(i + 1)
        edge[i + 1].append(i)

    edge[X - 1].append(Y - 1)
    edge[Y - 1].append(X - 1)

    dist = [[] for _ in range(N)]
    for i in range(N):
        dist[i] = bfs(i, N, edge)

    comb = tuple(itertools.combinations(range(N), 2))
    ans = [0 for _ in range(N)]

    for c in comb:
        v1, v2 = c[0], c[1]
        ans[dist[v1][v2]] += 1

    for i in range(1, N):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 164096
from collections import Counter
import sys

def main():

    num = int(input())
    data = list(map(int, input().split()))
    count_data = Counter(data)
    mod = 10 ** 9 + 7

    if num % 2 == 1:
        if count_data[0] != 1:
            print(0)
            sys.exit()
        for i in range(1, (num // 2) + 1):
            if count_data[i * 2] != 2:
                print(0)
                sys.exit()

    else:
        for i in range(num // 2):
            if count_data[i * 2 + 1] != 2:
                print(0)
                sys.exit()

    ans = pow(2, num // 2, mod)
    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 55660
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  200005

vi BIT(2*N);
void update(ll x,ll val)
{
    for(;x<N;x+=(x&-x))
    {
        BIT[x]+=(hell+val)%hell;
        BIT[x]%=hell;
    }
}
ll query(ll x)
{
    ll res=0;
    for(;x>0;x-=(x&-x))
    {
        res+=BIT[x];
        res%=hell;
    }
    return res;
}
void solve()
{
    ll n,k;
    cin>>n>>k;
    vector<pii>v;
    rep(i,0,k)
    {
        ll x,y;
        cin>>x>>y;
        v.pb({x,y});
    }
    update(1,1);
    update(2,-1);
    ll ans=0;
    ll amx=N-1;
    rep(i,1,n+1)
    {
        ll x=query(i);
        // cout<<x<<endl;
        rep(j,0,k)
        {
            
            update(min(amx,i+v[j].F),x);
            update(min(amx,i+v[j].S+1),-x);
        }
        // rep(i,1,n+1)
        // {
        //     cout<<query(i)<<" ";
        // }
        // cout<<endl;
    }  
    cout<<query(n)<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 6228
#include<iostream>
#include<algorithm>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int K,X;
    int i;
    cin >> K >> X;

    for( i = X - K + 1; i < X + K; i++){
        cout << i << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
import sys
#from collections import deque as dq
input = sys.stdin.readline

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

def lcm(a: int, b: int):
    return a * b // gcd(a, b)


def main():
	#N,A,B = map(int, input().split())
	S = input().rstrip()
	Q = int(input())
	#vA = list(map(int, input().split()))
	#vX = [input().rstrip() for _ in [0,]*N]
	
	rev = 0		# reverse
	
	DF = "" #dq([]) # reversed Head!!
	DR = "" #dq([])
	for q in range(Q):
		tq = input().split()
		if tq[0]=="1":
			rev ^= 1
		else:
			T,F,C = tq
			if F=="1":
				# C to top
				if rev == 0:
					DF += C #DF.appendleft(C) 
				else:
					DR += C #DR.append(C)
			else:
				# C to bottom
				if rev == 0:
					DR += C #DR.append(C)
				else:
					DF += C #DF.appendleft(C)	
	
	
	if rev == False:
		res = DF[::-1] + S + DR
	else:
		res = DR[::-1] + S[::-1] + DF

	print(res)
	
if __name__ == "__main__":
    main()


Measured memory_bytes: 4408
#include <iostream>

using namespace std;

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

    int cost, sx, sy, dx, dy;
    sx = sy = 0;
    bool flag = true;
    for (int i = 0; i < n; ++i) {
        cin >> cost >> dx >> dy;
        if (!flag) continue;
        int diff = (dx - sx) + (dy - sy);
        if (diff > cost) {
            flag = false;
            continue;
        }

        if ((cost - diff )% 2 != 0) {
            flag = false;
            continue;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 888
#include<iostream>

using namespace std;

int main(){
  int N, H, W, A[1000], B[1000];
  cin >> N >> H >> W;
  int count = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
    if(A[i] >= H && B[i] >= W) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int s,k,cnt;
int main(){
	ios::sync_with_stdio;
	cin>>k>>s;
	for(int i=0;i<=k;i++)
		for(int j=0;j<=k;j++){
			int l=s-i-j;
			if(l<=k&&l>=0)cnt++;
		}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

void End(int t, int r, int a, int o){
    printf("%d %d %d %d\n", t, r, a, o);
}

int Check(int x, int y, int z){
    int max, min1, min2;
    if(x>=y && x>=z){
        max=x;
        min1=y;
        min2=z;
    }
    else if(y>=z && y>=x){
        max=y;
        min1=x;
        min2=z;
    }
    else{
        max=z;
        min1=x;
        min2=y;
    }

    if(pow(max, 2)<(pow(min1, 2)+pow(min2, 2))) return 1; //Acute Triangle
    
    else if(pow(max, 2)==(pow(min1, 2)+pow(min2, 2)))    return 2; //Right Triangle
    
    else    return 3;  //Obtuse Triangle
}


int main(void){
    
    int a, b, c, A_num=0, O_num=0, R_num=0, T_num=0;
    while(1){
        scanf("%d %d %d", &a, &b, &c);
    
        if(a >= b+c || b >= c+a || c >= a+b){
            End(T_num, R_num, A_num, O_num);
            break;
        }
        else{
            T_num++;
            if(Check(a, b, c)==1) A_num++;
            else if(Check(a, b, c)==2) R_num++;
            else if(Check(a, b, c)==3) O_num++;
        }
    }
    return 0;
}



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

int main(){
  int X,Y,Z;
  cin >>X>>Y>>Z;
  
  int ans = X/(Y+Z);
  if(X%(Y+Z)<Z) ans--; 
  
  cout <<ans<< endl;
}

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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(62, 0);
    REP(i, n) {
        cin >> a[i];
        REP(j, 62) b[j] += ((a[i] & (1LL << j)) == 0 ? 0 : 1);
    }
    ll ans = 0;
    REP(i, n - 1) {
        REP(j, 62) if (b[j] > 0) b[j] -= ((a[i] & (1LL << j)) == 0 ? 0 : 1);
        ll x = 0;
        REP(j, 62) {
            if ((a[i] & (1LL << j)) == 0) {
                x += (b[j] * ((1LL << j) % MOD)) % MOD;
                x %= MOD;
            } else {
                x += (((n - i - 1) - b[j]) * ((1LL << j) % MOD)) % MOD;
                x %= MOD;
            }
        }
        ans += x;
        ans %= MOD;
    }
    cout << ans << EOL;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(){
	char ch;

	while(true)
	{
	    int sum = 0;
		while((ch = getchar()) != '\n'){
			sum += ch - '0';
		}
		if(sum == 0)
			break;
		else{
			printf("%d\n",sum);
		}
	}
}


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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
ll INF=1e18+10;
ll MOD=1e9+7;

const int N=1e5+2;
vector <int> adj[N];
bool vis[N];
ll ways[N],k;

void dfs(int v,int level)
{
    vis[v]=true;
    if(level==0)
        ways[v]=k;
    int i= (level == 0) ? 1 : 2;
    for(auto to : adj[v])
    {
        if(!vis[to])
        {
            ways[to]=k-i;
            i++;
            dfs(to,level+1);
        }
    }
}

int main()
{
    int n;
    cin>>n>>k;
    rep(i,0,n-1)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    dfs(1,0);

    ll way=1;
    rep(i,1,n+1)
    way=(way*ways[i])%MOD;

    cout<<way;
}


Measured memory_bytes: 10112
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
#include <queue>
using namespace std;

const long long INF = 1000000000;

void chmin(int &a, int b) { if(a > b) a = b;}

int mypow(int a, int b){
	if(b == 0) return 1;
	if(b == 1) return a;
	if(b == 2) return a * a;
	if(b%2 == 0) return mypow(mypow(a, b/2), 2);
	return a * mypow(a, b-1);
}

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

	const int num = 100100;
	int	dp[num];

	for(int i = 0; i < num; i++){
		dp[i] = INF;
	}
	dp[0] = 0;

	for(int i = 1; i < num; i++){
		int tmp1 = i;
		while(true){
			if(tmp1 == 1) chmin(dp[i], 1);
			if(tmp1%6 == 0) tmp1 /= 6;
			else break;
		}
		int tmp2 = i;
		while(true){
			if(tmp2 == 1) chmin(dp[i], 1);
			if(tmp2%9 == 0) tmp2 /= 9;
			else break;
		}
		for(int j = 1; j < i/2 + 1; j++){
			chmin(dp[i], dp[j] + dp[i-j]);
		}
	}

	cout << dp[N] << endl;

    
}

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

int main()
{
	string S, T;
	cin >> S >> T;
	sort(S.begin(), S.end());
	sort(T.rbegin(), T.rend());
	if ( S < T ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return ( 0 );
}


Measured memory_bytes: 256