akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 60;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n; cin>>n;
  string s; cin>>s;
  string h, t;
  int cnt = 0;
  rep(i, s.size()) {
    if (s[i] == '(') ++cnt;
    else --cnt;
    if (cnt < 0) {
      h += '(';
      ++cnt;
    }
  }
  while (cnt) {
    t += ')';
    --cnt;
  }
  print(h + s + t);

  return 0;
}


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

int main(){
  int N, Q;cin >> N >> Q;
  string s; cin >> s;
  vector<int> l(Q), r(Q);
  for(int i = 0; i < Q; i++){
    cin >> l[i] >> r[i];
  }
  vector<int> num(N, 0);
  for(int i = 0; i < N - 1; i++){
    if(s[i] == 'A' && s[i + 1] == 'C'){
      num[i + 1] = num[i] + 1;
    }
    else num[i + 1] = num[i];
  }
  for(int i = 0; i < Q; i++){
    cout << num[r[i] - 1] - num[l[i] - 1] << endl;
  }
  cout << endl;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 101000
using namespace std;
struct KSD
{
    int v,next;
}e[N<<1];
int head[N],cnt;
inline void add(int u,int v)
{
    e[++cnt].v=v;
    e[cnt].next=head[u];
    head[u]=cnt;
}
int n;
int sg[N];
void dfs(int x,int p)
{
    int i,v;
    sg[x]=0;
    for(i=head[x];i;i=e[i].next)
    {
        v=e[i].v;
        if(v==p)continue;
        dfs(v,x);
        sg[x]^=(sg[v]+1);
    }
}
int main()
{
    int i,j,T;
    int a,b;


        cnt=1;
        memset(head,0,sizeof(head));
        scanf("%d",&n);
        for(i=1;i<n;i++)
        {
            scanf("%d%d",&a,&b);
            add(a,b),add(b,a);
        }
        dfs(1,0);
        if(sg[1])puts("Alice");
        else puts("Bob");

    return 0;
}

Measured memory_bytes: 7296
n = int(input())
p = 10**9 + 7

def fact(n):
    n_ = 1
    yield n_
    for i in range(1, n+1):
         n_ = (n_*i) % p
         yield n_

def invfact(n, f, p):
    m = pow(f[n], p-2, p)
    yield m
    for i in range(n, 0, -1):
        m = m * i % p
        yield m

ans = 0
m = n - 1
f = list(fact(m))
rf = list(invfact(m, f, p))
rf.reverse()
perm = 0

for k in range((n+1)//2, n):
    b = m - k
    a = (m - 1) - (2 * b)
    perm_ = f[a+b] * rf[a] %p * f[k] % p
    ans += (perm_ - perm) %p * k % p
    ans %= p
    perm = perm_

print(ans)

Measured memory_bytes: 82212
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();

		Map<Character, Integer> map = new HashMap<Character, Integer>();
		for (int i = 0; i < n; i++) {
			char c = s.charAt(i);
			if (map.containsKey(c)) {
				map.put(c, map.get(c) + 1);
			} else {
				map.put(c, 1);
			}
		}

		long ans = 1L;
		for (int val : map.values()) {
			ans *= (val + 1);
			ans %= 1000000007;
		}
		if (ans == 0) {
			System.out.println(1000000006);
		} else {
			System.out.println(ans - 1);
		}
	}
}


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

N,Q = map(int, input().split())

edge = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

P = []
for i in range(Q):
    x,y = map(int, input().split())
    P.append((x,y))

V = [0]*N
for p in P:
    V[p[0]-1] += p[1]

parent = {1}
done = {1}
while parent:
    children = set()
    for p in parent:
        child = set()
        for i in edge[p]:
            if i not in done:
                V[i-1] += V[p-1]
                child.add(i)
                done.add(i)
        children |= child
    parent = children

print(*V)


Measured memory_bytes: 93948
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    if(a<b)
    {
        if(b<c){
            cout<<"Yes"<<endl;
         }
         else{
           cout<<"No"<<endl;
        }

    }
    else
        {
           cout<<"No"<<endl;
        }
    return 0;
}



Measured memory_bytes: 3084
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll n, x;
	scanf("%lld%lld", &n, &x);
	ll ans = n;
	ll a = x, b = n - x;
	for (;;)
	{
		if (a < b)swap(a, b);
		ll t = a / b;
		ans += t * 2LL * b;
		a %= b;
		if (a == 0)
		{
			ans -= b;
			break;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, m;
	cin >> n >> m;
	vector<vector<bool>> nx(n, vector<bool>(n, false));
	for (ll i = 0; i < m; i++) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		nx[a][b] = true;
		nx[b][a] = true;
	}

	vector<ll> p(n);
	for (ll i = 0; i < n; i++) p[i] = i;
	ll ans = 0;
	do {
		if (p[0]) break;
		for (ll i = 0; i < n - 1; i++) {
			if (!nx[p[i]][p[i + 1]]) break;
			if (i == n - 2) ans++;
		}
	} while (next_permutation(all(p)));
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>

#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;

// <<fixed<<setprecision(6)<<

int gcd(lint x, lint y){
	return y==0 ? x:gcd(y,x % y);
}


int main(){
  int n;
  cin>>n;
  vector<int> l;
  for (int i = 0; i < n; i++){
    int j;
    cin>>j;
    l.pb(j);
  }
  sort(all(l));
  int ans = l[l.size()/2]-l[l.size()/2-1];

  log(ans);
  

}


Measured memory_bytes: 892
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 16;

int n;
int a[MAXN][MAXN];
long long cost[(1 << MAXN) + 1023];
long long dp[(1 << MAXN) + 1023];

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        cost[i] = cost[i ^ (1 << j)];
        for (int k = j + 1; k < n; k++) {
          if (i & (1 << k)) {
            cost[i] += a[j][k];
          }
        }
        break;
      }
    }
  }

  for (int i = 0; i < (1 << n); i++) {
    for (int submask = i; submask >= 0; submask = (submask - 1) & i) {
      dp[i] = max(dp[i], dp[submask] + cost[i - submask]);
      if (submask == 0) {
        break;
      }
    }
  }

  cout << dp[(1 << n) - 1] << endl;

  return 0;
}


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

using namespace std;

#define rg register
#define In inline
#define ll long long
#define ld long double

const ld eps = 1e-10;
const int N = 2e5;

typedef pair<ll,ll> pll;

namespace IO{
	In ll read(){
		ll s = 0,ww = 1;
		char ch = getchar();
		while(ch < '0' || ch > '9'){if(ch == '-')if(ch == '-')ww = -1;ch = getchar();}
		while('0' <= ch && ch <= '9'){s = 10 * s + ch - '0';ch = getchar();}
		return s * ww;
	}
	In void write(ll x){
		if(x < 0)putchar('-'),x = -x;
		if(x > 9)write(x / 10);
		putchar('0' + x % 10);
	}
};
using namespace IO;

In int sgn(ld x){
	return x < -eps ? -1 : x > eps;
}

int n,top;
ll A[N+5],B[N+5],C[N+5],tA[N+5],tB[N+5];
pll S[N+5];
ld f[N+5];

bool cmp(pll a,pll b,pll c){
	ll dy1 = b.second - a.second,dx1 = b.first - a.first;
	ll dy2 = c.second - b.second,dx2 = c.first - b.first;
	return dy2 * dx1 < dx2 * dy1;
//	ld k1 = (ld)1.0 * (b.second - a.second) / (b.first - a.first);
//	ld k2 = (ld)1.0 * (c.second - b.second) / (c.first - b.first);
//	return sgn(k2 - k1) < 0;
}

void solve(){
	S[++top] = make_pair(1,A[1] - C[1]);
	for(rg int i = 2;i <= n + 1;i++){
		pair<ll,ll> p = make_pair(i,A[i] - C[i]);
		while(top > 1 && !cmp(S[top-1],S[top],p))top--;
		S[++top] = p;
	}
//for(rg int i = 1;i <= top;i++)cout<<S[i].first<<" "<<S[i].second<<endl;
	for(rg int i = 1;i < top;i++){
		ll xl = S[i].first,xr = S[i+1].first;
		ll yl = S[i].second,yr = S[i+1].second;
		for(rg int j = xl;j < xr;j++)f[j] = (ld)1.0 * (yl * (xr-j) + yr * (j-xl)) / (ld)(xr - xl);
	}
//for(rg int i = 1;i <= n + 1;i++)printf("%.12Lf ",f[i]);putchar('\n');
	for(rg int i = 1;i <= n + 1;i++)f[i] += C[i];
//for(rg int i = 1;i <= n + 1;i++)printf("%.12Lf ",f[i]);putchar('\n');
	ld ans = 0;
	for(rg int i = 1;i <= n;i++)ans += f[i];
	ans /= n;
	printf("%.12Lf\n",ans);
}

int main(){
//precision && overflow!
//use long long && long double !!!
//	freopen("AGC044E.in","r",stdin);
//	freopen("AGC044E.out","w",stdout);
	
	n = read();
	for(rg int i = 1;i <= n;i++)A[i] = read();
	for(rg int i = 1;i <= n;i++)B[i] = read();
	ll maxn = -1,s;
	for(rg int i = 1;i <= n;i++)if(A[i] > maxn)maxn = A[i],s = i;
	int cnt = 0;
	for(rg int i = s;i <= n;i++){
		cnt++;
		tA[cnt] = A[i];
		tB[cnt] = B[i];
	}
	for(rg int i = 1;i <= s;i++){
		cnt++;
		tA[cnt] = A[i];
		tB[cnt] = B[i];
	}
	memcpy(A,tA,sizeof(A));
	memcpy(B,tB,sizeof(B));
//for(rg int i = 1;i <= n + 1;i++)cout<<A[i]<<" ";cout<<endl;
//for(rg int i = 1;i <= n + 1;i++)cout<<B[i]<<" ";cout<<endl;
	
	C[1] = C[2] = 0;
	for(rg int i = 3;i <= n + 1;i++)C[i] = 2ll * B[i-1] + 2ll * C[i-1] - C[i-2];
//for(rg int i = 1;i <= n + 1;i++)cout<<C[i]<<" ";cout<<endl;
	solve();
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	ll t, a; cin>>t>>a;
	for(int i = 1; i < n; i++){
		ll nt, na;
		cin>>nt>>na;
		ll k = max((t + nt - 1)/nt, (a + na - 1)/na);
		t = k*nt;
		a = k*na;
	}
	cout<<t + a<<endl;


	return 0;
}

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

using namespace std;

int n;
bool v;

int main()
{
    scanf("%d\n", &n);
    for(int i = 0; i < n; i++)
    {
        char t;
        scanf("%c ", &t);
        if(t == 'Y')
        {
            printf("Four");
            return 0;
        }
    }
    printf("Three");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

const int INF = 10000000;

int W, H, bx, by;
char tile[22][22];
int d[22][22];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


void bfs();

void solve();


int main(void){
  int i, j;
  while(scanf("%d%d", &W, &H) && W && H){
    //scanf("%d%d", &W, &H);
      for(i = 0 ; i < H; i++){
        scanf("%s", tile[i]);
      }
      for(i = 0; i < W; i++){
        for(j = 0; j < H; j++){
          if(tile[j][i] == '@'){
            bx = i;
            by = j;
          }
        }
      }
      //printf("%d %d\n", bx, by);
      solve();
    }
  return 0;
}

void bfs(){
  struct pair{
    int first;
    int second;
  };

  struct queue{
    struct pair P[401];
    int head;
    int tail;
  };

  struct queue que;
  que.head = 0;
  que.tail = 0;
  int i, j;
  for(i = 0; i < W; i++){
    for(j = 0; j < H; j++){
      d[j][i] = INF;
    }
  }

  que.P[que.tail].first = bx;
  que.P[que.tail].second = by;
  d[by][bx] = 0;
  que.tail++;
  //que.head++;

  while(que.head < que.tail){
    struct pair state;
    state.first = que.P[que.head].first;
    state.second = que.P[que.head].second;
    que.head++;
    //printf("%d %d\n" ,que.head, que.tail);
    //if(p.first == gx && p.second == gy) break;

    for(i = 0; i < 4; i++){
      int nx = state.first + dx[i], ny = state.second + dy[i];

      if(0 <= nx && nx < W && 0 <= ny && ny < H && tile[ny][nx] != '#' && d[ny][nx] == INF){
        que.P[que.tail].first = nx;
        que.P[que.tail].second = ny;
        que.tail++;
        d[ny][nx] = d[state.first][state.second] + 1;
      }
    }
  }
  //return d[gx][gy];

}

void solve(){
  bfs();
  int ans = 0, i, j;
  for(i = 0; i < W; i++){
    for(j = 0; j < H; j++){
      if(d[j][i] != INF) ans++;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 604
#include <iostream>

using namespace std;

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

	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else if (N == 2) {
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}

	
	
		
	
}




Measured memory_bytes: 256
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,k;vi a(101);vi dp(N,-1);
void solve(){
  cin>>n>>k;
  rep(i,1,n)cin>>a[i],dp[a[i]]=1;
  //dp[i] is 1 if current player wins when i stones left
  rep(i,0,k)
    rep(j,1,n){
      if(dp[i]==-1){
        //this means that person having i stones left loses
        dp[i+a[j]]=1;
        //in this case the player having i+a[j] stones left
        //removes a[j] stones as the above comment is true and
        //he wins
      }
    }
  if(dp[k]==1)cout<<"First";
  else cout<<"Second";
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 15872
#include<iostream>
using namespace std;
int main()
{
    long long l[90];
    int n;
    cin>>n;
    l[0]=2;
    l[1]=1;
    for(int i=2;i<=n;i++)
        l[i]=l[i-1]+l[i-2];
    cout<<l[n];
    return 0;
}


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

class AtCoder{
  public static void Main(){

    string s = Console.ReadLine();
    char[] c = s.ToArray();
    Array.Sort(c);
    
    bool b = true;
    for (int i = 1; i < c.Length; i++){
        if(c[i] == c[i-1]){
            b = false;
            break;
        }
    }
    if(b) Console.WriteLine("yes");
    else Console.WriteLine("no");
  }
}


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

int main(){
  int R;
  double pi, l;
  cin >> R;
  pi = M_PI;
  l = 2 * R * pi;
  cout << fixed;
  cout << setprecision(3) << l << endl;
  return 0;
}

Measured memory_bytes: 3788
/*
 * 16-8-28_ABC044_A.cpp
 *
 *  Created on: 2016/08/28
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int N,K,X,Y;
	cin >> N >> K>> X >> Y;
	int ans = min(N,K)*X;
	if(N>K)
	ans += (N-K)*Y;
	cout <<ans<<endl;
	return 0;
}




Measured memory_bytes: 256
#include<iostream>

using namespace std;

int soremade(int k){
	int i, ans, q;
	for(i = 1, ans = 0, q = 9; i <= k; i++, q*=10){
		if(i % 2 == 1) ans += q;
	}
	return ans;
}

int keta(int n){
	int k = 0;
	for(int i = 1; i <= n; i *= 10, k++);
	return k;
}

int zeros(int k){
	int ans = 1;
	for(int i = 1; i < k; i++, ans*=10);
	return ans;
}
 
int main(){
	int n, k, ans;
	
	cin >> n;
	
	k = keta(n);
	ans = soremade(k - 1);
	if(k % 2 == 1) ans += (n - zeros(k)) + 1;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;

ll numLevels[51];
ll numInside[51];

ll solve(int level, ll amt) {
	if(level == 0) {
		assert(amt == 1);
		return 1;
	}
	amt--;
	ll ret = 0;
	if(amt == 0) return 0;
	if(amt <= numLevels[level-1]) return solve(level-1, amt);
	ret += numInside[level-1];
	amt -= numLevels[level-1];
	if(amt == 0) return ret;
	ret++;
	amt--;
	if(amt == 0) return ret;
	if(amt <= numLevels[level-1]) return ret + solve(level-1, amt);
	return ret + numInside[level-1];
}

void solve() {
	numLevels[0] = 1;
	numInside[0] = 1;
	for(int i = 1; i <= 50; i++) {
		numLevels[i] = 2 * numLevels[i-1] + 3;
		numInside[i] = 2 * numInside[i-1] + 1;
	}
	int n;
	ll amt;
	cin >> n >> amt;
	cout << solve(n, amt) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
	/*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
	*/
	solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}





const int N=2005;
int n,m,ans,f[N][N],top,s[N],l[N],r[N];
char c[N][N];

signed main(){
	read(n);read(m);
	ans=max(n,m);
	n--;m--;
	for(int i=0;i<=n;i++){
		scanf("%s",c[i]);
		for(int j=0;j<=m;j++) c[i][j]=c[i][j]=='.';
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) if((c[i][j]+c[i-1][j]+c[i-1][j-1]+c[i][j-1])%2==0)
			f[i][j]=f[i-1][j]+1;
	for(int i=1;i<=n;i++){
		f[i][s[top=1]=0]=-1;
		for(int j=1;j<=m;j++){
			while(top&&f[i][s[top]]>=f[i][j]) top--;
			l[j]=s[top]+1;
			s[++top]=j;
		}
		f[i][s[top=1]=m+1]=-1;
		for(int j=m;j;j--){
			while(top&&f[i][s[top]]>=f[i][j]) top--;
			r[j]=s[top]-1;
			s[++top]=j;
		}
		for(int j=1;j<=m;j++) ans=max(ans,(f[i][j]+1)*(r[j]-l[j]+2));
	}
	write(ans);
}

Measured memory_bytes: 19968
/**
*    author:  yuya1234
*    created: 16.07.2020 15:43:40
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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 (b<a) { a=b; return 1; } return 0; }
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}



int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);
  ll MOD=pow(10,9)+7;
  ll n;
  string s;
  cin>>n>>s;

  vector<int> a(26,1);

  REP(i,n)a[s[i]-'a']++;

  ll ans=1;
  REP(i,26)ans=(ans*a[i])%MOD;

  cout<<ans-1<<endl;

  return 0;
}

Measured memory_bytes: 3700
import math

n = int(input())
result = 0
for i in range(1, n+1):
  for j in range(1, n+1):
    for k in range(1, n+1):
      if i == 1 or j == 1 or k == 1:
        result += 1
        continue
      result += math.gcd(math.gcd(i, j), k)

print(result)


Measured memory_bytes: 67884
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int answer[101];
	int a,b;

	while( cin >> a >> b ){
		for( int i = 0;i < 101;i++ ) answer[i] = 0;

		answer[a]++;
		answer[b]++;

		while( cin >> a >> b && a != 0 ){
			answer[a]++;
			answer[b]++;
		}

		int count = 0;
		for( int i = 3;i < 101;i++ ){
			if( answer[i] % 2 ) count++;
		}
		if( answer[1] % 2 && answer[2] % 2 && !count ) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    
    a = [[0]*3 for i in range(3)]
    for i in range(3):
        a[i] = list(map(int, input().split()))
    n = int(input())
    b = [0]*n
    bingo = "No"
    for i in range(n):
        b[i] = int(input())
        for k in range(3):
            if a[k][0] == b[i]:
                a[k][0] = 0
            if a[k][1] == b[i]:
                a[k][1] = 0
            if a[k][2] == b[i]:
                a[k][2] = 0
    for i in range(3):
        if a[i][0]+a[i][1]+a[i][2] == 0:
            bingo = "Yes"
    for i in range(3):
        if a[0][i]+a[1][i]+a[2][i] == 0:
            bingo = "Yes"
    if a[0][0]+a[1][1]+a[2][2] == 0:
        bingo = "Yes"
    if a[2][0]+a[1][1]+a[0][2] == 0:
        bingo = "Yes"
     
    print(bingo)
main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e9;

signed main(){
  lint N; cin >> N;
  vector<lint> a(N);
  bool ok = true;
  for(lint i = 0; i < N; i++){
    cin >> a[i];
    if(a[i] % 2 != 0) ok = false;
  }
  if(!ok) cout << "first" << endl;
  else cout << "second" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),t,s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------



template<typename T,T MOD, T MOD2, T MOD3, T B>
struct RollingHash{
    vector<T> hash, hash2, hash3, p, q, r;
    RollingHash(){}
    RollingHash(const string &s){
        int n=s.size();
        hash.assign(n+1,0);
        hash2.assign(n+1,0);
        hash3.assign(n+1,0);
        p.assign(n+1,1);
        q.assign(n+1,1);
        r.assign(n+1,1);
        rep(i,n){
            hash[i+1]=(hash[i]*B+s[i])%MOD;
	        hash2[i+1]=(hash2[i]*B+s[i])%MOD2;
	        hash3[i+1]=(hash3[i]*B+s[i])%MOD3;
            p[i+1]=p[i]*B%MOD;
            q[i+1]=q[i]*B%MOD2;
            r[i+1]=r[i]*B%MOD3;
        }
    }

    void add(string &t){
	    const int oldLen=hash.size();
	    hash.resize(hash.size()+t.size(),0);
	    hash2.resize(hash.size()+t.size(),0);
	    hash3.resize(hash.size()+t.size(),0);
	    p.resize(hash.size()+t.size(),1);
	    q.resize(hash.size()+t.size(),1);
	    r.resize(hash.size()+t.size(),1);
	    rep(i,Size(t)){
	        hash[oldLen+i]=(hash[oldLen-1+i]*B+t[i])%MOD;
	        hash2[oldLen+i]=(hash2[oldLen-1+i]*B+t[i])%MOD2;
	        hash3[oldLen+i]=(hash3[oldLen-1+i]*B+t[i])%MOD3;
	        p[oldLen+i]=p[oldLen+i-1]*B%MOD;
	        q[oldLen+i]=q[oldLen+i-1]*B%MOD2;
	        r[oldLen+i]=r[oldLen+i-1]*B%MOD3;
	    }
    }
  
  //S[l, r)
  pair<T,pair<T,T>> find(int l,int R){
	if(l==R)return {0,{0,0}};
    T res=hash[R]+MOD-hash[l]*p[R-l]%MOD;		
    res%=MOD;
    T ret=hash2[R]+MOD2-hash2[l]*q[R-l]%MOD2;	
    ret%=MOD2;
	T rel=hash3[R]+MOD3-hash3[l]*r[R-l]%MOD3;	
    rel%=MOD3;
	return {res,{ret,rel}};
  }
};


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

    cin>>t>>s;
    const ll MOD1=1e9+7;
	const ll MOD2=998244353;
	const ll MOD3=998244601;
	const ll B=1777771;
	using RH=RollingHash<ll,MOD1,MOD2,MOD3,B>;

    RH A(t);
    RH BB(s);
    rep(i,Size(t)-Size(s)+1){
        auto X=A.find(i,i+Size(s));
        auto Y=BB.find(0,Size(s));
        if(X==Y)Cout(i);
    }
    return 0;
}



Measured memory_bytes: 51148
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;

#define sorted(vector) sort(vector.begin(),vector.end())
#define vmin(vector) *min_element(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())

//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n;
    cin>>n;
    L a(n-1,0);
    L b(n,1e18);
    for(int i=0  ;i<n-1  ;i++){
        cin>>a[i];
    }
    for(int i=0  ;i<n-1  ;i++){
        b[i]=min(a[i],b[i]);
        b[i+1]=min(a[i],b[i+1]);
    }
    cout<<vsum(b)<<endl;
    
}
    


Measured memory_bytes: 256
N, X = map(int, input().split())
layer_n = [0] * (N+1)
P_n = [0] * (N+1)
layer_n[0] = 1
P_n[0] = 1
for i in range(1,N+1):
    layer_n[i] = layer_n[i-1]*2 + 3
    P_n[i] = P_n[i-1]*2 + 1

def solve(n,x,ans):
    if x == 0:
        return ans
    if n == 0:
        return ans + 1
    mid = layer_n[n]//2 + 1
    if x < mid:
        return solve(n-1,x-1,ans)
    elif x == mid:
        return ans + P_n[n-1]+1
    else:
        x -= 2 + layer_n[n-1]
        ans += P_n[n-1]+1
        return solve(n-1,x,ans)

print(solve(N,X,0))


Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 405;

int t[100005][2];
int n,m;
bool f[N][N];
bool bz[N];

int main(){
	n=get();m=get();
	fo(i,1,m){t[i][0]=get();t[i][1]=get();}
	fo(i,1,n){
		f[i][i]=1;
		fd(j,m,1){
			if (f[i][t[j][0]]&&f[i][t[j][1]]){bz[i]=1;break;}
			if (f[i][t[j][0]])f[i][t[j][1]]=1;
			if (f[i][t[j][1]])f[i][t[j][0]]=1;
		}
	}
	int ans=0;
	fo(i,1,n)
	if (!bz[i])
		fo(j,i+1,n)
		if (!bz[j]){
			ans++;
			fo(x,1,n)
			if (f[i][x]&&f[j][x]){
				ans--;break;
			}
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long v = sc.nextLong();
        long b = sc.nextLong();
        long w = sc.nextLong();
        long t = sc.nextLong();

        if(Math.abs(a-b) <= (v-w)*t) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 35720
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 100000;

int main() {
	int N, C;
	int table[30] = { 0 };
	vector<pair<int, pair<bool, int>>> r;

	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		int s, t, c;
		cin >> s >> t >> c;

		s = (s * 2) - 1;
		t *= 2;
		c--;

		r.push_back(make_pair(s, make_pair(true, c)));
		r.push_back(make_pair(t, make_pair(false, c)));
	}

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

	int cnt = 0;
	int ans = 0;

	for (int i = 0; i < r.size(); i++) {
		int c = r[i].second.second;

		if (r[i].second.first) {
			if (table[c] == 0)cnt++;
			table[c]++;
		}
		else {
			if (table[c] == 1)cnt--;
			table[c]--;
		}
		ans = max(cnt, ans);
	}

	cout << ans << endl;

	return 0;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> L(N); cin >> L;
    int Lmax = 0;
    sort(all(L));
// cout<<"L:"; cout_h(L);
    Lmax = L.back();
    vector<int> dist(Lmax+1, 0);
    vector<int> acc(Lmax+1, 0);
    rep(i, N) {
        dist[L[i]]++;
    }
// cout<<"dist:"; cout_h(dist);
    rep1(i, Lmax+1) {
        acc[i] = acc[i-1]+dist[i];
    }
// cout<<"acc:";cout_h(acc);
    int ans = 0;
    int a, b;
    for (int ai = 0; ai < N - 2; ai++) {
        a = L[ai];
        for (int bi = ai + 1; bi < N - 1; bi++) {
            b = L[bi];
            int b_eq_c = 0;
            for (int i = bi+1; i < N; i++) {
                if (b == L[i]) {
                    b_eq_c++;
                    // cout << FMT3(ai, bi, b_eq_c) << endl;
                    
                } else {
                    break;
                }
            }
            ans += b_eq_c + acc[min(Lmax, a+b-1)] - acc[b];
        }
    }

    cout << ans << endl;
}


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

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

	if(a>=k){
		cout<<a-k<<" "<<b<<endl;
	}else{
		k-=a;
		cout<<0<<" "<<max(b-k,0LL)<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

const double PI = 3.141592653589793;

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

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

	vi S(M);
	vi T(M);

	vvi graph(N, vi());

	rep(i, M) {
		ll s, t;
		cin >> s >> t;
		s--; t--;
		S[i] = s; T[i] = t;

		graph[s].pb(t);
	}

    double emin = numeric_limits<double>::max();

	for (ll d = 0; d < N; d++) {
		vector<double> E(N, 0);
		for (ll i = N - 2; i >= 0; i--) {
			if (graph[i].size() == 1) {
				E[i] = E[graph[i][0]] + 1.0;
				continue;
			}

			double sum = 0.0;
			double max = 0.0;

			double size = graph[i].size();

			for (auto n : graph[i]) {
				sum += 1.0 + E[n];

				if (max < 1.0 + E[n]) {
					max = 1.0 + E[n];
				}
			}

			if (i == d) {
				size -= 1;
				sum -= max;
			}
			E[i] = sum / size;
		}
		if (E[0] < emin)
			emin = E[0];
	}

	printf("%.10f", emin);
	cout << endl;

	return 0;
}

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

int main() {
	int a; cin >> a;
	int b; cin >> b;
	if (13 <= a) {
		cout << b;
	}
	else if (6 <= a&&a <= 12) {
		cout << b / 2;
	}
	else if (0 <=a&&a<= 5) {
		cout << 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<climits>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
#define MAXN 100000
#define MAXM 100000
#define INF 1000000000000000
struct node
{
    int next,to;
    long long w;
}e[MAXM*2+5];
struct Qr
{
    int xr,dec;
    long long lim;
};
long long T;
int cnt,m,n;
int x,y,z,flag;
long long ri=INF,le=-INF;
long long vis[2][MAXN+5];
int b[MAXN+5];
void fpush(int u,int v,long long w)
{
    e[++cnt].next=b[u];
    e[cnt].w=w;
    e[cnt].to=v;
    b[u]=cnt;
}
int Ch(int x){if(x==-1)x=0;return x;}
void dfs(int xr,int dec,long long lim)
{
    if(flag)return ;
    for(int i=b[xr];i;i=e[i].next)
    {
        int xnext=e[i].to;
        long long nlim=e[i].w-lim;
        int FD=Ch(dec);
        if(vis[FD][xnext]!=INF)
        {
            if(vis[FD][xnext]!=nlim){flag=1;return ;}
            else continue;
        }
        vis[FD][xnext]=nlim;
        if(!FD)le=max(le,-vis[FD][xnext]);
        else ri=min(ri,vis[FD][xnext]);
        dfs(xnext,-dec,nlim);
    }
}
int main()
{
    fill(vis[0],vis[0]+MAXN+1,INF);
    fill(vis[1],vis[1]+MAXN+1,INF);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        fpush(x,y,z);fpush(y,x,z);
    }
    dfs(1,1,0);
    if(flag){printf("0\n");return 0;}//
    long long T=-1;
    for(int i=1;i<=n;i++)
        if(vis[0][i]!=INF&&vis[1][i]!=INF)
        {
            long long NT=(vis[1][i]-vis[0][i])/2;
            if(NT<0){flag=1;break;}
            if(T==-1)T=NT;
            else if(T!=NT){flag=1;break;}
        }
    if(flag){printf("0\n");return 0;}
    if(T!=-1)
    {
        if(T>le&&T<ri)printf("1\n");
        else printf("0\n");
    }
    else printf("%lld",max((long long)0,ri-le-1));
}

Measured memory_bytes: 15360
N = int(input())
h = [int(i) for i in input().split()]

# DPテーブルを初期化
dp = [float("inf")]*N

# 初期状態
dp[0] = 0
dp[1] = abs(h[0]-h[1])

# 足場iに辿り着くまでのコストを計算
for i in range(2,N):
    dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])


Measured memory_bytes: 13928
#02:08
#BFS
n,m,k = map(int,input().split())
peer = [[] for _ in range(n)]
num = [1 for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  num[a] += 1
  num[b] += 1
  peer[a].append(b)
  peer[b].append(a)
seen = [0 for _ in range(n)]
root = [i for i in range(n)]
cnt = [0 for _ in range(n)]
for i in range(n):
  if seen[i] == 1:
    continue
  seen[i] = 1
  now = [i]
  tmp = 1
  while now:
    last = now
    now = []
    for x in last:
      for y in peer[x]:
        if seen[y] == 0:
          seen[y] = 1
          now.append(y)
          root[y] = i
          tmp += 1
  cnt[i] = tmp
#print(root)
#print(cnt)
for i in range(n):
  cnt[i] = cnt[root[i]]
#print(cnt)
for i in range(n):
  cnt[i] -= num[i]
#print(cnt)
for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if root[a] == root[b]:
    cnt[a] -= 1
    cnt[b] -= 1
print(' '.join(map(str,cnt)))

Measured memory_bytes: 89632
def f(x):
    a = 0
    while x != 0:
        a += x % 10
        x //= 10
    return a

N = int(input())

Min = 1 + f(N-1)
for i in range((N//2)-1):
    Min = min(Min, f(i+2) + f(N-i-2))

print(Min)


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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	int l, r, d;
   	cin >> l >> r >> d;
   	cout <<(r/d) - (l-1)/d << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int a,b,c;
	int ans = 0;
	cin >> a>>b>>c;

	cout << solve(a+b >=c) << endl;
}

Measured memory_bytes: 3636
// Contest: AtCoder Beginner Contest 146 (https://atcoder.jp/contests/abc146)
// Problem: A: Can't Wait for Holiday (https://atcoder.jp/contests/abc146/tasks/abc146_a)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    string s; cin >> s;
    map<string, int> m{
            {"SUN", 7},
            {"MON", 6},
            {"TUE", 5},
            {"WED", 4},
            {"THU", 3},
            {"FRI", 2},
            {"SAT", 1},
    };
    cout << m[s] << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
signed main(){
    int n; string s;
    cin >> n >> s;
    int cntr = 0, cntg = 0, cntb = 0;
    rep(i, s.size()){
        if(s[i] == 'R') cntr++;
        if(s[i] == 'G') cntg++;
        if(s[i] == 'B') cntb++;
    }
    int sum = cntr * cntg * cntb;
    rep(j, n)rep(i, j){
        int k = 2*j - i;
        if (k < n && s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) sum--;
    }
    cout << sum << endl;
    return 0;
}

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

#define MAX_V 11
#define INF (INT_MAX/2)
void floydwarshall(int V, vector< vector<int> > &dist){
  for(int k = 0; k < V; k++){
    for(int i = 0; i < V; i++){
      for(int j = 0; j < V; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
  }
}

int main(void){
  int E;
  while(cin >> E && E != 0){
    int V, s, d, c;
    vector< vector<int> > dist(MAX_V, vector<int>(MAX_V, INF));
    V = -INF;

    while(E--){
      cin >> s >> d >> c;
      dist[s][d] = c;
      dist[d][s] = c;
      V = max(V, max(s, d));
    }
    V += 1;

    for(int i = 0; i < MAX_V; i++) dist[i][i] = 0;
    floydwarshall(V, dist);

    int ans, min_cost = INF;
    for(int i = 0; i < V; i++){
      int cost = 0;
      for(int j = 0; j < V; j++){
        cost += dist[i][j];
      }
      if(min_cost <= cost) continue;
      min_cost = cost;
      ans = i;
    }

    cout << ans << " " << min_cost << endl;
  }
  return 0;
}

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

using namespace std;

int main(){

  int N, A, B, sum = 0;
  cin >> N >> A >> B;
  
  for(int i = 1;i <= N;i++){
    if(i < 10){
      if(A <= i && i <= B){
	sum += i;
      }
    }else if(i < 100){
      if(A <= i / 10 + i % 10 && i / 10 + i % 10 <= B ){
	sum += i;
      }
    }else if(i < 1000){
      if(A <= i / 100 + i / 10 % 10 + i % 10 && i / 100 + i / 10 % 10 + i % 10 <= B ){
	sum += i;
      }
    }else if(i < 10000){
      if(A <= i / 1000 + i / 100 % 10 + i / 10 % 10 + i % 10 && i / 1000 + i / 100 % 10 + i / 10 % 10 + i % 10 <= B){
      sum += i;
      }
    }else{
       if(A <= 1 && 1 <= B)
      sum += 10000;
    }

  }

  
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3608
def gcd(a, b):  
  if b == 0: return a
  return gcd(b, a % b)
n, m =  map(int, input().split())
g = gcd(n, m)
l = n * m // g
n = n//g
m = m//g
s = list(str(input()))[::int(n)]
t = list(str(input()))[::int(m)]
if s == t:
  print(l)
else:
  print("-1")

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

namespace CSharpConsoleApp {

    delegate void test();
    public class Program {


        public static int Main() {
            var input = Console.ReadLine().Split(' ').ToList();
            var N = input[0];
            if (N.First() == N.Last())
                "Yes".QBox();
            else
                "No".QBox();
            return 0;
        }
    }
}

public static class Extensions {
    public static void QBox<T>(this T t) {
        Console.WriteLine(t);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,M,x,y;
int main(){
    cin >> N >> M;
    vector<int> kosu(N);
    set<int> st = {0};
    fill(ALL(kosu),1);
    int pos = 0;
    rep(i,M){
        cin >> x >> y;
        x--, y--;
        kosu[x]--,kosu[y]++;
        if(st.find(x) != st.end()) st.insert(y), pos = y;
        if(kosu[x] == 0) st.erase(x);
    }
    pr(sz(st));
}

Measured memory_bytes: 5376