akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

const int INF = 0x3f3f3f3f;

int dp[2010][2010], ndp[2010][2010];
int row[2010], MAXJ;
int a[6010];

int Query() {
	return MAXJ;
}

int query(int x) {
	return row[x];
}

void modify(int x, int y) {
	if (dp[x][y] == ndp[x][y]) return ;
	row[x] = max(row[x], ndp[x][y]);
	MAXJ = max(MAXJ, ndp[x][y]);
	dp[x][y] = ndp[x][y];
}

bool check(int a, int b, int c) {
	return a == b && b == c;
}

int main () {
	int n; scanf("%d", &n);
	for (int i = 0; i < 3 * n; i++) {
		scanf("%d", &a[i]);
		a[i]--;
	}
	if (n == 1) {
		if (a[0] == a[1] && a[1] == a[2]) {
			printf("1\n");
		} else printf("0\n");
		return 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			dp[i][j] = -INF;
		}
		row[i] = -INF;
	}
	MAXJ = -INF;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			int minj = 0x3f3f3f3f, maxj = -1;
			for (int k = 0; k < 5; k++) {
				if (i == k || j == k) continue;
				minj = min(minj, a[k]), maxj = max(maxj, a[k]);
			}
			dp[a[i]][a[j]] = dp[a[j]][a[i]] = minj == maxj;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			MAXJ = max(MAXJ, dp[i][j]);
			row[i] = max(row[i], dp[i][j]);
		}
	}
	int base = 0, now = 5;
	for (int i = 2; i < n; i++) {
		int x = a[now], y = a[now + 1], z = a[now + 2]; now += 3;
		if (x == y && y == z) {
			base++;
			for (int j = 0; j < n; j++) {
				ndp[x][j] = ndp[j][x] = max(dp[x][j], max(query(j) - 1, dp[j][x]));
			}
			ndp[x][x] = max(ndp[x][x], Query() - 1);
		} else {
			if (x == z) swap(z, y);
			if (y == z) swap(x, z);
			if (x == y) {
				for (int j = 0; j < n; j++) {
					ndp[z][j] = ndp[j][z] = max(dp[z][j], max(query(j), dp[j][x] + 1));
					ndp[x][j] = ndp[j][x] = max(dp[x][j], query(j));
				}
				ndp[x][z] = ndp[z][x] = max(ndp[x][z], max(Query(), dp[y][y] + 1));
				ndp[x][x] = max(ndp[x][x], max(Query(), dp[z][z] + 1));
			} else {
				for (int j = 0; j < n; j++) {
					ndp[x][j] = ndp[j][x] = max(dp[x][j], query(j));
					ndp[y][j] = ndp[j][y] = max(dp[y][j], query(j));
					ndp[z][j] = ndp[j][z] = max(dp[z][j], query(j));
				}
				ndp[x][y] = ndp[y][x] = max(ndp[x][y], max(Query(), dp[z][z] + 1));
				ndp[x][z] = ndp[z][x] = max(ndp[x][z], max(Query(), dp[y][y] + 1));
				ndp[y][z] = ndp[z][y] = max(ndp[y][z], max(Query(), dp[x][x] + 1));
			}
		}
		for (int j = 0; j < n; j++) {
			modify(x, j), modify(j, x);
			modify(y, j), modify(j, y);
			modify(z, j), modify(j, z);
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans = max(ans, dp[i][j] + check(i, j, a[3 * n - 1]) + base);
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 35236
function Main(input) {
  	inputArr = input.split("\n");
	var n = parseInt(inputArr[0], 10);
	var d = inputArr[1].split(" ");
    var ret = 0;
  
    dd = d.sort(function(a,b){
        var an = parseInt(a, 10);
        var bn = parseInt(b, 10);
        if( an < bn ) return -1;
        if( an > bn ) return 1;
        return 0;
	});
    var center = dd.length / 2 - 1;
    if (dd[center] === dd[center + 1]) {
        console.log(0);
    } else {
        console.log(dd[center + 1] - dd[center]);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17628
#include<iostream>
#include<random> // random_device mt19937
#include<map>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  int n; cin >>n;
  int m; cin >>m;
  vector<int> vec(n,-1);
  rep(_,m){
    int s,c; cin >>s >>c; s--;
    if(vec[s]>=0 and vec[s]!= c){
      printf("-1");
      return 0;
    }
    vec[s]=c;
  }
  if(vec[0]==0 and n!= 1){
    printf("-1");
    return 0;
  }
  if(vec[0]==-1) vec[0]=(n==1)?0:1;
  rep(i,n){
    printf("%d",vec[i]>=0?vec[i]:0);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	int h[n];
	rep(i, n) cin >> h[i];
	vector<int> a(m), b(m);
	vector<int> es[n];
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		es[a[i]].push_back(h[b[i]]);
		es[b[i]].push_back(h[a[i]]);
	}

	int ans = 0;
	rep(i, n) {
		int nh = h[i];
		sort(all(es[i]));
		if(lower_bound(all(es[i]), nh) == es[i].end()) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11352
#!/bin/sh
export LC_ALL=C
read n
a=1 b=1
while read x y
do
    p=$(((a+x-1)/x)) q=$(((b+y-1)/y)) m=$((p-((p-q)&(p-q)>>63))) a=$((x*m)) b=$((y*m))
done
echo $((a+b))

Measured memory_bytes: 376
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a < 3200) cout << "red" << endl;
	else cout << s << endl;
}

Measured memory_bytes: 256
import numpy as np

N, K = list(map(int, input().split(" ")))

h_list = []
for i in range(N):
    h_list.append(int(input()))

h_list = sorted(h_list)

out = np.min([h_list[i+K-1] - h_list[i] for i in range(N-K+1)])
print(out)

Measured memory_bytes: 20636
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
  ll a;
  cin>>a;
  cout<<a+a*a+a*a*a<<'\n';
}


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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define FORR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()             
#define MP( a, b )		make_pair( (a), (b) )
#define fi				first
#define se				second

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

int gcd( int a, int b ) {
	if( b == 0 ) return a;
	return		 gcd( b, a % b );
}

signed main() {
	int x, y;
	while( cin >> x >> y ) {
		int a = gcd( x, y );
		cout << a << " " << x * y / a << endl;
	}
}


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

main(){
int day;
int total;
int tmp;
vector<int> vt;
scanf("%d%d",&day,&total);
for(int i=0;i<total;i++){
scanf("%d",&tmp);
vt.push_back(tmp);
}

make_heap(vt.begin(),vt.end());

while(vt.size()>1){
tmp=vt.front();
pop_heap(vt.begin(),vt.end());
vt.pop_back();
tmp=tmp-vt.front();
pop_heap(vt.begin(),vt.end());
vt.pop_back();
vt.push_back(tmp);
push_heap(vt.begin(),vt.end());

}
if(vt.front()-1<0)cout<<0;
else cout<<vt.front()-1;



}


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


int main()
{
  int x, a, b, t, cnt=0;

  cin >> x >> a >> b;
  t = x-a;
  while ( t > 0 ) {
    if ( t-b >= 0 ) cnt++;
    t -= b;
  }

  cout << x-a-b*cnt << endl;
  
  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc149/tasks/abc149_a

A,B,K = map(int, input().split())

tcookie = 0
acookie = 0

# KがAより大きい
if A > K :
    tcookie = A - K 
    acookie = B

# KがA以下
if A <= K : 
    tcookie = 0
    # KがBより大きい
    if ( K - A ) < B:
        acookie = B - (K - A) 
    # KがB以下
    if ( K - A ) >= B:
        acookie = 0

print(str(tcookie) + " " +  str(acookie))


Measured memory_bytes: 3060
import math
pi=3.1415926535897932
a,b,h,m=map(int,input().split())
ad=h*30+m*0.5
bd=m*6.0
x=min(abs(ad-bd),360.0-abs(ad-bd))
if abs(x-180.0)<0.0000000001:
    print(a+b)
    exit()
elif abs(ad-bd)<0.000000001:
    print(abs(a-b))
    exit()
ans=a**2+b**2-(2*a*b*math.cos(math.radians(x)))
print(ans**0.5)


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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n;
ll s[N], A, B;
int dp[N];

int add(int a, int b) {
	a += b;
	if(a >= MOD) a -= MOD;
	return a;
}

int subs(int a, int b) {
	a -= b;
	if(a < 0) a += MOD;
	return a;
} 

bool ok[25][N];
int pref[N];
int Log[N];

bool check(int l, int r) {
	if(l > r) 
		return 0;
	assert(l <= r);
	if(l == r) return 1;
	int Log2 = Log[r - l + 1];
	return (ok[Log2][l] & ok[Log2][r - (1 << Log2) + 1]);
}

int get_sum(int l, int r) {
	if(l > r) return 0;
	if(!l) return pref[r];
	return subs(pref[r], pref[l - 1]);
}

int main() {
	megaRandom();
	scanf("%d%lld%lld", &n, &A, &B);
	//scanf("%d", &n);
	for(int i = 1; i <= n; i ++) 
		scanf("%lld", &s[i]);
	if(A > B) swap(A, B);
	//assert(n <= 10000);
	s[0] = -INF;
	for(int i = 0; i <= n; i ++)
		ok[0][i] = 1;
	for(int it = 1; it <= 20; it ++) {
		for(int i = 0; i + (1 << it) - 1 <= n; i ++) {
			bool can = ((s[i + (1 << (it - 1))] - s[i + (1 << (it - 1)) - 1]) >= A);
			ok[it][i] = (ok[it - 1][i] & ok[it - 1][i + (1 << (it - 1))] & can);			
		}
	}
	Log[1] = 0;
	for(int i = 2; i <= N - 123; i ++) {
		Log[i] = Log[i - 1];
		while((1 << (Log[i] + 1)) <= i)
			Log[i] ++;
	}
	//cout << ok[1][0];
	/*int q;
	scanf("%d", &q);
	for(int i = 1; i <= q; i ++) {
		int l, r;
		scanf("%d%d", &l, &r);
		if(check(l, r)) puts("GOOD");
		else puts("BAD");

	}
	return 0;   */
	dp[0] = 1;
	pref[0] = 1;
	for(int i = 1; i <= n; i ++) {
		pref[i] = pref[i - 1];
		int ps1 = 0, ps2 = 0;
		int ql = 0, qr = i;
		while(qr - ql > 1) {
			int mid = (ql + qr) >> 1;
			if(s[i] - s[mid] >= B)
				ql = mid;
			else 
				qr = mid;
		}
		ps1 = ql;		
		ql = 0, qr = i - 1;
		while(qr - ql > 1) {
			int mid = (ql + qr) >> 1;
			if(check(mid, i - 1))
				qr = mid;
			else 
				ql = mid;
		}
		if(check(ql, i - 1)) qr = ql;
		ps2 = qr;
		if(ps1 + 1 < ps2) 
			continue;		
		if(ps2 == 1) {
			assert(check(1, i - 1));
			ps2 = 0;
		}
		dp[i] = add(dp[i], get_sum(ps2, ps1));
		if((ps2 >= 2 && s[ps2] - s[ps2 - 2] >= A))
			dp[i] = add(dp[i], dp[ps2 - 1]);
		pref[i] = add(pref[i], dp[i]);
	}
	int res = 0;
	for(int i = n; i >= 0; i --) {
		if(i == 0 || i == n || (s[i + 1] - s[i - 1] >= A))
			res = add(res, dp[i]);
		if(i != n && s[i + 1] - s[i] < A)
			break;
	}
	printf("%d", res);
	return 0; 
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
int h, w;
string s[30][30];
/**********************************************/

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

    cin >> h >> w;
    REP(i, h) REP(j, w) cin >> s[i][j];

    REP(i, h) REP(j, w) if(s[i][j] == "snuke") cout << (char)('A'+j) << i+1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int N=5e5+10,mod=998244353;
int n,m,ans,fc[N],fi[N];
int main(){
	std::cin>>n>>m,fc[0]=fc[1]=fi[0]=fi[1]=1;
	for(int i=2;i<=m;i++)fc[i]=(ll)fc[i-1]*i%mod;
	for(int i=2;i<=m;i++)fi[i]=(ll)(mod-mod/i)*fi[mod%i]%mod;
	for(int i=2;i<=m;i++)fi[i]=(ll)fi[i-1]*fi[i]%mod;
	for(int i=n;i<=m;i++)ans=(ans+(ll)fc[m-1]*fi[i-1]%mod*fi[m-i])%mod;
	std::cout<<ans;
}

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

int main()
{
    int n,t;
    while(~scanf("%d%d", &n, &t))
    {
        int ti[200000+5];
        for(int i = 0; i < n; ++i)
        {
            scanf("%d",&ti[i]);
        }
        long long sum = t;
        for(int i = 1; i < n; ++i)
        {
            int num = ti[i] - ti[i-1];
            if(num > t) sum += t;
            else sum += num;
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
	int N, f = 0, c = 0;
	cin >> N;
	vector<int> A(N);
	rep(i, 0, N)cin >> A[i];
	rep(i, 0, N - 1) {
		if (f == 0) {
			if (A[i] == A[i + 1])continue;
			else if (A[i] > A[i + 1])f = -1;
			else f = 1;
		}
		else if (A[i] != A[i + 1] && (A[i + 1] - A[i]) * f < 0) {
			f = 0;
			c++;
		}
	}
	printf("%d\n", c + 1);
	return 0;
}


Measured memory_bytes: 640
//Now you are making me a boy with luvv...
//I don't want to do this but I'm being forced to ....pls help!!
#include <bits/stdc++.h>
using namespace std;
#define loop(x,n) for(int x = 0; x < n; ++x)
#define ed end()  
#define bg begin()
# define ld long double
#define ll long long
#define ub(v,a) upper_bound(all(v),a)
#define lb(v,a) lower_bound(all(v),a)
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tr(v,it) for(auto it=v.begin();it!=v.end();it++)
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.
#define vpresent(v,x) (find(all(v),x)!=v.end()) // vector
typedef vector< int > vi;
typedef vector< long long > vll;
typedef vector<pair<ll,ll>> vp;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
const long long max_sz = 1e5 + 1;
const long long mod = 1e9 + 7;
const long long MAXN = 4e18 + 1;
char flip(char k){ if(k=='0') return '1'; return '0'; }
ll sum_digit(ll n){ ll a=0,i; for(i=n;i>0;i=i/10){ a+=(i%10);} return a; }
ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a%b);
}
int main(){
                   // ios_base::sync_with_stdio(false);
                    //cin.tie(NULL);
                    //cout.tie(NULL);
 
                     ll t;
                    // cin >> t;
                     t=1;
                     while (t--){
                             ll n;cin>>n;
                             if(n>=30)cout<<"Yes"<<endl;
                             else cout<<"No"<<endl;
                     }
                    cerr << endl
                                  << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
                      return 0;
}


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

const int N = 1000;

double x[N][N];

int main() {
	clog << "Ready\n";
	
	int n, d;
	cin >> n >> d;
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j <= d; ++ j) {
			cin >> x[i][j];
		}
	}
	
	int cnt = 0;
	
	for (int it = 1; it <= n; ++ it) {
		for (int jt = it + 1; jt <= n; ++ jt) {
			double sum = 0;
			for (int i = 1; i <= d; ++ i) {
				sum += abs(x[it][i] - x[jt][i]) * abs(x[it][i] - x[jt][i]);
			}
			double comp = int(sqrt(sum));
			sum = double(sqrt(sum));
			cnt += (comp == sum);
		}
	}
	
	cout << cnt;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#define b 42
using namespace std;
using ll = long long;
int main(){
  ll N,K;
  cin>>N>>K;
  if(N%2==1){
    N++;
  }
  if(N/2>=K){
    cout<<"YES" <<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> p, h;
int F(int a) { return a == p[a] ? a : p[a] = F(p[a]); }
bool U(int a, int b){
	a = F(a); b = F(b);
	if(a == b) return 0;
	p[b] = a;
	h[b] = h[a] = h[a]+h[b];
	return 1;
}
main(){
	int n,m; cin >> n >> m;
	h.assign(n,1);
	p.resize(n);
	iota(begin(p),end(p),0);
	vector<pair<int,int> > adj(m);
	for(int i = 0; i < m; i++){
		int a,b; cin >> a >> b;
		a--; b--;
		adj[i] = {a,b};
	}
	int res = n*(n-1)/2;
	vector<int> sol;
	for(int i = m-1; i >= 0; i--){
		sol.push_back(res);
		int a,b; tie(a,b) = adj[i];
		a = F(a); b = F(b);
		int d = h[a]*h[b];
		if(U(a,b)) res -= d;
	}
	for(int i = m-1; i >= 0; i--) cout << sol[i] << endl;
}


Measured memory_bytes: 5364
/*|In The Name Of Allah|*/
//This Month Will Be Expert ISA
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

const int mod = 1e9+7;

int n;
long long k;
int a[N];
int f[N];

int main(){
    scanf("%d%lld" , &n , &k);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &a[i]);
    }
    for(int i = 1; i <= n; i++){
        scanf("%d" , &f[i]);
    }
    sort(a + 1 , a + n + 1);
    sort(f + 1 , f + n + 1);
    reverse(f + 1 , f + n + 1);
    long long l = 0 , r = 1e12;
    while(l < r){
        long long mid = (l + r) / 2;
        long long cntUSED = 0;
        for(int i = 1; i <= n; i++){
            cntUSED += max(0ll , a[i] - mid / f[i]);
        }
        if(cntUSED <= k){
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    printf("%lld\n" , r);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> h(n);
    vector<int> dp(n+1);

    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        int a=dp[i-1]+abs(h[i]-h[i-1]);
        int b=dp[i-2]+abs(h[i]-h[i-2]);
        if(a>b) dp[i]=b;
        else dp[i]=a;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 200005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<pii> vii;
vector<pll> vll;


lln arr[maxii];
lln arr2[maxii];
//bool check[maxii];
bool check2[1000][1000];
lln n,m;

int main()
{
    cin>>arr[0];
   cout<<"ABC"<<arr[0];
}






Measured memory_bytes: 3632
eval'N,K,*A='+`dd`.split*?,
A.sort!
b=s=K%2<1?1:A.pop
(K/2).times{x,y=A[0]*A[1],A[-2]*A[-1]
s*=x*b>y*b ?(A.shift 2;x):(A.pop 2;y)
s%=10**9+7}
p s

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

typedef long long ll;
const ll inf = 1e15;

int main() {
    int n;
    scanf("%d",&n);
    vector<int> v(n,0);
    for (int i = 0; i < n; i++) scanf("%d",&v[i]);
    sort(v.begin(),v.end());
    double ans = v[0];
    for (int i = 1; i < n; i++) ans = (double)(ans + v[i]) / 2;
    printf("%lf\n",ans);
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 1001001001;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    ll n, minus = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        if(a[i] < 0) minus++;
        a[i] = my_abs(a[i]);
    }
    sort(ALL(a));
    ll ans = 0;
    if((minus%2) == 0) ans += a[0];
    else ans += (-1)*a[0];
    rep(i, n-1) {
        ans += a[i+1];
    }
    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD;
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define long long long
using namespace std;
int n,mat[4][102];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;

    for(int i=1;i<=2;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>mat[i][j];
            mat[i][j]+=max(mat[i][j-1],mat[i-1][j]);
        }
    }
//    for(int i=1;i<=2;i++)
//    {
//        for(int j=1;j<=n;j++)
//        {
//            cout<<mat[i][j]<<" ";
//        }
//        cout<<endl;
//    }
    cout<<mat[2][n]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int N,M,ans;
	cin >> N;
	vector<int> vec;
	for(int i = 0;i < 2*N;i++){
		cin >> M;
		vec.push_back(M);
	}
	sort(vec.begin(),vec.end(),greater<int>());
	ans = 0;
	for(int i = 1;i < 2*N;i +=2)
		ans +=vec[i];
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

using namespace std;



int main() {

	int A, B, C;
	cin >> A >> B >> C;

	int max = B - C * A;
		
	if ((B - A * C) < 0)
		while ((B - A * C) < 0) {
			C--;

		}
	
	cout << C << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <math.h>           // sqrt()
#include <stdbool.h>

#define MAX_V 100

const int INF = 1000000000;
int V;
double cost[MAX_V][MAX_V];
double d[MAX_V];
int prev[MAX_V];

void
dijkstra(int s)
{
	bool used[MAX_V];

	for (int i = 0; i < V; ++i)
	{
		d[i] = INF;
		used[i] = false;
		prev[i] = -1;
	}

	d[s] = 0.0;
	while (true)
	{
		int v = -1;
		for (int u = 0; u < V; ++u)
		{
			if (!used[u] && (v == -1 || d[u] < d[v]))
				v = u;
		}

		if (v == -1)
			break;

		used[v] = true;
		for (int u = 0; u < V; ++u)
		{
			if (d[v] + cost[v][u] < d[u])
			{
				d[u] = d[v] + cost[v][u];
				prev[u] = v;
			}
		}
	}
}

void
solve(int s, int g)
{
	int path[MAX_V];

	dijkstra(s);
	if (d[g] == INF)
		printf("NA\n");
	else
	{
		int ix = 0;
		for (; g != -1; g = prev[g])
			path[ix++] = g;

		for (int i = ix - 1; i >= 0; --i)
			printf("%d%c", path[i] + 1, (i != 0) ? ' ' : '\n');
	}
}

int
main(int argc, char **argv)
{
	int x[MAX_V], y[MAX_V];

	while (true)
	{
		scanf("%d", &V);
		if (V == 0)
			break;

		for (int i = 0; i < V; ++i)
		{
			int b;
			int tx, ty;
			scanf("%d%d%d", &b, &tx, &ty);
			b--;
			x[b] = tx, y[b] = ty;
		}

		for (int i = 0; i < V; ++i)
		{
			for (int j = 0; j < V; ++j)
				cost[i][j] = (i == j) ? 0 : INF;
		}

		for (int i = 0; i < V; ++i)
		{
			for (int j = i + 1; j < V; ++j)
			{
				if (i != j)
				{
					int rx = x[i] - x[j], ry = y[i] - y[j];
					double r = sqrt(rx * rx + ry * ry);
					if (r <= 50.0)
					{
						cost[i][j] = r;
						cost[j][i] = r;
					}
				}
			}
		}

		int m;
		scanf("%d", &m);
		for (int i = 0; i < m; ++i)
		{
			int s, g;
			scanf("%d%d", &s, &g);
			s--, g--;
			solve(s, g);
		}
	}

	return 0;
}


Measured memory_bytes: 1804
a=int(input())
b=input()
c = 0
mx = 0
mxc = 0
for i in range(len(b)):
    if b[i] == ".":
        c += 1
        if mx < c:
            mx = c
            mxc = i+1
    else:
        c -= 1


print(int((mxc-mx)/2+(len(b)-mxc-mx+c)/2))

Measured memory_bytes: 3500
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <cctype>

using namespace std;

#define Int int64_t

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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

int main() {
	Int a, b, x; cin >> a >> b >> x;
	Int cnt1 = 0, cnt2 = 0;
	if (a == 0) {
		cnt1 = b/x+1;
	}
	else {
		cnt1 = b / x;
		cnt2 = (a - 1) / x;
	}
	
	
	
	cout << (Int)cnt1 - cnt2;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iostream>

#define MAXN 200000

using namespace std;
int N;
long long  a[MAXN] = {};

void solve() {
	cin >> N ;
	long long sum = 0;
	for(int i = 0; i<N; i++){
		cin >> a[i];
		sum += a[i];
	}

//	//差分をとる
//	long long base = a[0];
//	for(int i = 0; i<N; i++){
//		a[i] = a[i] - base ;
//	}
	long long sunuke_sum = 0;
	long long min = 2000000000;
	for(int i = 0; i<N-1; i++){
		sunuke_sum += a[i];
		long long tanuki_sum = sum - sunuke_sum;
		long long dif = abs(sunuke_sum - tanuki_sum);
		//printf("inf: sun:%lld  tanu:%lld, dif: %lld\n", sunuke_sum, tanuki_sum, dif);
		if(min > dif) min = dif;
	}

	printf("%lld\n", min);
}

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


Measured memory_bytes: 1792
// B - Count Balls
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N,A,B; cin>>N>>A>>B;
	ll c = A + B;
	ll d = N / c;
	ll ans = d * A;
	N -= d * c;
	cout<< (N<A? ans+N: ans+A) <<endl;
}

Measured memory_bytes: 256
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, m;
  cin >> n >> m;
  ll ans = 0; 
  ans+= (n)*(n-1);
  ans+= (m)*(m-1);
  cout << ans/2 << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main()
{
	int N, K;
	cin >> N >> K;
	int p[N];
	for(int i=0; i<N; i++) {
		cin >> p[i];
	}

	sort(p, p+SIZE_OF_ARRAY(p));
	long int total = 0;
	for(int i=0; i<K; i++) {
		total += p[i];
	}

	cout << total << "\n";

	return 0;
}


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

const int INF=2000000000;

struct edge{ int to; int cost; };
edge mke(int t,int c){ edge ed; ed.to=t; ed.cost=c; return ed;}

struct status{ int x; int cost; };
status mks(int x,int c){ status s; s.x=x; s.cost=c; return s;}
struct compare{
	bool operator()(status x,status y) const {
		return x.cost>y.cost;
	}
};

int main(){
static	int n,m,k,a[100002],b[100002],l[100002],s;
static	vector<edge> G[3002];
static	int cost[3002]; for(int i=0;i<3002;i++)cost[i]=INF;
static	bool used[3002]; for(int i=0;i<3002;i++)used[i]=false;
static	priority_queue<status,vector<status>,compare> que;

	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&a[i],&b[i],&l[i]);
		G[a[i]].push_back(mke(b[i],l[i]));
		G[b[i]].push_back(mke(a[i],l[i]));
	}
	for(int i=0;i<k;i++){
		scanf("%d",&s);
		que.push(mks(s,0));
	}

	while(!que.empty()){
		status s=que.top(); que.pop();
		if(!used[s.x]){
			cost[s.x]=s.cost;
			for(int i=0;i<G[s.x].size();i++){
				edge ed=G[s.x][i];
				if(cost[ed.to]>cost[s.x]+ed.cost){
					cost[ed.to]=cost[s.x]+ed.cost;
					que.push(mks(ed.to,cost[ed.to]));
				}
			}
			used[s.x]=true;
		}
	}
/*
for(int i=1;i<=n;i++){
	printf("%d\n",cost[i]);
}
*/
	int ret=0;
	for(int i=0;i<m;i++){
		ret=max(ret,(cost[a[i]]+cost[b[i]]+l[i]+1)/2);
	}

	printf("%d\n",ret);
}

Measured memory_bytes: 5384
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll h, w;
    cin >> h >> w;
    ll a[505][505];
    REP(i, h){
        REP(j, w){
            cin >> a[i][j];
        }
    }
    vector<ll> ans1, ans2, ans3, ans4;
    REP(i, h){
        if(i % 2 == 0){
            REP(j, w){
                if(j != w - 1){
                    if(a[i][j] % 2 == 1){
                        ans1.push_back(i + 1);
                        ans2.push_back(j + 1);
                        ans3.push_back(i + 1);
                        ans4.push_back(j + 2);
                        a[i][j + 1]++;
                    }
                }
                else if(i != h - 1){
                    if(a[i][j] % 2 == 1){
                        ans1.push_back(i + 1);
                        ans2.push_back(j + 1);
                        ans3.push_back(i + 2);
                        ans4.push_back(j + 1);
                        a[i + 1][j]++;
                    }
                }
            }
        }
        else{
            for(ll j = w - 1; j >= 0; j--){
                if(j != 0){
                    if(a[i][j] % 2 == 1){
                        ans1.push_back(i + 1);
                        ans2.push_back(j + 1);
                        ans3.push_back(i + 1);
                        ans4.push_back(j);
                        a[i][j - 1]++;
                    }
                }
                else if(i != h - 1){
                    if(a[i][j] % 2 == 1){
                        ans1.push_back(i + 1);
                        ans2.push_back(j + 1);
                        ans3.push_back(i + 2);
                        ans4.push_back(j + 1);
                        a[i + 1][j]++;
                    }
                }
            }
        }
    }
    
    cout << ans1.size() << '\n';
    REP(i, ans1.size()){
        cout << ans1[i] << ' ' << ans2[i] << ' ' << ans3[i] << ' ' << ans4[i] << '\n';
    }
}

Measured memory_bytes: 8148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int n,m,ans=0;
void Main(){
    cin>>n>>m;
    cout<<6-n-m<<endl;

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


Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = sc.nextInt();

		int dist500 = N/500;
		int rest500 = N%500;
		int dist5 = rest500/5;

		System.out.println(dist500*1000 + dist5*5);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,a=0,r=0,t=0,w=0;
 cin>>n;
 string s;
 while(n--)
 {
     cin>>s;
     if(s=="AC")a++;
     if(s=="TLE")t++;
     if(s=="RE")r++;
     if(s=="WA")w++;
 }
 cout<<"AC x "<<a<<"\nWA x "<<w<<"\nTLE x "<<t<<"\nRE x "<<r;

    return 0;
}




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

main() {
  int N; cin >> N;
  int K; cin >> K;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int x; cin >> x;
    sum += 2 * min(x, K - x);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  getLine
  s <- lines <$> getContents
  putStrLn $ shiritori s
  
shiritori l
  |length l/=(length .nub) l = "No"
  |otherwise = shiritori2 l

shiritori2 (x:y:ys)
  |last x==head y = shiritori2 (y:ys)
  |otherwise = "No"
shiritori2 (_:[]) = "Yes"

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

using namespace std;

void solve(void)
{
	long n, k;
	cin >> n >> k;
	vector<pair<long, long>> ps(n);
	for (int i = 0; i < n; i++)
	{
		cin >> ps[i].first >> ps[i].second;
	}
	sort(ps.begin(), ps.end());
	long now = 0;
	for (int i = 0; i < n; i++)
	{
		now += ps[i].second;
		if (now >= k)
		{
			cout << ps[i].first << endl;
			return;
		}
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        for (Int j = i + 1; j < n; j++) {
            for (Int k = j + 1; k < n; k++) {
                if (a[i] == a[j] or a[j] == a[k] or a[k] == a[i]) continue;
                Int b[3] = {};
                b[0] = a[i];
                b[1] = a[j];
                b[2] = a[k];
                sort(b, b + 3);
                if (b[0] + b[1] > b[2]) {
                    res++;
                }
            }
        }
    }
    print(res);
    return 0;
}


Measured memory_bytes: 3632
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
map<pint,int> co;
struct unionf{
	vector <int> data;
	unionf(int size):data(size,-1){}
	bool unions(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x]){int d=x;x=y;y=d;}
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool finds(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int find(int x){
		return -data[x];
	}
};
int main()
{
	int n,k,l,a,b;
	scanf("%d %d %d",&n,&k,&l);
	unionf uni(n+10),uni2(n+10);
	rep(i,k){
		scanf("%d %d",&a,&b);
		uni.unions(a-1,b-1);
	}
	rep(i,l){
		scanf("%d %d",&a,&b);
		uni2.unions(a-1,b-1);
	}
	rep(i,n) co[mp(uni.root(i),uni2.root(i))]++;
	rep(i,n){
		printf("%d",co[mp(uni.root(i),uni2.root(i))]);
		if(i<n-1) printf(" ");else printf("\n");
	}
}


Measured memory_bytes: 13568
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    if (S == "ABC") {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
}
  

Measured memory_bytes: 3548
s = gets.chomp

if s == 'SUN'
    puts 7
    
elsif s == 'MON'
    puts 6
    
elsif s == 'TUE'
    puts 5

elsif s == 'WED'
    puts 4

elsif s == 'THU'
    puts 3
    
elsif s == 'FRI'
    puts 2

else
    puts 1
end

Measured memory_bytes: 1788
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    sort(A, A+N);
    bool ok = true;
    rep(i,0,N-1){
        if(A[i] == A[i+1]) ok = false;
    }
    if(ok){
        print("YES");
    }else{
        print("NO");
    }
    

}

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

using namespace std;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    int tmp1, tmp2;
    tmp1 = abs(a - x);
    tmp2 = abs(b - x);

    if(tmp1 > tmp2){
        cout << "B" << endl;
    }else{
        cout << "A" << endl;
    }


}

Measured memory_bytes: 256
import itertools

N, M = map(int, input().split())
skss = []
for _ in range(M):
    k, *sks = map(int, input().split())
    skss.append(set(sks))
pMs = list(map(lambda x: x == '0', input().split()))

count = 0
for i in range(2 ** N):
    pMstmp = pMs[:]
    for j, b in enumerate(format(i, '0' + str(N) + 'b')):
        if b == '0':
            continue
        for k, sks in enumerate(skss):
            if j + 1 in sks:
                pMstmp[k] = not pMstmp[k]
    if all(pMstmp):
        count += 1

print(count)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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 N;
int d[1010];

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

  cin >> N;
  rep(i, N) cin >> d[i];

  int ans = 0;
  for (int i = 0; i + 1 < N; i++) {
    for (int j = i + 1; j < N; j++) {
      ans += d[i] * d[j];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void push(int);
int top =0;
int K[100];


int main(){
  int i = 0,j,x;
  char s[100],num;
   
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      K[top-1] = K[top-1] + K[top];
      K[top]= 0;
      top--;

    } else if ( s[0] == '-' ){
      K[top-1] = K[top-1] - K[top];
      K[top]= 0;
      top--;

    } else if ( s[0] == '*' ){
      K[top-1] = K[top-1] * K[top];
      K[top]= 0;
      top--;

    } else {
      x = atoi(s);
      push(x);
  }
  }
  printf("%d\n",K[top]);

  return 0;
}

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

Measured memory_bytes: 548
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n,k;cin>>n>>k;
	vector< double > a(n);
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) a[i] = (a[i]+1)/2.0;

	double cur=0;
	rep(i,0,k) cur+=a[i];
	double ans=cur;
	rep(i,k,n)
	{
		cur+=a[i]-a[i-k];
		ans=max(ans,cur);
	} 
	cout<<setprecision(20)<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


Measured memory_bytes: 1792
import Data.Array
import Data.Array.IO
import Control.Monad

type Grid = IOUArray (Int, Int) Char
type DP = IOUArray (Int, Int) Int


main = do
  [h,w] <- map read . words <$> getLine :: IO [Int]
  xss <- replicateM h getLine
  grid <- thaw $ listArray ((1,1),(h,w)) $ concat xss :: IO Grid
  dp <- newArray ((1,1),(h,w)) 0 :: IO DP
  writeArray dp (1,1) 1 
  let m = 10^9 + 7
  forM_ [1..h] $ \i -> 
    forM_ [1..w] $ \j -> do
      d <- readArray dp (i,j)
      g <- readArray grid (i,j)
      forM_ [(i+1,j),(i,j+1)] $ \n@(i',j') -> do
        unless (i' > h || j' > w) $ do
          d' <- readArray dp n
          g' <- readArray grid n
          unless (g' == '#') $ do
            writeArray dp n $ ((d+d') `mod` m)
  
  readArray dp (h,w) >>= print


Measured memory_bytes: 65532
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N, M = LMIIS()
    SC = XLMIIS(M)
    ans = [-1] * N
    for s,c in SC:
        if ans[s-1] != -1:
            if ans[s-1] != c:
                print(-1)
                return
        else:
            ans[s-1] = c


    if N != 1:
        if ans[0] == 0:
            print(-1)
            return
        elif ans[0] == -1:
            ans[0] = 1
    elif ans[0] == -1:
        ans[0] = 0


    intans = 0
    for a in ans:
        intans *= 10
        if a != -1:
            intans += a
    print(intans)

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import collections

def main(N, A):
    c = collections.Counter(A)
    [print(c[i+1]) for i in range(max(c.keys()))]
    [print(0) for i in range(max(c.keys()), N)]

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    # N = 7
    # A = list(map(int, "1 2 3 4 5 6".split()))
    main(N, A)


Measured memory_bytes: 34180
n = int(input())
li = list(map(int,input().split()))
mod = 10**9+7

sum = 0
for i in range(0,n):
    sum += li[i]
    sum %= mod

ans = 0
for i in range(0,n):
    sum -= li[i]
    if sum < 0:
        sum += mod
    ans += li[i] * sum
    ans %= mod
print(ans)

Measured memory_bytes: 31424
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    readint;
    auto a = readints;

    int min = a.reduce!((a, b) => min(a, b));
    int max = a.reduce!((a, b) => max(a, b));
    writeln(max - min);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int N;
string S;
int main(){
    cin >> N;
    cin >> S;
    int ans = N;
    for(int i = 1; i < N; i++){
        if(S[i - 1] == S[i]){
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512