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

struct UnionFind {
        vector<int> par;
        UnionFind(int n) : par(n) { for (int i = 0; i < n; i++) par[i] = i; }
        int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
        bool same(int x, int y) { return find(x) == find(y); }
        void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; par[x] = y; }
};

struct Edge {
        int a, b, cost;
};

bool comp(const Edge& e1, const Edge& e2) {
        return e1.cost < e2.cost;
}

int main() {
        int n;
        cin >> n;
        vector<long long> x(n), y(n);
        vector<pair<long long, int>> xx;
        vector<pair<long long, int>> yy;
        for (int i = 0; i < n; i ++) {
                cin >> x[i] >> y[i];
                xx.push_back(make_pair(x[i], i));
                yy.push_back(make_pair(y[i], i));
        }
        sort(xx.begin(), xx.end());
        sort(yy.begin(), yy.end());
        vector<Edge> e;
        for (int i = 0; i < n - 1; i ++) {
                long long d = abs(xx[i].first - xx[i + 1].first);
                Edge ee;
                ee.a = xx[i].second;
                ee.b = xx[i + 1].second;
                ee.cost = d;
                e.push_back(ee);
        }
        for (int i = 0; i < n - 1; i ++) {
                long long d = abs(yy[i].first - yy[i + 1].first);
                Edge ee;
                ee.a = yy[i].second;
                ee.b = yy[i + 1].second;
                ee.cost = d;
                e.push_back(ee);
        }
        UnionFind uf(n);
        sort(e.begin(), e.end(), comp);
        long long ans = 0;
        for (int i = 0; i < e.size(); i ++) {
                Edge ee = e[i];
                if (!uf.same(ee.a, ee.b)) {
                        uf.unite(ee.a, ee.b);
                        ans += ee.cost;
                }
        }
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 11108
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int W = Integer.parseInt(line[0]),
            H = Integer.parseInt(line[1]),
            N = Integer.parseInt(line[2]);
        
        int minX = 0,
            maxX = W,
            minY = 0,
            maxY = H;
        
        for(int n=0;n<N;n++){
        	line = br.readLine().split(" ");
        	int x = Integer.parseInt(line[0]),
            	y = Integer.parseInt(line[1]),
            	a = Integer.parseInt(line[2]);
            switch(a){
            	case 1:
            		minX = Math.max(minX,x);
            		break;
            	case 2:
            		maxX = Math.min(maxX,x);
            		break;
            	case 3:
            		minY = Math.max(minY,y);
            		break;
            	case 4:
            		maxY = Math.min(maxY,y);
            		break;
            }
        }
        if(minX<maxX && minY<maxY) System.out.println((maxX-minX)*(maxY-minY));
        else System.out.println("0");
    }
}

Measured memory_bytes: 8276
let rec take n = function
  | [] -> []
  | x :: xs ->
      if n = 0 then []
      else x :: take (n - 1) xs

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  Array.init n (fun _ ->
    Scanf.scanf "%d " @@ fun l -> l)
  |> Array.to_list
  |> List.sort (fun x y -> compare y x)
  |> take k
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n"


Measured memory_bytes: 384
#include<iostream>
#define AM_Y 200
#define PM_Y 300
using namespace std;
int main(){
	char c_name[15];
	int am, pm;
	for(int i=0;i<9;i++){
		cin>>c_name>>am>>pm;
		cout<<c_name<<" "<<(am+pm)<<" "<<((am*200)+(pm*300))<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;

ll N, K;
map<ll, ll> cnt;

int main() {
    cin >> N >> K;
    for(int i=0; i<N; i++) {
        int a, b; cin >> a >> b;
        cnt[a] += b;
    }
    
    ll num = 0;
    for(auto iter=cnt.begin(); iter!=cnt.end(); iter++) {
        num += iter->second;
        if(num >= K) {cout << iter->first << endl;; return 0;}
    }
}


Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<set>
#include<functional>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
using p = pair<ll,ll>;
const ll INF = (ll)1e9;
void a(){
    int h;
    int w;
    int n;
    cin >> h >> w >> n;
    int max = std::max(h,w);
    int min = std::min(h,w);

    for(int i=1;i<=min;i++){
        if(max*i>=n){
            cout << i;
            return;
        }
    }
    cout << 0;
}

void b(){
    int n;
    cin >> n;
    auto st=vector<p>(n,p(0,0));
    for(int i=0;i<n;i++){
        int x,l;
        cin >> x >> l;
        st[i] = make_pair(x+l,x-l);
    }
    sort(st.begin(),st.end());
    int ans=0,t=-INF;
    for(int i=0;i<n;i++){
        if(t<=st[i].second){
            ans++;
            t = st[i].first;   
        }
    }
    cout << ans;
}
int main(){
    b();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int N;
    cin >> N;
    vector<ll> a(N),b(N);
    REP(i,N) cin >> a[i];
    REP(i,N) cin >> b[i];
    ll addition = 0;
    ll over = 0;
    REP(i,N) {
        if(b[i] > a[i]) {
            ll diff = b[i]-a[i];
            addition += (diff+1)/2;
            a[i] += 2*((diff+1)/2);
        }
        over += (a[i] - b[i]);
    }
    ll mi = addition - over;
    cout << ( mi >= 0 ? "Yes" : "No") << endl;
}

int main() {
    solve();
    return 0;
}

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


int main() {
    int a,b,c,d,e,f,g,h,i;
    cin>> a >> b >> c >> d >> e >> f >> g >> h >> i;
    if(d-a==e-b&&e-b==f-c&&g-d==h-e&&h-e==i-f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  long long a,b,c;
  cin>>a>>b>>c;
  if(b-c>=0) cout<<"delicious"<<'\n';
  else if(c-b<=a) cout<<"safe"<<'\n';
  else cout<<"dangerous"<<'\n';
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    int n, a, b;
    std::cin >> n >> a >> b;
    std::cout << std::min(n*a, b) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

typedef long long ll;
typedef pair<int,int> P;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << (x-z) / (y+z) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n;
	cin >> n;
	map<string, int> mp;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	vector<string> v = { "AC", "WA", "TLE", "RE" };
	for (auto &it : v) {
		cout << it << " x " << mp[it] << endl;
	}
}


Measured memory_bytes: 3664
#include <stdio.h>

int main(){
  int X,Y,Z;
  scanf("%d %d %d",&X,&Y,&Z);
  int T;
  T=X;
  X=Y;
  Y=T;
  int U;
  U=X;
  X=Z;
  Z=U;
  printf("%d %d %d\n",X,Y,Z);
  return 0;
}

Measured memory_bytes: 1668
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n, k, s = nm()
ans_h = [str(s) for _ in range(k)]
if s==10**9 :
    ans_t = ['1' for _ in range(n-k)]
else:
    ans_t = [str(s+1) for _ in range(n-k)]
print(' '.join(ans_h + ans_t))

Measured memory_bytes: 55152
//omajinai
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//omajinai

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll e,x;
    if(d > c){
        x = c;
        c = d;
        d = x;
    }
    e = c * d;
    ll y = c,z = d;
    while(z > 0){
        ll f;
        f = z;
        z = y % z;
        y = f;
    }
    e = e / y;

    ll ans = 0;
    ans = b-a+1;
    ans -= b/c + b/d - b/e -((a-1)/c + (a-1)/d - (a-1)/e);

    cout << ans << endl;
}

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

typedef long long LL;
typedef unsigned long long ULL;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

const LL N = 100005;
 
LL ec = 0,to[N << 1],nxt[N << 1],hed[N],deg[N];
LL cnt = 0;
void add_edge(LL f,LL t){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec;
	deg[t] ++;
}
 
LL vis[N] = {0},val[N],dis[N];
LL eu[N],ev[N],n;
std::string s;
 
void solve(){
	std::queue <LL> q;
	for(LL i = 1;i <= n;i ++) if(deg[i] == 1 && s[i] == 'B') q.push(i);
	while(!q.empty()){
		LL u = q.front(); q.pop();
		vis[u] = 1;
		for(LL i = hed[u];i;i = nxt[i]){
			LL v = to[i];
			if(!vis[v]){
				deg[v] --;
				if(deg[v] == 1 && s[v] == 'B') q.push(v);
			}
		}
	}
	memset(deg,0,sizeof(deg));
	memset(hed,0,sizeof(hed)); ec = 0;
	for(LL i = 1;i < n;i ++){
		if(vis[eu[i]] || vis[ev[i]]) continue;
		add_edge(eu[i],ev[i]);
		add_edge(ev[i],eu[i]);
	}
	for(LL i = 1;i <= n;i ++){
		val[i] = 0;
		if(vis[i]) continue;
		if((s[i] == 'B' && deg[i] % 2 == 1) || (s[i] == 'W' && deg[i] % 2 == 0)){
			val[i] = 2;
			cnt ++;
		}
	}
}
 
LL td = 0;
LL d[N];
void dfs(LL u,LL f){
	d[u] = val[u];
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		dfs(v,u);
		td = std::max(td,d[u] + d[v]);
		d[u] = std::max(d[u],d[v] + val[u]);
	}
}
 
int main(){
	std::ios::sync_with_stdio(false);
	std::cin >> n;
	for(LL i = 1;i < n;i ++){
		std::cin >> eu[i] >> ev[i];
		add_edge(eu[i],ev[i]);
		add_edge(ev[i],eu[i]);
	}
	std::cin >> s; s = ' ' + s;
	solve();
	LL trt = 1,ans;
	for(LL i = 1;i <= n;i ++) if(!vis[i]) trt = i;
	dfs(trt,0);
	ans = ec + cnt - td;
	std::cout << ans << std::endl;
	return 0;
} 


Measured memory_bytes: 14184
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    /*
    let v = read_vec::<usize>();
    let (a, b) = (v[0], v[1]);
    if a <= 5 {
        println!("0");
    } else if a <= 12 {
        println!("{:?}", b / 2);
    } else {
        println!("{:?}", b);
    }
    */

    let v = read_vec::<i64>();
    let (r, d, mut x) = (v[0], v[1], v[2]);
    for i in 0..10 {
        x = r * x - d;
        println!("{:?}", x);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>

using namespace std;

long long n;
long long a[500000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 1; i < n; i++)
    {
        if (a[i] - 1 >= a[i - 1])
        {
            a[i]--;
        }
    }
    for (int i = 1; i < n; i++)
    {
        if (a[i - 1] > a[i])
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        String s = std.next();
        String abc = "ABC";
        Pattern p = Pattern.compile(abc);
        Matcher m = p.matcher(s);
        int count = 0;
        while (m.find()) {
            count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i=0; i<S.size()-1; i++) {
    if (S[i]!=S[i+1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std; //头文件和命名空间
int main(){
    long long iSize, iColored; //iSize-棋盘长宽；iColored-涂了色的格子数目
    while (cin>>iSize>>iColored){ //读入两个参数
        cout<<iSize*iSize-iColored<<endl; //计算未涂色格子数并输出
    }
    return 0; //结束
}

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

int top, S[1000];//top栈顶

void push(int x);
int pop();
int toNum(string a);


int main()
{
string a;
	int t1, t2;
	while (cin >> a) {
		if (a == "+") {
			t1 = pop();
			t2 = pop();
			push(t1 + t2);
		}
		else if (a == "-") {
			t1 = pop();
			t2 = pop();
			push(t2 - t1);
		}
		else if (a == "*") {
			t1 = pop();
			t2 = pop();
			push(t1 * t2);
		}
		else {
			push(toNum(a));
		}
	}
	cout << pop() << endl;
	return 0;
}

void push(int x)
{
	S[++top] = x;
}

int pop()
{
	top--;
	return S[top + 1];
}

int toNum(string a)
{
	int sign = 0;
	if (a[0] == '-')
		sign = 1;
	int pos = 0;
	int s = 0;
	while (pos < a.length()) {
		if (a[pos] < '0' || a[pos] > '9')
		{
			pos++;
			continue;
		}
		s = s * 10 + a[pos] - '0';
		pos++;
	}
	if (sign == 1)
		return -s;
	return s;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
		int n,a,cnt=0;
		cin>>n;
		map<int,bool>list;
		for(int i=0; i<n; i++){
			cin>>a;
			if(list[a]==false){
				cnt++;
				list[a]=true;
			}
			else{
				cnt--;
				list[a]=false;
			}
		}
		cout<<cnt<<endl;
}


Measured memory_bytes: 4864
#include <iostream>
#include <set>
int main () {

    int N;
    int M;
    int A;
    int B;
    std::set<int> st;
    std::multiset<int> mst;

    std::cin >> N >> M;

    for( int i=0 ; i < N; i++) {

        std::cin >> A;

        for( int j=0; j < A; j++){
            std::cin >> B;
            st.insert(B);
            mst.insert(B);
        }
    }

    int count=0;
    int tmp;

    for(auto element: st){
        tmp = mst.count(element);
        if(tmp == N){
            count++;
        }
    }
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int A, B, D[11][11], O[111][111], Nw[11][11];

int main() {
    scanf("%d%d", &A, &B);
    for(int i = 1; i <= A; i++)
        for(int j = 1; j <= B; j++)
            scanf("%d", &D[i][j]);
    memset(Nw, 63, sizeof Nw);
    for(int i = 0; i <= 100; i++)
        for(int j = 0; j <= 100; j++) {
            int c = 0;
            for(int a = 1; a <= A; a++)
                for(int b = 1; b <= B; b++)
                    c = max(c, D[a][b] - i * a - j * b);
            O[i][j] = c;
            for(int a = 1; a <= A; a++)
                for(int b = 1; b <= B; b++)
                    Nw[a][b] = min(Nw[a][b], i * a + j * b + c);
        }
    for(int i = 1; i <= A; i++)
        for(int j = 1; j <= B; j++)
            if(D[i][j] != Nw[i][j]) {
                puts("Impossible");
                return 0;
            }
    puts("Possible\n204 10401\n");
    for(int i = 1; i <= 100; i++) printf("%d %d X\n", i, i + 1);
    for(int i = 1; i <= 101; i++)
        for(int j = 102; j <= 202; j++)
            printf("%d %d %d\n", i, j, O[i - 1][202 - j]);
    for(int i = 102; i <= 201; i++) printf("%d %d Y\n", i, i + 1);
    puts("1 202");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int main() {
    cin.sync_with_stdio(false);
	int n,a,b;
	cin >> n >> a >> b;
	int cnt = 0;
	while(cnt < 100000) {
		cnt++;
		if(a < b) {
			if(a+1 != b) {
				a++;
			} else if(a == 1) {
				cout << "Borys" << endl;
				return 0;
			} else a--;
		} else if(a > b) {
			if(a-1 != b) {
				a--;
			} else if(a == n) {
				cout << "Borys" << endl;
				return 0;
			} else a++;
		}

		if(b < a) {
			if(b+1 != a) {
				b++;
			} else if(b == 1) {
				cout << "Alice" << endl;
				return 0;
			} else b--;
		} else {
			if(b-1 != a) {
				b--;
			} else if(b == n) {
				cout << "Alice" << endl;
				return 0;
			} else b++;
		}
	}
	cout << "Draw" << endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int main()
{
  double L;
  cin >> L;
  double a = L / 3;
  cout << fixed << setprecision(15);
  cout << a * a * a << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] strArray = str.split(" ");
		
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		int c = Integer.parseInt(strArray[2]);
		
		if(a < b && b < c){
		System.out.println("Yes");
	    }
		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24444
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[600][600];

int main(){
  cin >> s;
  rep(i,0,s.sz)d[s[i]-'a']++;
  l = 0;
  rep(i,0,26){
    if(d[i] % 2){
      l++;
    }
  }
  if(l != 0)puts("No");
  else puts("Yes");
  return 0;
}

Measured memory_bytes: 2304
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
class UnionFind(n: Int) {
    val v = Array(n) {
        -1
    }

    fun unite(a: Int, b: Int) {
        val ar = find(a)
        val br = find(b)
        if (ar == br) {
            return
        }
        if (v[ar] > v[br]) {
            v[br] += v[ar]
            v[ar] = br
        } else {
            v[ar] += v[br]
            v[br] = ar
        }
    }

    fun find(i: Int): Int {
        if (v[i] < 0) {
            return i
        }
        v[i] = find(v[i])
        return v[i]
    }

    fun same(a: Int, b: Int): Boolean {
        return find(a) == find(b)
    }

    fun size(i: Int): Int {
        return -v[find(i)]
    }
}

fun main() {
    val (n, m) = intList()
    val v = mutableListOf<Pair<Int, Int>>()
    repeat(m) {
        val (a, b) = intList()
        v.add(Pair(a, b))
    }
    var c = 0
    repeat(m) { i ->
        val friends = Array(n + 1) { 0 }
        val unionFind = UnionFind(n + 1)
        lateinit var removed: Pair<Int, Int>
        0.until(m).forEach { j ->
            if (i != j) {
                val (a, b) = v[j]
                friends[a]++
                friends[b]++
                unionFind.unite(a, b)
            } else {
                removed = v[j]
            }
        }
        if (!unionFind.same(removed.first, removed.second)) {
            c++
        }
    }
    println(c.toString())
}


Measured memory_bytes: 37052
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res)*(x));
        }
        x=((x)*(x));
        y=y/2;
    }
    return res;
}
 

 
 
  
int main(){
 
  /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

double l,ans;
cin>>l;

ans=l*l*l;

printf("%.12lf",ans/27);





 
  
 
   return 0;
 
    
 }

Measured memory_bytes: 256
#include <stdio.h>
#define N 101

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

void insertion(int arr[], int n) {
    int key, i, j;
    Printing(arr, n);
    for (i = 1; i < n; i++) {
        key = arr[i];
        j = i - 1;
        while(j >= 0 && key < arr[j]){
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = key;
        Printing(arr, n);
    }
}


int main() {
    int n, i, arr[N];
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    insertion(arr, n);
    return 0;
}

Measured memory_bytes: 600
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

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

	ll sum = 0;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0) {
			continue;
		}

		ll m = n / i - 1;
		if (m <= i) {
			continue;
		}

		sum += m;


	}
	cout << sum << endl;
}

Measured memory_bytes: 3644
require 'pp'

n, k = gets.chomp!.split(" ").map(&:to_i)

if k == 0
    puts n * n
    exit 0
end

sum = 0
(k + 1).upto(n) do |b|
    x = (n / b) * (b - k)
    if n % b >= k
        x += (n % b - k + 1)
    end
    #puts x
    sum += x
end

puts sum


Measured memory_bytes: 2172
#include <cstdio>
#include <iostream>

using namespace std;

//5 3
//8
//1
//7
//3
//9
int check(int N[], int n, int k, int w) {

	int i = 0;
	for (int j = 0; j < k; ++j) {
		int s = 0;
		while (s + N[i] <= w) {
			s += N[i];
			i++;
			if (i == n)
				return n;
		}
	}
	return i;
}

int main() {

	int MAX_W = 1000000000;

	int n, k;
	scanf("%d %d", &n, &k);

	int N[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &N[i]);
	}

	int left = 0;
	int right = MAX_W;
	while (left < right) {
		int mid = (left + right) / 2;
		if (check(N, n, k, mid) == n) {
			right = mid;
		} else {
			left = mid + 1;
		}
	}
	cout << right << endl;
	return 0;
}

Measured memory_bytes: 3612
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

x,c = m()

if x < c:
    print(0)
else:
    print(10)

Measured memory_bytes: 3436
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var AB = Sarray();
            var A = AB[0];
            var B = AB[1];
            var ans = A - B - B;
            WriteLine(ans < 0?0:ans);
        }
    }
}


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

int main()
{
    int n;
    cin >> n;
    string s[100];
    int i, i1;
    int m = 0;
    for(i = 0; i < n; i++)
    {
        cin >> s[i];
        if (i != 0)
        {
            if (s[i][0] != s[i - 1][s[i - 1].size()-1])
            {
                m = 1;
            }
        }
        for (i1 = 0; i1 < i; i1++)
        {
            if (s[i1] == s[i]) {
                m = 1;
            }
        }
    }
    if (m == 0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
    }

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60




const int MAX_V = 200 + 1;
int d[MAX_V][MAX_V]; // 重み付き隣接行列
					 // ワーシャルフロイドではこれを更新していく
					 // 最初、辺がない場合はINFで初期化
					 // d[i][j] : iからjまでの最短距離
int V, E; // V : 頂点数(Vertex)
		  // E : 辺数(Edge)

int R;
vector<int> L;

void input() {
	cin >> V >> E >> R;

	for (int i = 0; i < R; i++) {
		int tmp; cin >> tmp; L.push_back(tmp);
	}
	sort(L.begin(), L.end());

	// 初期化
	for (int i = 1; i <= V; i++) {
		for (int j = 1; j <= V; j++) {
			if (i != j && d[i][j] == 0) d[i][j] = INF; // この初期化を忘れてはいけない
													   // i == jのときは d[i][i] = 0
		}
	}

	for (int i = 0; i < E; i++) {
		int start, end;
		cin >> start >> end;
		cin >> d[start][end];
		// 無効グラフなら
		d[end][start] = d[start][end];
	}
}

void warshall_floyd() {

	for (int k = 1; k <= V; k++) {
		for (int i = 1; i <= V; i++) {
			for (int j = 1; j <= V; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

void solve() {
	warshall_floyd();
	ll ans = LLINF;

	do {
		ll tmp = 0;
		for (int i = 1; i < R; i++) tmp += d[L[i]][L[i - 1]];
		ans = min(ans, tmp);
	} while (next_permutation(L.begin(), L.end()));
	cout << ans << endl;
}

int main() {
	input();
	solve();

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
vector<int> F[100001];
vector<int> B[100001];
int bel=0;
vector<int> belong[100000];
map<int,int> p;
int visited[100000]={};
void dfs(int now,int c){
    int cn=0;
    if(!visited[now]){
        visited[now]=1;
        belong[c].push_back(now);
        p[now]=c;
        //keyは人、値は所属番号
        for(int j=0;j<F[now].size();j++){
            int child = F[now][j];
            if(!visited[child]){
                dfs(child,c);
                cn++;
            }
        }
        if(cn==0){
            bel++;
            //もう回り切った＝＞所属しているグループを変える
        }
    }
    
}
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        F[a].push_back(b);
        F[b].push_back(a);
    }
    map<int,vector<int>> B;
    rep(i,k){
        int a,b;
        cin>>a>>b;
        //B[a].push_back(b);
       // B[b].push_back(a);
       B[a].push_back(b);
       B[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        /*
        cout<<i<<"がブロックしてる人 ";
        rep(j,B[i].size()){
            cout<<B[i][j]<<" ";
        }
        cout<<endl;
        */
    }
    for(int i=1;i<=n;i++){
        dfs(i,bel);
    }
    /*
    rep(i,bel){
        cout<<i<<"個目のグループ所属 ";
        rep(j,belong[i].size()){
            cout<<belong[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    for(int i=1;i<=n;i++){
        int block=0;
        if(B[i].size()>=1){
            rep(j,B[i].size()){
                if(p[i]==p[B[i][j]]){
    
                    block++;
                }
            }
        }
        int bsize=belong[p[i]].size();
        int fsize=F[i].size();
        //cout<<bsize<<"-"<<fsize<<"-1-"<<block<<"=";
        cout<<bsize-fsize-1-block<<" ";
    }
}

Measured memory_bytes: 29176
# Aizu Problem 0011: Drawing Lots
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


         
w = int(input())
slots = list(range(1, w + 1))
n = int(input())
for k in range(n):
    a, b = [int(_) for _ in input().split(',')]
    slots[a-1], slots[b-1] = slots[b-1], slots[a-1]
for s in slots:
    print(s)

Measured memory_bytes: 7760
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

int main(void) {
    cin >> n;
    unordered_map<int, bool> aa;

    rep(i, 0, n) {
        cin >> a;
        if (aa[a]) {
            cout << "NO" << endl;
            return 0;
        } else {
            aa[a] = true;
        }
    }
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 8520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
ll lcm(ll a, ll b) {
    return a/gcd(a,b)*b;
} 
ll f(ll x, int c, int d) {
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/lcm(c,d);
    return res;
}
int main() {
    ll a, b;
    int c, d;
    cin >> a >> b >> c >> d;
    ll ans = f(b,c,d) - f(a-1, c, d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  std::vector<std::vector<int>> T(N);
  rep(i,M) {
    int a,b; std::cin >> a >> b;
    T[a-1].push_back(b-1);
    T[b-1].push_back(a-1);
  }

  for(auto&& next : T[N-1]) {
    for(auto&& nnext : T[next]) {
      if ( nnext == 0 ) {
        std::cout << "POSSIBLE" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "IMPOSSIBLE" << std::endl;
  return 0;
}


Measured memory_bytes: 12016
using System;
using System.Linq;

namespace C_Christmas_Eve
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var raw_input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = raw_input[0];
            int K = raw_input[1];
            var h = Enumerable.Range(0, N)
                .Select(x => Console.ReadLine())
                .Select(int.Parse)
                .ToArray();

            h = h.OrderBy(x => x).ToArray();

            var min = Enumerable.Range(0, N - K + 1)
                .Select(x => h[x + K - 1] - h[x])
                .Min();

            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 21596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace templete
{
    class arc97_c
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int k = int.Parse(Console.ReadLine());
            List<string> list = new List<string>();
            int i,j;
            int n = str.Length;

            for(i=0; i<n; i++){
                for(j=0; j<n-i; j++){
                    if(j+1 <= 5){
                        list.Add(str.Substring(i, j+1));
                    }
                }
            }

            string[] arr = list.Distinct().ToArray();
            Array.Sort(arr);

            //foreach(var item in arr){
            //    WriteLine(item);
            //}
            WriteLine(arr[k-1]);

        }
    }
}

Measured memory_bytes: 15328
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int n;
vector<int> vec;

void read(){
  cin >> n;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    vec.push_back(a);
  }
}

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

  read();

  lli sum = 0;
  
  vector<int> ans;
  for(int i=0;i<n;i++) ans.push_back(INT_MAX);

  for(int i=0;i<sz(vec);i++){
    ans[i] = min(ans[i], vec[i]);
    ans[i+1] = min(ans[i+1], vec[i]);
  }

  for(auto i : ans) sum += i;
  cout << sum << endl;
  // 0 153 10 10 23
  // [0 0] 10 10 10 23




  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for( int x = 0; x <= k; ++x ){
		for( int y = 0; y <= k; ++y ){
			int z = s - x - y;
			if( 0 <= z && z <= k){
				++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0) {
        cout << "No" << endl;
        return 0;
    } else if (4 * a * b < (c - a - b) * (c - a - b)) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  int n, m;
  int a[100][100];
  int b[100];

  cin >> n >> m;

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

  for ( int i = 0; i < m; i++ )
    {
      cin >> b[i];
    }

  for ( int i = 0; i < n; i++ )
    {
      int c = 0;
      for ( int j = 0; j < m; j++ )
        {
          c += a[i][j] * b[j];
        }
      cout << c << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
 
int main(){
    int i, j, r, c;
    int array[102][102];
 
    cin >> r >> c;
 
    for (i = 1; i <= r + 1; i++){
        for (j = 1; j <= c + 1; j++){
            array[i][j] = 0;
        }
    }
 
    for (i = 1; i <= r; i++){
        for (j = 1; j <= c; j++){
            cin >> array[i][j];
            array[i][c+1] += array[i][j];
            array[r+1][j] += array[i][j];
            array[r+1][c+1] += array[i][j];
        }
    }
 
    for (i = 1; i <= r + 1; i++){
        for (j = 1; j <= c + 1; j++){
            if (j != 1) cout << " ";
            cout << array[i][j];
        }
        cout << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1200
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip().split()[0]

is_w_list = [1 if s=="W" else 0 for s in S ]
cumsum_w = np.append(np.array([0]),(np.cumsum(is_w_list)[:-1])) 

is_e_list = [not(x) for x in is_w_list[::-1]]
cumsum_e = np.append(np.array([0]),(np.cumsum(is_e_list)[:-1]))[::-1]
# print(cumsum_e+cumsum_w)
print(np.min(cumsum_w+cumsum_e))

Measured memory_bytes: 26760
n = int(input())
h = list(map(int, input().split()))
maxh = max(h)
ans = 0
for j in range(maxh):
    countnow = False
    for i in range(n):
        if h[i] != 0:
            h[i] -= 1
            if not countnow:
                ans+=1
                countnow=True
        else:
            countnow = False
print(ans)

Measured memory_bytes: 39024
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

char s[1000010];

inline int C(int n, int m) { return (n & m) == m; }

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n;
	scanf("%d%s", &n, s + 1);
	if(n == 1) putchar(s[1]), puts("");
	else {
		--n;
		int find1 = 0;
		for(int j = 1; j <= n; j++)
			s[j] = abs(s[j] - s[j + 1]), find1 |= s[j] == 1;
		if(!find1) for(int i = 1; i <= n; i++) s[i] >>= 1;
		find1 ^= 1;
		int t = 0;
		for(int j = 1; j <= n; j++) t ^= C(n - 1, j - 1) * (s[j] & 1);
		cout << (int(t) << find1) << endl;
	}
	return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main()
{
	int n, a[100];

	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}
	for(int i = n-1; i > 0 ; --i)
	{
		printf("%d ", a[i]);
	}
	printf("%d\n", a[0]);

	return 0;
}


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

using namespace std;

int main(void) {
  int r, g, b; cin >> r >> g >> b;
  
  if (((g&0x1) == 0 && (b&0x3) == 0) || ((g&0x1) == 1 && (b&0x3) == 2)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

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

int h[100055],dp[100055];
const int inf = 0x3f3f3f;
int main()
{
	int n,k;
	
	memset(dp,inf,sizeof(dp));
	dp[0]=dp[1]=0;
	cin>>n>>k;
	//h[1]=inf;
	h[0]=inf;
	for(int i=1;i<=n;i++)
		cin>>h[i];
		//dp[2]=
		for(int i=2;i<=n;i++)
			for(int j=1;j<=k&&i-j>0;j++)
			{
				dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
			//	cout<<dp[i]<<"  "<<dp[i-j]+abs(dp[i]-dp[i-j])<<endl;
			}

	cout<<dp[n]<<endl;
	return 0;
} 
//max(h[i],h[i-2])-min(h[i],h[i-2])

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int main() {
  string S;
  cin >> S;

  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
}

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

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
    int a, b, k;
    cin >> a >> b >> k;

    int cnt = 0, i = min(a, b);

    while (1)
    {
        if (a % i == 0 && b % i == 0)
        {
            cnt++;
            if (cnt == k)
            {
                cout << i << endl;
                break;
            }
        }
        i--;
    }
}


Measured memory_bytes: 256