akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000, MAX_M = 100000, MAX_Q = 100000;
int N, M, Q;
int a[MAX_M], b[MAX_M];
int v[MAX_Q], d[MAX_Q], c[MAX_Q];
                            
struct edge { int to, cost; };
const int MAX_V = 100000, INF = INFINT;

// Vの初期化を忘れない。
int V;
vector<edge> G[MAX_V];
int dist[MAX_V];
int dp[MAX_V][11];

void add_edge(int v, int u, int cost) {
  G[v].push_back((edge){u, cost});
  G[u].push_back((edge){v, cost});
}

void dfs(int v, int di, int c) {
  if (dp[v][di] != 0) return;
  if (di == 0) {
    dp[v][di] = c; return;
  }
  dp[v][di] = c;

  dfs(v, di-1, c);
  for (int i = 0; i < G[v].size(); ++i) {
    int u = G[v][i].to;
    dfs(u, di-1, c);
  }
}


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

  cin >> N >> M;
  rep(i, M) cin >> a[i] >> b[i];
  rep(i, M) {--a[i]; --b[i];}
  cin >> Q;
  rep(i, Q) cin >> v[i] >> d[i] >> c[i];
  rep(i, Q) {--v[i];}
  V = N;

  rep(i, M) {
    add_edge(a[i], b[i], 1);
  }

  rrep(i, Q) {
    dfs(v[i], d[i], c[i]);
  }

  rep(i, N) {
    cout << dp[i][0] << endl;
  }

  return 0;
}


Measured memory_bytes: 15220
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    S = S.replaceAll("eraser", "");
    S = S.replaceAll("erase", "");
    S = S.replaceAll("dreamer", "");
    S = S.replaceAll("dream", "");
   
    System.out.println(S.length() == 0 ? "YES" : "NO");
  }
}

Measured memory_bytes: 28628
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p,x;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>s;
    n=s.size();
    for(i=0;i<n;i++)
    {
        cout<<"x";
    }
    cout<<"\n";
    return 0;
}



Measured memory_bytes: 384
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int size = n.length();
        int min = 99999;
        int sabun = 0;

        for(int i = 0;i<size-2;i++){
            int a = Integer.parseInt(n.substring(i,i+3));
            sabun = Math.abs(a-753);
            if(min>sabun){
                min = sabun;
            }

        }
        System.out.println(min);

    }
}


Measured memory_bytes: 22100
#include <stdio.h>

typedef int value_type ;

void quicksort(value_type a[], int left, int right);
value_type med3(value_type x, value_type y, value_type z);

int main()
{
	int N, i,tmp;
	int array[100001];

	scanf("%d", &N);

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

	}
	
	quicksort(array, 0, N - 1);

	int num = array[N / 2] - array[N / 2 - 1];

	printf("%d\n", num);
	
    return 0;
}


value_type med3(value_type x, value_type y, value_type z) {
	if (x < y) {
		if (y < z) return y; else if (z < x) return x; else return z;
	}
	else {
		if (z < y) return y; else if (x < z) return x; else return z;
	}
}

/* クイックソート
* a     : ソートする配列
* left  : ソートするデータの開始位置
* right : ソートするデータの終了位置
*/
void quicksort(value_type a[], int left, int right) {
	if (left < right) {
		int i = left, j = right;
		value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2 ではオーバーフローしてしまう */
		while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
			while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
			while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
			if (i >= j) break;
			tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i], a[j] を交換 */
			i++; j--;
		}
		quicksort(a, left, i - 1);  /* 分割した左を再帰的にソート */
		quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
	}
}


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



ll maxProfit(vector < int > &weights, vector < int > &values, int W) {
  int n = weights.size();
  int maxVal = 0;
  for (int i = 0; i < n; i++) {
    maxVal += values[i];
  }
  vector < vector < ll > >dp(n + 1, vector < ll >(maxVal + 1, INT_MAX));
  for (int i = 0; i < n + 1; i++) {
    dp[i][0] = 0;
  }
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < maxVal + 1; j++) {
      if (values[i - 1] <= j) {
        dp[i][j] = min(dp[i][j], weights[i - 1] + dp[i - 1][j - values[i - 1]]);
      }

      dp[i][j] = min(dp[i][j], dp[i - 1][j]);
    }
  }

  ll maxPro = 0;

  // cout<<"printing dp table"<<endl;
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < maxVal + 1; j++) {
      if (dp[i][j] <= W) {
        maxPro = max(maxPro, (long long int) j);
      }
      // cout<<dp[i][j]<<" ";
    }
    // cout<<endl;
  }

  return maxPro;

}


int main() {
  //int test;
  //cin>>test;
  //while (test--) {
    int n;
    cin>>n;
    int W;
    cin>>W;
    vector < int > weights(n, 0);
    vector < int > values(n, 0);
    for (int i = 0; i < n; i++) {
      cin>>weights[i];
      cin>>values[i];
    }

    cout<<maxProfit(weights, values, W)<<endl;
  //}
  return 0;
}


Measured memory_bytes: 83080
#include <iostream>

using namespace std;

int main() {
  int n;
  string str;
  cin >> n >> str;
  for (int i = 0; i < str.length(); ++i) {
    int idx = (str[i] - 'A' + n) % 26 + 'A';
    str[i] = (char) idx;
  }
  cout << str << endl;
  return 0;
}


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

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

	vector<int> road(N, 0);
	for(int i=0; i<M; i++)
	{
		int a, b;
		cin >> a >> b;

		road[a-1]++;
		road[b-1]++;
	}

	for(int i=0; i<N; i++)
		cout << road[i] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>		
#include <stdio.h>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main()
{
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if(s == "Cloudy"){
		cout << "Rainy" << endl;
	}
	else if (s == "Rainy") {
		cout << "Sunny" << endl;
	}
}

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

using namespace std;

const long MOD = 1e9 + 7;

int main(){
  int N;
  int s[105];
  int sum = 0;
  vector<int> ten;
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> s[i];
    sum += s[i];
    if(s[i]%10!=0){
      ten.push_back(s[i]);
    }
  }
  sort(ten.begin(),ten.end());
  if(sum%10==0){
    if(ten.size()==0){
      cout << 0 << endl;
    }else{
      sum -= ten[0];
      cout << sum << endl;
    }
  }else{
    cout << sum << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pll =  pair<ll,ll>;

const ll mod = 1000000007;
const ll inf = 1000000000000000;

#define pi acos(-1)
#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define vsort(xx) sort(xx.begin(),xx.end())
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll n,m,i;
    cin>>n;
    ll a[n],sum=0;
    for(i=0;i<n;i++){cin>>a[i];sum+=a[i];}
    cin>>m;
    ll pos,val;
    while(m--){
        cin>>pos>>val;
        cout<<sum+val-a[pos-1]<<"\n";
    }
    
   
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n]; int minn[n];
	
	for(int i=0;i<n;i++)
	{
	cin>>arr[i];    
	}
	minn[0]=arr[0];
	int ans=1;
	for(int i=1;i<n;i++)
	{
	    if(arr[i]>=minn[i-1]){ ans++; minn[i]=arr[i];}
	    else minn[i]=minn[i-1];
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n=5;
  vector<Int> v(n);
  for(Int i=0;i<n;i++) cin>>v[i];

  Int res=0;
  for(Int x:v) res+=(x+10-1)/10*10;
  Int ans=res;
  for(Int x:v) chmin(ans,res-(x+10-1)/10*10+x);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main() {

  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  ans += min(a, k);
  k -= min(k, a);
  k -= min(k, b);
  ans -= min(c, k);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3468
'''
ITP-1_4-C
 ?¨???????
???????????´??° a, b ??¨?????????????????? op ?????????????????§???a op b ????¨??????????????????°?????????????????????????????????
????????????????????? op ??????"+"(???)???"-"(???)???"*"(???)???"/"(???)???????????¨?????????????????§????????????????????´?????????
?°???°?????\??????????????¨????????????????¨????????????¨????????????
???Input
??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????
 a op b
op ??? '?' ?????¨??? ??\?????????????????????????????????????????±???????????????????????£????????????????????????
???Output
?????????????????????????????????????¨??????????????????????????????????????????????
'''
# import
import sys

# ?????°??????????????????
for inputData in sys.stdin:
    inputList = inputData.split()
    a, op, b = int(inputList[0]), inputList[1], int(inputList[2])
    retVal = 0

    # 0?????´??? ????????????
    if op == '?':
        # exec end
        break
    elif op == '+':
        retVal = a + b
    elif op == '-':
        retVal = a - b
    elif op == '*':
        retVal = a * b
    elif op == '/':
        retVal = a // b
    else:
        retVal = 0

    # ????????????
    print(retVal)

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

int main() {
  string s; cin>>s;
  int n=s.size();

  bool ok=true;
  if (n%2==1) {
    rep(i, n/4) {
      if (s[i]!=s[n/2-1-i]) ok=false;
      if (s[n-1-i]!=s[n/2+1+i]) ok=false;
    }
  }
  else {
    rep(i, n/4) {
      if (s[i]!=s[n/2-i]) ok=false;
      if (s[n/2+1+i]!=s[n-1-i]) ok=false;
    }
  }
  rep(i, n/2) {
    if (s[i]!=s[n-1-i]) ok=false;
  }
  if (ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int& x : A) cin >> x, --x;
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (i == A[A[i]]);
  }
  cout << ans / 2 << endl;
}

Measured memory_bytes: 640
n, m, x = map(int, input().split())
c = [list(map(int, input().split())) for i in range(n)]

aho = []  # ans[money, skill, skilll, skillll]
for i in range(2**n):
    buy = list(map(int, bin(i)[2:].zfill(n)))
    baka = [0] * (m+1)
    for j in range(n):
        if buy[j]:
            for k in range(m+1):
                baka[k] += c[j][k]
    judge = 1
    for j in baka[1:]:
        if j < x:
            judge = 0
    if judge:
        aho.append(baka)

if len(aho) == 0:
    print(-1)
else:
    print(sorted(aho)[0][0])

Measured memory_bytes: 11176
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int modi = 1e9+7;

void solve(){
	ll n,k;
	cin >> n >> k;
	ll maxbit = 0;
	ll ck= k;
	while(ck>0){
		
		maxbit++;
		ck>>=1;
	}
	ll a[n];
	map<ll,ll> cnt;
	ll sum = 0;
	for(ll i =0;i<n;i++){
		cin >> a[i];
		ll ca = a[i];
		ll bit =0;
		while(ca>0){
			if(ca&1)
				cnt[bit]++;
			bit++;
			ca>>=1;
		}
		sum+=a[i];
		// maxbit = max(maxbit,bit);
	}
	vvl dp(62,vl(2,-1));

	function<ll(ll,ll)> digit_dp =[&](ll bit, ll smaller){
		// cout << bit << endl;
		if(bit == -1){
			return 0ll;
		}

		if(dp[bit][smaller]!=-1){
			return dp[bit][smaller];
		}
		ll &ans = dp[bit][smaller];
		ans = 0;
		
		if(smaller){
			ans = max(ans,max((1ll<<(bit))*cnt[bit]+digit_dp(bit-1,1),(1ll<<(bit))*(n-cnt[bit]) + digit_dp(bit-1,1)));
		}
		else{
			// ll i = 0;
			if((k>>bit)&1){
				ans = max(ans,(1ll<<(bit))*cnt[bit]+digit_dp(bit-1,1));
				ans= max(ans,(1ll<<(bit))*(n-cnt[bit])+digit_dp(bit-1,0));

			}
			else{
				ans = max(ans,(1ll<<(bit))*cnt[bit]+digit_dp(bit-1,0));
			}
		}
		return ans;
	};
	ll ans = max(sum,digit_dp(60,0));
	dbg(dp);
	cout << ans << endl;

}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 4368
Rectangle = 0
Rhombus = 0
try:
    while True:
        a, b, c = map(int,input().split(","))
        if a == b :
            Rhombus += 1
        elif a**2 + b**2 == c**2 :
            Rectangle += 1
except EOFError:
    pass
    
print(Rectangle)
print(Rhombus)


Measured memory_bytes: 5600
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>
#define INF 0x3f3f3f3f
#define CLR(a) memset(a, 0, sizeof(a))
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	int n;
	while(cin>>n){
		if(n<=111)
			cout<<"111"<<endl;
		else if(n<=222)
			cout<<"222"<<endl;
		else if(n<=333)
			cout<<"333"<<endl;
		else if(n<=444)
			cout<<"444"<<endl;
		else if(n<=555)
			cout<<"555"<<endl;
		else if(n<=666)
			cout<<"666"<<endl;
		else if(n<=777)
			cout<<"777"<<endl;
		else if(n<=888)
			cout<<"888"<<endl;
		else
			cout<<"999"<<endl;
	}
	return 0;
}

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

#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>

const double PI=3.14159265358979323846;

int main() {

    double a, b, x;
    cin >> a >> b >> x;

    double S;
    S = x / a;

    double theta;
    double c;
    if (S > a * b / 2) {
        S = a * b - S;
        c = S * 2 / a;
        theta = atan2(c, a);
    }
    else {
        c = S * 2 / b;
        theta = atan2(b, c);
    }

    cout << setprecision(15) << theta * (180.0 / PI) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF (1<<30)
using ll = long long;
using namespace std;
 
int main(){
	int A, B;
	cin >> A >> B;
	int max = A+B;
	if( A-B > A+B ){
		max = A-B;
	}
	if( A*B > max ){
		max = A*B;
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;
use utf8;
use v5.18;

my ( $a, $b, $c, $d ) = split( / /, <STDIN> );

if ( abs( $a - $c ) <= $d ) {
    print "Yes\n";
}
elsif ( abs( $a - $b ) <= $d && abs( $b - $c ) <= $d ) {
    print "Yes\n";
}
else {
    print "No\n";
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define maxn (1000+10)
#define mod 10000003
#define lnode node*2,start,mid
#define rnode node*2+1,mid+1,end
using namespace std;
int main()
{   ios::sync_with_stdio(false);
	#define int ll
    int n,k,swt=0,sum=0;
	string s;
	cin>>n>>k;
	cin>>s;
	for(int i=0;i<n-1;i++)
	{
	
	  if(s[i+1]==s[i])
	    swt=0;
	  else
	  {  if(swt==0)
	     {  swt=1;
	        sum+=1;
		 }
		 s[i+1]=s[i];
		 
	  }
	  if(swt==0&&sum>=k) break;
    }
	int res=1,ans=0;
	for(int i=0;i<n;i++)
	  if(s[i+1]==s[i])
	    res+=1;
	  else
	  {  ans+=res-1;
	     res=1; 
	  }    	
	//cout<<s<<endl; 
	cout<<ans;
	return 0;
}

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

const int mod = 1000000007;

int frac(int n){
  if (!n) return 1;
  int64_t ret = (int64_t) n * frac(n - 1);
  return ret % mod;
}
int modinv(int i){
  int x = 1, y = 0, z = 0, w = 1;
  int m = mod;
  while (m > 0){
    int q = i / m, r = i % m;
    int temp1 = x, temp2 = y;
    x = z; z = temp1 - q * z;
    y = w; w = temp2 - q * w;
    i = m; m = r;
  }
  while (x < 0) x += mod;
  return x;
}

int comb(int n, int i){
  int a = frac(n), b = frac(i), c = frac(n - i);
  int d = (int64_t) b * c % mod;
  int ret = (int64_t) a * modinv(d) % mod;
  return ret;
}

int main(){
  int x, y; cin >> x >> y;
  if ((x + y) % 3){
    cout << 0 << endl;
    return 0;
  }
  int m = (2 * x - y) / 3;
  int n = (2 * y - x) / 3;
  if (m < 0 || n < 0){
    cout << 0 << endl;
    return 0;
  }
  cout << comb(m + n, m) << endl;
}


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

#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
typedef long double ld;
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
const int N=2e5+5;
int mod=1e9+7;
int par[N];
ll n,m;
pair<int,int>arr[N];
int findpar(int x)
{
if(par[x]==0)
   return x;

 return par[x]=findpar(par[x]);
}
ll ans[N]={};
ll mp[N];
int main()
{
    FIO
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>arr[i].first>>arr[i].second;
    }
    ll co=n*(n-1)/2;
    for(int i=m-1;i>=0;i--)
    {
        ans[i]=co;
        if(findpar(arr[i].first)==findpar(arr[i].second))
            continue;
        else
        {
            int x=arr[i].first, y=arr[i].second;
            co+=mp[findpar(x)]*(mp[findpar(x)]+1)/2;
            co+=mp[findpar(y)]*(mp[findpar(y)]+1)/2;
            mp[findpar(x)]+=mp[findpar(y)]+1;
            par[findpar(y)]=findpar(x);
            co-=mp[findpar(x)]*(mp[findpar(x)]+1)/2;

        }

    }
    for(int i=0;i<m;i++)
    {
        cout<<ans[i]<<endl;

    }



return 0;

}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 209
#define eps 0.000000001
ll n,m,i,j,k,l,t,arr[sz][sz],mm;
vector<ll>v;
int main()
{
    scanf("%lld",&n);
    for(int ii=1;ii<=n;ii++)
    {
    char c[sz];
       cin>>c;
        m=strlen(c);
        l=0;
        j=0;
        k=0;
        for(i=0;i<m;i++)
        {
            if(c[i]=='.')
                j=i+1;
            else
            {
            k=k*10+c[i]-'0';
            }
        }
        l=m-j;
        if(l==m)
            l=9;
        else
            l=9-l;
        while(l>0)
            k*=10,l--;
       // a+=eps;
      //  k=a*1000000000;
       // b=(k*1.0)/1000000000;
       // cout.precision(9);
      //  cout <<fixed << b+eps << endl;
        //if(b+eps==a)
          //  k--;
       // else if(b-eps==a)
         //   k++;
        j=0;
        l=0;
      //  printf("%lld\n",k);
        while(k%2==0 && k>1)
            j++,k/=2;
        while(k%5==0 && k>4)
            l++,k/=5;
       // printf("%lld %lld\n",j,l);
        arr[j][l]++;
    }
    m=0;
    mm=0;
    for(i=0;i<=44;i++)
    {
        for(j=0;j<=20;j++)
        {
            for(k=0;k<=44;k++)
            {
                for(l=0;l<=20;l++)
                {
                    if(i==k && j==l)
                    {
                        if(i>=9 && j>=9)
                        {
                            //if(i==9 && j==9)
                          //  printf("gbfb\n");
                            t=(arr[i][j]*(arr[i][j]-1))/2;
                            m+=t;
                        }
                    }
                    else
                    {
                        if(i+k>=18 && j+l>=18)
                        {
                            mm+=(arr[i][j]*arr[k][l]);
                        }
                    }
                }
            }
        }
    }
    printf("%lld\n",m+mm/2);
    return 0;
}


Measured memory_bytes: 3836
#include <stdio.h>

int main (int argc, char *argv[]) {
int a;
int b;
int c;
int k;

    do{
        scanf("%d",&a);
        scanf("%d",&b);
        scanf("%d",&c);
        scanf("%d",&k);
    }while(a<1 || a>50 || b<1 || b>50 || c<1 || c>50 || k<1 || k>10);

    int max = 0;
    for(int i = 0;i < k;i++){
        if(max < a){
            max = a;
        }
        if(max < b){
            max = b;
        }
        if(max < c){
            max = c;
        }
        if(max == a){
            a = a*2;
        }else if(max == b){
            b = b*2;
        }else{
            c = c*2;
        }
    }
    printf("%d \n",a+b+c);
}

Measured memory_bytes: 128
import math
import heapq
import sys
from collections import Counter
import numpy as np

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#s = [input() for i in range(3)]

N=int(input())
points = []
for i in range(N):
    p = str(input()).split(" ")
    points.append((int(p[0]), int(p[1])))

#print(points)

total_dis=0
for i in range(N):
    for j in range(i+1,N):
        total_dis+=math.sqrt((points[i][0]-points[j][0])**2+(points[i][1]-points[j][1])**2)
        #print(total_dis)
        
print(2*total_dis/N)

Measured memory_bytes: 12488
open System
open System.Linq;


let N=stdin.ReadLine()|>int
let S=stdin.ReadLine()

[<EntryPoint>]
let sf argv =
    let mutable ans=1
    for i in [1..N-1] do
        ans <- if S.[i]<>S.[i-1] then ans+1 else ans
    printfn "%d" ans
    0 

Measured memory_bytes: 16476
#include <iostream>

int main(){
  int S, s, m, h;
  std::cin >> S;
  h = S / 3600;
  m = ( S % 3600) / 60;
  s = ( S % 3600) % 60;

  std::cout << h << ":" <<  m << ":" << s << std::endl;
}



Measured memory_bytes: 3080
#include <stdio.h>
int main()
{
  int n, i, j, b, ans=1;
  scanf("%d", &n);
  int m[n];
  for(i=0;i<n;i++){
    scanf("%d", &m[i]);
  }
  for(i=0; i<n; i++){
    for(j=n-1; j>i; j--){
      if(m[i] > m[j]){
        b = m[i];
        m[i] = m[j];
        m[j] = b;
      }
    }
  }
  for(i=0;i<n-1;i++){
    if(m[i]!=m[i+1]){
      ans+=1;
    }
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 128
x = int(input())
i = 1

while True:
    if i <= x:
        if i % 3 == 0:
            print(' {}'.format(i), end='')
        elif str(i).find('3') != -1:
            print(' {}'.format(i), end='')
    else:
        break
    i += 1
print()


Measured memory_bytes: 5872
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll X[1010], Y[1010];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> X[i] >> Y[i];
	bool odd = false, even = false;
	rep(i, 0, N) {
		if((X[i] + Y[i]) % 2) odd = true;
		else even = true;
	}
	if(odd && even) {
		cout << -1 << "\n";
		return;
	}
	if(even) {
		rep(i, 0, N) {
			X[i]--;
		}
	}
	int M = 39;
	cout << (even ? M + 1 : M) << "\n";
	for(int i = 0; i < M; i++) {
		cout << (1ll << (M - i - 1)) << " ";
	}
	if(even) cout << 1 << "\n";
	else cout << "\n";
	rep(i, 0, N) {
		string str;
		rer(j, M, 0) {
			ll d = (1ll << j);
			// debug(X[i], Y[i], d);
			if(X[i] + Y[i] >= 0 && Y[i] - X[i] >= 0) {
				str +=  'U';
				Y[i] -= d;
			}
			else if(X[i] + Y[i] >= 0 && Y[i] - X[i] <= 0) {
				str += 'R';
				X[i] -= d;
			}
			else if(X[i] + Y[i] <= 0 && Y[i] - X[i] >= 0) {
				str += 'L';
				X[i] += d;
			}
			else {
				str += 'D';
				Y[i] += d;
			}
		}
		if(even) str += 'R';
		cout << str << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

int main()
{
	char s;
	cin >> s;
	if(s<='z'&&s>='a')
	{
		cout << 'a';
	}
	if(s<='Z'&&s>='A')
	{
		cout << 'A';
	}
	return 0;
}

Measured memory_bytes: 3628
from fractions import gcd

def prime_factorize(n):
  factor = []
  for i in range(2, int(n**0.5)+1):
    while n % i == 0:
      n //= i
      factor.append(i)
  if n != 1:
    factor.append(n)
  return factor

A, B = map(int, input().split())
N = gcd(A, B)
l = set(prime_factorize(N))
print(len(l)+1)

Measured memory_bytes: 5600
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    while(1){
        string x;
        cin>>x;
        if(x=="0"){
            break;
        }
        int sum=0;
        for(int i=0;i<x.size();i++){
            sum+=x.at(i)-'0';
        }
        cout<<sum<<endl;    
    }
}



Measured memory_bytes: 3160
#include <stdio.h>

int main() {

    int n, h;
    int cnt = 1;

    scanf("%d", &n);
    scanf("%d", &h);
    int hmax = h;

    for (int i = 1; i < n; i++) {
        scanf("%d", &h);
        if (hmax <= h) {
            cnt += 1;
            hmax = h;
        }

    }

    printf("%d", cnt);


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ld n; cin >> n;
    cout << n * 2 * pi << "\n";
}

Measured memory_bytes: 3804
#include<iostream>
#define int long long
using namespace std;
signed main(){
  int q,h,s,d,n;
  int qr,hr,sr,dr,sum;
  cin >> q >> h >> s >> d >> n;
  qr=q*8;
  hr=4*h;
  sr=s*2;
  dr=d;
  if(qr<hr&&qr<sr&&qr<dr){
    cout << (q*4)*n<<endl;
  }
  else if(hr<qr&&hr<sr&&hr<dr){
    cout << (h*2)*n<<endl;
  }else if(sr<qr&&sr<hr&&sr<dr){
    cout << n*s<<endl;
  }
  else {
    sum=(n/2)*d;
    if(n%2!=0){
      if(qr<hr&&qr<sr) sum+=4*q;
      else if(hr<qr&&hr<sr) sum+=2*h;
      else sum+=s;
    }
    cout << sum <<endl;

  }
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
g=array(N)
(N-1).times do
    a,b,c=get_i
    a-=1
    b-=1
    g[a]=[] if g[a].nil?
    g[a].push([b,c])
    g[b]=[] if g[b].nil?
    g[b].push([a,c])
end
$cost=array(N,-1)
def bfs(g,s)
    queue=[]
    $cost[s]=0
    queue.push([s,0])
    until queue==[]
        curr=queue.shift
        next if g[curr[0]].nil?
        g[curr[0]].each do|v,c|
            next if $cost[v]!=-1
            $cost[v]=$cost[curr[0]]+c
            queue.push([v,$cost[v]])
        end
    end
end
Q,K=get_i
bfs(g,K-1)
Q.times do
    x,y=get_i
    x-=1
    y-=1
    puts $cost[x]+$cost[y]
end

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

vector<vector<pair<int, int>>> zeta;

pair<int, int> calc (int i, int t) {
    if (zeta[i][t].first != 0) return zeta[i][t];
    pair<int, int> p, q, r;
    if (i & (1 << (t-1))) {
        q = calc(i, t-1);
        r = calc(i - (1<<(t-1)), t-1);
        if (q.first > r.first) {
            p = {q.first, max(r.first, q.second)};
        }else {
            p = {r.first, max(q.first, r.second)};
        }
    }else {
        p = calc(i, t-1);
    }
    return zeta[i][t] = p;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(1<<N);
    for (int i = 0; i < (1<<N); i++) scanf("%d", &A[i]);
    zeta = vector<vector<pair<int, int>>>(1<<N, vector<pair<int, int>>(N+1));
    for (int i = 0; i < (1<<N); i++) zeta[i][0] = {A[i], 0};
    for (int i = 0; i < (1<<N); i++) calc(i, N);
    int ans = 0;
    for (int i = 1; i < (1<<N); i++) {
        ans = max(ans, zeta[i][N].first+zeta[i][N].second);
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 51200
#include<bits/stdc++.h>
using namespace std;
 
 
int main() {
    string str;
    cin >> str;

    int len = str.size();
    for( int n = 0 ; n < len ; ++n ){
        if( n %2 == 0 ){
            cout<<str[n];
        }

    }
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int n;

    while(1){
        int mp = 0,md = 0;
        cin >> n;
        if(n == 0) break;
        int p,d1,d2;
        for(int i = 0; i < n; i++){
            cin >> p >> d1 >> d2;
            if(md < d1 + d2){
                md = d1 + d2;
                mp = p;
            }
        }
        cout << mp << " " << md << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<map>
using namespace std;
 
int n;
string str;

int main()
{
    ios::sync_with_stdio(false);
    while(cin>>n){
    	bool boo=true;
    	map<string,int> imap;
    	string s;
    	for(int i=0;i<n;++i)
		{
    		cin>>str;
    		if(boo){
	    		if(imap[str]){
	    			boo=false;
				}
				imap[str]=1;
				if(i){
					if(str[0]!=s.back()){
						boo=false;
					}
				}
				s=str;
			}
		}
		if(boo)	cout<<"Yes"<<endl;
		else	cout<<"No"<<endl;
	}
    
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  string s, t;
  cin >> s >> t;
  int count = 0;
  rep(i, s.size()) {
    if (s.at(i) != t.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3892
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    ll ans = 0;
    for (ll i = 1; i < S.size(); i++) {
        if (S[i] != S[i - 1]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

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

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

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

    vector<long long> c(n);
    for (int i = 0; i < n; i++) {
        c[i] = a[i] - b[i];
    }

    sort(c.begin(), c.end());
    sort(lower_bound(c.begin(), c.end(), 0), c.end(), greater<long long>());
    for (int i = 1; i < n; i++) {
        c[i] += c[i - 1];
    }

    vector<long long>::iterator r = lower_bound(c.begin(), c.end(), 0);
    cout << (r == c.begin() ? 0 : (r != c.end() ? r - c.begin() + 1 : -1)) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <map>

using namespace std;


vector<int> solve(vector<vector<int>> points){
    int x, y, h, tmp;
    int pivot = 0;
    for (int i=0; i < points.size(); i++){
        if (points[i][2] != 0){
            pivot = i;
            break;
        }
    }
    for (int i=0; i <= 100; i++){
        for (int j=0; j <= 100; j++){
            h = points[pivot][2] + abs(points[pivot][0] - i) + abs(points[pivot][1] - j);
            for (int k = 0; k < points.size(); k++) {
                tmp = max(h - abs(i - points[k][0]) - abs(j - points[k][1]), 0);
                if (tmp != points[k][2]) {
                    h = -1;
                    break;
                }
            }
            if (h > 0){
                x = i;
                y = j;
                break;
            }
        }
        if (h > 0) break;
    }

    return vector<int>({x, y, h});
}

int main() {
    int N;
    int x, y, h;
    cin >> N;
    vector<vector<int>> points;
    for (int i=0; i < N; i++){
        cin >> x >> y >> h;
        points.push_back(vector<int>{x, y, h});
    }

    vector<int> ans = solve(points);

    cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){

    int n;
    I(n);
    set<string > s;
    string s1;
    string a[n+2];
    cin>> a[1];
    s.insert(a[1]);
    bool fl = 0;
    for(int i = 2;i <= n;i ++){
        cin>>a[i];
        int l = a[i-1].size();
        if(a[i][0] != a[i-1][l-1]){
            fl = 1;
        }
        s.insert(a[i]);
    }
    if( s.size() != n)fl = 1;
    if(!fl)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

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

    long long ans[2] = {};
    int left = A.front(), right = A.front(), left_p = 1, right_p = N - 1;
    while (true) {
        ans[0] += abs(A[right_p] - right);
        right = A[right_p];
        right_p--;
        if (right_p < left_p) break;

        ans[0] += abs(A[right_p] - left);
        left = A[right_p];
        right_p--;
        if (right_p < left_p) break;

        ans[0] += abs(A[left_p] - right);
        right = A[left_p];
        left_p++;
        if (right_p < left_p) break;

        ans[0] += abs(A[left_p] - left);
        left = A[left_p];
        left_p++;
        if (right_p < left_p) break;
    }

    left = A.back();
    right = A.back();
    left_p = 0;
    right_p = N - 2;
    while (true) {
        ans[1] += abs(A[left_p] - left);
        left = A[left_p];
        left_p++;
        if (right_p < left_p) break;

        ans[1] += abs(A[left_p] - right);
        right = A[left_p];
        left_p++;
        if (right_p < left_p) break;

        ans[1] += abs(A[right_p] - left);
        left = A[right_p];
        right_p--;
        if (right_p < left_p) break;

        ans[1] += abs(A[right_p] - right);
        right = A[right_p];
        right_p--;
        if (right_p < left_p) break;
    }

    cout << max(ans[0], ans[1]) << endl;
}

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

int main(){
  int A,B,C,X;cin>>A>>B>>C>>X;
  int ans=0;
  REP(i,A+1){
    REP(j,B+1){
      REP(k,C+1){
        int t = 500*i+100*j+50*k;
        if(t>=X){ if(t==X){++ans;}break;}
      }
    }
  }
  cout << ans <<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    int k = -1;
    int mini = LONG_LONG_MAX;
    for(int i = 0 ; i <n ; i++){
        if(abs(a[i]) < mini){
            mini = abs(a[i]);
            k = i;
        }
    }
    if(k == -1){
        int sum = 0;
        for(int i = 0 ; i<n ; i++){
            sum += a[i];
        }
        cout<<sum<<endl;
    }else {
        for(int i = 0 ; i < k ; i++){
            if(a[i] < 0){
                a[i] *= -1;
                a[i+1] *= -1;
            }
        }
        for(int i = n - 2 ; i >= k ; i--){
            if(a[i+1] < 0){
                a[i+1] *= -1;
                a[i] *= -1;
            }
        }
        int sum = 0;
        for(int i = 0 ; i < n ; i++){
            sum += a[i];
        }
        cout<<sum<<endl;
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

using namespace std;
typedef pair<int, int> P;
// input


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
    ll int A, B, C, D;
    cin >> A >> B >> C >> D;
    A--;

    ll int L, l, lcm, dust = 999;
    if (C < D) L = D, l = C;
    else  L = C, l = D;

    while(dust != 0) {
        dust = L % l;
        L = l, l = dust;
    }
    lcm = C * D / L;
    cout << B - A - ((B/C + B/D - B/lcm) - (A/C + A/D - A/lcm)) << endl;
}

Measured memory_bytes: 256
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

signed main() {

	int n;
	cin >> n;
	vector<pair<int,int>> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i].second >> d[i].first;
	}

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

	int time = 0;
	for (int i = 0; i < n; i++) {
		time += d[i].second;
		if (time > d[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;


	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{    
    int a,b,k;
    cin >> a >> b >> k;

    int c = a;
    for(int i=a;i<=min(a+k-1,b);++i)
    {
        cout << i << endl;
        c = i;
    }

    for(int i=max(c+1,b-k+1);i<=b;++i)
    {
        cout << i << endl;
    }

    return 0;
}

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

using namespace std;

int N;
string S;

int dp[5001][5001];

int main() {
    cin >> N >> S;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (S[i] != S[j]) {
                dp[i][j] = 0;
                continue;
            }
            if (i == 0) {
                dp[i][j] = 1;
            } else {
                dp[i][j] = min(dp[i-1][j-1] + 1, j - i);
            }
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 96768
#include "iostream"
using namespace std;

int main()
{


	int c;
	c = 0;
	int a[10000]; 

	while(true){

		int x;
		cin >> x;
		a[c] = x;
		if (x == 0)break;
//		cout << "Case　" << i <<":　" << x << endl;

		c++;
    }
	for (int i = 0; i <= c;i++){
		
		if (a[i]==0)break;

		cout << "Case " << i+1 << ": " << a[i] << endl;

	}

	return 0;
}


Measured memory_bytes: 3012