akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

typedef pair<int, int> pii;
const int N = int(2e5) + 2;
const int inf = (int)1e15;

int n, r, s, u, v, m, k;

int lab1[N], mask[N], cnt;
int Find1(int u) {return lab1[u] < 0? u: lab1[u] = Find1(lab1[u]);}
void Union1(int r, int s) {
    if(lab1[r] > lab1[s]) swap(r, s);
    lab1[r] += lab1[s], lab1[s] = r;
}

struct TLab{
    unordered_map<int, int> mmap;
    int lab;
} lab[N];
int Find(int u) {return lab[u].lab < 0? u: lab[u].lab = Find(lab[u].lab);}
void Union(int r, int s) {
    if(lab[r].lab > lab[s].lab) swap(r, s);
    lab[r].lab += lab[s].lab, lab[s].lab = r;
    for(auto p: lab[s].mmap) lab[r].mmap[p.fi] += p.se;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m >> k;
    memset(&lab1, -1, sizeof lab1);
    while(m --) {
        cin >> u >> v;
        r = Find1(u), s = Find1(v);
        if(r != s) Union1(r, s);
    }
    for(int i = 1; i <= n; ++i) if(lab1[i] < 0) mask[i] = ++cnt;
    for(int i = 1; i <= n; ++i) {
        if(lab1[i] > 0) mask[i] = mask[Find1(i)];
        lab[i].lab = -1;
        ++lab[i].mmap[mask[i]];
    }
    while(k --) {
        cin >> u >> v;
        r = Find(u), s = Find(v);
        if(r != s) Union(r, s);
    }
    for(int i = 1; i <= n; ++i) cout << lab[Find(i)].mmap[mask[i]] << ' ';
}


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

class Disjonset{
public:
    vector<int> p;
    Disjonset(int n){
        p.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
        }
    }
    
    bool same(int x,int y){
        return findParent(x) == findParent(y);
    }
    void unite(int x,int y){
        x = findParent(x);
        y = findParent(y);
        p[x] = y;
    }
    
    int findParent(int x){
        if(x!=p[x]){
            p[x] = findParent(p[x]);
        }
        return p[x];
    }
};

class Edge{
public:
    int source,target,cost;
    Edge(int source=0, int target=0, int cost=0):
    source(source),target(target),cost(cost){}
    bool operator < (const Edge &e) const {
        return cost < e.cost;
    }
};




int kruskal(int N,vector<Edge> edges){
    Disjonset d = Disjonset(N+1);
    int totalCost = 0;
    sort(edges.begin(),edges.end());
    for(int i=0;i<edges.size();i++){
        if(!(d.same(edges[i].source,edges[i].target))){
            totalCost += edges[i].cost;
            d.unite(edges[i].source,edges[i].target);
        }
    }
    return totalCost;
}

int main(int argc, const char * argv[]) {
    int V,E;
    cin >> V >> E;
    vector<Edge> edges;
    for(int i=0;i<E;i++){
        int s,t,c;
        cin >> s>>t>>c;
        edges.push_back(Edge(s,t,c));
    }
    
    cout << kruskal(V, edges) << endl;
    
    return 0;
}



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


int main() {
	int n; cin >> n;
	vector<pair<int, int>>p;
	int ans = 0;
	vector<int>a;
	for (int i = 0; i < n; i++) {
		int b; cin >> b; a.push_back(b);
	}
	sort(a.begin(), a.end());

	int g = a[n - 1], l = a[0];
	for (int i = 1; i < n-1; i++) {
		if (a[i] >= 0) break;
		p.push_back(make_pair(g, a[i]));
		g -= a[i];
	}
	for (int i = n - 2; i > 0; i--) {
		if (a[i] < 0) break;
		p.push_back(make_pair(l, a[i]));
		l -= a[i];
	}
	p.push_back(make_pair(g, l));
	ans = g - l;

	cout << ans << endl;
	for (int i = 0; i < p.size(); i++) {
		cout << p[i].first << " " << p[i].second << endl;
	}

	return 0;
}


Measured memory_bytes: 3188
h, w = map(int, input().split())
s = [input() for _ in range(h)]

for i in range(1,h-1):
    for j in range(1,w-1):
        if(s[i][j] == "#"):
            if(s[i - 1][j] == "." and s[i + 1][j] == "." and s[i][j - 1] == "." and s[i][j + 1] == "."):
                print("No")
                # print("[%d][%d]"%(i,j))
                exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SIZE 10005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int V;
vector<int> G[SIZE];
vector<int> rG[SIZE];
vector<int> vs;
bool used[SIZE];
int cmp[SIZE]; //属する強連結成分のトポロジカル順序

void add_edge(int from,int to){
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v){
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]])dfs(G[v][i]);
	}
	vs.push_back(v);
}

void rdfs(int v,int k){
	used[v] = true;
	cmp[v] = k;
	for(int i=0;i<rG[v].size();i++){
		if(!used[rG[v][i]])rdfs(rG[v][i],k);
	}
}

void scc(){
	memset(used,0,sizeof(used));
	for(int i=0;i<V;i++){
		if(!used[i])dfs(i);
	}
	memset(used,0,sizeof(used));
	int k=0;
	for(int i=V-1;i>=0;i--){
		if(!used[vs[i]])rdfs(vs[i],k++);
	}
}

int main()
{
	int E;
	cin >> V >> E;
	int s,t;
	for(int i=0;i<E;i++){
		cin >> s >> t;
		add_edge(s,t);
	}
	scc();
	int Q;
	cin >> Q;
	for(int i=0;i<Q;i++){
		cin >> s >> t;
		if(cmp[s] == cmp[t])puts("1");
		else puts("0");
	}

	return 0;
}



Measured memory_bytes: 4704
#include <iostream>
using namespace std;
char field[3][3];

void check() {
	for (int i = 0; i < 3; ++i) {
		if (field[i][0] != '+' && field[i][0] == field[i][1]) {
			if (field[i][1] == field[i][2]) {
				cout << field[i][2] << endl; return;
			}
		}
	}
	for (int i = 0; i < 3; ++i) {
		if (field[0][i] != '+' && field[0][i] == field[1][i]) {
			if (field[1][i] == field[2][i]) {
				cout << field[2][i] << endl; return;
			}
		}
	}

	if (field[0][0] != '+' && field[0][0] == field[1][1] && field[1][1] == field[2][2]) {
		cout << field[0][0] << endl;  return;
	}
	
	if (field[0][2] != '+' && field[0][2] == field[1][1] && field[1][1] == field[2][0]) {
		cout << field[0][2] << endl; return;
	}
	cout << "NA" << endl;
	return;
}

int main() {

	while (cin >> field[0][0], field[0][0]-'0') {
		cin >> field[0][1] >> field[0][2];

		for (int i = 1; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				cin >> field[i][j];
			}
		}
		check();
	}

	return 0;
}

Measured memory_bytes: 1132
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == 500*i+100*j+50*k:
                count+=1
print(count)

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;

  double l = n / 1.08;
  double r = (n+1) / 1.08;
  ll ans = ll(r);
  if(n*1.0 <= ans * 1.08 && ans*1.08 < (n+1)*1.0)
    cout << ans << endl;
  else
    cout << ":(" << endl;
    //cout << ans*1.08 << endl;
}


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

int abs(int a, int b){
  if (a > b) return a - b;
  else return b - a;
}

int main(){
  int N; cin >> N;
  vector<int> backet(N,0); 
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    backet.at(a)++;
  }
  
  bool flg = true;
  if(backet.at(0) > 0 && N % 2 == 0) flg = false;
  if(backet.at(0) > 1 && N % 2 == 1) flg = false;
  else{
    for(int i = 0; i < N; i++){
      if(backet.at(i) > 2){
        flg = false;
      }
    }
  }
  int ans = 1;
  if(flg){
    for(int i = 0; i < N/2; i++) ans = ans * 2 % 1000000007;
  }
  else ans = 0;
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
    int N;cin>>N;
    vector<int> up(N),down(N),left(N),right(N);
    for(int i=0;i<N;i++)cin>>up.at(i);
    for(int i=0;i<N;i++)cin>>down.at(i);
    left.at(0)=up.at(0);
    for(int i=1;i<N;i++)left.at(i)=left.at(i-1)+up.at(i);
    right.at(N-1)=down.at(N-1);
    for(int i=N-2;i>=0;i--)right.at(i)=right.at(i+1)+down.at(i);
    int ans=0,now;
    for(int i=0;i<N;i++){
        now=left.at(i)+right.at(i);
        ans=max(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
const int MOD = 1e9+7;
int n,k,x,t,a,b,m;
string s;
vi v;
ll sum[200010];

int main(){

	cin >> n >> k;
	ll ans=0;
	init(sum);
	for(int i =1;i<=200005;i++){
		sum[i]=(sum[i-1]%MOD+i%MOD)%MOD;
	}
	for(int i =k;i<=n+1;i++){
		// i = 3 n = 5
		// sum(n) = 5+4+3+2+1 - (n-k-1+n-k-2+...+0)

		 ans=(ans%MOD+((sum[n]%MOD-sum[max(0,n-i)%MOD]%MOD+MOD)-(sum[i-1]%MOD)+1)%MOD+MOD)%MOD;
	}
	cout << ans;

	
	return 0;
}

Measured memory_bytes: 5196
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[][][] house = new int[4][3][10];
		int n = scan.nextInt();
		for(int i = 0; i < n; i++){
			int b = scan.nextInt() - 1;
			int f = scan.nextInt() - 1;
			int r = scan.nextInt() - 1;
			int v = scan.nextInt();
			house[b][f][r] += v;
		}
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 10; k++){
					System.out.print(" " + house[i][j][k]);
				}System.out.println();
			}
			if(i != 3) System.out.println("####################");
		}

	}

}

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

typedef long long ll;

ll a, b, c, d, T, len, l, r, mid;

ll calc(ll x, ll y) {
	if(x*y == 0) return max(x, y);
	return (x + y)/(min(x, y) + 1);
}

bool check(ll x) {
	ll A = x/(len + 1)*len + x%(len + 1);
	ll B = x/(len + 1) - (x%(len + 1) == 0);
	if(A > a) return false;
	return (calc(a - A, b - B) <= len);
}

int main() {
	cin>>T;
	while(T--) {
		scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
		len = calc(a, b);
		l = 0, r = a + b;
		while(l < r) {
			mid = (l + r + 1)>>1;
			if(check(mid)) l = mid;
			else r = mid - 1;
		}
		for(ll i = c; i <= min(l, d); i++)
			cout<<((i%(len + 1) == 0) ? 'B':'A');
		for(ll i = max(c, l + 1); i <= d; i++)
			cout<<(((a + b - i + 1)%(len + 1) == 0) ? 'A':'B');
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    string key = "keyence";
    bool yes = true;
    for(int i = 0; i < 7; i++) {
        if(S[i] != key[i]) {
            yes = false;
            break;
        }
    }
    if(yes) {
        cout << "YES";
        return 0;
    }

    yes = true;
    for(int i = 0; i < 7; i++) {
        if(S[N - 1 - i] != key[6 - i]) {
            yes = false;
            break;
        }
    }
    if(yes) {
        cout << "YES";
        return 0;
    }

    for(int i = 0; i < 7; i++) {
        yes = true;
        for(int j = 0; j < i; j++) {
            if(S[j] != key[j]) {
                yes = false;
                break;
            }
        }
        for(int j = N - 1; j >= N - 1 - (6 - i); j--) {
            if(S[j] != key[6 - (N - 1 - j)]) {
                yes = false;
                break;
            }
        }
        if(yes) {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <utility>
#include <algorithm>

using namespace std;

vector<int> djset, szset;
vector<pair<int, pair<int, int>>> G;

int root(int x)
{
    int v = djset[x];
    while (v != djset[v]) v = djset[v];
    djset[x] = v;
    return v;
}

int main(void)
{
    int N;
    cin >> N;
    G.resize(N * N);
    int count = 0;
    int temp;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> temp;
            if (i == j || temp == -1) continue;
            G[count++] = make_pair(temp, make_pair(i, j));
        }
    }
    djset.resize(count);
    szset.resize(count, 1);
    G.erase(G.begin() + count, G.end());
    sort(G.begin(), G.end());
    for (int i = 0; i < count; i++) djset[i] = i;
    int v[2], r[2];
    int ans = 0;
    for(auto i : G)
    {
        v[0] = i.second.first;
        v[1] = i.second.second;
        for (int i = 0; i < 2; i++) r[i] = root(v[i]);
        if (r[0] == r[1]) continue;
        if (szset[r[1]] > szset[r[0]]) swap(r[0], r[1]);
        djset[r[1]] = r[0];
        szset[r[0]] += szset[r[1]];
        szset[r[1]] = 0;
        ans += i.first;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  if (n >= 10) cout << r << endl;
  else cout << r + 100 * (10 - n) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
 
signed main(){
   int a;
   scanf("%lld",&a);
   int MIN=INT_MAX,MAX=INT_MIN,sum=0;
   int b;
   for(int c=0;c<a;c++){
       scanf("%lld",&b);
       MIN=min(MIN,b);
       MAX=max(MAX,b);
       sum+=b;
       }
       printf("%lld %lld %lld\n",MIN,MAX,sum);
}

Measured memory_bytes: 3204
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
a, b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
d = max(a,b,c)
if a==d:
    a*=10
elif b==d:
    b*=10
elif c==d:
    c*=10
print("{}".format(a+b+c))
#print("{} {}".format(a+b+c, s))

Measured memory_bytes: 3316
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLine().toInt()
    val b = sc.nextLine().split(" ").map { it.toInt() }
    println(problem135_b(a, b))
}

fun problem135_b(a: Int, b: List<Int>): String {
    val list = b.toMutableList()

    var swapCount = 0

    for (i in 1..b.size) {

        // 間違っている場合入れ替えを行う
        if (list[i - 1] != i) {

            if (swapCount > 0) {
                return "NO"
            }

            val tmpA = list[i - 1]
            list[i - 1] = list[tmpA - 1]    // 左側の値を正しいものに
            list[tmpA - 1] = tmpA
            swapCount++

        }
    }
    return "YES"
}



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

typedef long long ll;

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

    set<ll> s;

    ll a[3];
    for(int i = 0; i < n; i++){
        cin >> a[0] >> a[1] >> a[2];
        sort(a, a+3);
        s.insert(a[2] + 10000*a[1] + 100000000*a[0]);
    }

    cout << n-(int)(s.size()) << endl;
    return 0;
}


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

int main(){
    int t[5], k;
    bool out = false;

    cin >> t[0] >> t[1] >> t[2] >> t[3] >> t[4] >> k;


    for(int lp=0; lp<5; lp++){
        for(int llpp=lp+1; llpp<5; llpp++){
            if(t[llpp]-t[lp]>k){
                out = true; break;
            }
        }
    }

    cout << (out==false ? "Yay!" : ":(") << endl;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if (b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if (c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if (c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;

 

}
 


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

int main(void) {
    int sor[3];
    for (int i = 0; i < 3; i++){
        cin >> sor[i];
    }
    sort(sor, sor + 3);
    cout << sor[0] << ' ' << sor[1] << ' ' << sor[2] << endl;
    return 0;
        
}




Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  vector<int> a(9);
  int n;
  r1(i,9) cin >> a.at(i);
  cin >> n;
  r1(i,n) {
    int b=0;
    cin >> b;
    r1(j,9) if(b==a.at(j)) a.at(j)=0;
  }
  vector<int> b(8,0);
  r1(i,3) {
    b.at(0)+=a.at(i);
    b.at(1)+=a.at(i+3);
    b.at(2)+=a.at(i+6);
  }
  r1(i,3) {
    b.at(3)+=a.at(i*3);
    b.at(4)+=a.at(i*3+1);
    b.at(5)+=a.at(i*3+2);
  }
  b.at(6)=a.at(0)+a.at(4)+a.at(8);
  b.at(7)=a.at(2)+a.at(4)+a.at(6);
  string s="No";
  r1(i,8) if(b.at(i)==0) s="Yes";
  cout << s << endl;
}


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

using namespace std;

const long long maxn = 1e5 + 7;

long long n, ans;

vector<long long> a;

void solve() {
	cin >> n;
	a.resize(n);
	for (long long i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	ans = a[0];
	for (long long i = 2, j = 1; i < n; i += 2) {
		ans += a[j];
		if (i != n - 1) {
			ans += a[j];
		}
		j++;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);    
    //freopen("input.txt", "r", stdin);
	solve();
    return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> v(h);
    vector<int> a;
    auto ans = make_v(h, w, 0);
    a.emplace_back(-1);
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            if(s[j] == '#') v[i].emplace_back(j);
        }
        if(!v[i].empty()) {
            v[i].emplace_back(w);
            a.emplace_back(i);
        }
    }
    int cnt = 1;
    for (int i = 1; i < a.size(); ++i) { // i番目の列
        int l = -1;
        for (int j = 0; j+1 < v[a[i]].size(); ++j) {
            for (int y = a[i-1]+1; y <= a[i]; ++y) {
                for (int x = l+1; x <= v[a[i]][j]; ++x) {
                    ans[y][x] = cnt;
                }
            }
            cnt++;
            l = v[a[i]][j];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 1; j < w; ++j) {
            if(!ans[i][j] && ans[i][j-1]){
                ans[i][j] = ans[i][j-1];
            }
        }
    }
    for (int i = 1; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(!ans[i][j] && ans[i-1][j]){
                ans[i][j] = ans[i-1][j];
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(j) printf(" ");
            printf("%d", ans[i][j]);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1792
#71 表計算

r, c = map(int,input().split())

a = []
rsum = []
for i in range(r):
    a.append(list(map(int,input().split())))
    a[i].append(sum(a[i]))
    
for i in range(r):
    print(" ".join(list(map(str, a[i]))))
    
csum = []
for j in range(c+1):
    su = 0
    for i in range(r):
        su += a[i][j]
    csum.append(su)
    
print(" ".join(list(map(str, csum))))




Measured memory_bytes: 5696
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
using namespace std;
#define pb push_back
#define F(i,a,b) for(int i=a;i<b;++i)
#define Fl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first;
#define Y second;
#define mp make_pair;
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int MOD = 1000000007;




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

 	//int t{},T{};
 	//cin>>t;T=t;
 	//while(t--){
        //cout<<"------------- #"<<T-t<<endl;
        int n{},k{},a{},b{},c{},s{},f{};
        cin>>n;
        if(n%1000==0){
            cout<<0<<endl;
        }else{
            cout<<1000-n+1000*(n/1000)<<endl;
        }
    //}
    
    
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    while(t--){
	    string s,p;
	    cin>>s>>p;
            char c = p.at(p.size()-1);
	    string x=s + c; 
	    if(x.compare(p)==0)
		    cout<<"Yes"<<endl;
	    else
		    cout<<"No"<<endl;
    
    }
    return 0;
} 


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

using ll = long long;
using ii = pair<ll,int>;

const int N = 1e5+10;
int x, y, z;
struct data{
  int a, b, c;
  bool operator<(data o) const {
    return a - b < o.a - o.b;
  }
}seq[N];

ll pre[N], suf[N];
priority_queue<ii, vector<ii>, greater<ii>> q;

int main() { 
  scanf("%d %d %d", &x, &y, &z);
  for(int i = 0; i < x + y + z; i++) {
    scanf("%d %d %d", &seq[i].a, &seq[i].b, &seq[i].c);
  } sort(seq, seq + x + y + z);

  ll cur = 0;
  for(int i = 0; i < y; i++) {
    q.push({seq[i].b - seq[i].c, i});
    cur += seq[i].b;
  }
  pre[y - 1] = cur;
  for(int i = y; i < x + y + z; i++) {
    q.push({seq[i].b - seq[i].c, i});
    cur += seq[i].b;
    auto U = q.top(); q.pop();
    cur -= seq[U.second].b;
    cur += seq[U.second].c;
    pre[i] = cur;
  }
  while(!q.empty()) q.pop();
  cur = 0;
  for(int i = y + z; i < x + y + z; i++) {
    q.push({seq[i].a - seq[i].c, i});
    cur += seq[i].a;
  }
  suf[y + z] = cur;
  for(int i = y + z - 1; i >= 0; i--) {
    q.push({seq[i].a - seq[i].c, i});
    cur += seq[i].a;
    auto U = q.top(); q.pop();
    cur -= seq[U.second].a;
    cur += seq[U.second].c;
    suf[i] = cur;
  }
  ll ans = 0;
  for(int i = y - 1; i + 1 <= y + z; i++) {
    ans = max(ans, pre[i] + suf[i + 1]);
  } printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4340
#include <iostream>

#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::vector;

static int
solve(int N, long long K, vector<int> &A)
{
  vector<int> mark(N);
  int pos = 0;
  for (long long k = 1; k <= K; k++)
  {
    if (mark[pos] != 0)
    {
      long long rest = (K - k + 1) % (k - mark[pos]);
      for (long long r = 0; r < rest; r++)
      {
        pos = A[pos] - 1;
      }
      break;
    }
    else
    {
      mark[pos] = int(k);
      pos = A[pos] - 1;
    }
  }
  return pos + 1;
}

int
main()
{
  int N;
  long long K;
  cin >> N >> K;
  vector<int> A(N);
  for (int n = 0; n < N; n++)
  {
    cin >> A[n];
  }
  cout << solve(N, K, A) << endl;
  return 0;
}


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

int H, W, A[1 << 18], B[1 << 18];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> A[i];
	for (int i = 0; i < W; i++) cin >> B[i];
	sort(A, A + H);
	sort(B, B + W);

	for (int i = H - 1; i >= 0; i--) {
		for (int j = W - 1; j >= W - A[i]; j--) B[j]--;
		sort(B, B + W);
	}

	for (int i = 0; i < W; i++) {
		if (B[i] != 0) {
			cout << "0" << endl;
			return 0;
		}
	}
	cout << "1" << endl;
	return 0;
}


Measured memory_bytes: 3156
'''
○ 基本方針
'(' を1上昇、')'を1下降とイメージすると、
この問題は「0未満にならず、最終的に0になるか」と言い換えられる。

1. ／ 型
2. V 型で上昇
3. V型で下降
4. ＼型
の順で使えばよい。

2は、V字の最下点が最も高いものから使うのが最適。（徐々に、大きく沈み込むものを使えるようになる）
3は、(|下降| - V字の最下点) が最も大きいものから使うのが最適。（沈み込みが大きいものは早めに消化する）

ここで、1は2、3は4と合わせて考えて良い。
'''

Yes = 'Yes'
No = 'No'

def main():
    # 入力
    N = int(input())
    up = []     # 上昇が0以上のもの
    down = []   # 上昇が0未満のもの
    for _ in range(N):
        S = input()
        h, b = 0, 0 # h:上昇数、b:最下点
        for s in S:
            if s=='(':
                h += 1
            else:
                h -= 1
                b = min(b, h)
        #
        if h>=0:
            up.append((h, b))
        else:
            down.append((h, b))
    # 演算
    up.sort(key=lambda t: t[1], reverse=True)           # 上昇は、最下点が高いものから使う
    down.sort(key=lambda t: t[0]-t[1], reverse=True)    # 下降は、沈み込み後の反転上昇が大きいものから使う
    H = 0   # 現在の高さ
    for h, b in up + down:
        if H+b>=0:  # 高さが0未満にならない条件
            H += h
        else:
            print(No)
            return
    # 出力
    if H == 0:
        print(Yes)
    else:
        print(No)


main()



Measured memory_bytes: 91788
#include<stdio.h>
#include<string.h>

#define STRING_MAX (200000+1)
#define MAP_SIZE 26
#define A_VALUE 97

int main(void){
    char s[STRING_MAX], t[STRING_MAX];
    int map1[MAP_SIZE], map2[MAP_SIZE];
    for(int i = 0; i < MAP_SIZE; i++){
        map1[i] = -1;
        map2[i] = -1;
    }
    scanf("%s\n%s", s, t);
    int length = strlen(s);

    for(int i = 0; i < length; i++){
        if(map2[s[i] - A_VALUE] >= 0){
            if(map2[s[i] - A_VALUE] != t[i]){
                printf("No\n");
                return 0;
            }
        }
        if(map1[t[i] - A_VALUE] >= 0){
            if(map1[t[i] - A_VALUE] != s[i]){
                printf("No\n");
                return 0;
            }
        }
        if(map2[s[i] - A_VALUE] < 0){
            map2[s[i] - A_VALUE] = t[i];
        }
        if(map1[t[i] - A_VALUE] < 0){
            map1[t[i] - A_VALUE] = s[i];
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
S = input()

happy = 0
ncc = 1 # number of connected components
for i in range(N):
    if S[i] == 'L':
        if i > 0 and S[i - 1] == 'L':
            happy += 1
    elif S[i] == 'R':
        if i < N - 1 and S[i + 1] == 'R':
            happy += 1
    if i > 0 and S[i] != S[i - 1]:
        ncc += 1
if ncc >= 3:
    p = min(K, (ncc - 1) // 2)
    ncc -= 2 * p
    happy += 2 * p
    K -= p
if ncc == 2 and K > 0:
    happy += 1
print(happy)

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

int main()
{
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    set<int> s1;
    for(int i=0; i<N;){
        if(S[i] == 'o'){
            s1.insert(i);
            i += C + 1;
        }else{
            i++;
        }
    }
    set<int> s2;
    for(int i=N-1; i>=0;){
        if(S[i] == 'o'){
            s2.insert(i);
            i -= C + 1;
        }else{
            i--;
        }
    }
    if(s1.size() > K) return 0;
    if(s2.size() > K) return 0;

    set<int> s;
    set_intersection(
        s1.begin(), s1.end(),
        s2.begin(), s2.end(),
        inserter(s, s.end())
    );

    for(auto c : s) cout << (c+1) << endl;

    return 0;
}


Measured memory_bytes: 29828
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b + c || b == a + c || c == a + b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	double pi=acos(-1);
	
	int r;
	cin>>r;
	
	double ans=2*r*pi;
	printf("%.10f\n",ans);
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<int>> num(20, vector<int>(n));
    rep(i,n) rep(j,20) if(a[i] >> j & 1) num[j][i]++;

    ll ans = 0;
    vector<int> cnt(20);
    int idx = 0;
    rep(i,n){
        while(1){
            if(idx == n) break;
            bool flag = true;
            rep(j,20) if(cnt[j] + num[j][idx] > 1) flag = false;
            if(!flag) break;
            rep(j,20) cnt[j] += num[j][idx];
            idx++;
            if(idx == n) break;
        }
        ans += idx - i;
        rep(j,20) cnt[j] -= num[j][i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 20388
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;

int u[14] = {} , n , sum , tot;
int w[52];
int memo[1000][52];


int f(int s){
	if(memo[sum][s] >= 10000) return false;
	else memo[sum][s]++;

	if(s==0){
		for(int i = n ; i > 0 ; i--){
			cout << w[i] << (i!=1?" ":"\n");
		}
		return true;
	}
	if(s==n){
		for(int i = 1 ; i <= 13 ; i++){
			if(u[i]){
				--u[i];
				sum += i;
				w[s] = i;
				if( f(s-1) ) return true;
				sum -= i;
				++u[i];
			}
		}
	}else{

		bool chk = 0;
		for(int i = 1 ; i <= 13 ; i++){
			if(u[i] && tot % i == 0) chk = true;
		}
		
		if(!chk ){
			
			return false;
		}
		for(int i = 1 ; i <= 13 ; i++){
			if(u[i] && sum % i == 0){
				--u[i];
				sum += i;
				w[s] = i;
				if( f(s-1) ) return true;
				sum -= i;
				++u[i];
			}
		}
	}
	return false;
}
int main(){
	while(cin >> n && n){
		
		tot = 0;
		memset(memo,0,sizeof(memo));
		for(int i = 1 ; i <= 13 ; i++){
			u[i] = 0;
		}
		for(int i = 0 ; i < n ; i++){ int a; cin >> a; ++u[a]; tot += a; }
		sum = 0;
		if(!f(n)) cout << "No" << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    string s;
    cin >> s;
    ll r = 0;
    ll tmp = 0;
    
    rep(i, (ll)s.size()) {
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
            tmp++;
            r = max(r, tmp);
        } else {
            tmp = 0;
        }
        
    }
    
    mes(r);
    
    
        
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 3616
main = do
 [_,k] <- map read . words <$> getLine
 a <- map read . words <$> getLine
 print (solve a k)

solve :: [Int] -> Int -> Int
solve [x] p = 0
solve (x:xs) p = mod (mod (mod (div (p*(p+1)) 2) 1000000007 *length [c | c <- xs, c < x] + mod (div (p*(p-1)) 2) 1000000007 * length [c | c <- xs, c > x])1000000007 + solve xs p) 1000000007

Measured memory_bytes: 1404
var stdin = require("fs").readFileSync("/dev/stdin", "utf8");
stdin = stdin.trim().split("\n").reverse();
function input(){return stdin.pop()};
var stdout = [];
function print(x){stdout.push(x)};


var n = parseInt(input());
var h = input().split(" ").map(n=>parseInt(n));


var maxh = h[0];
var ans = 1
for (i=1; i < n; i++){
    if (h[i] > maxh-1){
        ans++;
        maxh = h[i]
    }
}

print(ans);


stdout = stdout.join("\n");
console.log(stdout);

Measured memory_bytes: 7372
f=lambda:map(int,input().split())
h,w,n=f()
c=[(h-2)*(w-2)]+[0]*9
d={}
while n:
 n-=1;x,y=f()
 for i in range(9):
  a=(x+i%3,y+i//3)
  if h>=a[0]>2<a[1]<=w:t=d[a]=d.get(a,0)+1;c[t-1]-=1;c[t]+=1
print(*c)

Measured memory_bytes: 166484
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*A = map(int, read().split())
    
    L = [A[0]]
    R = deque([A[-1]])

    for i in range(1,N):
        L.append(L[-1] ^ A[i])
        R.appendleft(R[0] ^ A[-(i+1)])

    ans = [R[1]]
    for i in range(1,N-1):
        ans.append(L[i-1] ^ R[i+1])
    ans.append(L[-2])

    print(*ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 42788
#include <iostream>

using namespace std;
    
int main() {
	int N;
	cin >> N;
	if(N == 2){
		int A, B;
		cin >> A;
		cin >> B;
		cout << A + B;
	}
	else{
		cout << "Hello World" <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class BATCoder {
public:
  void solve(std::istream &cin, std::ostream &cout) {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
      int cnt = 0;
      for (int j = i; j < s.size(); ++j) {
        if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') {
          cnt++;
        } else {
          break;
        }
      }
      ans = max(ans, cnt);
    }
    cout << ans << endl;
  }
};


int main() {
  BATCoder solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
s = str(input())
k = int(input())
sub = []
c = 5
if len(s)  < 5:
  c = len(s)
for i in range(c):
  for j in range(len(s)-i):
    sub.append(s[j:j+i+1])

sub = list(set(sub))
sub.sort()
print(sub[k-1])


Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll inf = 1e9+7;
int a,b,c;

int main() {
	cin>>a>>b>>c;
	if(a+b>=c){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, k, ans, a, b;
	cin >> n >> k;
	if (k == 1) ans = 0;
	else ans = (n - k);
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

#define N 8
#define FREE 1
#define NOT_FREE 0

int row[N],col[N],dpos[15],dneg[15],A[N][N];
int i,j,n,r,c;

void printBoard(){
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(A[i][j]&&row[i]!=j)return;
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void putQueen(int i){
  int j;
  if(i==N){
    printBoard();
    return;
  }

  for(j=0;j<N;j++){
    if(col[j]==NOT_FREE||dpos[i+j]==NOT_FREE||dneg[i-j+N-1]==NOT_FREE)continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    putQueen(i+1);
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  scanf("%d",&n);

  for(i=0;i<15;i++){
    dpos[i]=dneg[i]=FREE;
  }

  for(i=0;i<N;i++){
    col[i]=row[i]=FREE;
    for(j=0;j<N;j++){
      A[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    A[r][c]=90;
  }
  putQueen(0);
  return 0;
}



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

int main()
{
    int X, Y;
    cin >> X >> Y;
    if (Y % 2 == 1)
    {
        cout << "No" << endl;
        return 0;
    }
    int a = 2 * X - Y / 2, b = Y / 2 - X;
    if (a < 0 || b < 0)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

struct Point{
  double x;
  double y;
};

void Koch(int, struct Point, struct Point);

int main(){
  int n;
  struct Point s, t;

  scanf("%d",&n);

  s.x = 0;
  s.y = 0;
  t.x = 100;
  t.y = 0;

  printf("%.8f %.8f\n",s.x,s.y);
  Koch(n, s, t);
  printf("%.8f %.8f\n",t.x,t.y);

  return 0;
}

void Koch(int x, struct Point a, struct Point b){
  struct Point s, t, u;

  if(x == 0) return;

  double radian = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(radian) - (t.y - s.y) * sin(radian) + s.x;
  u.y = (t.x - s.x) * sin(radian) + (t.y - s.y) * cos(radian) + s.y;

  Koch(x - 1, a, s);
  printf("%.8f %.8f\n",s.x,s.y);
  Koch(x - 1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  Koch(x - 1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  Koch(x - 1, t, b);
}



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

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

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

  vector <int> a(n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    count = count + a[i];
  }
  // printVec(a);
  sort(a.rbegin(), a.rend());
  // cout <<"----";
  // printVec(a);
  int check = count / (m * 4);

  bool ans = true;
  for(int i = 0; i < m; i++) {
    if (a[i] * m * 4 < count) {
      ans = false;
      break;
    }
  }
  if (ans == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  	return 0;
}

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

int main(void){
    int n, a[5][205], sum = 0, max = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[1][i];
    for (int i = 1; i <= n; i++) {
        cin >> a[2][i];
        sum += a[2][i];
    }
    sum += a[1][1];
    if (max < sum) max = sum;
    for (int i = 1; i < n; i++) {
        sum += (a[1][i + 1] - a[2][i]);
        if (max < sum) max = sum;
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    int n, k;
    cin >> n >> k;
    double ret = 0;
    rep(l, n) {
        if (l >= k) ret++; 
        else {
            int m = ceil(log2(double(k)/(l+1)));
            ret += 1.0 / double(pow(2, m)); 
        }
    } 
    ret /= n;
    cout << setprecision(10) <<  ret << endl;
    return 0;
}

Measured memory_bytes: 640
from collections import Counter
#K,X = map(int,input().split())
N = int(input())
S = [''.join(sorted(input())) for i in range(N)]
result = 0
c = {}
for s in S:
    if c.get(s) is None:
        #print('None')
        c[s] = 1
    else:
        result += c[s]
        c[s] += 1
print(result)

Measured memory_bytes: 19760
//============================================================================
// Name        : ReversePoland.cpp
// Author      : koike
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <stack>
#include <sstream>

using namespace std;
const int BLOCK_LENGTH = 3;
const char PLUS = '+';
const char MINUS = '-';
const char POWER = '*';
const char NOT_BLOCK = 'n';
std::stack<int> numStack;


bool strIsDigit(string str) {
	try{
		stoi(str);
	}catch (std::invalid_argument e) {
		return false;
	}

	return true;
}

void calcStackNums(string ope) {

	int result = 0;
	const char* c_ope = ope.c_str();

	int var2 = numStack.top();
	numStack.pop();
	int var1 = numStack.top();
	numStack.pop();

	switch (c_ope[0]) {
		case PLUS:
			result = var1 + var2;
			break;
		case MINUS:
			result = var1 - var2;
			break;
		case POWER:
			result = var1 * var2;
			break;
		default:
			cout << "calc error" << endl;
			break;
	}

	numStack.push(result);
}

void calcPoland(vector<string> &formula) {

	string top;

	for (vector<string>::iterator it = formula.begin(); it != formula.end(); ++it)
	{
		if (strIsDigit(*it)) {
			numStack.push(stoi(*it));
		}
		else {
			calcStackNums(*it);
		}
	}
}


vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main() {

	string s;
	getline(cin, s);
	vector<string> formula = split(s,' ');

	calcPoland(formula);

	cout << numStack.top() << endl;

	return 0;
}

Measured memory_bytes: 3280
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

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

signed main() {
	int n, m;
	cin >> n >> m;

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

	int cnt = 0;
	for(int i = 0; i < n; i++) {
		if((double)a[i] < (double)sum / (4.0 * (double)m)) cnt = cnt;
		else cnt ++;
	}

	if(cnt >= m) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


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

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+10), b(n+10), c(n+10);
    for (int i=0; i<n; i++){
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }

    vector<vector<int>> dp(n+10, vector<int> (3, 0));
    dp.at(0).at(0) = a.at(0);
    dp.at(0).at(1) = b.at(0);
    dp.at(0).at(2) = c.at(0);

    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            if(j == 0){
                chmax(dp.at(i+1).at(1), dp.at(i).at(j)+b.at(i+1));
                chmax(dp.at(i+1).at(2), dp.at(i).at(j)+c.at(i+1));
            } else if(j==1){
                chmax(dp.at(i+1).at(0), dp.at(i).at(j)+a.at(i+1));
                chmax(dp.at(i+1).at(2), dp.at(i).at(j)+c.at(i+1));
            } else {
                chmax(dp.at(i+1).at(0), dp.at(i).at(j)+a.at(i+1));
                chmax(dp.at(i+1).at(1), dp.at(i).at(j)+b.at(i+1));                
            }
        }
    }

    int ans;
    ans = max(max(dp.at(n-1).at(0), dp.at(n-1).at(1)), dp.at(n-1).at(2));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  int X[M];
  for(int i=0;i<M;i++){
    cin >> X[i];
  }
  sort(X,X+M);
  vector<int> sub;
  int ans = 0;
  if(M > 1 && M > N){
  for(int i=0;i<M-1;i++){
    sub.push_back(X[i+1]-X[i]);
  }
  std::sort(sub.begin(),sub.end());
  for(int i=0;i<sub.size()-N+1;i++){
    ans += sub[i];
  }
}
  cout << ans << endl;
  return 0;
}


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



Measured memory_bytes: 2104
using System;

class _0107
{
    public static void Main()
    {
        int n;
        double x, y, z, r;
        string[] bar;
        while (true)
        {
            bar = Console.ReadLine().Split();
            if (bar[0] == "0" && bar[1] == "0" && bar[2] == "0") break;
            x = double.Parse(bar[0]) / 2;
            y = double.Parse(bar[1]) / 2;
            z = double.Parse(bar[2]) / 2;
            n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                r = double.Parse(Console.ReadLine());
                if (Math.Sqrt(x * x + y * y) < r) { Console.WriteLine("OK"); continue; }
                if (Math.Sqrt(y * y + z * z) < r) { Console.WriteLine("OK"); continue; }
                if (Math.Sqrt(z * z + x * x) < r) { Console.WriteLine("OK"); continue; }
                Console.WriteLine("NA");
            }
        }
    }
}

Measured memory_bytes: 5656
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
	int a,b;

	for(int i=0;i<7;i++){
		cin>>a>>b;
		cout<<a-b<<endl;
	}


	return 0;
}

Measured memory_bytes: 3096