akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

ll h, w, i, j;
ll l[2000][2000];
ll r[2000][2000];
ll d[2000][2000];
ll u[2000][2000];
string s[2000];
ll ans;

int main(void) {
    cin >> h >> w;
    for (i = 0; i < h; i++) {
        cin >> s[i];
    }
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                l[i][j] = 0;
            } else if (j == 0) {
                l[i][j] = 1;
            } else {
                l[i][j] = l[i][j-1]+1;
            }
        }
    }
    for (i = 0; i < h; i++) {
        for (j = w-1; j >= 0; j--) {
            if (s[i][j] == '#') {
                r[i][j] = 0;
            } else if (j == w-1) {
                r[i][j] = 1;
            } else {
                r[i][j] = r[i][j+1]+1;
            }
        }
    }
    for (i = 0; i < w; i++) {
        for (j = 0; j < h; j++) {
            if (s[j][i] == '#') {
                u[j][i] = 0;
            } else if (j == 0) {
                u[j][i] = 1;
            } else {
                u[j][i] = u[j-1][i]+1;
            }
        }
    }
    for (i = 0; i < w; i++) {
        for (j = h-1; j >= 0; j--) {
            if (s[j][i] == '#') {
                d[j][i] = 0;
            } else if (j == h-1) {
                d[j][i] = 1;
            } else {
                d[j][i] = d[j+1][i]+1;
            }
        }
    }
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            ans = max(ans, l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(void)
{
	double a,b,x;
	scanf("%lf%lf%lf",&a,&b,&x);
	double arg;
	
	arg=atan(x*2/(a*b*b))*180/3.14159265;
	if(x*2/(a*b)<=a)
		printf("%lf",90-arg);
	else{
		arg=atan((a*a*b-x)*2/(a*a*a))*180/3.14159265;
		printf("%lf",arg);
	}
	return 0;
}
	

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
struct dt{
	int a;
	bool once;
}x[2*N];

bool cmp(struct dt x1,struct dt x2)
{
	return x1.a>x2.a;
}

int main()
{
	int n,h;
	cin>>n>>h;	
	for(int i=0;i<2*n;){
		cin>>x[i].a;
		x[i++].once=false;
		cin>>x[i].a;
		x[i++].once=true;
	}
	sort(x,x+2*n,cmp);
	int m=0,s=0;;
	while(h>0){
		if(x[m].once){
			h-=x[m].a;
			s++;
			m++;
		}
		else{
			s+=h/x[m].a;
			if(h%x[m].a>0)
				s++;
			break; 
		}
	}
	cout<<s<<endl;
	return 0;	
} 

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

template<typename T> inline void fastin(T& num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

int main() {
  int N;
  fastin(N);

  int ans = 0, cnt = 1;

  for (int i = 0; i < N; i++) {
    int a;
    fastin(a);
    if (a == cnt) cnt++;
    else ans++;
  }

  cout << ((ans == N) ? -1 : ans) << "\n";
}

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

#define MAX 60000

int main(void) {
    int prime[MAX] ={};
    int n;
    
    for(int i = 2; i < MAX; ++i) {
        if(prime[i] != 0)   continue;
        int j = i + i;
        while(j < MAX) {
            ++prime[j];
            j += i;
        }
    }
    
    while(cin >> n) {
        int i = n - 1;
        while(i >= 2) {
            if(prime[i] == 0) {
                cout << i;
                break;
            }
            --i;
        }
        i = n + 1;
        while(i < MAX) {
            if(prime[i] == 0) {
                cout << ' ' << i << endl;
                break;
            }
            ++i;
        }
    }
    return 0;
}


Measured memory_bytes: 3248
#include<cstdio>

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


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

#define forsn(i,s,n) for(tint i=(s);i<(tint)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) for(tint i = tint(n)-1; i >= 0; i--)
#define debug(x) cout << #x << " = "  << x << endl

using namespace std;

typedef long long tint;

random_device rd;
mt19937 gen(rd());

uniform_int_distribution<tint> dis(1, 10000);

void imprimirVector (vector<tint> v)
{
	if (!v.empty())
	{ 
		tint p = tint(v.size());
		cout << "[";
		forn(i,p-1)
			cout << v[i] << ",";
		cout << v[p-1] << "]" << endl;
	}
	else
		cout << "[]" << endl;
}

bool is_palindrome(const string &s)
{
	string s_reversed = s;
	reverse(s_reversed.begin(),s_reversed.end());
	return (s == s_reversed);
}

int main()
{
	#ifdef ACMTUYO
		assert(freopen("entrada.in", "r", stdin));
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	string s;
	while (cin >> s)
	{
		
		tint n = tint(s.size());
		
		string s_reversed = s;
		string s_first_half = s.substr(0,(n-1)/2);
		string s_second_half = s.substr((n+1)/2,n);
		bool is_strong_palindrome = is_palindrome(s) && is_palindrome(s_first_half) && is_palindrome(s_second_half);
		if (is_strong_palindrome)
			cout << "Yes\n";
		else
			cout << "No\n";
		
	}
	
	
	return 0;
}






Measured memory_bytes: 256
#include <stdio.h>

int main () {

  int i, j = 0;
  for (i = 1; i < 10; i++) {                                                                                                                                 
    for ( j = 1; j < 10; j++) {                                                                                                                              
      fprintf(stdout, "%dx%d=%d\n", i , j , i * j);
    }
  }
  return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define up(a,b) (((a)%(b)==0)?((a)/(b)):((a)/(b))+1)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
 
ll mymod(ll a, ll b)
{
	return (a%b + b)%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}
struct edge
{
	ll src;
	ll to;
	ll val;
	ll index;
};
struct node
{
	vll adj;
	ll parent;
	ll time;
	ll ex_time;
	ll indegree;
};

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll k;
	cin>>k;
	queue<ll> q;
	REP(i,1,10)
	{
		q.push(i);
	}
	ll x=0;
	set<ll> vis;
	while(true)
	{
		ll f=q.front();
		q.pop();
		x++;
		if(x==k)
		{
			cout<<f<<endl;
			exit(0);
		}
		ll d = f%10;
		if(vis.count(10*f+d-1)==0 && d!=0)
		{
			q.push(10*f+d-1);
		}
		if(vis.count(10*f+d)==0)
		{
			q.push(10*f+d);
		}
		if(vis.count(10*f+d+1)==0 && d!=9)
		{
			q.push(10*f+d+1);
		}
	}
	return 0;
}




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

typedef long long ll;

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

  ll sum = 0;
  for(int i=0; i<(1<<S.size()-1); i++) {
    ll num = S.at(0)-'0'; // char->number
    for(int j=0; j<S.size()-1; j++) {
      if(i & (1<<j)) {
        sum += num;
        num = 0;
      }
      num = num*10 + (S.at(j+1)-'0');
    }
    sum += num;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int a, b;
	cin >> a >> b;
	int c = (a + b + 2 - 1) / 2;
	cout << c << endl;
}

Measured memory_bytes: 256
count = gets.chomp.to_i
result = []
count.times do
  a, b, c = gets.chomp.split.map(&:to_i).sort
  if a**2 + b**2 == c**2
    result << 'YES'
  else
    result << 'NO'
  end
end
result.each {|ans| puts ans}

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

int main(){

	for (int i = 0; i < 9; i++){
		for (int j = 0; j < 9; j++){
			cout << i + 1 << "x" << j + 1 << "=" << (i+1)*(j+1) << endl;
		}
	}
	//getchar();

	return 0;
}

Measured memory_bytes: 1112
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n=int(input())
s=[int(input()) for i in range(n)]
m=inf
for si in s:
    if si%10!=0:
        m=min(m,si)
S=sum(s)
if S%10!=0:
    print(S)
else:
    if m == inf :
        print(0)
    else:
        print(S-m)



Measured memory_bytes: 38256
#include <iostream>                                                    
#include <vector>                                                      
#include <algorithm>                                                   
using namespace std;                                                   
                                                                       
int main(void) {                                                       
  int n;                                                               
  cin >> n;                                                            
  vector<int> S(n);                                                    
  for (int i=0; i<n; i++) {                                            
    cin >> S[i];                                                       
  }                                                                    
  sort(S.begin(), S.end());                                            
                                                                       
  int q;                                                               
  cin >> q;                                                            
  vector<int> T(q);                                                    
  for (int i=0; i<q; i++) {                                            
    cin >> T[i];                                                       
  }                                                                    
                                                                       
  int ans = 0;                                                         
  for (int i=0; i<q; i++) {                                            
    if (binary_search(S.begin(), S.end(), T[i])) {                     
      ans++;                                                           
    }                                                                  
  }                                                                    
  cout << ans << endl;                                                 
}                                                                      
                           

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

int primecheck(int n){
    int i;
    
    if(n==0||n==1)return 0;
    if(n==2||n==3)return 1;
    
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0)return 0;
    }
    return 1;
}
//1???????´???°???0??????????´???°???

int main(void){
    int i,n,cnt,sum;
    
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        
        for(i=sum=cnt=0;cnt<n;i++){
            if(primecheck(i)==1){
                cnt++;
                sum+=i;
            }
        }
        printf("%d\n",sum);
    }
    
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#include <numeric>

using namespace std;

class CSkip {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        long long n, x;
        cin >> n >> x;
        vector<long long int> x_vec(n);
        x_vec.push_back(x);
        for (int i = 0; i < n; ++i) {
            cin >> x_vec[i];
        }
        long long int now = x;
        vector<long long int> diff_vec;
        for (int j = 1; j < n+1; ++j) {
            diff_vec.push_back(abs(x_vec[j] - x_vec[j - 1]));
        }
        if (diff_vec.size() == 1) {
            cout << diff_vec[0] << endl;
        }else{
            long long int ans = 0;
            for (int k = 0; k < diff_vec.size(); ++k) {
                if (ans == 0) ans = diff_vec[k];
                else ans = __gcd(ans, diff_vec[k]);
            }
            cout << ans << endl;
        }
    }
};


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


Measured memory_bytes: 2800
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL; 																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																							   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

int tab[1000005];

///////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> tab[i];	
	}
	
	int licznik = 0;
	for(int i = 0; i < n; i++){
		if(tab[i] != i + 1) licznik++;
	}
	
	if(licznik <= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	
	
	
	
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
    double n;
    cin>>n;
    // double ans=-INF;
    // for(int i=1;i<=floor(n);i++){
    //     ans=max(ans,i+sqrt(n*n-i*i));
    // }
    cout<<fixed<<setprecision(11);
    cout<<max(sqrt(2.0)*n, floor(n)+1)<<endl;
	return 0;
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  const double pi = acos(-1.0);
  double a, b, x;
  cin >> a >> b >> x;
  if(x > a * a * b / 2.0){
    //cout << (double)2.0 * b / a - 2.0 * x / (a * a * a) << "\n";
    //printf("%.10f\n", atan((2.0 * b / a - 2.0 * x / (a * a * a))));
    printf("%.10f\n", (180.0 / pi ) * atan((double)(2.0 * b / a - 2.0 * x / (a * a * a))));

  }else{
    printf("%.10f\n", -(180.0 / pi) * atan(2 * x / (a * b * b)) + 90.0);
  }
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    char s[16];
    int f = 0;

    cin >> s;
    for (int i = 0; s[i]; ++i) {
        if (f == 0 && s[i] == 'h') f = 1;
        else if (f == 1 && s[i] == 'i') f = 0;
        else f = 2;
    }
    cout << (f == 0 ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
sum_A = 0
dict = defaultdict(int)
for i in A:
    dict[i] += 1

for v in dict.values():
    sum_A += v * (v - 1) // 2

for i in A:
    print(sum_A - (dict[i] - 1))


Measured memory_bytes: 26780
(N,), a, b = $<.map{|s|s.split.map &:to_i}
n = b.inject(:+) - a.inject(:+)
if n < 0
  puts :No
  exit
end
u = d = 0
a.zip(b).map{|x,y|
  diff = y - x
  if diff > 0
    u += diff / 2
    d += diff % 2
  else
    d += -diff
  end
}
# p n
# p u,d
puts [u, d].max > n ? :No : :Yes


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

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

struct UnionFind
{
    vector<int> parent;
    UnionFind(int n) : parent(n) {
        for(int i = 0; i < n; i++) parent[i] = i;
    }

    int root(int x){
        return x == parent[x] ? x : (parent[x] = root(parent[x]));
    }

    void unite(int x, int y){
        int rx = root(x), ry = root(y);
        if(rx != ry) parent[rx] = parent[ry];
        return;
    }

    bool isSame(int x, int y){
        return root(x) == root(y);
    }
};

int main()
{
    int n, m; cin >> n >> m;
    UnionFind u(n);
    int xi, yi, zi;
    rep(i, m){
        cin >> xi >> yi >> zi;
        --xi, --yi;
        u.unite(xi, yi);
    }

    int ans = 0;
    vector<bool> checked(n);
    rep(i, n){
        int ri = u.root(i);
        if(!checked[ri]){
            checked[ri] = true;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4520
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
vector<ll> fac(1e6),inv(1e6),finv(1e6);
void initcom(){
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int compress(vector<int> &x,int w){
    vector<int> sx;
    for(int i=0;i<(int)x.size();++i){
        for(int d=-2;d<=2;++d){
            int t=x[i]+d;
            if(t>=0&&t<w) sx.push_back(t);
        }
    }
    sort(sx.begin(),sx.end());
    sx.erase(unique(sx.begin(),sx.end()),sx.end());
    for(int i=0;i<(int)x.size();++i){
        x[i]=lower_bound(x.begin(),x.end(),x[i])-x.begin();
    }
    return (int)sx.size();
}
int main(){
    int a,b,c;cin>>a>>b>>c;
    int k;cin>>k;
    int cnt=0;
    while(a>=b){
        b*=2;
        cnt++;
    }
    while(b>=c){
        c*=2;
        cnt++;
    }
    if(cnt<=k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 26532
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=8000;
const long INF=1e9;
int main(){
	int a,b,x;cin>>a>>b>>x;
    double check=1.*a*a*b/2;
	double res;
	cout.precision(16);
    if(check>=x) res=1.*a*b*b/x/2;
    else res=2.*(a*a*b-x)/a/a/a;
    cout<<fixed<<atan(res)*180/3.1415926535<<endl;
}

Measured memory_bytes: 256
#coding:utf-8

s = int(input())

list = [s]

for i in range(1000000):
  n = list[i]
  if n%2 == 0:
    f = int(n/2)
  else:
    f = int(3*n+1)

  if f in list:
    print(i+2)
    break
  else:
    list.append(f)
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define N 1000
using namespace std;
typedef long long ll;
bool used[N];
 
ll SumD(ll a,ll d,ll n){return (n*(2*a+(n-1)*d))/2;}
 
bool mark(ll n){
  bool res=1;
  for(ll i=1;i*i<=N;i++)res&=!used[i],used[i]=1;
  return res;
}
 
int main(){
  while(1){
    ll n,m,p[21];
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<m;i++)cin>>p[i];
    sort(p,p+m);
   
    ll sum=0,cnt=0;
    for(int i=0;i<m;i++){
      sum+=SumD(p[i],p[i],n/p[i]);
      cnt+=n/p[i];
      memset(used,0,sizeof(used));
      for(int j=0;j<i;j++){
    ll lcm=(p[i]/__gcd(p[i],p[j]))*p[j];
    if(!mark(lcm))continue;
    sum-=SumD(lcm,lcm,n/lcm);
    cnt-=(n/lcm);
      }
    }
 
    printf("%.8f\n",(1.0*SumD(1,1,n)-sum)/max(1LL,(n-cnt)));
  }
  return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=1e9+7;
const int MAX=300010;

signed main(){
    string s,t;cin>>s>>t;
    ll n=s.size();
    ll m=t.size();
    ll ans=m;
    rep(i,n-m+1){
        ll cnt=0;
        rep(j,m){
            if(s[i+j]!=t[j])cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

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

int a[101];
bool b[101];

int main()
{
  int i, x, n, ck, dif, ans;
  
  cin >> x >> n;
  
  for(i=0; i<n; i++){
    cin >> a[i];
    b[a[i]] = 1;
  }
  
  ck = 1000, ans = 1000;
  for(i=0; i<=101; i++)
  {
    if(b[i] != 1)
    {
      dif = abs(i-x);
      
      if(dif < ck){
        ans = i;
        ck = dif;
      }
      
     }
  }
   
  cout << ans << endl;
  
 return 0; 
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
from itertools import combinations
def inpl(): return map(int, input().split())

N = int(input())
P = [int(input()) for _ in range(N)]
score = [0]*(N+1)

for p in P:
    score[p] = score[p-1] + 1

print(N - max(score))

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

int main() {
	int n;
	cin>>n;
	int a,num=0;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a%2==1)num++;
	}
	if(num%2)cout<<"NO"<<endl;
	else{
		cout<<"YES"<<endl;
	}
}

Measured memory_bytes: 256
n, l = map(int, input().split())

li = [x for x in range(l, l+n)]
t_i = 0
mi = 301
for i in range(len(li)):
  if mi >= abs(li[i]):
    mi = abs(li[i])
    t_i = i
n_sum = sum(li)
print(n_sum-li[t_i])

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

char mas[100][101];
int w,h;
int grx[4]={0,1,0,-1},gry[4]={1,0,-1,0};

void sha(int,int);
void as(int,int);
void at(int,int);

int main(){
  int cnt;
  while(1){
    cin >> h >> w;
    cnt = 0;
    if(w == 0 && h == 0) break;
    for(int i=0;i<100;i++) memset(mas[i],-1,sizeof(mas[i]));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mas[i][j];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(mas[i][j] == '#'){
	  sha(j,i);
	  cnt++;
	}
	else if(mas[i][j] == '*'){
	  as(j,i);
	  cnt++;
	}
	else if(mas[i][j] == '@'){
	  at(j,i);
	  cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
}

void sha(int x,int y){
  mas[y][x] = '0';
  for(int i=0;i<4;i++){
    int nx = x + grx[i];
    int ny = y + gry[i];
    if(nx >= 0 && nx < w && ny >= 0 && ny < h && mas[ny][nx] == '#'){
      sha(nx,ny);
    }
  }
}

void as(int x,int y){
  mas[y][x] = '0';
  for(int i=0;i<4;i++){
    int nx = x + grx[i];
    int ny = y + gry[i];
    if(nx >= 0 && nx < w && ny >= 0 && ny < h && mas[ny][nx] == '*'){
      as(nx,ny);
    }
  }
}

void at(int x,int y){
  mas[y][x] = '0';
  for(int i=0;i<4;i++){
    int nx = x + grx[i];
    int ny = y + gry[i];
    if(nx >= 0 && nx < w && ny >= 0 && ny < h && mas[ny][nx] == '@'){
      at(nx,ny);
    }
  }
}

Measured memory_bytes: 1476
from itertools import combinations
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]
ans = 0
for i in range(1 << H):
    hs = []
    for h in range(H):
        if (i >> h) & 1:
            hs.append(h)
    for j in range(1 << W):
        ws = []
        for w in range(W):
            if (j >> w) & 1:
                ws.append(w)
        tmp = 0
        for h in range(H):
            if h in hs:
                continue
            for w in range(W):
                if w in ws:
                    continue
                tmp += C[h][w] == '#'
        if tmp == K:
            ans += 1

print(ans)

Measured memory_bytes: 74296
N = gets.chomp.to_i
a = Math.sqrt(N).ceil.to_i
b = 0

if N == 1
    puts "0 0 1 0 0 1"
    exit
end

if N >= a*(a-1)
    b = a
else
    b = a-1
end

d = a*b-N
print a," ",b," ",a-1," 0 0 ",b-d
puts

Measured memory_bytes: 3836
i = gets.to_f
pay = i*100/108
pay = pay.round
if 0 <= pay * 1.08 -i && pay * 1.08 -i < 1
  p pay
elsif 0 <= (pay+1) * 1.08 -i && (pay+1) * 1.08 -i < 1
  p pay+1
elsif 0 <= (pay-1) * 1.08 -i && (pay-1) * 1.08 -i < 1
  p pay-1
else
  print ":("
end

Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;
 

 
int main(void){
	long long N,M;
	cin>>N>>M;
	if(M<=(ll)2*N){
		cout<<M/(ll)2<<endl;
	}else{
		
		long long ans=0;
		ans+=N;
		M=M-2*N;
		ans+=M/(ll)4;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int N;
    cin >> N;
  
    int h0, h1;
    int pos_sum = 0;
    for(int i=0; i<N; i++){
        if(i==0){
            cin >> h0;
            pos_sum += h0;
        }else{
            cin >> h1;
            if(h1-h0>0){pos_sum += h1-h0;}
            h0 = h1;
        }
    }

    cout << pos_sum << endl;

    return 0;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,x,t;
    cin >> n >> x >> t;
    for(i=1; ;i++){
        if(i*x>=n){
            break;
        }
    }
    t = i*t;
    printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int len = s.size();
    if(len<=n)
    {
        cout<<s<<endl;
    }
    else
    {
        for(int i=0; i<n; i++)
        {
            if(i<n)
            {
                cout<<s[i];
            }

        }
        cout<<"..."<<endl;
    }
}


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const ll N=1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
 
int main(){
	ll x;
	cin>>x;
	// cout<<x<<endl;
	for(ll i=-200;i<=200;i++){
		for(ll j=-200;j<=200;j++){
			if(i*i*i*i*i-j*j*j*j*j==x){
				// cout<<i*i*i*i*i<<endl;
				// cout<<j*j*j*j*j<<endl;
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
}

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

P = []
X = []
Y = []

PAppend = P.append
XAppend = X.append
YAppend = Y.append
for i in range(N):
  PAppend([int(x) for x in input().split()])
  XAppend(P[i][0])
  YAppend(P[i][1])

X.sort()
Y.sort()

S = [[0] * N for _ in range(N)]
for i in range(N):
  for j in range(N):
    for k in P:
      if k[0] <= X[i] and k[1] <= Y[j]:
        S[i][j] += 1

ans = float('inf')
for i in range(N - 1):
  for j in range(N - 1):
    for k in range(i + 1, N):
      for l in range(j + 1, N):
        PCount = S[k][l]
        if i > 0:
          PCount -= S[i - 1][l]
        if j > 0:
          PCount -= S[k][j - 1]
        if i > 0 and j > 0:
          PCount += S [i - 1][j - 1]
        if PCount >= K:
          ans = min(ans, (X[k] - X[i]) * (Y[l] - Y[j]))

print(ans)

Measured memory_bytes: 45548
#include "stdio.h"
int main(){
  int k,x,i,max;
  scanf("%d",&k);
  scanf("%d",&x);
  if(x-k>=-1000000)i=x-k+1;
  else i=-1000000;
  if(x+k<=1000000)max=x+k;
  else max=1000000;


for ( ; i < max; i++) {
  printf("%d\n",i);
}

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

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

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

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int n,x; cin>>n>>x;
	int min=1001;
	int a[n]; for(int &i:a) { cin>>i; chmin(min,i); x-=i; }
	cout<<n+x/min<<endl;
}


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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,x; cin >> n >> x;
    vector<int> l(n);
    rep(i,0,n) cin >> l.at(i);

    int cnt=0;
    int d=0;
    repe(i,0,n){
        if(d<=x) cnt++;
        d=d+l[i];
    }
    cout << cnt ENDL;
    
    return 0;
}

Measured memory_bytes: 6000
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
int main() 
{ 
	ll a,b;
	cin >> a >> b;
	string s1="",s2="";
	for(ll i=0;i<a;i++)
		s1+=('0'+b);
	for(ll i=0;i<b;i++)
		s2+=('0'+a);
	if(s1<=s2)
		cout << s1 << "\n";
	else
		cout << s2 << "\n";
} 

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int u,r;
    u=ty-sy;
    r=tx-sx;
    rep(i,u)cout<<'U';
    rep(i,r)cout<<'R';
    rep(i,u)cout<<'D';
    rep(i,r+1)cout<<'L';
    rep(i,u+1)cout<<'U';
    rep(i,r+1)cout<<'R';
    cout<<'D'<<'R';
    rep(i,u+1)cout<<'D';
    rep(i,r+1)cout<<'L';
    cout<<'U';
	return 0;
}


Measured memory_bytes: 3548
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
typedef long long ll;
ll a[N],b[N];
int main ()
{
	ll n;
	while(scanf("%I64d",&n)!=EOF)
	{
		ll ans=0;
		for(int i=0;i<n;i++)
		{
			scanf("%I64d",&a[i]);
			ans+=a[i];
		}
		for(int i=0;i<n-1;i++)
			b[i]=a[i+1]-a[i];
		b[n-1]=a[0]-a[n-1];
		int flag=1;
		if(ans%((1+n)*n/2))
			flag=0;
		if(flag)
		{
			ll k=ans/((1+n)*n/2);
			for(int i=0;i<n;i++)
				if((k-b[i])%n||b[i]-k>0)
					flag=0;
		}
		printf("%s\n",flag?"YES":"NO");
	}
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(elem => int.Parse(elem)).OrderBy(elem => elem).ToArray();
            var check = Enumerable.Repeat(true, A.Last() + 1).ToArray();
            foreach (var i in Enumerable.Range(0, N))
            {
                if (check[A[i]] == false)
                {
                    continue;
                }

                for (var j = 2 * A[i]; j <= A.Last(); j += A[i])
                {
                    check[j] = false;
                }
            }

            var answer = new Dictionary<int, int>();
            foreach (var i in Enumerable.Range(0, N))
            {
                if (check[A[i]])
                {
                    if (answer.ContainsKey(A[i]))
                    {
                        answer[A[i]]++;
                    }
                    else
                    {
                        answer[A[i]] = 1;
                    }
                }
            }

            Console.WriteLine(answer.Count(elem => elem.Value == 1));
        }
    }
}


Measured memory_bytes: 56308
N=int(input())
T=[0]*5
for i in range(N):
    S=input()
    if S[0]=="M": T[0]+=1
    elif S[0]=="A": T[1]+=1
    elif S[0]=="R": T[2]+=1
    elif S[0]=="C": T[3]+=1
    elif S[0]=="H": T[4]+=1

ans=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans+=T[i]*T[j]*T[k]
print(ans)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int f[N];
int64 c[N];

int find(int x) {
  if (f[x] != f[f[x]]) f[x] = find(f[x]);
  return f[x];
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<ii> e(m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &e[i].first, &e[i].second);
    --e[i].first;
    --e[i].second;
  }
  for (int i = 0; i < n; ++i) {
    f[i] = i;
    c[i] = 1;
  }
  vector<int64> ret(m);
  ret[m - 1] = 0;
  for (int i = m - 1; i >= 1; --i) {
    int x = e[i].first, y = e[i].second;
    int rx = find(x), ry = find(y);
    ret[i - 1] = ret[i];
    if (rx != ry) {
      f[ry] = rx;
      ret[i - 1] -= c[rx] * (c[rx] - 1) / 2;
      ret[i - 1] -= c[ry] * (c[ry] - 1) / 2;
      c[rx] += c[ry];
      ret[i - 1] += c[rx] * (c[rx] - 1) / 2;
    }
  }
  for (int i = 0; i < m; ++i) {
    printf("%lld\n", (int64)n * (n - 1) / 2 - ret[i]);
  }
  return 0;
}


Measured memory_bytes: 4096
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N, T;
  cin >> N >> T;
  vector<pair<int, int>> Cost(N);
  for (int i = 0; i < N; i++) {
    cin >> Cost[i].first >> Cost[i].second;
  }
  int ans = 1001;
  int index = -1;
  for (int i = 0; i < N; i++) {
    if (Cost[i].second <= T) {
      if (ans > Cost[i].first) {
        ans = Cost[i].first;
        index = i + 1;
      }
    }
  }

  if (index == -1) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  int B[M], A[N][M];
  for(int i=0;i<M;i++) cin >> B[i];
  for(int i=0;i<N;i++) {
    for(int j=0;j<M;j++) {
      cin >> A[i][j];
    }
  }
  int ans = 0;
  for(int i=0;i<N;i++) {
    int sum = C;
    for(int j=0;j<M;j++) {
      sum += B[j]*A[i][j];
    }
    if(sum > 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    double ans = w * h / 2.0;
    bool isMultiple = (w / 2 == x && h / 2 == y);

    cout << setprecision(20) << ans << ' ' << isMultiple << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long n,k;
long long v[2001][2001];
const int MOD=1e9+7;
int main()
{
    scanf("%lld%lld",&n,&k);
    v[0][0]=1;
    for(int i=1;i<=n;i++)
	{
        v[i][0]=1;
        for(int j=1;j<=i;j++)
            v[i][j]=(v[i-1][j-1]+v[i-1][j])%MOD;
    }
    for(int i=1;i<=k;i++)
        printf("%lld\n",v[n-k+1][i]*v[k-1][i-1]%MOD);
    return 0;
}

Measured memory_bytes: 30080
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int n;
	cin>>n;
	vector<long> prices (n);
	for(int i=0;i<n;i++)
	    cin>>prices[i];
	long money=1000;
	for(int i=1;i<n;i++)
	{
	    if(prices[i]>prices[i-1])
	    {
	        long stocks=money/prices[i-1];
	        money=money-(stocks*prices[i-1]);
	        money=money + stocks*prices[i];
	    }
	}
	cout<<money<<endl;
}


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

int main() {
	int w, h; char c; cin >> w >> h >> c;
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
		if (i == 0 || i == h - 1) {
			if (j == 0 || j == w - 1) cout << "+";
			else cout << "-";
		}
		else {
			if (j == 0 || j == w - 1) cout << "|";
			else if (i == (h - 1) / 2 && j == (w - 1) / 2) cout << c;
			else cout << ".";
		}
		if (j == w - 1) cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    if( n%2 == 0){
        string s1(n/2,'0');
        string s2(n/2,'0');
        for(int i=0; i<n/2; i++){
            s1.at(i) = s.at(i);
        }
        for(int i=0; i<n/2; i++){
            s2.at(i) = s.at(i+n/2);
        }
        if(s1 == s2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read
    H, W, D = (int(i) for i in input().split())
    R = [r for r in read().rstrip().split(b'\n')]
    A = [[int(i) for i in r.split()] for r in R[:H]]

    B = [0]*(H*W+1)
    pos = {A[i][j]: (i+1, j+1) for i in range(H) for j in range(W)}

    for i in range(D+1, H*W+1):
        y, x = pos[i - D]
        ny, nx = pos[i]
        power = abs(nx - x) + abs(ny - y)
        B[i] = B[i - D] + power

    for r in R[H+1:]:
        le, ri = (int(i) for i in r.split())
        print(B[ri] - B[le])


if __name__ == '__main__':
    main()


Measured memory_bytes: 69216
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = 0;
            while ((n = int.Parse(Console.ReadLine())) != 0)
            {
                var m = int.Parse(Console.ReadLine());
                var s = Console.ReadLine();

                var count = new int[m];
                for (var i = m - 1; i >= 2; i--)
                {
                    if (s[i] == 'I')
                    {
                        if (s[i - 2] == 'I' && s[i - 1] == 'O')
                        {
                            count[i - 2] = count[i] + 1;
                        }
                    }
                }
                Console.WriteLine(count.Count(i => i >= n));
            }
        }
    }
}

Measured memory_bytes: 12796
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	if(a >= 13) System.out.println(b);
      	else if(a >= 6) System.out.println(b/2);
      	else System.out.println("0");
    }
}

Measured memory_bytes: 35668
#include <queue>
#include <string>
#include <iostream>

const std::string words[] = {
  "dream", "dreamer", "erase", "eraser",
};

bool can_make_s_from_empty_string(const std::string & s) {
  std::queue<int> q; q.push(0);

  while(!q.empty()) {
    const auto pos { q.front() }; q.pop();
    if(pos == s.length()) {
      return true;
    }
    for(auto && word : words) {
      const auto found { s.substr(pos, word.length()) == word };
      if(found) {
        q.push(pos + word.length());
      }
    }
  }

  return false;
}

int main() {
  std::string s;
  std::cin >> s;

  std::cout
    << (can_make_s_from_empty_string(s) ? "YES" : "NO")
    << std::endl;

  return 0;
}

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

int main() {
	int N, Y;
	cin >> N >> Y;
	int A=-1, B=-1, C=-1;
	for (int i=0; i<=N; i++){
	    for (int j=0; i+j<=N; j++){
	        int k=N-i-j;
	        if (10000*i+5000*j+1000*k==Y){
	           A=i;
	           B=j;
	           C=k;
	        }
	    }
	}
	cout << A << " " << B << " " << C << endl;
}


Measured memory_bytes: 256