akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
  //  #endif
   ll k,q;
   cin>>n>>k>>q;
   vector<int>v(n,k),v2(n);
   for(int i=0;i<q;i++)
   	{
   		cin>>a;
   		a--;
   		v2[a]++;
   	}

   for(int i=0;i<n;i++){
   	v[i]-=(q-v2[i]);
   }

   //for(auto it:v)cout<<it<<" ";
   //	cout<<endl;
   for(auto it:v){
   	if(it<=0)
   		cout<<"No"<<endl;
   	else cout<<"Yes"<<endl;
   }
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


Measured memory_bytes: 1408
// ------------------------------------
// Date:2018/ 3/ 1
// Problem:ABC 055 TrainingCamp b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

long int memo[101010];

int main()
{
  int N;
  cin >> N;
  // power = 1;
  memo[0] = 1;
  FOR(i, 1, N + 1) {
    memo[i] = (memo[i - 1] * i) % MOD;
  }
  cout << memo[N] << endl;
  
  return 0;
}



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

int main() {
    int N;
    int a[114514]; 
    cin >> N; 
    a[0] = 0; 
    for (int i = 1; i <= N; ++i)
    cin >> a[i]; 
    int S = 0; 
    for (int i = 0; i <= N; ++i) 
    S += abs (a[i]-a[i+1]); 
    for (int i = 1; i <= N; ++i){
    cout << S - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) 
      + abs(a[i-1]-a[i+1]) << endl; 
  }
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

ll aru[101010];
ll cnt[101010];

int main(){

    ll N, M;
    cin >> N >> M;
    aru[1] = 1;
    for(ll i = 1; i <= N; i++)cnt[i] = 1;
    for(ll i = 0; i < M; i++){
        ll x, y;
        cin >> x >> y;
        if(aru[x]){
            cnt[x]--;
            cnt[y]++;
            if(cnt[x] == 0)aru[x] = 0;
            aru[y] = 1;
        }
        else{
            cnt[x]--;
            cnt[y]++;
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= N; i++)if(aru[i])ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  string s;
  cin>>s;
  while(s.size()){
    if(s.size()==1)break;
    s.erase(s.begin()+s.size()-1);
    //cout<<s<<endl;
    if(s.size()%2==1)continue;
    bool ok=true;
    rep(i,s.size()/2){
      if(s[i]!=s[s.size()/2+i])ok=false;
    }
    if(ok){
      cout<<s.size()<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define INF 1e9
#define MOD 1000000007;//1e9+7

void solve() {
    long long N;
    cin >> N;
    cout << (N - 1)*N / 2;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL cnt[100001];
int main(){
	int n;
	cin>>n;
	LL a,sum=0;
	for(int i=0;i<n;i++){
		cin>>a;
		sum+=a;
		cnt[a]++;
	}
	int q;
	cin>>q;
	while(q--){
		LL b,c;
		cin>>b>>c;
		sum+=(cnt[b]*c-b*cnt[b]);
		cnt[c]+=cnt[b];
		cnt[b]=0;
		cout<<sum<<"\n";
	}
}


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

int main(void)
{
    int n, c=0;
  	cin>>n;
    vector<int> color(9,0);
    rep(i,n){
        int a;
      	cin >> a;
        if(a < 3200) color[a/400]++;
        else color[8]++;
    }
    rep(i,8) if(color[i]) c++;
    if(c) cout << c;
    else cout << 1;
    cout << " " << c + color[8] << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef vector<vector<int> > mat;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

mat goal(5, vector<int>(5,-1));
set<mat> mp;

int hogex[12] = {0,1,2,3,0,1,2,3,4,1,2,3};
int hogey[12] = {0,1,1,1,2,2,2,2,2,3,3,3};
int dist(mat a) {
  int res = 0;
  REP(x,5) {
    REP(y,5) {
      if (a[x][y] > 0) {
        res += abs(x-hogex[a[x][y]]) + abs(y-hogey[a[x][y]]);
      }
    }
  }
  return res;
}

int main() {
  goal[2][0] = 0;
  REP(i,3) goal[i+1][1] = i+1;
  REP(i,5) goal[i][2] = i+4;
  REP(i,3) goal[i+1][3] = i+9;
  goal[2][4] = 0;
  
  int a;
  while(cin >> a, a!=-1) {
    mp.clear();
    mat ma(5, vector<int>(5, -1));
    ma[2][0] = a;
    REP(i,3) {
      cin >> a;
      ma[i+1][1] = a;
    }
    REP(i,5) {
      cin >> a;
      ma[i][2] = a;
    }
    REP(i,3) {
      cin >> a;
      ma[i+1][3] = a;
    }
    cin >> a;
    ma[2][4] = a;

    queue<pair<mat, int> > Q;
    Q.push(pair<mat, int>(ma, 0));
    mp.insert(ma);
    bool ff = 0;
    while(!Q.empty()) {
      mat ma2 = Q.front().first;
      int d = Q.front().second;
      Q.pop();
//      cout << d << " " << mp.size() << endl;
      if (d > 20) break;
      if (ma2 == goal) {
        ff = 1;
        cout << d << endl;
        break;
      }
      if (d + dist(ma2) > 20) continue;
      
      vector<int> zx,zy;
      REP(x,5) REP(y,5) {
        if (ma2[x][y] == 0) {
          zx.push_back(x);
          zy.push_back(y);
        }
      }
      REP(i,2) {
        int x = zx[i], y = zy[i];
        REP(k,4) {
          int xx = x + dx[k];
          int yy = y + dy[k];

          if (xx<0 || xx>=5 || yy<0 || yy>=5) continue;
          if (ma2[xx][yy] == -1) continue;

          mat tmp = ma2;
          swap(tmp[x][y], tmp[xx][yy]);
          if (mp.count(tmp)) continue;
          mp.insert(tmp);
          Q.push(make_pair(tmp, d+1));
        }
      }
    }
    if (!ff)
      cout << "NA" << endl;
  }
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
typedef long long ll;

const int D = 1000;
int arr[2][2*D + 1][2*D + 1];

int get(int j, int x1, int y1, int x2, int y2) {
	return arr[j][x2+1][y2+1] - arr[j][x1][y2+1] - arr[j][x2+1][y1] + arr[j][x1][y1];
}

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

	int n, d;
	cin >> n >> d;
	// Divide the plane into D^2 partitions
	// Say d = 3,
	// a b c a b c a b c
	// d e f d e f d e f
	// g h i g h i g h i
	// a b c a b c a b c
	// d e f d e f d e f
	// g h i g h i g h i
	// a b c a b c a b c
	// d e f d e f d e f
	// g h i g h i g h i
	// We can move points within the same partition arbitrarily. Points cannot switch partitions.
	vector<int> cou(d*d, 0);
	for (int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		x %= d;
		y %= d;
		++cou[x + y * d];
	}
	
	// All partitions want to be packed into a square, or a rectangle with one side d shorter than the other
	// Find points with longest edge size, and put them into bads. Points not in bads are not a concern
	int mx = -1;
	vector<pair<int, int>> bads;
	for (int i = 0; i < d*d; ++i) {
		if (! cou[i]) continue;

		int w = 1;
		while(w*w < cou[i]) {
			++w;
		}
		int h = (cou[i] + (w-1)) / w;

		if (w > mx) {
			mx = w;
			bads.clear();
		}
		if (w == mx) bads.push_back({i, (bool)(w > h)});
	}

	// Fill the two-dimensional sum-array so we can count how many points are in a rectangle fast.
	int sq_cou = 0;
	for (auto pr : bads) {
		int i = pr.first;
		int j = pr.second;

		int x = i % d;
		int y = i / d;
		++x; ++y;

		if (j == 0) ++sq_cou;

		++arr[j][x][y];
		++arr[j][x+d][y];
		++arr[j][x][y+d];
		++arr[j][x+d][y+d];
	}
	
	for (int j = 0; j < 2; ++j) {
		for (int x = 0; x <= 2*d; ++x) {
			for (int y = 0; y <= 2*d; ++y) {
				if (x == 0) {
					arr[j][x][y] += arr[j][x][y-1];
				} else if (y == 0) {
					arr[j][x][y] += arr[j][x-1][y];
				} else {
					arr[j][x][y] += arr[j][x-1][y] + arr[j][x][y-1] - arr[j][x-1][y-1];
				}
			}
		}
	}

	// Binary search answer
	int low = 0;
	int high = d-1;
	while(low != high) {
		int mid = (low + high) >> 1;
		bool works = false;
		for (int x = 0; x < d; ++x) {
			for (int y = 0; y < d; ++y) {
				// Rectangles must not be in [mid+1, d-1] x [mid+1, d-1]
				if (get(1, x + mid + 1, y + mid + 1, x + d-1, y + d-1) != 0) continue;
				// Squares must be in [0, mid] x [0, mid]
				if (get(0, x, y, x + mid, y + mid) != sq_cou) continue;
				works = true;
			}
		}
		if (works) high = mid;
		else low = mid + 1;
	}
	
	// Calculate answer
	if (mx == -1) {
		cout << "0\n";
	} else {
		int ans = (mx - 1) * d + low;
		cout << ans << '\n';
	}
}

Measured memory_bytes: 36340
#include<stdio.h>
#include<math.h>
int main(){
double a[100],b[100],ans=0,s,z,l,m,n;
int num=0,i;
while(scanf("%lf,%lf\n",&a[num],&b[num])!=EOF){
num++;
}
for(i=2;i<num;i++){
l=(a[0]-a[i])*(a[0]-a[i])+(b[0]-b[i])*(b[0]-b[i]);
l=sqrt(l);
m=(a[0]-a[i-1])*(a[0]-a[i-1])+(b[0]-b[i-1])*(b[0]-b[i-1]);
m=sqrt(m);
n=(a[i]-a[i-1])*(a[i]-a[i-1])+(b[i]-b[i-1])*(b[i]-b[i-1]);
n=sqrt(n);
z=(l+m+n)/2;
s=z*(z-l)*(z-m)*(z-n);
s=sqrt(s);
ans=ans+s;
}
printf("%lf\n",ans);
return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;

int a[N], id[N];

bool cmp(int x, int y){
	return a[x] < a[y];
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) id[i] = i;
	sort(id + 1, id + n + 1, cmp);
	int ans = 0;
	for (int i = 1; i <= n; i++) ans += (i % 2 != id[i] % 2);
	printf("%d", ans / 2);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		String[] b = x.split(" ");
		int[] e = new int[b.length];
		for (int i = 0; i < e.length; i++) {
			e[i] = Integer.parseInt(b[i]);

		}
		if (e[0] >= e[2] + e[4] && e[1] >= e[3] + e[4]&&e[2]-e[4]>=0&&e[3]-e[4]>=0) {
			System.out.println("Yes");

		} else {
			System.out.println("No");

		}

	}
}

Measured memory_bytes: 26332
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
struct Node{
	long long l,r;
	bool operator <(const Node &other)const{
	    return (l*other.r<r*other.l);
	}
}q[maxn];
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a*n,b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
int n,a[N],ans,x=1;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=2;i<=n;i++)
	{
		if(a[i]==a[i-1]) x++;
		else
		{
			if(x%2==1) ans++;
			x=1;
		} 
	} 
	if(x%2==1) ans++;
	cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void BubbleSort(int n, string *bnums) {
	
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = n - 1; j > i; j--)
		{
			
			if (bnums[j].at(1) < bnums[j - 1].at(1)) {
				string tmp = bnums[j];
				bnums[j] = bnums[j - 1];
				bnums[j - 1] = tmp;
			}
			
		}
	}

	for (int i = 0; i < n; i++)
	{
		cout << bnums[i];
		if (i != n - 1) cout << " ";
		else cout << endl;

	}
	cout << "Stable" << endl;

}

void SelectionSort(int n, string *bnums, string *snums) {
	bool FLAG = false;
	for (int i = 0; i < n - 1; i++)
	{
		int mini = i;

		for (int j = i + 1; j < n; j++)
			if (snums[j].at(1) < snums[mini].at(1)) mini = j;
		
		if (mini != i) {
			string tmp = snums[i];
			snums[i] = snums[mini];
			snums[mini] = tmp;
		}
	}

	for (int i = 0; i < n; i++)
	{
		cout << snums[i];
		if (i != n - 1) cout << " ";
		else cout << endl;

		if (bnums[i] != snums[i]) FLAG = true;
	}

	if (FLAG) cout << "Not stable" << endl;
	else cout << "Stable" << endl;

}


int main() {
	int n;
	string	*bnums, *snums;

	cin >> n;

	bnums = new string[n];
	snums = new string[n];

	for (int i = 0; i < n; i++) {
		cin >> bnums[i];
		snums[i] = bnums[i];
	}

	BubbleSort(n, bnums);
	SelectionSort(n, bnums, snums);

	return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



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++)






















using ld = long double;

int main(){
    ll n, k;
    cin >> n >> k;
    ld ans = 0.0;
    for(ll i = 1; i <= n; i++){
        ll t = i;
        ld p = 1.0 / (ld)n;
        while(t < k){
            t *= 2;
            p /= 2.0;
        }
        ans += p;
    }
    printf("%.11Lf\n", ans);
}

Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))

b = []
for i in range(n):
  dis = a[i] - a[i-1]
  if dis > 0:
    b.append(dis)
  
b.append(k - a[len(a)-1] + a[0])

c = b.remove(max(b))

print(sum(b))

Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

double calc(double x) {
   return (x * (x+1)) / 2 / x;
}

int main()
{
  int n, k;
  cin >> n >> k;
  vector<double> vec(n);
  vector<double> culsum(n+1, 0);
  rep(i,n) cin >> vec.at(i);
  reps(i, 1, n+1) culsum.at(i) = culsum.at(i-1) + calc(vec.at(i-1));
  double ans = 0;
  rep(i, n-k+1) ans = max(culsum.at(i+k) - culsum.at(i), ans);
  printf("%.8f\n", ans);

  return 0;
}

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

int main() {
    string s;
    ll k, ans = 0, cntf = 0, cntl = 0;
    cin >> s >> k;
    for (int i = 0; i < s.size(); i++) {
        int cnt = 1, j = i;
        while (i < s.size() && s[i] == s[i + 1]) {
            cnt++;
            i++;
        }
        if (j == 0 && i == s.size() - 1) {
            ans = (ll)s.size() * k / 2;
            cout << ans << endl;
            return 0;
        }
        if (j == 0) cntf = cnt;
        if (i + 1 == s.size()) cntl = cnt;
        ans += cnt / 2;
    }
    ans *= k;
    if (s[0] == s.back() && cntf % 2 && cntl % 2) ans += k - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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 <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


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;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

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

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b, c; cin >> a ;
	//string s,t; cin >> s>>t;
	cout << a * 800 - 200 * (a / 15);

	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;

vector<vector<int> > path;
queue<tuple<int, int, int> > q;
vector<vector<bool> > seen;

typedef long long ll;

ll countv = 0;
ll K = 0;


#define MOD (1000000007)

void push(int num, int timing, int count) {
    if(seen[num][timing] != true) {
        q.push(make_tuple(num, timing, count));
        seen[num][timing] = true;

        //cout << num+1 << ":" << timing << "-" << count << endl;
    }
}


int main() {
    ll N, M;
    cin >> N >> M;


    path.assign(N, vector<int>());
    seen.assign(N, vector<bool>(3, false));
    for(ll i = 0; i < M; i++) {
        ll u, v;
        cin >> u >> v;
        u--;v--;
        path[u].push_back(v);
        //path[v].push_back(u);
    }

    ll S, T;
    cin >> S >> T ;
    S--; T--;

    push(S, 0, 0);
    while(q.size() >= 1) {
        tuple<int, int, int> p = q.front(); q.pop();
        int current = get<0>(p);
        int timing = get<1>(p);
        int count = get<2>(p);
        if(current == T && timing == 0) {
            cout << count / 3 << endl;
            return 0;
        }
        for(ll i = 0; i < path[current].size(); i++) push(path[current][i], (timing + 1 ) % 3, count+1);
    }

    cout << -1 << endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

ll c[10000005];

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

    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; ++i){
        ++c[i];
        ans += c[i] * i;
        for(int j = i + i; j <= n; j += i){
            ++c[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 81680
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
int n;
ll ans;
ll dp[1000001][3];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	dp[0][1]=2;
	dp[0][0]=8;
	rep(i,n-1){
		dp[i+1][0]=dp[i][0]*8;
		dp[i+1][0]%=mod;
		dp[i+1][1]=dp[i][1]*9;
		dp[i+1][1]%=mod;
		dp[i+1][1]+=dp[i][0]*2;
		dp[i+1][1]%=mod;
		dp[i+1][2]=dp[i][2]*10;
		dp[i+1][2]%=mod;
		dp[i+1][2]+=dp[i][1];
		dp[i+1][2]%=mod;
	}
	cout<<dp[n-1][2];
	re 0;
}


Measured memory_bytes: 26924
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }



int main() {
  cout << fixed << setprecision(25);

  ll a, b, c;
  scanf("%lld %lld.%lld", &a, &b, &c);
  b = b * 100 + c;
  ll ans = a * b / 100;
  printf("%lld\n", ans);




  
  return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};

ll H, W, K;

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> H >> W >> K;
  vector<string> s(H);
  rep(i, H)cin >> s[i];
  ll ans = 0;
  rep(i, 1<<H){
    rep(j, 1<<W){
      ll cnt = 0;
      rep(h, H){
        rep(w, W){
          if(s[h][w]=='#' and i>>h&1!=0 and j>>w&1!=0){
            cnt++;
          }
        }
      }
      if(cnt==K)ans++;
    }
  }
  cout <<  ans;
  return 0;
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
      else
      cout<<"safe";  
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3504
import sys
input = sys.stdin.readline
def main():
    num = list(map(int, input().split()))
    MAX = max(num)
    CNT = 0
    for i in range(3):
        num[i] -= MAX
        CNT -= num[i]
    if CNT%2 == 0:
        ans = CNT//2
        print(ans)
    else:
        ans = CNT//2 + 2
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
/*
本宝的程序外人别想看！！

name: [夏宝宝]
run time：[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include<bits/stdc++.h>
using namespace std;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	cout.sync_with_stdio(false);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	
	cin>>n>>k;
	
	int sum=0;
	
	while(1)
	{
		if(n!=0)
		{
			n/=k;
			
			sum++;
		}
		else
		{
			break;
		}
	} 
	
	cout<<sum<<endl;
	
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc097/tasks/arc097_a

#include <algorithm>
#include <cmath>
#include <iostream>
#include <regex>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = INF;
    string s;
    cin >> s;
    cin >> n;

    // Kが5以下のため、aを検索してなかったらb
    char cmin = *std::min_element(ALL(s));
    string smin{cmin};
    vector<string> v;

    // 最小の文字に対して4文字以下続く文字列を正規表現で検索すると、5通り以上になる
    // a, ab, abc, abcd, abcde
    smatch match;
    string word = "";

    string str = s;
    for (int i = 0; i < 5; i++) {
        if (i == 0) {
            word = ".";
        } else if (i == 1) {
            word = "..";
        } else if (i == 2) {
            word = smin + "..";
        } else if (i == 3) {
            word = smin + "...";
        } else if (i == 4) {
            word = smin + "....";
        }
        regex reg(word);
        auto it = str.cbegin();
        while (regex_search(it, str.cend(), match, reg)) {
            for (auto &x : match) {
                v.push_back(x);
                // cout << x << endl;
            }

            // イテレータをマッチした先頭要素＋１にずらす
            it += match.position(0) + 1;
        }
    }

    // ソートする
    sort(ALL(v));
    // 隣接する重複要素を削除
    unique(ALL(v));

    // FOREACH(x, v) { cout << x << endl; }
    cout << v[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1660
def prime_num(n):
    f = 3
    while f * f <= n:
        if n % f == 0:
            return 1
        f += 2
    return 0

x = int(input())
if x == 2:
    print(x)
    exit()
prime = (x//2)*2 + 1
while 1 == 1:
    if prime_num(prime) == 0:
        print(prime)
        exit()
    prime += 2

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


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  int x,y; cin >> x >> y;
  for(int i = 0; i <= x; i++){
    int now = i * 2 + (x-i) * 4;
    if(now == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int D; cin >> D;
    vector<int> C(26 + 1);
    for (int i = 1; i <= 26; i++) cin >> C[i];
    vector<vector<int>> S(D + 1, vector<int>(26 + 1));
    for (int i = 1; i <= D; i++) {
        for (int j = 1; j <= 26; j++) cin >> S[i][j];
    }

    vector<int> last(26 + 1, 0);
    for (int d = 1; d <= D; d++) {
        int ans;
        ll grd = (-1) * INF;
        for (int t = 1; t <= 26; t++) {
            ll sum = 0;
            sum += (ll)S[d][t];
            int bef = last[t];
            last[t] = d;
            for (int i = 1; i <= 26; i++) {
                sum -= (ll)C[i] * (d - last[i]);
            }
            if (chmax(grd, sum)) ans = t;
            last[t] = bef;
        }
        last[ans] = d;
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
 

int main(){
	
	int h,w;cin>>h>>w;
	
	rep(i,h)
	{
		string s;cin>>s;
		cout <<s<<endl;
		cout <<s<<endl;
	}
	
}

//cout << ans << endl;

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

using namespace std;
 
const long long inf = 1e18;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

ll n,m,k;
ll dp[100001];
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	fr(i,2,n)
		dp[i] = inf;
	VI v(n);
	for (auto &x:v)
		cin >> x;
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);
	for (int i = 2;i < n;i++) {
		for (int j = 1;j <= k;j++) {
			if (i - j < 0)
				break;
			dp[i] = min(dp[i],dp[i-j] + abs(v[i] - v[i-j]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		
		//String s=sc.next();
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		
				
				
				
			
		
		
		System.out.println(b%a==0?a+b:b-a);
		
	}	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}


Measured memory_bytes: 22996
def resolve():
    MOD = 10**9+7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    P = []
    M = []
    for a in A:
        if a < 0:
            M.append(a)
        else:
            P.append(a)
    p_n = len(P)
    m_n = len(M)
    # 正の値にできるかを判定する
    ok = False
    if p_n > 0:
        if N == K:
            ok = (m_n%2==0) # 負の値が偶数あるとTrue
        else:
            ok = True
    # 負の値しか無い場合
    else:
        ok = (K % 2 == 0) # Kが偶数なら負の値を偶数個選べる

    ans = 1
    # 正の値にできない
    if not ok:
        # 絶対値が小さい順にソート
        A.sort(key=lambda x:abs(x))
        for i in range(K):
            ans *= A[i]
            ans %= MOD
    else:
        P.sort()
        M.sort(reverse=True)
        if K%2== 1:
            ans *= P.pop()
            ans %= MOD
        pair = []
        # 2個ずつ処理する
        while len(P) >= 2:
            x = P.pop()
            x *= P.pop()
            pair.append(x)
        while len(M) >= 2:
            x = M.pop()
            x *= M.pop()
            pair.append(x)
        pair.sort(reverse=True)
        for i in range(K//2):
            ans *= pair[i]
            ans %= MOD
    ans %= MOD
    print(ans)

if __name__ == "__main__":
    resolve()


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

int main(){
    int n;
    int s[100];
    cin >> n;
    int total=0;
    for(int i=0;i<n;i++){
      cin >> s[i];
      total+=s[i];
    }
    sort(s,s+n);
    if(total%10){
      cout << total << endl;
    }else{
      for(int i=0;i<n;i++){
        if(s[i]%10){
          cout << total-s[i] << endl;
          return 0;
        }
      }
      cout << 0 << endl;
      return 0;
    }

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc073
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int ans = 0;
            for(int i = 0; i < N; i++)
            {
                string[] str = Console.ReadLine().Split(' ');

                int l = int.Parse(str[0]);
                int r = int.Parse(str[1]);
                ans += r - l + 1;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
from itertools import combinations
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

n,m=map(int,input().split())
uf=UnionFind(n)
e=[]
ans=[]
for _ in range(m):
  a,b=map(int,input().split())
  e.append((a,b))
n_m=n*(n-1)//2
for i,j in e[::-1]:
  ans.append(n_m)
  if not uf.isSameGroup(i,j):
    k=uf.Count(i)*uf.Count(j)
    n_m-=k
    uf.Unite(i,j)
for i in ans[::-1]:
  print(i)

Measured memory_bytes: 95436
#include<iostream>
#include<map>
#include<vector>
using namespace std;

typedef pair<int, int> P;

int main() {
    int H, W, D;
    cin >> H >> W >> D;
    vector<P> v(H*W+1);
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            int a;
            cin >> a;
            v[a] = P(i, j);
        }
    }
    
    vector<int> d(H*W+1, 0);
    for(int i = 1; i + D <= H * W; i++) {
        d[i+D] = d[i] + abs(v[i+D].first - v[i].first) + abs(v[i+D].second - v[i].second);
    }

    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++) {
        int L, R;
        cin >> L >> R;
        cout << d[R] - d[L] << endl;
    }


    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,ans=0,a;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> a;
    ans+=2*min(a,k-a);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];

int main(){
    int n,k;
    int count=0;
    cin>>n>>k;
    rep(i,n){
        cin>>h[i];
        if(h[i]>=k)
            count++;
    }
    cout<<count<<endl;
    return 0; 
}




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

static const int NMAX = 105;
static const int WMAX = 10005;
static const int DIAGONAL = 1;
static const int TOP = 0;

struct Item {
  int value, weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];

void compute(int &maxValue, vector<int> &selection) {
  for (int w = 0; w <= W; w++) {
    C[0][w] = 0;
    G[0][w] = DIAGONAL;
  }

  for (int i = 0; i <= N; i++) C[i][0] = 0;

  for (int i = 1; i <= N; i++) {
    for (int w = 1; w <= W; w++) {
      C[i][w] = C[i - 1][w];
      G[i][w] = TOP;
      if (items[i].weight > w) continue;
      if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
        C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
        G[i][w] = DIAGONAL;
      }
    }
  }

  maxValue = C[N][W];
  selection.clear();
  for (int i = N, w = W; i >= 1; i--) {
    if (G[i][w] == DIAGONAL) {
      selection.push_back(i);
      w -= items[i].weight;
    }
  }

  reverse(selection.begin(), selection.end());
}

void input() {
  cin >> N >> W;
  for (int i = 1; i <= N; i++) {
    cin >> items[i].value >> items[i].weight;
  }
}

int main() {
  int maxValue;
  vector<int> selection;
  input();
  compute(maxValue, selection);

  cout << maxValue << endl;

  return 0;
}


Measured memory_bytes: 11040
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,p3[13],L,tot;
string t;
int son[797170][3],laz[797170],leaf[797170],p[797170],lid[797170];
void push_down(int x){
	if(leaf[x]){laz[x]=0;return;}
	if(laz[x]){
		laz[x]=0;
		laz[son[x][0]]^=1;
		laz[son[x][1]]^=1;
		laz[son[x][2]]^=1;
		swap(son[x][1],son[x][2]);
	}
	return;
} 
void update(int x){
	if(leaf[x]) return;
	push_down(x);
	update(son[x][2]);
	int tmp=son[x][0];
	son[x][0]=son[x][2];
	son[x][2]=son[x][1];
	son[x][1]=tmp;
	return;
}
void build(int x,int cu,int level){
	if(level==n){leaf[x]=1;lid[x]=cu;return;}
	son[x][0]=++tot;build(son[x][0],cu+p3[level]*0,level+1);
	son[x][1]=++tot;build(son[x][1],cu+p3[level]*1,level+1);
	son[x][2]=++tot;build(son[x][2],cu+p3[level]*2,level+1);
	return;
}
void dfs(int x,int cu,int level){
	if(leaf[x]){p[lid[x]]=cu;return;}
	push_down(x);
	dfs(son[x][0],cu+p3[level]*0,level+1);
	dfs(son[x][1],cu+p3[level]*1,level+1);
	dfs(son[x][2],cu+p3[level]*2,level+1);
	return;
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>t;
	p3[0]=1;
	for(int i=1;i<=n;i++) p3[i]=p3[i-1]*3;
	tot=1;
	build(1,0,0);
	for(int i=0;i<t.size();i++){
		if(t[i]=='R') update(1);
		else laz[1]^=1;
	}
	dfs(1,0,0);
	for(int i=0;i<p3[n];i++) cout<<p[i]<<' ';
	cout<<endl;
	return 0;
}


Measured memory_bytes: 25116
#include <iostream>
#include <set>
#include <array>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll INF = 1LL << 50;

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

    vector<int> as(m); 
    vector<int> bs(m);
    vector<ll>  cs(m);

    for (int i = 0; i < m; i++) 
    {
        cin >> as[i] >> bs[i] >> cs[i];
        as[i]--;
        bs[i]--;
        cs[i] = -cs[i];
    }

    vector<ll> dist(n, INF);
    dist[0] = 0;

    for (int loop = 0; loop < n - 1; loop++)
    {
        for (int i = 0; i < m; i++)
        {
            if (dist[as[i]] != INF && dist[bs[i]] > dist[as[i]] + cs[i]) 
            {
                dist[bs[i]] = dist[as[i]] + cs[i];
            }
        }
    }

    vector<bool> negative(n, false);

    for (int loop = 0; loop < n; loop++)
    {
        for (int i = 0; i < m; i++)
        {
            if (dist[as[i]] != INF && dist[bs[i]] > dist[as[i]] + cs[i])
            {
                dist[bs[i]] = dist[as[i]] + cs[i];
                negative[bs[i]] = true;
            }
            if (negative[as[i]]) negative[bs[i]] = true;
        }
    }

    if (negative[n - 1])
    {
        cout << "inf" << endl;
    }
    else
    {
        cout << -dist[n - 1] << endl;
    }
}

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

typedef long long LL;
LL N, A, D, LCM, ans;
unordered_map<LL,map<LL,LL>> C;

void add(LL p, LL x, LL y) {
  if (C[p].find(x) == C[p].end()) C[p][x] = y;
  C[p][x] = max(C[p][x], y);
}

int main () {
  scanf("%lld%lld%lld",&N,&A,&D);
  if (D < 0) {
    D *= -1;
    A *= -1;
  }
  if (D == 0) {
    ans = (A == 0) ? 1 : N+1;
  } else {
    for (LL i=0;i<=N;++i) {
      LL p = (A * i) % D;
      if (p < 0) p += D;
      LL a = (A * i) / D;
      LL x = a + (i-1 + 0  ) * i / 2ll;
      LL y = a + (N-1 + N-i) * i / 2ll;
      add(p, min(x,y), max(x,y));
    }
    for (auto MP : C) {
      auto M = MP.second;
      LL cur = M.begin()->first - 1;
      for (auto pr : M) {
        if (pr.first > cur) {
          ans += pr.second - pr.first + 1;
          cur = pr.second;
        } else if (pr.second > cur) {
          ans += pr.second - cur;
          cur = pr.second;
        }
      }
    }
  }
  printf("%lld\n",ans);
}


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

using namespace std;

int main()
{
   int n,x,t;
   cin>>n>>x>>t;
   int num = (n-1)/x;
   num = num +1;
   cout<<num*t<<endl;
   
   return 0;
}

Measured memory_bytes: 3588
w, h, x, y, r = list(map(int, input().split()))

cl_up = y + r
cl_down = y - r
cl_left = x - r
cl_right = x + r

if cl_up > h or cl_down < 0 or cl_left < 0 or cl_right > h:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 5596