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

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

    int h, w, black = 0;
    cin >> h >> w;

    int D[h][w];
    vector<string> S(h);
    for(int i = 0; i < h; i++){
        cin >> S[i];
        for(int j = 0; j < w; j++){
            black += (S[i][j] == '#');
            D[i][j] = 1e9;
        }
    }

    D[0][0] = 1;
    int dx[4] = {-1, 1, 0, 0};
    int dy[4] = {0, 0, -1, 1};

    queue<pair<int, int>> q;
    q.push({0, 0});
    while(!(q.empty())){
        pair<int, int> tmp = q.front();
        q.pop();
        int x = tmp.first;
        int y = tmp.second;
        for(int i = 0; i < 4; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 or ny < 0 or nx >= h or ny >= w){
                continue;
            }
            if(S[nx][ny] == '.' and D[x][y] + 1 < D[nx][ny]){
                D[nx][ny] = D[x][y] + 1;
                q.push({nx, ny});
            }
        }
    }

    if(D[h - 1][w - 1] == 1e9){
        cout << -1 << endl;
    }else{
        cout << h * w - (black + D[h - 1][w - 1]) << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int _abs(int num) {
	if(num > 0) return num;
	return -num;
}
 
int main(void) {
	int N, X, Y;
	int d;
	int num[2000] = {0};
	
	int i,j;
	
    scanf("%d %d %d", &N, &X, &Y);
	
	X--;
	Y--;

	for(i = 0; i < N - 1; i++) {
		for(j = i+1; j < N; j++) {
			d = j - i;
			
			if( (_abs(i - X) + 1 + _abs(j - Y)) < d ) {
				d = _abs(i - X) + 1 + _abs(j - Y);
			}
			if( (_abs(i - Y) + 1 + _abs(j - X)) < d ) {
				d = _abs(i - X) + 1 + _abs(j - Y);
			}
			
			num[d - 1]++;
		}
	}

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void)
{
    int N, H, max = 0, count = 0;
    
    cin >> N;
    
    rep (i, N)
    {
        cin >> H;
        if (max <= H)
        {
            count++;
            max = H;
        }
    }
    
    cout << count << endl;
}


Measured memory_bytes: 256
def hit(n, m, goal, d, dans)
  h = 0
  until h == d
    yoko = dans[h]
    if m != n - 1 and yoko[m] == 1
      m += 1
    elsif m.nonzero? and yoko[m - 1] == 1
      m -= 1
    end
    h += 1
  end
  goal == m
end

until (n = $<.gets.to_i).zero?
  m    = $<.gets.to_i - 1
  goal = $<.gets.to_i - 1
  d    = $<.gets.to_i
  dans = Array.new(d) { $<.gets.chomp.chars.map(&:to_i) }
  output = if hit(n, m, goal, d, dans)
    0
  else
    result = catch(:jump) do
      d.times do |h|
        (n - 1).times do |x|
          f = [-1, 0, 1].map do |dx|
            a = dans[h][x + dx]
            a ? a.zero? : nil
          end.compact.all?
          if f
            dans[h][x] = 1
            throw(:jump, [h + 1, x + 1]) if hit(n, m, goal, d, dans)
            dans[h][x] = 0
          end
        end
      end
      result = false
    end
    result ? "#{result[0]} #{result[1]}" : 1
  end
  puts output
end



Measured memory_bytes: 6880
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solveA(args);
//		solveB(args);
//		solveC(args);
//		solveD(args);
//		solveE(args);
//		solveF(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		int N= nextInt();
		int ans = 0;
		for(int i=1;i<11;i++) {
			if(i*1000-N>=0) {
				pw.println(i*1000-N);
				return;
			}
		}

	}
	public static void solveB(String[] args) throws Exception{

	}
	public static void solveC(String[] args) throws Exception{

	}
	public static void solveD(String[] args) throws Exception{

	}

	public static void solveE(String[] args) throws Exception{

	}

	public static void solveF(String[] args) throws Exception{

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25400
#include<stdio.h>
int gcd(int x,int y){
    if(x<y){
        int tmp;
        tmp=y;
        y=x;
        x=tmp;
    }
    while(y>0){
        int r;
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}
int main(void){
    int x,y;
    scanf("%d %d",&x,&y);
    printf("%d\n",gcd(x,y));
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    unsigned long long x,y;
    cin >> x >> y;
    int ans=0;
    while(x<=y){
        ++ans;
        x*=2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
D = list(map(int, input().split()))
D.sort()
print(D[n//2] - D[(n//2)-1])

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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n-1; ++i)
    {
        int t;
        cin >> t;
        --t;
        v[t] += 1;
    }
    for(int i = 0; i < n; ++i)
    {
        cout << v[i] << endl;
    }
}

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

using namespace std;

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

  int n, k;
  cin >> n >> k;

  bool digits[10] = {false};

  for (int i = 0; i < k; ++i) {
    int x; cin >> x;
    digits[x] = true;
  }

  int mx_int = ~(1 << 31);
  while (n < mx_int) {
    int tmp = n;

    while (tmp) {
      if (digits[tmp % 10]) break;
      else tmp /= 10;
    }

    if (!tmp) break;
    else n++;
  }

  cout << n << "\n";
}


Measured memory_bytes: 3512
#include <iostream>

using namespace std;

int main()
{
    int k,x;

    cin>>k>>x;

    if(k==1) cout<<x;

    else
        {
            for(int i=x-k+1;i<=x+k-1;i++)
            {
                cout<<i<<" ";
            }
    }



        return 0;
}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define elif else if
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

signed main() {
    string S, T;
    cin >> S >> T;
    char D[26];
    char E[26];
    rep(i, 26) D[i] = E[i] = -1;
    rep(i, S.size()) {
        if (D[S[i] - 'a'] != -1 || E[T[i] - 'a'] != -1) {
            if (D[S[i] - 'a'] != T[i] || E[T[i] - 'a'] != S[i]) {
                cout << "No\n";
                return 0;
            }
        } else {
            D[S[i] - 'a'] = T[i];
            E[T[i] - 'a'] = S[i];
        }
    }
    cout << "Yes\n";
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a, b;
	cin >> a >> b;
	
	int ans  = 0;
	for(int i=a; i<=b; i++){
		int x[5];
		x[0] = i % 10;
		x[1] = (i/10) % 10;
		x[2] = (i/100) % 10;
		x[3] = (i/1000) % 10;
		x[4] = (i/10000) % 10;
		
		if(x[0] == x[4] && x[1] == x[3]){
			ans++;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
fn main() {
    let h: usize = read();
    let w: usize = read();
    let mut s: Vec<String> = Vec::new();
    for _i in 0..h {
        s.push(read());
    }

    for _i in 0..w + 2 {
        print!("#");
    }
    println!();
    for i in 0..h {
        print!("#");
        print!("{}", s[i]);
        print!("#");
        println!();
    }
    for _i in 0..w + 2 {
        print!("#");
    }
    println!();
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 1_000_000_007;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

pub fn factorial(n: u32) -> u32 {
    if n == 0 {
        return 1;
    }
    let mut r = n;
    for i in 0..n - 1 {
        r *= n - i - 1;
    }
    r
}

pub fn combination(n: u32, m: u32) -> u32 {
    factorial(n) / factorial(m) / factorial(n - m)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to) : from(-1), to(to), cost(-1) {}
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T,int>>> que;que.push(P(0,s));
  while(!que.empty()){
    pair<T,int> p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(make_pair(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

  int n;
signed main(){
  cin>>n;bool b = false;
  rep(i,3){
  if(n % 10 == 7){
    b = true;
  }else{
    n /= 10;
  }
  }
  cout << (b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
int N;
vint G[100];
int D[100];
const int NIL = -1;
int tt;

int main() {

	cin >> N;
	rep(i, N){
		int id, n; cin >> id >> n; id--;
		rep(j, n){
			int id_to; cin >> id_to; id_to--;
			G[id].push_back(id_to);
		}
	}

	rep(i, N){ D[i] = NIL; }

	queue<pair<int, int>> q;
	q.push(make_pair(0, 0));

	while (!q.empty()){

		pair<int, int> p = q.front(); q.pop();
		int i = p.first;
		int d = p.second;

		if (D[i] != NIL) continue; // prevent second visit

		D[i] = d;
		vint v = G[i];
		for (auto &j : v)
		{
			if (D[j] == NIL) { q.push(make_pair(j, d + 1)); }
		}
	}

	rep(i, N){
		cout << (i + 1) << " " << D[i] << endl;
	}
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<map<char,int>> d(n);
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    for(int j=0;j<s.size();j++)
      d.at(i)[s.at(j)]++;
  }
  map<char,int> m=d.at(0);
  for(auto x:m){
    char k=x.first;
    for(int i=0;i<n;i++)
      m[k]=min(m[k],d.at(i)[k]);
  }
  for(auto x:m)
    for(int i=0;i<x.second;i++)
      cout<<x.first;
  cout<<endl;
}

Measured memory_bytes: 256
a,b,c = gets.chomp.split(' ').map(&:to_i)
num_of_odd = 0
arr = [[a,0],[b,0],[c,0]]
arr.each do |x|
  if x[0] % 2 != 0
    x[1] = 1
    num_of_odd += 1
  end
end
count = 0
if num_of_odd == 1#偶数に1を足す。
  count += 1
  arr.each do |x|
    if x[1] != 1
      x[0] += 1
    end
  end
elsif num_of_odd == 2#奇数に1を足す。
  count += 1
  arr.each do |x|
    if x[1] == 1
      x[0] += 1
    end
  end
end
nums = [arr[0][0],arr[1][0],arr[2][0]] 
max = nums.max
nums.each do |num|
  while max - num > 0
    count += 1
    num += 2
  end
end 
puts count

Measured memory_bytes: 14268
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main(void){
    int n,d,i,j,k,ans=0;
    cin >> n >> d;
    vector<vector<int>>a(n,vector<int>(d));
    for(i=0;i<n;i++){
        for(j=0;j<d;j++) cin >> a[i][j];
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            int sum=0;
            for(k=0;k<d;k++){
                int tmp = abs(a[i][k]-a[j][k]);
                sum+=tmp*tmp;
            }
            for(k=0;k<=sum;k++){
                if(k*k==sum) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
stones = list(input())

W_sum = stones.count('W')
R_sum = stones.count('R')

ans = min(W_sum, R_sum)
Wnum = 0
Rnum = 0
for i in range(n):
    if stones[i] == 'W':
        Wnum += 1
    else:
        Rnum += 1
    ans = min(ans, max(Wnum, R_sum - Rnum))

print(ans)

Measured memory_bytes: 10772
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(X: int):
    if X >= 30:
        ret = YES
    else:
        ret = NO
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61852
#include<bits/stdc++.h>
 using namespace std;
 
 // #define  int           long long
 #define pb                push_back
 #define ppb               pop_back
 #define pf                push_front
 #define ppf               pop_front
 #define all(x)            (x).begin(),(x).end()
 #define uniq(v)           (v).erase(unique(all(v)),(v).end())
 #define sz(x)             (int)((x).size())
 #define fr                first
 #define sc                second
 #define pint              pair<int,int>
 #define rep(i,a,b)        for(int i=a;i<b;i++)
 #define mem1(a)           memset(a,-1,sizeof(a))
 #define mem0(a)           memset(a,0,sizeof(a))
 #define ppc               __builtin_popcount
 #define ppcll             __builtin_popcountll
 #define vint			   vector<int>
 #define vpint			   vector<pair<int,int>>
 #define mp                make_pair


 void reader() 
 { 
 #ifndef ONLINE_JUDGE 
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout); 
 #endif
 }
 
 void fastIO() {ios_base::sync_with_stdio(false); cin.tie(NULL);}
 
 
 
 void solve()
 {
 
 int n,x,t;
 cin>>n>>x>>t;
 n=ceil(n/(float)x);
 cout<<n*t;
 
 
 cout<<"\n";
 }
 
 
 
 signed main()
 {
 	reader(); fastIO();
 	long long t=1;
 	//cin>>t;
 	while(t--) solve();
 	return 0;
 }

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

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 

vector<vector<int>> adj,parent;
int n;
vi ans,dp;
vector<bool> visited;

void dfs(int v) {
    visited[v] = true;
    for (int u : adj[v]) {
        if (!visited[u])
            dfs(u);
    }
    ans.push_back(v);
}

void topological_sort() {
    visited.assign(n, false);
    ans.clear();
    for (int i = 0; i < n; ++i) {
        if (!visited[i])
            dfs(i);
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    int m,a,b;
    cin >> n >> m;
    adj.assign(n,vector<int>());
    rep(i,n-1+m) {
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
    }
    topological_sort();
    dp.assign(n,-1);
    for (int v: ans) {
        for (int u: adj[v]) {
            if (dp[u]==-1) {
                dp[u] = v;
            }
        }
    }
    rep(i,n) {
        cout << (dp[i])+1 << '\n';
    }
    return 0;

    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


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

    ll sum = 0;
    rep(i, 1, n + 1) {
        if (i % 3 && i % 5)
            sum += i;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3640
//package com.company;

import java.io.*;
import java.util.*;

public class Main {
    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            long S = sc.nextLong();
            long sqS = (long) Math.sqrt(S);
            long x1 = 0, y1 = 0;
            long x2 = Math.min(1_000_000_000, sqS + 1), y3 = sqS;
            while (x2 * y3 < S) y3++;
            long diff = x2 * y3 - S;
            long y2 = diff, x3 = 1;
            pw.println(x1 + " " + y1 + " " + x2 + " " + y2 + " " + x3 + " " + y3);
        }
    }

    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("input"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("output"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.err.println("Memory increased: " + (usedMemoryAfter - usedMemoryBefore) / 1000000);
        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

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

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

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

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

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

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
 
using namespace std;
 
int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i=0; i<N; i++) {
        for (int j=0; j<D; j++) {
            cin >> X[i][j];
        }
    }

    int answer = 0;
    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            int yij = 0;
            for (int k=0; k<D; k++) {
                int diff = abs(X[i][k] - X[j][k]);
                yij += diff * diff;
            }

            bool check = false;
            for (int k=0; k<=yij; k++) {
                if (k*k == yij) {
                    check = true;
                }
            }
            if (check) {
                answer++;
            }
        }
    }
    cout << answer;
 
    return 0;
};

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

int min( int a, int b )
{
    if( a < b )
        return a;
    else
        return b;
}

int calcDistance( int r[26][26], int s, int t, int h, int w )
{
    int sum = 0;
    for( int i = 1; i <= h; i++ )
        for( int j = 1; j <= w; j++ )
        {
            if( i != s && j != t )
                sum += r[i][j] * min( (int)fabs( i - s ), (int)fabs( j - t ) );
        }
    return sum;
}

int main()
{
    int h, w;

    cin >> h >> w;

    int road[26][26];
    for( int i = 1; i < 26; i++ )
        for( int j = 1; j < 26; j++ )
            road[i][j] = -1;

    for( int i = 1; i <= h; i++ )
        for( int j = w; j >= 1; j-- )
            cin >> road[i][j];
    
    int m = 10000000;
    for( int i = 1; i <= h; i++ )
        for( int j = 1; j <= w; j++ )
        {
            int x = calcDistance( road, i, j, h, w );
            if( m > x )
                m = x;
        }

    cout << m << endl;

    return 0;

}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc165/abc165_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int N, M, Q;
ll ans = 0;
vector<int> buf(0);
vector<int> a(0);
vector<int> b(0);
vector<int> c(0);
vector<int> d(0);

void dfs(int i, const int range_start, const int range_end) {
  if (i == N) {
    // 全桁埋めたので判定
    // rep(l, N) { cout << buf[l] << " "; }
    // cout << endl;

    ll tmpans = 0;
    rep(i, Q) {
      if (buf[b[i]] - buf[a[i]] == c[i]) tmpans += d[i];
    }
    ans = max(tmpans, ans);
  } else {
    repi(j, range_start, range_end + 1) {
      if (i != 0 && buf[i - 1] > j) continue;
      buf[i] = j;
      dfs(i + 1, range_start, range_end);
    }
  }
}

/**
 * https://www.hamayanhamayan.com/entry/2020/05/02/225726
 * 重複順列 dfsによる全探索(全列挙)
 * 必要ない箇所は探索しないことを枝刈りという
 * #dfs #全探索 #枝刈り
 */
int main() {
  INPUT_FILE CIN_OPTIMIZE;

  cin >> N >> M >> Q;

  buf.resize(N);
  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  rep(i, Q) {
    int _a, _b;
    cin >> _a >> _b >> c[i] >> d[i];
    _a--;
    _b--;
    a[i] = _a;
    b[i] = _b;
  }

  dfs(0, 1, M);
  cout << ans << endl;
}

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

using namespace std;

void solve() {
  int k, n;
  cin >> n >> k;
  vector<int> vals(n);
  for (int i = 0; i < n; ++i) {
    cin >> vals[i];
  }

  int64_t sum = 0;
  int64_t max_sum = 0;

  for (int i = 0; i < n; ++i) {
    sum += vals[i];
    if (k <= i) {
      sum -= vals[i - k];
    }
    max_sum = max(max_sum, sum);
  }

  auto res = (max_sum + k) / 2.;
  cout << setprecision(19) << res << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 1024
#####

import numpy as np
from numpy import newaxis, float32, float64, int32, int64, int16, int8, uint8, uint32, complex64, complex128

#####

def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs



def main(inputs):
	n,p=getIntList(inputs[0])
	s=inputs[1][0]
	
	ans=0
	if p%2==0 or p%5==0:
		for i0 in range(len(s)-1,-1,-1):
			sub=int(s[i0:i0+1])
			if sub%p==0:
				ans+=i0+1
	else:
		numP0=np.zeros(p, int32)
		numP0[0]=1
		r=0
		modD=int(1%p)
		for i0 in range(len(s)-1,-1,-1):
			
			sub=s[i0:i0+1]
			sub=int(sub)
			sub=r+sub*modD
			r=sub%p
			ans+=numP0[r]
			numP0[r]+=1
			modD=int((modD*10)%p)
	print(ans)
		
	

if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)
	

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

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


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

int n;
vector<int> p, q;

int main() {
    cin >> n;
    p.assign(n, 0);
    q.assign(n, 0);
    iota(q.begin(), q.end(), 1);
    for(int i = 0; i < n; i++)  cin >> p[i];

    int diff = 0;
    for(int i = 0; i < n; i++) {
        if(p[i] != q[i])  diff++;
    }
    if(diff == 0 || diff == 2)  cout << "YES" << endl;
    else                        cout << "NO" << endl;
}

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

int main() {
  int N;

  // 変数Nで入力を受け取る
  cin >> N;
  
  double a;
  
  if (N%2==0) {
  a = N / 2;
}
else {
  a = N / 2 + 1;
}


    
   double kakuritu = a / N;

  cout << kakuritu << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
const int MX = 100005;
 
int main(){
  int n;
  cin >> n;
  int ans;
  if(n % 1000 == 0){
    cout << 0 << endl;
  }else{
    ans = 1000 - n % 1000;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        boolean judge = (a <= c && c <= b) || b <= c && c <= a;
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include <cstdio>

using namespace std;

const int INF = 1000;

int n, m;
int ct[101], ch[101];
int tsum, hsum;

int main() {
  while (true) {
    scanf("%d %d", &n, &m);
    if (n == 0 && m == 0) break;
    tsum = hsum = 0;
    for (int i=0;i<n;i++) { scanf("%d", &ct[i]); tsum += ct[i]; }
    for (int i=0;i<m;i++) { scanf("%d", &ch[i]); hsum += ch[i]; }
    int min_t, min_h, min_sum = INF;
    for (int i=0;i<n;i++) {
      for (int j=0;j<m;j++) {
        if (tsum-ct[i]+ch[j] == hsum+ct[i]-ch[j]) {
          if (min_sum > ct[i]+ch[j]) {
            min_t = ct[i];
            min_h = ch[j];
            min_sum = ct[i]+ch[j];
          }
        }
      }
    }
    if (min_sum == INF) puts("-1");
    else printf("%d %d\n", min_t, min_h);
  }
  return 0;
}

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

int Solve(int a, int b, int c, int d) {
  int r = min(d, b) - max(a, c);
  return max(0, r);
}

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << Solve(a, b, c, d) << "\n";
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <map>
#include <string>
#include <cmath>
#include <queue>
#include <ctime>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 10;

vector<ll> vec;
ll q;
bool used[SIZE];

int main() {
    fastInp;

    ll n, k;
    cin >> n >> k;
    vec.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> vec[i];
        vec[i]--;
    }

    ll ind = 0, cnt = 0, cnt2 = 0;
    while (true) {
        used[ind] = 1;
        cnt++;

        ind = vec[ind];

        if (cnt >= k) {
            cout << ind + 1;
            return 0;
        }
        if (used[ind]) {
            k -= cnt;
            ll nd = ind;
            ind = vec[ind];
            cnt2++;
            while (ind != nd) {
                ind = vec[ind];
                cnt2++;
            }

            k %= cnt2;

            while (k > 0) {
                ind = vec[ind];
                k--;
            }

            cout << ind + 1;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4976
#include <iostream>
#include <cmath>

bool canTalk(int a, int b, int c, int d) {
    // Check if a and c can communicate directly
    if (std::abs(a - c) <= d) {
        return true;
    }
    // Check if they can communicate through b
    if (std::abs(a - b) <= d && std::abs(b - c) <= d) {
        return true;
    }
    return false;
}

int main() {
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    std::cout << (canTalk(a, b, c, d) ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
 
 
 
 
 
 
 





int dp[1005][5005];
int main()
{
     int n,m;
     cin>>n>>m;
     vector<int> b(m,0);
     vector<int> cost(m);
     for(int i=0;i<m;i++){
          cin>>cost[i];
          int x;cin>>x;
          for(int j=0;j<x;j++){
               int y;cin>>y;
               b[i]|=(1<<(y-1));
          }
     }
     for(int i=0;i<=1000;i++){
          for(int j=0;j<=5000;j++)
          dp[i][j]=INT_MAX;
     }
     dp[0][0]=0;
     for(int i=0;i<m;i++){
          for(int j=0;j<(1<<n);j++){
               if(dp[i][j-(j&b[i])]!=INT_MAX)
               {dp[i+1][j]=dp[i][j-(j&b[i])]+cost[i];}
               dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
          }
          cout<<"\n";
     }
     int x=(1<<n)-1;
     if(dp[m][x]==INT_MAX)cout<<-1;
     else cout<<dp[m][x];
     
}
































Measured memory_bytes: 23152
#include <string.h>
#include <iostream>
using namespace std;

int main() {
  int N;
  string r;
  cin >> N >> r;
  if (N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  for (int i = 0; i < N / 2; i++) {
    if (r[i] != r[N / 2 + i]) {
      cout << "No" << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#define max 2000001
#define vmax 10000
using namespace std;

int main()
{
	unsigned short *a,*b;
	
	int c[vmax+1];
	int n,i,j;
	scanf("%d",&n);
	
	memset(c,0,sizeof(c));
	a=(unsigned short *)malloc(sizeof(short)*n+1);
	b=(unsigned short *)malloc(sizeof(short)*n+1);
	for(i=0;i<n;i++)
	{
		scanf("%hu",&a[i+1]);
		c[a[i+1]]++;
	}
	for(i=1;i<=vmax;i++)
	    c[i]=c[i]+c[i-1];
	for(j=1;j<=n;j++)
	{
		b[c[a[j]]]=a[j];
		c[a[j]]--;
	}
	for(i=1;i<=n;i++)
	{
		if(i>1) printf(" ");
		printf("%hu",b[i]);
	}
	printf("\n");
	return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

int32_t main() {

    string s; cin >> s;
    int n = s.length();
    
    vector<int> ans(n);

    int cur = 0;
    while(cur < n) {
        int prev = cur;
        while(s[cur] == 'R') cur++;
        int left = cur-prev;
        while(s[cur] == 'L') cur++;
        int right = cur-prev-left;
        ans[left+prev-1] = left/2 + left%2 + right/2;
        ans[left+prev] = right/2 + right%2 + left/2;
    }

    for(int i = 0; i < n; ++i) {
        cout << ans[i] << " ";
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 1024
from math import asin, atan2, cos, sin, sqrt
from typing import List, Tuple


def tangent_point(circle: Tuple[float, float, float],
                  point: Tuple[float, float]) -> List[Tuple[float, float]]:
    cx, cy, cr = circle
    x, y = point

    p = (cx - x) ** 2 + (cy - y) ** 2
    q = cr ** 2
    r = sqrt(p - q)

    t0 = atan2(cy - y, cx - x)
    t1 = asin(cr / sqrt(p))

    return [(x + r * cos(t0 + t1), y + r * sin(t0 + t1)),
            (x + r * cos(t0 - t1), y + r * sin(t0 - t1))]


if __name__ == '__main__':
    x, y = map(lambda x: float(x), input().split())
    cx, cy, cr = map(lambda x: float(x), input().split())

    ps = tangent_point((cx, cy, cr), (x, y))

    p1, p2 = ps
    if p1 > p2:
        p1, p2 = p2, p1

    print("{:.6f} {:.6f}".format(*p1))
    print("{:.6f} {:.6f}".format(*p2))



Measured memory_bytes: 7328
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    int A, B, C, D, E, K;
    cin >> A >> B >> C >> D >> E >> K;
    if (max(A, max(B, max(C, max(D, E)))) - min(A, min(B, min(C, min(D, E)))) > K) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

typedef pair<pair<double,int> ,pair<int,int> > ppi;
vector<pair<pair<double,int>,int> > vp[31];
int dv[]={-1,0,1};
double d[31][31][32];
double INF=1000100010;
int m,n,s,g;
double dijkstra(){
    priority_queue<ppi,vector<ppi>,greater<ppi> > pq;
    rep(i,n)rep(k,n)rep(j,32) d[i][k][j]=INF;
    d[s][s][1]=0.0;
    pq.push({{0.0,-1},{1,s}});
    while(!pq.empty()){
        ppi pi=pq.top();pq.pop();
        int t=pi.second.second;
        int u=pi.second.first;
        double cost=pi.first.first;
        if(t==g&&u==0) return cost;
        for(auto it:vp[t]){
            if(it.second==pi.first.second) continue;
            int lm=it.first.second;
            double dist=it.first.first;
            if(lm<u||u<=0) continue;
            rep(i,3){
                int tv=u+dv[i];
                if(d[it.second][t][tv]>cost+dist/u){
                    d[it.second][t][tv]=cost+dist/u;
                    pq.push({{d[it.second][t][tv],t},{tv,it.second}});
                }
            }
        }
    }
    return -1;
}

int main(){
    while(cin>>n>>m,n|m){
        rep(i,n) vp[i].clear();
        cin>>s>>g;
        --s,--g;
        int x,y,ci;
        double di;
        rep(i,m){
            cin>>x>>y>>di>>ci;
            --x,--y;
            vp[x].pb(make_pair(di,ci),y);
            vp[y].pb(make_pair(di,ci),x);
        }
        double ans=dijkstra();
        if(ans==-1)cout<<"unreachable"<<endl;
        else cout<<fixed<<setprecision(12)<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4328
import java.util.Scanner;

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

		sc.close();

		for(int i=0; (2*i)<s.length(); i++){
 			System.out.print(s.charAt(2*i));
		}
	}
}

Measured memory_bytes: 30192
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int c = sc.nextInt();

		int[][] table = new int[r+1][c+1];

		for (int row = 0; row < r; row++) {
			for (int col = 0; col < c; col++) {
				int now = sc.nextInt();

				table[row][col] = now;

				table[row][c] += now;
				table[r][col] += now;
				table[r][c] += now;
			}
		}
		sc.close();

		for(int[] col : table) {
			StringJoiner sj = new StringJoiner(" ");
			for(int val : col) {
				sj.add(String.valueOf(val));
			}
			System.out.println(sj);
		}
	}
}

Measured memory_bytes: 41336
"""Binary Indexed Tree (Fenwick Tree)"""
class BIT:
    def __init__(self, n):
        self.n = n
        
        #BIT木データ
        self.data = [0]*(n+1)
        
        #元配列
        self.el = [0]*(n+1)
    
    """A1~Aiまでの累積和"""
    def Sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            
            #LSB(Least Significant Bit)の獲得:i&(-i)
            i -= i & (-i) 
        return s
    
    """Ai += x"""
    def Add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    
    """Ai ~ Ajまでの累積和"""
    def Get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.Sum(j) - self.Sum(i)
    
s = input()
s = s.replace('BC', 'D')
mode = 0
res = 0
for i in range(len(s)):
    if s[i] == 'B' or s[i]=='C':
        mode = 0
    elif s[i] == 'A':
        mode += 1
    else:
        res += mode
print(res)

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

typedef unsigned long ul;
typedef long long int ll;
typedef pair<ll, ll> P;
#define pb push_back
#define mp make_pair
#define REP(i,n) REPN(i,0,n)
#define REPN(i,m,n) for(int i=m; i<(n); i++)
#define dump(x) cout << #x << " = " << (x) << endl

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

    int ab, bc, ca;
    cin >> ab >> bc >> ca;

    int l1, tmp, l2;
    l1 = min(ab, bc);
    tmp = max(ab, bc);
    l2 = min(tmp, ca);

    cout << l1 * l2 / 2 << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n;
int main(){
	cin>>n;
	ll sum=0;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			ll k=n/i;
			k-=1;
			if(k>0 && n%k==n/k) sum+=k;
			//if(i-1>0 && n/(i-1)==n%(i-1)) sum+=i-1;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fio ios_base::sync_with_stdio(0);cin.tie(0)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define slld(t) scanf("%lld",&t)
#define plld(t) printf("%lld\n",t)
#define sc(t) scanf("%c",&t)
#define pb(x) push_back(x)
#define ii pair<int,int>
#define vi vector<int>
#define vvi vector<vi >
#define vii vector<ii >
#define vvii vector<vii >
#define clr(x) memset(x,0,sizeof(x))
#define rep(i,begin,end) for(__typeof(end) i=begin-(begin>end);i!=end-(begin>end);i+=1-2*(begin>end))
#define MOD 1000000007
#define MAX 105
#define EPS 1e-9
using namespace std;

int main()
{
	ll n,k,x,y,ans=0;
	slld(n);
	slld(k);
	slld(x);
	slld(y);
	rep(i,1,n+1)
	{
		if(i<=k) ans += x;
		else ans += y;
	}
	plld(ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INFTY 2097152
void sol(int p[101],int m[101][101],int n ){
  int i,j,l,k;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=l+i-1;
      m[i][j]=INFTY;
      for(k=i;k<j;k++){
	if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      }
    }
  }
}

int main(){
  int i,p[101],m[101][101],n,j,k,l;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
    m[i][i]=0;
  }


  sol(p,m,n);

  printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2104
#include <set>
#include <cstdio>
#include <cctype>
#include <unistd.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

char buffer[4 * 1024 * 1024];
int pos = 0;
int end = 0;

__attribute__((always_inline)) int mygetchar(){
  if(pos == end){
    end = read(0, buffer, sizeof(buffer));
    pos = 0;
  }
  return buffer[pos++];
}

__attribute__((always_inline)) int getInt(){
  int ret = 0, c;
  c = mygetchar();
  while(!isdigit(c)) c = mygetchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = mygetchar();
  }
  return ret;
}

int a[100000 + 3];
int b[100000 + 3];

int main(){
  int n = getInt();

  REP(i,n){
    int aa = getInt();
    int bb = getInt();

    a[aa]++; b[bb]++;
  }

  int ans = 0;
  int peo = 1;

  REP(i,100000 + 3){
    peo += a[i];
    if(i > 0) peo -= b[i - 1];

    if(peo >= i){
      ans = i - 1;
    }
  }

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

  return 0;
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    set<int> se;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (se.find(a) == se.end()) se.insert(a);
        else se.erase(a);
    }

    cout << se.size() << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 8248
import collections

class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n+1))
        self.rank = [0]*(n+1)

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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


N, K, L = map(int, input().split())
uf1 = UnionFind(N)
for _ in range(K):
    x, y = map(int, input().split())
    uf1.unite(x, y)

uf2 = UnionFind(N)
for _ in range(L):
    x, y = map(int, input().split())
    uf2.unite(x, y)

parents = [(uf1.find(i), uf2.find(i)) for i in range(1, N+1)]
lc = collections.Counter(parents)
ans = []
for i in range(N):
    ans.append(lc[parents[i]])
print(*ans)

Measured memory_bytes: 58968