akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
string s, t;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s >> t;
  ll ans = 3;
  if(s[0] != t[0]) ans *= 2;
  FOR(i, 0, n-1){
    if(s[i] == s[i+1]) continue;
    if(s[i] == t[i]){
      ans *= 2;
    }else if(s[i+1] != t[i+1]){
      ans *= 3;
    }
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeSet;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			TreeSet<Integer> set = new TreeSet<>();
			IntStream.range(0, n).forEach(i -> set.add(scanner.nextInt()));
			System.out.println(set.last() - set.first());
		}
	}
}


Measured memory_bytes: 36248
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, k; cin >> n >> k;
    vector<ll> x(n), y(n);
    REP(i, n) cin >> x[i] >> y[i];

    vector<ll> unqx = x, unqy = y;
    UNIQUE(unqx);
    UNIQUE(unqy);
    ll unx = unqx.size(), uny = unqy.size();

    ll ans = LINF;
    REP(i0, uny-1) REP(j0, unx-1) RANGE(i1, i0+1, uny-1) RANGE(j1, j0+1, unx-1) {
        ll num = 0;
        ll y0 = unqy[i0];
        ll y1 = unqy[i1];
        ll x0 = unqx[j0];
        ll x1 = unqx[j1];
        REP(i, n) {
            if (x0 <= x[i] && x[i] <= x1 && y0 <= y[i] && y[i] <= y1) {
                num++;
            }
        }
        if (num >= k) {
            chmin(ans, (y1 - y0) * (x1 - x0));
        }
    }

    cout << ans << endl;

    
}

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

int main(){
    int n,b,f,r,v;
    cin >> n;
    int A[4][3][10]={};
    for (int i=0; i<n; i+=1){
        cin >> b >> f >> r >> v;
        A[b-1][f-1][r-1] += v;
    }
    
    for (int j=0; j<4; j+=1){
        for (int k=0; k<3; k+=1){
            for (int l=0; l<10; l+=1){
                cout << " " << A[j][k][l];
                if (l==9) cout << "\n";
            }
        }
        if (j!=3) cout << "####################" << "\n";
    }
    
    return 0;

}


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

int main() {
    int n;
    cin >> n;
    int ans = 30;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        int cnt = 0;
        while (a % 2 == 0) {
            a /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def calc(c, q, h, w)
  n = 0
  while q.size > 0
    e = q.shift
    n += 1 if e[0] > n
    (-1..1).each do |di|
      (-1..1).each do |dj|
        i = e[1][0] + di
        j = e[1][1] + dj
        if i >= 0 && i < h && j >= 0 && j < w
          if (c[i][j] -= 1) == 0
            q.push([e[0] + 1, [i, j]])
          end
        end
      end
    end
  end
  n
end
1.times do
  c, q = [], []
  h, w = gets.split.map(&:to_i)
  h.times do |i|
    c[i] = gets.chomp.split(//).map(&:to_i)
    c[i].each.with_index do |e, j|
      q.push([0, [i, j]]) if c[i][j] == 0
    end
  end
  puts calc(c, q, h, w)
end

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

int main()
{
    int n,s[105],num=0;
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
    	scanf("%d",&s[i]);
    	if (s[i]%2==1&&i%2==1) num++;
	}
	printf("%d",num);
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<ll,ll> P;
typedef struct pair<int,P> P2;

P dp[100001]={};
ll r[100001]={};

ll d[1001]={};
int a[200001]={};
int main() {
	int n;
	ll l;
	cin>>n>>l;
	string str;
	ll lastn=1;
	for(int i=0;i<n;++i){
		cin>>str;
		ll pos=1;
		r[1]=0;
		for(int j=1;j<str.size()+1;++j){
			if(str[j-1]=='0'){
				if(dp[pos].first==0){
					lastn++;
					dp[pos].first=lastn;
					r[lastn]=j;
					pos=lastn;
				}else{
					pos=dp[pos].first;
				}
			}
			if(str[j-1]=='1'){
				if(dp[pos].second==0){
					lastn++;
					dp[pos].second=lastn;
					r[lastn]=j;
					pos=lastn;
				}else{
					pos=dp[pos].second;
				}
			}
		}
		dp[pos].first=pos;
	}
	ll res=0;
	for(int i=1;i<lastn+1;++i){

		if((dp[i].first!=i)&&((dp[i].first==0)||(dp[i].second==0))){
			ll d=l-r[i];
			ll g=1;
			while(d%2==0){
				g=g<<1;
				d=d/2;
			}
			res=res^g;
		}
	}
	if(res==0){
		cout<<"Bob"<<endl;
	}else{
		cout<<"Alice"<<endl;
	}
	return 0;
}


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

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

  //  string s;
    int k;
    cin>>k;
  //  l=s.length();
    for(int i=0;i<k;i++)
    {
        cout<<"ACL";
    }
    return 0;
}

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

int cmp(const void *a, const void *b)
{
  return *(uint64_t *)b - *(uint64_t *)a;
}

int main()
{
  int n, k;
  uint64_t h[200000], r = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  if (n <= k)
  {
    cout << 0 << endl;
    return 0;
  }
  qsort(h, n, sizeof(uint64_t), cmp);
  for (int i = k; i < n; i++)
  {
    r += h[i];
  }
  cout << r << endl;
}


Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
template<class Type> void join(const Type& a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

signed main(){
    string s; cin >> s;
    string t; cin >> t;
    vector<vector<int>> pos(26);
    for(int i = 0; i <  s.size(); ++i)
        pos[s[i] - 'a'].push_back(i);
	
    for(auto c : t)
        if(pos[c-'a'].empty())  return puts("-1") * 0;
	
    //vector<int>nextIndex(26,0LL);
	
    int ans = 0;
    int nowIndex = -1;
    int ssize = s.size();
    for(auto c : t){
        char key = c - 'a';
        auto itr = (upper_bound(pos[key].begin(),pos[key].end(),nowIndex));
        if(itr != pos[key].end()){
            ans +=  *itr - nowIndex;
        } else {
            itr = pos[key].begin();
            ans += ssize - nowIndex + *itr;
        }
        nowIndex = *itr;
		//cout<<nowIndex<<endl;//!!!!!!
        //nextIndex[key] = (next(itr) == pos[key].end() ? 0 :( nextIndex[key] + 1));
		//join(nextIndex);//!!!
    }
    cout << ans << endl;
}




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

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

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

int main(){
 
  string s; cin >> s;
  int white = 0, black = 0;

  int ans1 = 0;
  int ans2 = 0;
  rep(i, s.length()){
    if(i % 2 == 0 and s[i] != '0') ans1 ++;
    if(i % 2 == 1 and s[i] != '1') ans1 ++;
    if(i % 2 == 0 and s[i] != '1') ans2 ++;
    if(i % 2 == 1 and s[i] != '0') ans2 ++;
  }

  pr(min(ans1, ans2));

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define F(i,j,k) for(int i=j;i<=k;i++)
#define DF(i,j,k) for(int i=j;i>=k;i--)
#define M(x,y) make_pair(x,y)
const ll MOD=1e9+7;
using namespace std;
template<typename T>inline void read(T &n){
    T w=1;n=0;char ch=getchar();
    while(!isdigit(ch)&&ch!=EOF){if(ch=='-')w=-1;ch=getchar();}
    while(isdigit(ch)&&ch!=EOF){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}
    n*=w;
}
template<typename T>inline void write(T x){
     if(x<0){x=-x;putchar('-');}
     if(x>9)write(x/10);
     putchar(x%10+48);
}
template<typename T>inline void writeln(T x){
     write(x);
     puts("");
}
map <ll,ll> ans;
inline ll dfs(ll x){
	if(ans[x]!=0)return ans[x];
	return ans[x]=(dfs(x/2)+dfs((x-1)/2)+dfs((x-2)/2))%MOD;
}
int main(){
 	ll n;read(n);
 	ans[0]=1;
 	ans[1]=2;
 	dfs(n);
	writeln(ans[n]); 
	return 0;
}

Measured memory_bytes: 256
// Gear4        
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;
using ld = long double;
using ll = long long;
#define endl '\n'
const int inf = 1e9, mod = 1e9 + 7;
const ll INF = 9e18;
const ld EPS = 1e-9, PI = acosl(-1.0);
string s; int k;
int main() {
    SYNC
    cin >> s >> k;
    set<string> st;
    FOR(len, 1, min(7, (int)s.length() + 1)) {
        FOR0(i, (int)s.length()-len+1) {
            st.insert(s.substr(i, len));
            
        }
    }

    k--;
    while(k--) {
        st.erase(st.begin());
    }
    cout << *(st.begin());
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

struct edge{
    int to,dis;
};

int main() {

    int N,M,L;
    Scd3(N,M,L);

    vector<vector<edge>> e(N);
    vector<vll> t(N,vll(N,{INF,INF}));
    // t[kyuyu][used]
    Rep(i,N) t[i][i] = {0,0};

    int a,b,c;
    Rep(i,M){
        Scd3(a,b,c);
        a--,b--;
        if( c > L ) continue;
        e[a].push_back({b,c});
        e[b].push_back({a,c});
    }

    priority_queue<pair<pll,int>, vector<pair<pll,int>>, greater<pair<pll,int>> > q;
    Rep(i,N){
        q.push({{0,0},i});
        while( q.size() ){
            int from = q.top().second;
            pll dist = q.top().first;
            q.pop();
            if( t[i][from] < dist ) continue;
            for( edge tt : e[from] ){
                int to = tt.to;
                int di = tt.dis;
                pll old = t[i][to];
                pll ne;
                if( dist.second+di > L ){
                    ne = {dist.first+1,di};
                }else{
                    ne = {dist.first,dist.second+di};
                }
                if( ne < old ){
                    t[i][to] = ne;
                    q.push( {ne,to} );
                }
            }
        }
    }

    // Rep(i,N) Rep(j,N){
    //     printf ("%lld,%lld%c", t[i][j].first, t[i][j].second, j == N-1 ? '\n' : ' ' );
    // }

    int Q;
    Scd(Q);

    Rep(i,Q){
        Scd2(a,b);
        a--,b--;
        printf ("%lld\n", t[a][b].first == INF ? -1 : t[a][b].first );
    }

    // Rep(k,N) Rep(i,N) Rep(j,N){
    //     d[i][j] = min( d[i][j] , d[i][k] + d[k][j] );
    // }

    return 0;
}




Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    if(b%a==0){out(a+b);}
    else out(b-a);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    string S;
    cin >> S;
    int N = S.length();
    int a[N];
    REP(i, N) a[i] = (int)(S[i] - '0');

    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    else {
        FOR(i, 1, N) {
            int prev = 1;
            while(i - prev >= 0) {
                if (a[i - prev] == -1) {
                    prev++;
                }
                else if (a[i] != a[i - prev]) {
                    a[i] = -1;
                    a[i - prev] = -1;
                    break;
                }
                else {
                    break;
                }
            }
        }
        int count = 0;
        REP(i, N) {
            if (a[i] == -1) count++;
        }
        cout << count << endl;
    }

    return 0;
}


Measured memory_bytes: 896
import itertools


def main():
    N = int(input())
    caps = {x: 0 for x in "MARCH"}
    for _ in range(N):
        S = input()
        if S[0] in caps:
            caps[S[0]] += 1
    ans = 0
    for comb in itertools.combinations("MARCH", 3):
        tmp = 1
        for c in comb:
            tmp *= caps[c]
        ans += tmp
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47832
#include<iostream>
#include<stack>
#include<cstdlib>
using namespace std;

int main(){
    stack<int> S;
    int a,b,x;
    string s;

    while(cin>>s){
        if (s[0] == '+'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        }else if(s[0] == '-'){
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a-b);
        }else if(s[0] == '*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);
        }else{
            S.push(atoi(s.c_str()));
        }
    }
    cout << S.top() << endl;
    return 0;
}



Measured memory_bytes: 3192
N=int(input())
s=list(input() for i in range(N))
M=int(input())
t=list(input() for i in range(M))
ans=0
for i in s:
    key=0
    for j in s:
        if i==j:
            key+=1
    for j in t:
        if i==j:
            key-=1
    ans=max(ans,key)
print(ans)

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

int main() {
  int n;
  cin >> n ;
  long long total = 0;
  for (int i = 0; i < n; i++) {
    if((i+1)%3!=0&&(i+1)%5!=0)
    {total += i+1;}
      
  }
  cout << total <<endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=200010;
char a[maxn];
char b[maxn];
bool sign[maxn]={false};
char zm[30];
int main()
{
	scanf("%s",a);
	scanf("%s",b);
	for(int i=0;i<26;i++)
		zm[i]='a'+i;
	int len=strlen(a);
	int i;
	for(i=0;i<len;i++)
	{
		if(zm[a[i]-'a']==b[i])
			sign[b[i]-'a']=true;
		else{
			if(sign[b[i]-'a']==true || sign[zm[a[i]-'a']-'a']==true)
				break;
			int w;
			int j;
			for(j=0;j<26;j++)
			{
				if(zm[j] == b[i])
				{
					w = j; break;
				}
			}
			zm[w] = zm[a[i]-'a'];
			zm[a[i]-'a'] = b[i];
			sign[b[i]-'a'] = true;	
		}
	}
	if(i<len)
		puts("No");
	else
		puts("Yes");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#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, C;
    cin >> A >> B;
    
    cout << (A-1)*(B-1) << endl;



   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll k,x;
    cin>>k>>x;
    for(ll i=x-k+1;i<x+k;i++) cout<<i<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(int loop_dump=0; loop_dump<(int)ar.size(); loop_dump++) cout << "[" << loop_dump << "]:" << ar[loop_dump] << endl
#define DUMPL(ar) for(int loop_dump=0; loop_dump<(int)ar.size(); loop_dump++) { cout << ar[loop_dump]; if(loop_dump<(int)ar.size()-1) cout << ' '; } cout << endl;
#define COUT(x) cout << x << endl
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl
using namespace std;

/*
456 123 ... 3 87
123 87  ... 1 36
87 36   ... 2 15
36 15   ... 2 6
15 6    ... 2 3
6  3    ... 2 0
*/

int gcd(int x, int y){
    if(y > x){
        int tmp = x;
        x = y;
        y = tmp;
    }
    int r;
    r = x % y;
    while(r != 0){
        x = y;
        y = r;
        r = x % y;
    }

    return y;
}

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

    int a, b;
    cin >> a >> b;
    lint g;

    g = gcd(a, b);
    // COUT(g);
    // COUT((lint)a*b);
    COUT(((lint)a*b)/g);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <stack>
#include <iomanip>
#include <cmath>


using namespace std;


typedef long long ll;
typedef long double ld;


const ll MOD = 1000000007ll;


ll modSum(ll a, ll b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}


ll modProd(ll a, ll b) {
  return ((a % MOD) * (b % MOD)) % MOD;
}


ll getPowMod(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPowMod(x, e/2);
    return modProd(tmp, tmp);
  } else {
    ll tmp = getPowMod(x, e-1);
    return modProd(tmp, x);
  }
}


ll getPow(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPow(x, e/2);
    return tmp * tmp;
  } else {
    ll tmp = getPow(x, e-1);
    return tmp * x;
  }
}


bool isEven(ll x) {
  ll tmp = ((x % 2) + 2) % 2;
  return tmp == 0;
}


ll getSumOfDigitsInBase(ll n, ll b) {
  ll ret = 0;
  while (n > 0) {
    ret += n % b;
    n /= b;
  }
  return ret;
}












const int MAXN = 100002;
const int MAXLOG = 20;


ll N, L, Q;
vector<ll> X;
ll memo[MAXN][MAXLOG];



void input() {
  cin >> N;
  ll tmp;
  for (int i = 0 ; i < N ; i++) {
    cin >> tmp;
    X.push_back(tmp);
  }
  cin >> L >> Q;
}

void preprocess() {
  for (int l = 0 ; l < MAXLOG ; l++) {
    memo[N][l] = N;
  }
  for (int i = N-1 ; i >= 0 ; i--) {
    auto it = lower_bound(X.begin(), X.end(), X[i]+L+1);
    if (it != X.end()) {
      it--;
    }
    memo[i][0] = (int)(it-X.begin());
    for (int l = 1 ; l < MAXLOG ; l++) {
      memo[i][l] = memo[memo[i][l-1]][l-1];
    }
  }
  /*
  for (int i = 0 ; i <= N ; i++) {
    for (int l = 0 ; l < MAXLOG ; l++) {
      cout << "memo[" << i << "][" << l << "] = " << memo[i][l] << "\n";
    }
  }
  */
}


ll getAns(ll from, ll to) {
  ll ans = 0;
  ll at = from;
  for (int i = MAXLOG-1 ; i >= 0 ; i--) {
    if (memo[at][i] <= to) {
      ans += getPow(2, i);
      at = memo[at][i];
    }
  }
  if (at != to) {
    ans++;
  }
  return ans;
}


void solve() {
  int a, b;
  for (int i = 1 ; i <= Q ; i++) {
    cin >> a >> b;
    cout << getAns(min(a, b)-1, max(a, b)-1) << "\n";
  }
}


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

  int T;
//  cin >> T;
  T = 1;

  for (int i = 0 ; i < T ; i++) {
    input();
    preprocess();
    solve();
  }

  return 0;
}


Measured memory_bytes: 17396
#include <iostream>
#include <vector>
#include <algorithm>
#define N 500000
using namespace std;

int main(){

  int n;
  int a,b,i;
  int sosu[N];
  bool judge;

  sosu[0] = 2;
  for(a=3,i=1;a<1000000;a++){
    judge = true;
    for(b=0;sosu[b]*sosu[b] <= a;b++){
      if(a%sosu[b] == 0){
	judge = false;
	break;
      }
    }
    if(judge){
      sosu[i] = a;
      i++;
    }
  }
  sosu[i] = 1000000;
  while(cin >> n){
    if(0<n && n<1000000){
      for(i=0;sosu[i]<=n;i++);
      cout << i << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1472
a,b,c,d,e,f=map(int,input().split())
wl=set()
i=0
while i*100*a<=f:
    j=0
    while i*100*a+j*100*a<=f:
        wl.add(i*100*a+j*100*a)
        j+=1
    i+=1
sl=set()
i=0
while i*c<=f:
    j=0
    while i*c+j*d<=f:
        sl.add(i*c+j*d)
        j+=1
    i+=1
max=0
x=0
y=0
for w in wl:
    if w==0:
        continue
    for s in sl:
        if w//100*e>=s and w+s<=f:
            if x==0 and y==0:
                x=w
                y=s
            if max<s/(w+s):
                max=s/(w+s)
                x=w+s
                y=s
print(x,y)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdint>
#include <memory>
#include <algorithm>

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using usize = std::size_t;
template<typename T>
using Vector = std::vector<T>;
using String = std::string;
template<typename T>
using UniquePointer = std::unique_ptr<T>;
using std::to_string;
using std::cin;
using std::cout;
using std::getline;
using std::stoi;
using std::endl;

#define rep(i, max) for(usize i = 0; i < max; ++i)
#define loop while(true)


UniquePointer<String> readLine() {
    UniquePointer<String> line(new String());
    getline(cin, *line);
    return line;
}

template<typename T>
UniquePointer<Vector<T>> readVector(usize num) {
    UniquePointer<Vector<T>> list(new Vector<T>(num));
    rep(i, num) {
        cin >> list[i];
    }
    return list;
}

template<typename T>
void writeLine(T arg) {
    cout << arg << endl;
}

void program();

int main()
{
    std::ios::sync_with_stdio(false);
    program();
}

void program() {
    auto s = *readLine();
    auto t = *readLine();
    i32 minCount = std::numeric_limits<i32>::max();
    for (usize i = 0; i + t.size() - 1 < s.size(); ++i) {
        int count = 0;
        rep(j, t.size()) {
            if (s[i + j] != t[j]) ++count;
        }
        minCount = std::min(count, minCount);
    }
    writeLine(minCount);
}

Measured memory_bytes: 3612
#include <stdio.h>

int PARENT(int);
int LEFT(int);
int RIGHT(int);

int main() {
    int i, n;
    scanf("%d", &n);
    int A[5000];
    for(i = 0; i < 5000; i++) A[i] = 0;
    for(i = 1; i <= n; i++) scanf("%d", &A[i]);
    for(i = 1; i <= n; i++) {
        printf("node %d: ", i);
        printf("key = %d, ", A[i]);
        if(i / 2 != NULL) printf("parent key = %d, ", A[PARENT(i)]);
        if(A[2 * i] != 0) printf("left key = %d, ", A[LEFT(i)]);
        if(A[2 * i + 1] != 0 || A[2 * i + 1] != NULL) printf("right key = %d, ", A[RIGHT(i)]);
        printf("\n");
    }
    return 0;
}

int PARENT(int a) {
 return a / 2;   
}

int LEFT(int b) {
    return 2 * b;
}

int RIGHT(int c) {
   return 2 * c + 1; 
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define de(x) cout<<#x<<" = "<<x<<endl
#define sz(a) (int)(a.size())
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
vector<pii> v;
vector<int> e[105];
int vis[105];
int je,js,ok;
void dfs(int g,int u) {
    if(u==je) {ok=0;return ;}
    vis[u]=1;
    int sz=e[u].size();
    rep(i,0,sz-1) {
        int to=e[u][i];
        if(to==g) continue;
        if(vis[to]) continue;
        if((u==js&&to==je)||(u==je&&to==js) )continue;
        dfs(u,to);
    }
}
int main() {
    int n,m,a,b;
    while(~scanf("%d%d",&n,&m)) {
        v.clear();
        for(int i=0;i<105;++i) e[i].clear();
        for(int i=1;i<=m;++i) {
            scanf("%d%d",&a,&b);
            v.pb(mp(a,b));
            e[a].pb(b);
            e[b].pb(a);
        }
        int cnt=0;
        rep(i,0,m-1) {
            memset(vis,0,sizeof vis);
            js=v[i].fi,je=v[i].se;
            ok=1;
            dfs(-1,js);
            cnt+=ok;
        }
        printf("%d\n",cnt);
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static String solve (int[] hand) {
		Arrays.sort(hand);
		int[] check = new int[14];
		for (int i = 0; i < hand.length; i++)
			check[hand[i]]++;
		int pair2 = 0, pair3 = 0, pair4 = 0;
		for (int i = 1; i < check.length; i++) {
			if (check[i] == 2) pair2++;
			if (check[i] == 3) pair3++;
			if (check[i] == 4) pair4++;
		}
		if (pair4 == 1) return "four card";
		if (pair3 == 1 && pair2 == 1) return "full house";

		boolean straightFlg = true;
		for (int i = 1; i < hand.length; i++) {
			if (hand[i] != hand[i - 1] + 1) {
				straightFlg = false;
				break;
			}
		}
		boolean straightFlg2 = hand[0] == 1 && hand[1] == 10 &&
							   hand[2] == 11 && hand[3] == 12 && hand[4] == 13;
		if (straightFlg || straightFlg2) return "straight";
		if (pair3 == 1) return "three card";
		if (pair2 == 2) return "two pair";
		if (pair2 == 1) return "one pair";
		return "null";
	}

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {
			String[] str = line.split(",");
			int[] nums = new int[5];
			for (int i = 0; i < nums.length; i++)
				nums[i] = Integer.parseInt(str[i]);
			System.out.println(solve(nums));
			line = null;
		}

	}

}

Measured memory_bytes: 16924
#include <bits/stdc++.h>
#define MXX 2000000000
using namespace std;

int arr[100005];
int dp[100005];

int solve(int n, int k){
  dp[n] = 0; dp[n+1] = MXX;
  for(int i = (n-1); i>=1; --i){
    int curcost = MXX;
    for(int j = 1; j<=k; ++j){
    	int chk = i+j;
      	if(chk<=n){
           curcost = min(curcost, dp[chk]+abs(arr[i]-arr[chk]));
        }
      	else{
        	break;
        }
    }
    dp[i] = curcost;
  }
  return dp[1];
}

int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  for(int i = 1; i<=n; ++i){
    scanf("%d",&arr[i]);
  }
  printf("%d\n",solve(n,k));
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define MAX_N 10000

int main(){
  int N,Q,i,j,S[MAX_N],T,res = 0;
  scanf("%d",&N);

  for(i = 0 ; i < N ; i++){
    if(i < N)break;
  }
  
  for(i = 0 ; i < N ; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&Q);
  for(i = 0 ; i < Q ; i++){
    scanf("%d",&T);
    for(j = 0 ; j < N ; j++){
      if(T == S[j]){
        ++res;
        break;
      }
    }
  }
  printf("%d\n",res);
  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    BeatMeScanf;
    //freopen("G:/C++/in.txt", "r", stdin);
    //freopen("G:/C++/out.txt", "w", stdout);

    int n, k;
    cin>>n>>k;

    vector<int> v;
    for(int i = 0; i<n; i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
    }
    if(k>=n)
        cout<<0<<endl;
    else
    {
        sort(v.begin(), v.end());
        long long ans = 0;
        for(int i = 0; i<n-k; i++)
            ans+=v[i];
        cout<<ans<<endl;
    }

    return 0;
}



Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    char s[n];
    int ans = 1;
    cin >> s[0];
    
    for(int i = 1; i < n; i++){
        cin >> s[i];
        if (s[i-1] != s[i]){
            ans += 1;
        }
    }
   
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_

int TLE_TERROR()
{
 	ll a,b,c,d,ma;
 	cin>>a>>b>>c>>d;
 	ma=max({a*c,a*d,b*c,b*d});
 	cout<<ma;
 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TESTS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    string s;
    cin >> s;

    ll n = s.length();

    ll diff = 0;

    rep(i,n)
    {
    	if(s[i]=='0')
    		diff++;
    	else
    		diff--;
    }

    diff = abs(diff);

    cout << n-diff << endl;
}


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

#define MAX 100000
typedef long long llong;
int num{ 1 }, truck{ 1 };
llong T[MAX];

int check(llong P) {
    int count = 0;
    for (int j = 0; j < truck; j++) {
        llong s = 0;
        while (s + T[count] <= P) {
            s += T[count];
            count++;
            if (count == num) return num;
        }
    }
    return count;
}

llong solve(int count, int maxw) {
    llong left{ 0 }, right{ count * maxw };

    while (right - left > 1) {
        llong mid = (left + right) / 2;
        int volume = check(mid);
        if (volume >= num) right = mid;
        else left = mid;
    }

    return right;
}

int main()
{
    scanf("%d %d", &num, &truck);
    int maxw = 1;
    for (int i = 0; i < num; i++) {
        int w = 0;
        scanf("%d", &w);
        T[i] = w;
        if (maxw <= w) maxw = w;
    }

    llong ans = solve(num, maxw);
    cout << ans << "\n";
}


Measured memory_bytes: 4008
const input = require("fs").readFileSync("/dev/stdin", "utf8")
let cin = input.split(/ |\n/), cid = 0
const next = () => cin[cid++]
const nexts = (n) => cin.slice(cid, cid+=n).map(i=>parseInt(i))

const alpha = next()

function isUpperCase(str) {
    return str === str.toUpperCase();
}

isUpperCase(alpha) ? console.log('A') : console.log('a')


Measured memory_bytes: 29668
#include <iostream>
using namespace std;
int main() {
	int N,x;
	cin >> N;
	if ( N%1000 == 0) {
		cout << 0 << endl;
	}
	else {
		x = N / 1000;
		x++;
		cout<<1000*x-N <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3616
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

ll f(ll m, vector<ll> &A) {
  ll ret = 0;
  for (int i = 0; i < A.size(); i++) {
    ret += abs(A[i] - m);
  }
  return ret;
}

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

  ll r = 1e9 - 1, l = -1e9 + 1;
  while(r - l > 2) {
    ll m0 = (l * 2 + r) / 3;
    ll m1 = (l + 2 * r) / 3;
    if (f(m0, A) < f(m1, A)) {
      r = m1;
    } else {
      l = m0;
    }
  }
  cout << f((r + l) / 2, A) << endl;

  
  return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

struct UF{

    vector<int> par; // 親なら、-(自分の集合の大きさ)
    int n;

    UF( int _n ) : n(_n){
        par.assign( _n+1, -1 );
    }

    int size( int a ){
        return -par[root(a)];
    }

    int root( int a ){
        if( par[a] < 0 ) return a;
        return par[a] = root( par[a] );
    }

    bool same( int a , int b ){
        return root(a) == root(b);
    }

    bool unite( int a, int b ){
        a = root(a);
        b = root(b);
        if( a == b ) return false;
        if( size(a) < size(b) ) swap(a,b);
        // size は a > b
        par[a] += par[b];
        par[b] = a;
        return true;
    }

};

int main() {

    int N,M;
    Scd2(N,M);

    vector<int> a(M);
    vector<int> b(M);

    Rep(i,M){
        Scd2(a[i],b[i]);
    }

    reverse( a.begin(), a.end() );
    reverse( b.begin(), b.end() );

    ll tmp = (ll)N*(N-1)/2;
    ll tt = 0;
    vector<ll> ans(M);
    UF u(N);
    Rep(i,M){
        ans[i] = tmp - tt;
        if( !u.same( a[i], b[i] ) ){
            tt += u.size(a[i]) * u.size(b[i]);
            u.unite( a[i], b[i] );
        }
    }

    reverse( ans.begin() , ans.end() );

    Rep(i,M){
        printf( "%lld\n", ans[i] );
    }

    return 0;
}



Measured memory_bytes: 3328
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define INF 1LL << 61

struct edge{ int from, to; ll cost; };

int main(){
	int n, m; scanf("%d %d", &n, &m);
	edge e[2000];
	rep(i, m){
		int a, b; ll c;
		scanf("%d %d %lld", &a, &b, &c);
		e[i] = (edge){a - 1, b - 1, -c};
	}
	ll d[1000]; fill(d, d + n, INF);
	d[0] = 0;
	rep(i, n - 1) rep(j, m){
		if(d[e[j].from] == INF) continue;
		d[e[j].to] = min(d[e[j].to], d[e[j].from] + e[j].cost);
	}
	int f[1000] = {};
	rep(i, n) rep(j, m){
		if(d[e[j].from] == INF) continue;
		if(d[e[j].to] > d[e[j].from] + e[j].cost){
			d[e[j].to] = d[e[j].from] + e[j].cost;
			f[e[j].to] = 1;
		}
		if(f[e[j].from]) f[e[j].to] = 1;
	}
	if(f[n - 1]) puts("inf");
	else printf("%lld\n", -d[n - 1]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys


def main():
    K, Q = map(int, input().split())
    D = list(map(int, input().split()))

    for _ in range(Q):
        n, x, m = map(int, input().split())
        md = [D[i] % m for i in range(K)]
        smda = 0
        mda0 = 0
        for i in range((n - 1) % K):
            if md[i] == 0:
                mda0 += 1
            smda += md[i]
        smd = smda
        md0 = mda0
        for i in range((n - 1) % K, K):
            if md[i] == 0:
                md0 += 1
            smd += md[i]
        roop = (n - 1) // K
        res = n - 1 - (x % m + smd * roop + smda) // m - md0 * roop - mda0
        print(res)


main()


Measured memory_bytes: 64348
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
    
    void solve() throws IOException {
        String s=next();
        String t=next();
        int ans=Integer.MAX_VALUE;
        for (int i=0;i<=s.length()-t.length();i++) {
            int na=0;
            for (int j=0;j<t.length();j++) {
                if (s.charAt(i+j)!=t.charAt(j)) na++;
            }
            //System.out.println(i+" "+na);
            ans=Math.min(ans,na);
        }
        //out.flush();
        System.out.println(ans);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 32660
import sys
input = sys.stdin.readline

# ユニオンファインド
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m= map(int, input().split())
a= [list(map(int, input().split())) for i in range(n)]
uf=UnionFind(m)
x=[0]*m
for i in range(n):
    if a[i][0]==1:
        x[a[i][1]-1]=1
    else:
        for j in range(1,len(a[i])-1):
            uf.union(a[i][j]-1,a[i][j+1]-1)
            if x[a[i][j]-1]==0:
                x[a[i][j]-1]=1
            if j==len(a[i])-2:
                if x[a[i][j+1]-1]==0:
                    x[a[i][j+1]-1]=1

for i in range(m):
    if x[i]==0:
        if i==m-1:
            uf.union(m-1,0)
        else:
            uf.union(i,i+1)

y=uf.group_count()
if y==1:
    print('YES')

else:
    print('NO')


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    sort(items.begin(), items.end());
    P p = items[N - 1];
    cout << p.second + p.first << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1792
function over(x){
   if(x>=10)x=x-10+1;
   return x;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var n=arr.shift()-0;
var id=arr.shift().split("");
id.reverse();
var a=arr.shift()-0;
var ary=arr.shift().split(" ").map(Number);
var k=[];
var sum=0;
for(var i=0;i<id.length;i++){
   var v=id[i];
   if(v=="*"){
      if(i%2==0)k.push(1);
      else k.push(2);
   }else{
      if(i%2==0)sum+=v-0;
      else sum+=over((v-0)*2);
   }
}
var dp=[];
for(var i=0;i<=k.length;i++){
   dp[i]=[];
   for(var s=0;s<100;s++)dp[i][s]=0;
}
 
dp[0][0]=1;
 
for(var i=0;i<k.length;i++){
   for(var j=0;j<ary.length;j++){
      for(var s=0;s<100;s++){
         dp[i+1][s+over(ary[j]*k[i])]+=dp[i][s];
      }
   }
}
var ans=0;
for(var s=0;s<100;s++){
   if((sum+s)%10==0)ans+=dp[k.length][s];
}
console.log(ans);

Measured memory_bytes: 17684
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>
using namespace std;
int main(){
	int M;
	vector<int>ans;
	long long int N,x,y;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>x>>y;
		x=min(x,N-x+1);
		y=min(y,N-y+1);
		ans.push_back((min(x,y)+2)%3 + 1);
	}
	for(int i=0;i<M;i++){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>
#include <map>

int main (){
	int n;

	std::cin >> n;

	std::string s;

	std::cin >> s;

	std::sort(s.begin(), s.end());

	int count = 1;
	long long ans = 1;

	for (size_t i = 1; i < s.length(); i++)
	{
		if (s[i - 1] != s[i]) {
			ans *= (count + 1);
			ans %= 1000000007;
			count = 0;
		}
		count++;
	}

	std::cout << (ans * (count + 1) - 1) % 1000000007  << std::endl;

	return 0;
}

Measured memory_bytes: 512