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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (2600006)
ll n, m, mod = 998244353, f[MAXN], inv[MAXN];
int main(){
	FAST
	cin>>n>>m;
	auto qexp=[&](ll x,ll e){
		ll sum=1;
		while(e){
			if(e&1) sum*=x, sum%=mod;
			x*=x,x%=mod;
			e>>=1;
		}
		return sum;
	};
	f[0]=1; FOR(i,1,MAXN-1) f[i]=f[i-1]*i%mod;
	inv[MAXN-1] = qexp(f[MAXN-1], mod-2); DEC(i,MAXN-2,0) inv[i]=inv[i+1]*(i+1)%mod;
	auto C=[&](ll n,ll k){
		return n < k ? 0ll : f[n] * inv[k] % mod * inv[n-k] % mod;
	};
	ll ans=C(3*m+(n-1), n-1);
	cerr<<ans<<'\n';
	ans -= n * C(3*m-(2*m+1)+(n-1), n-1) % mod, ans += mod, ans %= mod;
	FOR(odd,m+1,n){
		if((3*m-odd)%2==0) ans -= C(n, odd) * C((3*m - odd)/2 + (n-1), n-1) % mod, ans += mod, ans %= mod;
	}
	cout<<ans<<'\n';
}


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

int main(){
    int long long N, K;
    cin >> N >> K;
    vector<int long long> H(N);
    for(int i = 0; i < N; i++){
        cin >> H.at(i);
    }
    sort(H.begin(), H.end());
    int long long A = 0;
    for(int long long i = 0; i < (N - K); i++){
        A = A + H.at(i);
    }
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
	int w;
	int h;
	int x;
	int y;
	int r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(w - r >= x && h - r >= y && r <= x && r <= y){
		printf("%s\n","Yes");
	}else{
		printf("%s\n","No");
	}

	return 0;
}


Measured memory_bytes: 2692
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int bad_list[2000000];
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> A;
    REP(i, n) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(ALL(A));
    int now_itr = 0;
    REP(i, (1 << n)) {
        int ans = 0;
        int now = i;
        int q = 0;
        for (q = 0; now != 0; q++) {
            if (now % 2 == 1) {
                ans += A[q];
            }
            now /= 2;
        }
        if (k == ans) {
            bad_list[now_itr] = i;
            now_itr++;
        }
    }
    int ans = n;
    int now_cnt = 0;
    set<int> already_done;
    for (int i = 0;; ++i) {
        if (i % 100 == 0) {
            if ((long double)clock() / (long double)CLOCKS_PER_SEC >= 0.90) {
                break;
            }
        }
        int now = 0;
        int cnt = 0;
        for (int q = 0; q < n; ++q) {
            if (xor128() % 2LL == 1LL) {
                now += (1 << q);
            }
            else {
                cnt++;
            }
        }
        if (ans > cnt&&already_done.find(now) == already_done.end()) {
            already_done.insert(now);
            now_cnt++;
            int ok = 1;
            REP(i, now_itr) {
                if ((bad_list[i] & now) == bad_list[i]) {
                    ok = 0;
                    break;
                }
            }
            if (ok == 1) {
                ans = cnt;
            }
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    init();
    solve();
}



Measured memory_bytes: 42668
X, Y = list(map(int, input().split()))

kame = 0
tsuru = 0

ans = False
for ki in range(101):
    for ti in range(101):
        if ki + ti != X:
            continue
        sm = 4 * ki + 2 * ti
        if sm == Y:
            ans = True


if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

  const int INF = 10000000;
  int ans = 0;
  int h,w;
  
  int sy,sx,gy,gx;
  char c[55][55];
  int d[55][55];

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

int bfs(){
  queue<pair<int,int>> que;
  
  FOR(i,0,h-1){
    FOR(j,0,w-1){
      d[i][j] = INF;
    }
  }
  que.push(pair<int,int>(sy,sx));
  d[sy][sx] = 0;

  while(que.size()){
    pair<int,int> p = que.front();
    que.pop();

    if(p.first == gy && p.second == gx) break;

    FOR(i,0,3){
      int ny = p.first + dy[i];
      int nx = p.second + dx[i];

      // cout << nx << endl;
      // cout << ny << endl;
      // cout << c[ny][nx] << endl;
      // cout << d[ny][nx] << endl;

      if(nx>=0 && nx<w && ny>=0 && ny<h && c[ny][nx]=='.' && d[ny][nx] == INF){
        que.push(pair<int,int>(ny,nx));
        d[ny][nx] = d[p.first][p.second] + 1;
        // cout << ny << " " << nx << " " <<  d[ny][nx] << endl;
      }
    }
  }
  return d[gy][gx];
}


int main() {

  cin >> h >> w;
  gy = h-1;
  gx = w-1;

  int counts = 0;

  FOR(i,1,h){
    string s;
    cin >> s;
    FOR(j,1,w){
      c[i-1][j-1]=s[j-1];
      if(s[j-1]=='#') ++counts;
    }
  }

  int route = bfs();

  if(route==INF) cout << -1 << endl;
  
  else cout << h*w - route - counts - 1 << endl;

  // cout << bfs() << " " << counts << endl;

  // cout << d[0][0] << " " << d[0][1] << " " << d[0][2] << endl;

}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N);
  REP(i, 0, N) {
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<>());

  ll ans = A[0];
  REP(i, 1, N - 1) {
    ll a = A[(i - 1) / 2 + 1];
    ans += a;
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lb long double
#define pb push_back
#define l first
#define r second
#define qwerty3 -> first
#define qwerty4 -> second
#define umap unordered_map
#define uset unordered_set
#define pii pair < int , int >

using namespace std;

const int N = 5000005;
const int M = 1000000007;
const lb PI = acos(-1);

ll x , y , z , k;
ll a[N] , b[N] , c[N] , d[N] , s[N];

int main()
{
    ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);

    ll i , j;

    cin >> x >> y >> z >> k;

    for(i = 1 ; i <= x ; i++)
        cin >> a[i];

    for(i = 1 ; i <= y ; i++)
        cin >> b[i];

    for(i = 1 ; i <= z ; i++)
        cin >> c[i];

    ll m = 0 , cnt = 0;

    for(i = 1 ; i <= x ; i++)
        for(j = 1 ; j <= y ; j++)
            d[++m] = a[i] + b[j];

    sort(d + 1 , d + m + 1 , greater < ll > ());
    sort(c + 1 , c + z + 1 , greater < ll > ());

    m = min(m , k);

    for(i = 1 ; i <= m ; i++)
        for(j = 1 ; j <= z ; j++)
            s[++cnt] = d[i] + c[j];

    sort(s + 1 , s + cnt + 1 , greater < ll > ());

    for(i = 1 ; i <= k ; i++)
        cout << s[i] << '\n';

    return 0;
}


Measured memory_bytes: 39168
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    cout << s[0] + to_string(s.size() - 2) + s[s.size() - 1] << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1L<<60;
struct Edge {
	long long from;
	long long to;
	long long cost;
};

vector<Edge> es;
vector<long long> d;
long long V, E, from;

void shortest_path(long long s){
	for (long long i = 0; i < V; i++) d[i] = INF;
	d[s] = 0;
	long long count = 0;
	while(true){
		count++;
		bool update = false;
		for(long long i = 0; i < E; i++){
			Edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update) break;
		if(count == V - 1){
			d[s] = INF;
			break;
		}
	}
}

bool find_negative_loop() {
	for(long long i = 0; i < V; i++) d[i] = 0;
	for(long long i = 0; i < V; i++){
		for(long long j = 0; j < E; j++){
			Edge e = es[j];
			if(d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				if(i == V - 1) return true;
			}
		}
	}
	return false;
}

int solve() {
	cin >> V >> E >> from;
	d.resize(V);
	for(long long i = 0; i < E; i++) {
		long long a, b, cost;
		cin >> a >> b >> cost;
		Edge e = {a, b, cost};
		es.push_back(e);
	}
	shortest_path(from);
	if(d[from] == INF) {
		cout << "NEGATIVE CYCLE" << endl;
	}else {
		for(long long i = 0; i < V; i++){
			if(d[i] == INF){
				cout << "INF" << endl;
			}else{
				cout << d[i] << endl;
			}
		}
	}
	return 0;
}

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



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

int main(){
    for(int i = 1; ; i++){
        int x, y;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x > y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        cout << x << " " << y << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3040
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b)
    puts("a < b");
    if(a==b)
     puts("a == b");
     if(a>b)
     puts("a > b");
     return 0;
}


Measured memory_bytes: 2608
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;
using System.Xml;

namespace hello_world
{
	class Program
	{

		static void Main(string[] args)
		{
			string[] s = Console.ReadLine().Split(' ');
			int a = int.Parse(s[0]);
			int b = int.Parse(s[1]);
			int AC = 0, WA = 0;
			int[] wwa = new int[a];
			bool[] no = new bool[a];
			int[] qq = new int[b];
			for(int i = 0; i < b; i++)
			{
				string[] w = Console.ReadLine().Split(' ');
				qq[i] = int.Parse(w[0]);
				if (no[qq[i]-1])
					continue;
				else if(w[1].Equals("AC"))
				{
					AC++;
					WA += wwa[qq[i]-1];
				
					no[qq[i] - 1] = true;
						}else if (w[1].Equals("WA"))
				{
					wwa[qq[i]-1]++;
				}


			}Console.WriteLine("{0} {1}", AC, WA);
		}

	}

	}



Measured memory_bytes: 17868
import java.util.Scanner;

//Minimal Backgammon
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt(), T = sc.nextInt(), l = sc.nextInt(), b = sc.nextInt();
			if((n|T|l|b)==0)break;
			boolean[] lose = new boolean[n+1];
			for(int i=0;i<l;i++)lose[sc.nextInt()] = true;
			boolean[] back = new boolean[n+1];
			for(int i=0;i<b;i++)back[sc.nextInt()] = true;
			double[][] p = new double[T+1][n+1];
			p[0][0] = 1.0;
			for(int t=0;t<T;t++)for(int i=0;i<=n;i++){
				if(i==n){
					p[t+1][n] += p[t][n]; continue;
				}
				for(int j=1;j<=6;j++){
					double dt = p[t][i]/6.0;
					int next = i+j;
					if(n<next){
						int d = next-n;
						next = n-d;
					}
					if(lose[next]){
						if(t+2<=T)p[t+2][next] += dt;
					}
					else if(back[next]){
						p[t+1][0] += dt;
					}
					else p[t+1][next] += dt;
				}
			}
			System.out.printf("%.6f\n", p[T][n]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  string s, t; cin >> s >> t;
  int mini = s.length();
  for(int i = 0; i < s.length() - t.length() + 1; i++){
    int tmp = 0;
    for(int j = i; j < i + t.length(); j++){
      if(s[j] != t[j-i]){
        tmp++;
      }
    }
    mini = min(tmp, mini);
  }
  cout << mini << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // 主処理
        char[] array = s.toCharArray();
        int result = 0;
        for (char c : array) {
            result += c == '+' ? 1 : -1;
        }

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


Measured memory_bytes: 21716
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let b: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let a_sum: usize = a.iter().sum();
    let b_sum: usize = b.iter().sum();
    if a_sum > b_sum {
        return "No".to_string();
    }
    let c = b_sum - a_sum;

    let mut c1: usize = 0;
    let mut c2: usize = 0;
    for i in 0..n {
        if a[i] > b[i] {
            c1 += a[i] - b[i];
        }
        if b[i] > a[i] {
            c2 += (b[i] - a[i] + 1) / 2;
        }
    }
    if c1 > c || c2 > c {
        return "No".to_string();
    }

    return "Yes".to_string();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h;
  while(cin>>h,h){
    int a[10][5],ans=0;
    for(int i=0;i<h;i++)
      for(int j=0;j<5;j++)cin>>a[i][j];
    bool f=1;
    while(f){
      f=0;
      for(int i=0;i<h;i++){
	int c=1,p=0;
	for(int j=1;j<5;j++)
	  if(a[i][p]==a[i][j])c++;
	  else if(c<3)c=1,p=j;
	  else break;
	if(c>=3){
	  ans+=c*a[i][p];
	  for(int k=0;k<c;k++)a[i][p+k]=0;
	}
      }
      for(int i=0;i<5;i++)
	for(int j=1;j<h;j++)
	  for(int k=j;k>0;k--)
	    if(!a[k][i]&&a[k-1][i])swap(a[k][i],a[k-1][i]),f=1;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int MOD = (int) 998244353;
//const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n, q;
LL m;
int a[maxn], b[maxn], c[maxn];

int f[maxn];
int find_f(int x)
{
    if(x == f[x]) return x;
    return f[x] = find_f(f[x]);
}

void work()
{
    cin >>n >>m >>q;
    for(int i = 0; i < q; i++) cin >>a[i] >>b[i] >>c[i];

    for(int i = 0; i < n; i++) f[i] = i;

    int cnt = 0, comp = n;
    for(int i = 0; i < q; i++)
    {
        if(c[i] == 0)
        {
            int fx = find_f(a[i]), fy = find_f(b[i]);
            f[fx] = fy;

            if(fx != fy) comp--;
        }
    }

    for(int i = 0; i < q; i++)
    {
        if(c[i] == 1)
        {
            if(find_f(a[i]) == find_f(b[i]))
            {
                cout <<"No" <<endl;
                return ;
            }
            cnt++;
        }
    }

    LL mn = n - (cnt == 0), mx = (LL) comp * (comp - 1) / 2 + (n - comp);

    if(mn <= m && m <= mx)
    {
        cout <<"Yes" <<endl;
    }
    else
    {
        cout <<"No" <<endl;
    }
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    scanf("%d", &tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 1792
#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, K, Atmp;
    cin >> N >> K;
    vector<int> child(N);
    vector<int> d(K);
    vector<vector<int>> A(100, vector<int>(100));
    rep(i, K){
        cin >> d.at(i);
        rep(j, d.at(i)){
            cin >> A.at(i).at(j);
        }
    }

    rep(i, K){
        rep(j, d.at(i)){
            child.at(A.at(i).at(j)-1)=1;
        }
    }
    int c=0;
    rep(i, N){
        if(child.at(i)==0){
            c++;
        }
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 3672
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

a,b,c = gi

puts c >= a && c<=b ? 'Yes' : 'No'



Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a-b==b-c)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50f\n", a)//少数出力
#define printdbd(a) printf("%.16f\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {
	
	int n;
	scanf("%d", &n);
	bool b = false;
	rep1(i, 9) {
		if (n % i == 0 && n / i < 10)b = true;
	}
	printyn(b);
}

Measured memory_bytes: 888
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = "YES";
        var dic = new Dictionary<char, int>();
        dic.Add('a', 0);
        dic.Add('b', 0);
        dic.Add('c', 0);
        for (int i = 0; i < s.Length; i++)
        {
            dic[s[i]]++;
        }

        if (s.Length == 1)
        {
            ans = "YES";
        }
        else if (s.Length == 2)
        {
            if (dic['a'] == 2 || dic['b'] == 2 || dic['c'] == 2) ans = "NO";
        }
        else
        {
            foreach (var item in dic)
            {
                var tnum = (int)Math.Floor((double)(s.Length) / (double)3);
                if (item.Value < tnum || item.Value > tnum +1)
                {
                    ans = "NO";
                }
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}


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

int n;
vector<int> x(10),y(10);
 
double dist(int i, int j) {
  double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
  }
  
 void solve() {

  cin >> n;
  for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
  
  vector<int> k(n);
  rep(i, n) {
  k.at(i) = i + 1; 
   }
   
  double sum = 0.0;
  do {
  for(int i = 0; i < n - 1; i++){
  sum += dist(k.at(i), k.at(i + 1));
  }
  } while (next_permutation(k.begin(),k.end()));
  
  int factorial = 1;
  for(int i = 2; i <= n; i++) {
   factorial *= i;
   }
   
   cout << fixed << setprecision(10) << sum / factorial;
   return;
   }
  
  int main(){
  solve();
  return 0;
  }

Measured memory_bytes: 4260
package main

import (
	"fmt"
)

func main() {

	var N, A int
	fmt.Scanf("%d", &N)

	member := make([]int, N)
	for i := 1; i < N; i++ {
		fmt.Scanf("%d", &A)
		member[A-1] = member[A-1] + 1
	}

	for i := 0; i < N; i++ {
		fmt.Println(member[i])
	}
}


Measured memory_bytes: 6492
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

double minkowski (const vector<double> &x, const vector<double> &y, int p) {
	double sum = 0;
	for (size_t i = 0; i < x.size(); i++) {
		sum += pow(abs(x[i] - y[i]), p);
	}
	return pow(sum, 1.0 / p);
}

double chebyshev (const vector<double> &x, const vector<double> &y) {
	double ret = 0.0;
	for (size_t i = 0; i < x.size(); i++) {
		ret = max(ret, abs(x[i] - y[i]));
	}
	
	return ret;
}

int main() {
	int n;
	cin >> n;
	vector<double> x(n), y(n);
	for (auto &e : x) cin >> e;
	for (auto &e : y) cin >> e;
	
	cout << fixed << setprecision(10);
	cout << minkowski(x, y, 1) << '\n';
	cout << minkowski(x, y, 2) << '\n';
	cout << minkowski(x, y, 3) << '\n';
	cout << chebyshev(x, y) << '\n';
	
	return 0;
}


Measured memory_bytes: 3468
#include<stdio.h>
#include<string.h>
#include<iostream>

using namespace std;

typedef struct {
	char name[100];
	int time;
}Px;
Px Q[100000];

int min(int a, int b) { return a < b ? a : b; }

int head, tail;

void enqueue(Px x) {
	Q[tail] = x;
	tail = (tail + 1)%100000;
}

Px dequeue() {
	Px x = Q[head];
	head = (head + 1) % 100000;
	return x;
}


int main()
{
	int n,q,c, sum = 0;
	Px u;
	cin >> n >> q;
	for (int i = 1; i <= n; i++) {
		cin >> Q[i].name >> Q[i].time;
	}
	head = 1, tail = n + 1;
	
	while (head != tail) {
		u = dequeue();
		c = min(q, u.time);
		u.time -= c;
		sum += c;
		if (u.time > 0) enqueue(u);
		else {
			cout << u.name << ' ' << sum << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 13268
#include<stdio.h>

int main()
{
    int n,i;
    scanf("%d",&n);
    int flag =0;

    int arr[n];

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

    }



    for(i=0;i<n;i++)
    {
        if(arr[i]%2 == 0 && arr[i]%3 != 0 && arr[i]%5 != 0)
        {
            flag = 1;
            break;

        }
    }

    if(flag == 0)
        printf("APPROVED\n");
    else if(flag == 1)
        printf("DENIED\n");

    return 0;
}







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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n, m;
    cin >> n >> m;

    vb dont(n + 1, false);
    rep(i, 0, m) {
        int a;
        cin >> a;
        dont[a] = true;
    }

    vll dp(n + 1, 0);
    dp[0] = 1;

    rep(i, 1, n + 1) {
        if (dont[i]) { continue; }
        if (i - 1 >= 0) { dp[i] = (dp[i] + dp[i - 1]) % MOD; }
        if (i - 2 >= 0) { dp[i] = (dp[i] + dp[i - 2]) % MOD; }
    }
    cout << dp.back() << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

void Main() {
    long long N, A, B;
    cin >> N >> A >> B;

    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
        return;
    }

    long long AtoLast = N - A;
    long long BtoTop = B - 1;

    if (AtoLast < BtoTop) {
        // A will move to Last
        long long BtoLast = N - B;
        long long ans = (BtoLast + 1) + (N - (A + BtoLast + 1)) / 2;
        cout << ans << endl;
    }
    else {
        // B will move to Top
        long long AtoTop = A - 1;
        long long ans = (AtoTop + 1) + (B - (AtoTop + 1) - 1) / 2;
        cout << ans << endl;
    }
    return;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int a,b,c;
    char op;
    for(int i = 0;; i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '+'){
            c = a + b;
        }
        else if(op == '-'){
            c = a - b;
        }
        else if(op == '*'){
            c = a * b;
        }
        else if(op == '/'){
            c = a / b;
        }
        else if(op == '?'){
            break;
        }
        printf("%d\n",c);
    }
    return 0;
}


Measured memory_bytes: 2744
def maxHeapify(A, i):
    l = left(i)
    r = right(i)
    # 左の子、自分、右の子で値が最大のノードを選ぶ
    if l <= H and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r <= H and A[r] > A[largest]:
        largest = r

    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        maxHeapify(A, largest)


def left(i):
    return i*2


def right(i):
    return i*2 + 1


def buildMaxHeap(A):
    for i in range(H//2, 0, -1):
        maxHeapify(A, i)


H = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

buildMaxHeap(A)
print('', *A[1:])



Measured memory_bytes: 63700
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    string S,T;
    cin >> S >> T;
    int s = len(S);
    int t = len(T);
    int ans = infi;
    rep(i,s-t+1){
        int a = 0;
        rep(j,t) if(S[i+j] != T[j]) a++;
        chmin(ans,a);
    }
    cout << ans << endl;
    
    

    return 0;
}


Measured memory_bytes: 3584
s = int(input())

def f(n):
    if n % 2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1

m = s
s = {s}
ans = 1

for i in range(1000000):
    m = f(m)
    ans += 1
    if m in s:
        print(ans)
        exit()
    else:
        s.add(m)

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

int main(){
  int N;
  cin>>N;
  vector<pair<double,pair<ll,ll>>> xy(N);
  for(int i=0;i<N;i++){
    ll x,y;
    cin>>x>>y;
    xy.at(i).second.first=x;
    xy.at(i).second.second=y;
    complex<double> c(x,y);
    xy.at(i).first=arg(c);
  }
  

  sort(xy.begin(),xy.end());

  ll ans=0;
  for(int i=0;i<N;i++){
    ll x=0;
    ll y=0;
    for(int j=0;j<N;j++){
      x+=xy.at((i+j)%N).second.first;
      y+=xy.at((i+j)%N).second.second;
      ans=max<ll>(ans,x*x+y*y);
    }
  }
  printf("%.12Lf\n",sqrtl(ans));
}


Measured memory_bytes: 512
n,m = map(int,input().split())
ab=[]
for i in range(n):
    ab.append([int(j) for j in input().split()])
ab.sort()
cnt = 0
ans = 0
for i in ab:
    cnt += int(i[1])
    ans += int(i[0])*int(i[1])
    if cnt >= m:
        ans -= int(i[0])*(cnt-m)
        print(ans)
        break

Measured memory_bytes: 21616
#N,K入力
N,K= map(int,input().split())
#街のテレポート先入力
A = [int(i)-1 for i in input().split()]
judge = [-1] * N
judge[0] = 0
#初期位置
a = 0
#移動回数
step = 1

while step != K +1:
    #移動する街を決める
    a = A[a]
    if judge[a] > -1:
        break
    #何回目の移動なのか加える
    judge[a] = step
    step = step + 1

if step == K +1:
    print(a+1)
    # プログラム終了
else:
    width = step - judge[a]
    s =(K - judge[a]) % width
    print(judge.index(judge[a]+s)+1)

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

using namespace std;

const int inf = 1e9;

string s;
int n, m;

//A 国人は座れればいい。左端から見ていき空いている椅子に座る。
void A(){
	for(int j=0; j< n; j++) if(s[j] == '#'){s[j] = 'A'; break;}
}


//B 国人は A 国人が苦手。 A 国人の隣以外で、右端から空いている椅子に座る。ただし、 A国人の隣しか空いていない場合、我慢して左端から空いている椅子に座る。
void B(){
	for(int j=n-1; 0 <= j; j--){
		if(s[j] != '#') continue;
		if(j == n-1 && s[j-1] != 'A'){s[j] = 'B'; return;}
		else if(j == 0 && s[j+1] != 'A'){s[j] = 'B'; return;}
		else if(s[j-1] != 'A' && s[j+1] != 'A'){s[j] = 'B'; return;}
	}
	for(int j=0; j< n; j++){
		if(s[j] == '#'){s[j] = 'B'; return;}
	}
}

//C 国人は人の隣に座りたい。左側から順に座っている人を見ていき、一番左側に座っている人 の右隣に座ろうとするが、そこが埋まっているならその人の左隣に座ろうとする。そこも埋まっ ているなら次の人の隣に同条件で座ろうとする。どの椅子にも人が座っていなければ真ん中(椅 子の数が奇数の場合 (n+1)/2 、偶数の場合 n/2+1 )の椅子に座る。
void C(){
	bool possible = true;
	for(int i=0; i< n; i++) if(s[i] != '#'){possible = false; break;}
	if(possible){s[(n%2==0 ? n/2 : (n+1)/2-1)] = 'C'; return;}

	for(int j=0; j < n; j++){
		if(s[j] != '#'){
			if(j != n-1 && s[j+1] == '#'){s[j+1] = 'C'; return;}
			if(j != 0 && s[j-1] == '#'){s[j-1] = 'C'; return;}
		}
	}
}

//D 国人は人の隣に座りたくない。一番近い人との距離が、一番大きくなる椅子に座ろうとする。 同条件の椅子が複数ある場合や、どうしても誰かの隣に座らなければならない場合、その中で一 番左側にある椅子に座る。誰も座っていない場合は左端の椅子に座る。
void D(){
	int maxd = 0, p = 0;
	for(int j=0; j < n; j++){
		if(s[j] != '#') continue;
		int d = 0, idx = j;
		while(0 <= idx && s[idx] == '#') idx--;
		d = (idx == -1 ? inf : j-idx);
		idx = j;
		while(idx < n && s[idx] == '#') idx++;
		d = min(d, (idx == n ? inf : idx-j));
		if(maxd < d){maxd = d; p = j;}
	}
	s[p] = 'D';
}

int main(){
	while(cin >> n >> m, n+m){
		s.clear();
		for(int i=0; i< n; i++) s+= "#";
		for(int i=0; i< m; i++){
			string t; cin >> t;
			if(t == "A")A();
			if(t == "B")B();
			if(t == "C")C();
			if(t == "D")D();
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	string s;
	cin >> s;
	int ans = 0;
	char b = s[0];
	if(count(all(s),'R') == 0)
	{
		cout << 0 << endl;
	} else if (count(all(s),'R') == 1)
	{

		cout << 1 << endl;
	} else if (count(all(s),'R') == 2)
	{
		if (s[0] == 'R' && s[2] == 'R')
			cout << 1 << endl;
		else
			cout << 2 << endl;
	} else
		cout << 3 << endl;

	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
  static int[] par;
  static int[] rank;
  static long[] size;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    par = new int[n];
    rank = new int[n];
    size = new long[n];
    int m = sc.nextInt();
    init(n);
    long[] ans = new long[m + 1];
    ans[m] = ((long)n * (long)(n - 1)) / 2;
    int[] a = new int[m];
    int[] b = new int[m];
    for(int i = 0; i < m; i++) {
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
    }
    for(int i = m - 1; i >= 0; i--) {
      if(same(a[i], b[i])) {
        ans[i] = ans[i + 1];
      } else {
        ans[i] = ans[i + 1] - (size(a[i]) * size(b[i]));
      }
      unite(a[i], b[i]);
    }
    for(int i = 1; i <= m; i++) {
      System.out.println(ans[i]);
    }
  }
  static void init(int m) {
    for(int i = 0; i < m; i++) {
      par[i] = i;
      rank[i] = 1;
      size[i] = 1;
    }
  }
  static int find(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }
  static void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x != y) {
      if(rank[x] < rank[y]) {
        par[x] = y;
        rank[y] += rank[x];
        size[y] += size[x];
      } else {
        if(rank[x] == rank[y]) {
          if(x > y) {
            par[x] = y;
            rank[y] += rank[x];
            size[y] += size[x];
          } else {
            par[y] = x;
            rank[x] += rank[y];
            size[x] += size[y];
          }
        } else {
          par[y] = x;
          rank[x] += rank[y];
          size[x] += size[y];
        }
      }
    }
  }
  static boolean same(int x, int y) {
    return find(x) == find(y);
  }
  static long size(int x) {
    return size[find(x)];
  }
}

Measured memory_bytes: 97140
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static List<int>[] li;
	static bool[] b,h;
	static int ans=0;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		li=new List<int>[s[0]];
		b=new bool[s[0]];
		h=new bool[s[0]];
		for(int i=0;i<s[0];i++){li[i]=new List<int>();}
		for(int i=0;i<s[1];i++){
			int[] e=sc.Ia;
			li[e[0]].Add(e[1]);
		}
		for(int i=0;i<s[0]&&ans==0;i++){
			if(!b[i]){Fu(i,i);}
		}
		Console.WriteLine("{0}",ans);
	}
	static void Fu(int a,int g){
		b[a]=true;
		h[a]=true;
		for(int i=0;i<li[a].Count;i++){
			if(h[li[a][i]]){ans=1;}
			else if(!b[li[a][i]]){Fu(li[a][i],g);}
		}
		h[a]=false;
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}


Measured memory_bytes: 18296
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100;

int main(void){
    ll H, W;
    string a[MAX_N];
    ll cnt_h[MAX_N], cnt_w[MAX_N];

    cin >> H >> W;

    rep(h, H) cin >> a[h];
    
    rep(w, W) cnt_w[w] = 0;
    rep(h, H) cnt_h[h] = 0;

    rep(w, W) rep(h, H) if (a[h][w] == '#') break; else if (h == H - 1) cnt_w[w] = 1; 
    rep(h, H) rep(w, W) if (a[h][w] == '#') break; else if (w == W - 1) cnt_h[h] = 1;

    rep(h, H){
        if (cnt_h[h] == 1) continue;
        rep(w, W){
            if (cnt_w[w] == 1) continue;
            cout << a[h][w];
        }
        cout << "" << endl;
    } 

    return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
start = min(X)
stop = max(X)
count = 0 
ans = 10**10
for i in range(start, stop+1):
    count = 0
    for x in X:
        count += (x-i)**2
    ans = min(count, ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((ll)(x).size())
#define inf          1<<25

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

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

int main() {
    ll n;
    cin >> n;
    
    ll ans = 0;
    rep(i, sqrt(n)) {
        ll x = (i+1) * (i+1);
        if (x <= n) ans = x;
    }
    cout << ans << endl;
    
    return 0;
}

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

const double EPS = 1e-8;
typedef complex<double> P;
typedef vector<P> VP;
double cross(P a, P b){
    return (conj(a)*b).imag();
}
P crosspointLL(P a1, P a2, P b1, P b2){
    double A = cross(a2-a1, b2-b1);
    double B = cross(a2-a1, a2-b1);
    return b1 + B/A * (b2-b1);
}
bool isParallel(P a, P b){
    return abs(cross(a,b)) < EPS;
}
int ope(P& from, P& to, P& move, P& fix){
    if(isParallel(to -from, fix -move)){
        from = to;
        return 1;
    }else if(isParallel(to -from, fix -from)){
        return 1e9;
    }else{
        move = crosspointLL(fix, fix+to-from, move, move+from-fix);
        from = to;
        return 2;
    }
}

int main(){
    int x,y;     
    while(cin >> x){
        vector<VP> tri(2, VP(3));
        for(int i=0; i<2; i++){
            for(int j=0; j<3; j++){
                if(i!=0 || j!=0) cin >> x;
                cin >> y;
                tri[i][j] = P(x,y);
            }
        }
        for(int i=0; i<2; i++){
            if(cross(tri[i][1] -tri[i][0], tri[i][2] -tri[i][0]) < EPS){
                swap(tri[i][1], tri[i][2]);
            }
        }
         
        int ans = 5;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                for(int v=1; v<=2; v++){
                    for(int q=1; q<=2; q++){
                        vector<VP> t = tri;
                        int ret1 = ope(t[0][i], t[1][j], t[0][(i+v)%3], t[0][(i+2*v)%3]);
                        int ret2 = ope(t[0][(i+q)%3], t[1][(j+q)%3], t[0][(i+2*q)%3], t[0][i]);
                        ans = min(ans, ret1 +ret2 +1);
                    }
                }
            }
        }
        if(ans == 5) cout << "Many" << endl;
        else cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int main(){
	
	int n;
	
	while(true){
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		string str[100];
		
		int score[100];
		
		for(int i = 0; i < n; i++){
			cin >> str[i];
			score[i] = 0;
			for(int j = 0; j < n - 1; j++){
				int hoge;
				cin >> hoge;
				if(hoge == 0){
					score[i] += 100;
				}else if(hoge == 1){
					score[i] -= 1;
				}
			}
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n - 1; j++){
				if(score[j] < score[j + 1]){
					swap(score[j], score[j + 1]);
					swap(str[j], str[j + 1]);
				}
			}
		}
		
		for(int i = 0; i < n; i++){
			cout << str[i] << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 3000