akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <string>
#include <vector>

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

using namespace std;

string s;
int x, y;

int main() {
    cin >> s;
    scanf("%d %d", &x, &y);
    vector<int> movex;
    vector<int> movey;
    int n = s.length();

    bool direc = true;
    while (true) {
        if (direc) {
            int l = s.find('T');
            if (l==-1) {
                movex.push_back(s.length());
                break;
            }
            movex.push_back(l);
            s = s.substr(l+1, s.length()-l+1);
            direc = false;
        } else {
            int l = s.find('T');
            if (l==-1) {
                movey.push_back(s.length());
                break;
            }
            movey.push_back(l);
            s = s.substr(l+1, s.length()-l+1);
            direc = true;
        }
    }

    x -= movex[0];
    movex.erase(movex.begin());

    vector<vector<bool>> dpx(movex.size()+1, vector<bool>(2*n+1, false));
    vector<vector<bool>> dpy(movey.size()+1, vector<bool>(2*n+1, false));
    dpx[0][n] = true;
    dpy[0][n] = true;
    REP(i, movex.size()) {
        REP(j, 2*n+1) {
            if (dpx[i][j]) {
                if (j+movex[i]<=2*n)
                    dpx[i+1][j+movex[i]] = true;
                if (j-movex[i]>=0)
                    dpx[i+1][j-movex[i]] = true;
            }
        }
    }
    REP(i, movey.size()) {
        REP(j, 2*n+1) {
            if (dpy[i][j]) {
                if (j+movey[i]<=2*n)
                    dpy[i+1][j+movey[i]] = true;
                if (j-movey[i]>=0)
                    dpy[i+1][j-movey[i]] = true;
            }
        }
    }
    if (0<=x+n && x+n<=2*n && 0<=y+n && y+n<=2*n)
        printf(dpx[movex.size()][x+n] && dpy[movey.size()][y+n] ? "Yes\n" : "No\n");
    else
        printf("No\n");
    return 0;
}


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

int n;
vector<int> v, p;

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.push_back(x);
    p.push_back(x);
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < n; ++i) {
    if(lower_bound(v.begin(), v.end(), p[i]) - v.begin() <
       n / 2)
      cout << v[n / 2] << endl;
    else
      cout << v[n / 2 - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3948
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CRally solver = new CRally();
        solver.solve(1, in, out);
        out.close();
    }

    static class CRally {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] x = new int[n];
            // 気合で
            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
            }
            int sum = 100000000;
            for (int i = 1; i <= 100; i++) {
                // 中心はi
                int tmp = 0;
                for (int j = 0; j < n; j++) {
                    tmp += (i - x[j]) * (i - x[j]);
                }
                sum = Math.min(sum, tmp);
            }
            out.println(sum);
        }

    }
}



Measured memory_bytes: 21972
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c = M()
ans = 'NO'
for i in range(1, 101):
    if (a*i)%b==c:
        ans = 'YES'
        break
print(ans)

Measured memory_bytes: 74124
#include<bits/stdc++.h>
#define re          return
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define PI            3.141592653589793l
#define fill(c,val) memset(c,val,sizeof(c))
#define sz(x)       (int)x.size()
#define LB lower_bound
#define UB upper_bound
#define inf 1e9
#define bsa(v,n,a) binary_search(v,v+n,a)
#define bsv(v,a) binary_search(v.begin(),v.end(),a)
using namespace std;
typedef long long ll;
const ll INF=(1LL<<60)-1;
ll const nax=1e5+5;
int main(){
	    int t=1;
//	    cin>>t;
	while(t--){ 
	    string s,t; cin>>s>>t;
	    t+=t;
	    if(t.find(s)!=-1) cout<<"Yes";
	    else cout<<"No";
	    cout<<endl;
   }
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

vector<ll> fact,inv;

ll f(ll a,ll b, ll p){  // a^b mod pを求める
	if (b == 0)return 1;
	else if (b % 2 == 0){
		ll d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return d * d % mod;
	}else{
		return a * f(a,b-1,p) % mod;
	}
}

void init(ll n){
	fact.resize(n+1,1LL);
	inv.resize(n+1,1LL);
	for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
		fact[i] = fact[i-1] * i % mod;
	for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
		inv[i] = f(fact[i],mod-2,mod) % mod;
}

ll comb(ll n,ll k){  //n_C_k
	if (n < k) return 0;
	return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}

vector<vector<ll>> g, di_g;
vector<ll> dp, dp2, subtree_size, parent, used;

void dfs(ll cur){
	used[cur]=true;
	dp[cur] = 1;
	subtree_size[cur] = 1;
	for(auto next: g[cur]){
		if(used[next]) continue;

		di_g[cur].push_back(next);
		parent[next]=cur;
		dfs(next);
		subtree_size[cur] += subtree_size[next];
		dp[cur]*=dp[next];
		dp[cur]%=mod;

		dp[cur]*=inv[subtree_size[next]];
		dp[cur]%=mod;
	}
	dp[cur]*=fact[subtree_size[cur]-1];
	dp[cur]%=mod;
}

int main()
{
	ll n;
	cin>>n;
	g.resize(n,vector<ll>());
	di_g.resize(n,vector<ll>());
	dp.resize(n,0);
	dp2.resize(n,0);
	used.resize(n);
	subtree_size.resize(n,0);
	parent.resize(n,-1);
	rep(i,n-1){
		ll a,b;
		cin>>a>>b;
		g[a-1].push_back(b-1);
		g[b-1].push_back(a-1);
	}
	init(n+10);

	ll root = 0;
	dfs(root);


	vector<ll> dp_power(n,0);
	rep(i,n)dp_power[i] = power(dp[i],mod-2);

	queue<int> que;
	que.push(root);
	while(!que.empty()){
		int cur=que.front();que.pop();
		dp2[cur] = 1LL;

		if(parent[cur]!=-1){
			ll tmp=dp2[parent[cur]];
			tmp*=dp_power[cur];
			tmp %= mod;

			tmp *= fact[subtree_size[cur]];
			tmp %= mod;

			tmp *= inv[n-1];
			tmp %= mod;

			tmp *= fact[n-subtree_size[cur]-1];
			tmp %= mod;

			dp2[cur]*=tmp;
			dp2[cur]%=mod;
			dp2[cur]*=inv[n-subtree_size[cur]];
			dp2[cur]%=mod;

		}

		for(auto x:di_g[cur]){
				dp2[cur]*=dp[x];
				dp2[cur]%=mod;
				dp2[cur]*=inv[subtree_size[x]];
				dp2[cur]%=mod;
				que.push(x);
			
		}
		dp2[cur]*=fact[n-1];
		dp2[cur]%=mod;
	}

	rep(i,n){
		cout<<dp2[i]<<endl;
	}


	return 0;
}

Measured memory_bytes: 36796
#include <iostream>
#include <cstring>
#include <set>
#include <vector>

using namespace std;

using ll = long long;

#define F first
#define S second


int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> a(n), b(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i].F >> a[i].S;
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i].F >> b[i].S;
    }
    for (int i = 0; i < n; i++) {
        int idx = 1;
        int mn = 1e9;
        for (int j = 0; j < m; j++) {
            int dis = abs(a[i].F - b[j].F) + abs(a[i].S - b[j].S);
            if (dis < mn) {
                mn = dis;
                idx = j + 1;
            }
        }
        cout << idx << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String line = sc.nextLine();
		int H = Integer.parseInt(line.split(" ")[0]);
		int W = Integer.parseInt(line.split(" ")[1]);
		int[][] squares = new int[H][W];
		boolean[][] done = new boolean[H][W];
		int blocks = 0;
		for (int i = 0; i < H; i++) {
			line = sc.nextLine();
			for (int j = 0; j < W; j++) {
				if (line.substring(j, j + 1).equals("#")) {
					squares[i][j] = -1;
					blocks++;
				}
			}
		}
		Queue<P> q = new LinkedList<>();
		q.add(new P(0, 0, 0));
		while (!q.isEmpty()) {
			P p = q.poll();

			if (p.x < 0 || p.x >= H || p.y < 0 || p.y >= W)
				continue;
			if (squares[p.x][p.y] < 0)
				continue;
			if (done[p.x][p.y])
				continue;

			q.add(new P(p.x + 1, p.y, p.dist + 1));
			q.add(new P(p.x - 1, p.y, p.dist + 1));
			q.add(new P(p.x, p.y + 1, p.dist + 1));
			q.add(new P(p.x, p.y - 1, p.dist + 1));

			squares[p.x][p.y] = p.dist;
			done[p.x][p.y] = true;

			if (p.x == W - 1 && p.y == H - 1)
				break;
		}

		if (squares[H - 1][W - 1] <= 0) {
			System.out.println("-1");
		} else {
			System.out.println(H * W - squares[H - 1][W - 1] - 1 - blocks);
		}
	}
}

class P {
	int x;
	int y;
	int dist;

	P(int x, int y, int dist) {
		this.x = x;
		this.y = y;
		this.dist = dist;
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
 
int main(void) {
  int N, i, j, ans = 0;
  char S[110];
  scanf("%d %s", &N, S);

  for (i = 0; i < N; i++) {
    int alf1[30] = {0};
    int cnt = 0;
    for (j = 0; j < i; j++) alf1[S[j] - 'a']++;
    for (j = i; j < N; j++) {
      if (alf1[S[j] - 'a'] > 0) {
        cnt++;
        alf1[S[j] - 'a'] = 0;
      }
    }
    if (ans < cnt) ans = cnt;
  }
  printf("%d\n", ans);
  
  return 0;
}
      

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<vector<char>> ss(2 * n, vector<char>(2 * n));
    for (i64 i = 0; i < n; i++) {
        for (i64 j = 0; j < n; j++) {
            cin >> ss[i][j];
            ss[i + n][j] = ss[i][j + n] = ss[i + n][j + n] = ss[i][j];
        }
    }

    i64 ans = 0;
    for (i64 i = 0; i <= 2 * n - 2; i++) {
        i64 ay = min(i, n - 1), ax = min(2 * n - 2 - i, n - 1);

        i64 err = 0;
        for (i64 ry = 0; ry < n; ry++) {
            for (i64 rx = ry; rx < n; rx++) {
                if (ss[ay + ry][ax + rx] != ss[ay + rx][ax + ry]) err++;
            }
        }
        if (!err) ans += min(ay, ax) + 1;
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  if(a-1>=b) cout<<a+a-1<<endl;
  else if(a==b) cout<<a+b<<endl;
  else if(b-1>=a)cout<<b+b-1<<endl;
  return 0;
}


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

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

using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i, n){
		cin >> h[i];
	}
	ll ans = 0;
	ll cnt = 0;
	sort(h.begin(), h.end(), greater<ll>());
	for(int i = 0; i < n; i ++){
		if(cnt < k){
			cnt++;	
		}else{
			ans += h[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

// https://kamino.hatenablog.com/entry/cpp-permutation-combination
void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s+1;
        recursive_comb(indexes, s, rest - 1, f);
    }
}

void foreach_comb(int n, int k, std::function<void(int *)> f) {
    int indexes[k];
    recursive_comb(indexes, n - 1, k, f);
}

int main(void) {
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<int> a(Q);
    vector<int> b(Q);
    vector<int> c(Q);
    vector<int> d(Q);
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    int maxP = 0;
    foreach_comb(M, N, [&](int *indexes) {
            int p = 0;
            for (int i = 0; i < Q; i++) {
                if (indexes[b[i]-1] - indexes[a[i]-1] == c[i]) p += d[i];
            }
            maxP = max(maxP, p);
            });
    cout << maxP << endl;

    return 0;
}



Measured memory_bytes: 3172
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

int main(){
	int N;
	cin >> N;
	int A[2][N];
	int sum1 = 0;
	int sum0 = 0;
	FOR(i,0,N) cin >> A[0][i];
	FOR(i,0,N){
		cin >> A[1][i];
		sum1 += A[1][i];
	}
	int max = 0;
	FOR(i,0,N){
		sum0 += A[0][i];
		if (sum0 + sum1 > max) max = sum0 + sum1;
		sum1 -= A[1][i];
	}

	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());

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


int main(){
	int a,b;
	while(cin>>a){
		cin>>b;
		if(a>b) swap(a,b);
		cout<<gcd(a,b)<<endl;
	}
}

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

int main(){
    int n,dd,cnt=1;
    cin >> n;
    vector<int> V(n);
    for(int i=0;i<n;i++) cin >>V[i];
    sort(V.begin(),V.end());
    dd = V[0];
    for(int i=1;i<n;i++){
        if(dd != V[i]) cnt++;
        dd = V[i];
    }
    cout << cnt;
}


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

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

typedef long long ll;

#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 INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

struct UnionFind {
  vector<int> d; // 親の番号、但し根の場合はサイズのマイナス
  UnionFind(int n): d(n,-1) {}
  int root(int x) { // 根を見つける
    if (d[x] < 0) return x;
    return d[x] = root(d[x]); // 経路圧縮
  }
  bool unite(int x, int y) { // 結合
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);} // 親が一緒
  int size(int x) { return -d[root(x)];} // サイズ
};


int main(){
    int N,M,K;
    cin>>N>>M>>K;
    UnionFind uf(N);
    int a,b;
    vector<vector<int>> A(N);
    rep(i,M){
        cin>>a>>b;
        a--;
        b--;
        uf.unite(a,b);
        A[a].push_back(b);
        A[b].push_back(a);
    }
    rep(i,K){
        cin>>a>>b;
        a--;
        b--;
        A[a].push_back(b);
        A[b].push_back(a);
    }
    rep(i,N){
        int ans=uf.size(i)-1;
        for(int a : A[i]){
            if(uf.same(i,a)) ans--;
        }
        cout<<ans<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 10380
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.IntMap as IM
main=mapM_(mapM_ print.solve).analyze.map(map(fst.fromJust.B.readInt).B.words).B.lines=<<B.getContents
analyze([n]:cs)=(n,abcs,q,k,xys):analyze rs where
  (abcs,[q,k]:qs)=splitAt(n-1)cs
  (xys,rs)=splitAt q qs
analyze []=[]
solve(n,abcs,q,k,xys)=map(\[x,y]->d IM.! x+d IM.! y)xys where
  g=V.accum(flip(:))(V.replicate(n+1)[])$concatMap(\[a,b,c]->[(a,(b,c)),(b,(a,c))])abcs
  d=f(IM.empty)k(-1)0
  f m t s c=foldr(\(i,d)m->if i==s then m else f m i t(c+d))(IM.insert t c m)$g V.! t where

Measured memory_bytes: 73340
#include <iostream>

using namespace std;

int main()
{
    int n, m, a, x, k=0;
    cin>>n>>m;
    int v[m+1];
    for(int i=0; i<=m; i++){
        v[i]=0;
    }
    for(int i=0; i<n; i++){
        cin>>a;
        for(int j=0; j<a; j++){
            cin>>x;
            v[x]++;
        }
    }
    for(int i=1; i<=m; i++){
        if(v[i]==n)
            k++;
    }
    cout<<k;

    return 0;
}


Measured memory_bytes: 256
import bisect
q = int(input())
l = []
r = []
for _ in range(q):
    line = list(map(int, input().split()))
    l.append(line[0])
    r.append(line[1])
like2017 = []
pn = [2]
for L in range(3, 10**5):
    chk = True
    for L2 in pn:
        if L%L2 == 0:
            chk = False
            break
    if chk:
        pn.append(L)
for prime in pn:
    if (prime+1)//2 in pn:
        like2017.append(prime)
for i in range(q):
    left = bisect.bisect_left(like2017, l[i])
    right = bisect.bisect_right(like2017,r[i])
    print(right - left)

Measured memory_bytes: 73176
import heapq
import sys

input = sys.stdin.readline

def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d



n,m=map(int,input().split())#n:頂点数　w:辺の数

edge = [[] for i in range(n)] #edge[i] : iから出る道の[重み,行先]の配列

l=[list(map(int,input().split())) for i in range(m)]
for i in range(m):
    x,y,z =l[i][0],l[i][1],l[i][2]
    x-=1
    y-=1
    edge[x].append([z,y])
    edge[y].append([z,x])
for i in range(1,n):
    edge[i].append([0,i-1])
#print(edge)
#print(dijkstra_heap(0))
a=dijkstra_heap(0)

if a[-1]==float('inf'):
    print(-1)
else:
    print(a[-1])

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

using namespace std;

int f(int n, int base) {
  int ret = 0;
  while (n > 0) {
    int r = n % base;
    n /= base;
    ret += r;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int minn = N;
  for (int i = 0; i < N + 1; i++)
    minn = min(f(N - i, 6) + f(i, 9), minn);
  cout << minn << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl count(100010,0);
    vl v(n);rep(i,n){
        ll a;cin >> a;
        count[a]++;
    }
    ll ans=0;
    rep(i,100000){
        if(i==0)continue;
        chmax(ans,count[i-1]+count[i]+count[i+1]);
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 1792
n, a, b = input().split() # a = blue, b = red
n, a, b = int(n), int(a), int(b)

if a == 0:
  print(0)
else:
  c = n // (a + b)
  d = n % (a + b)
  print(c * a + (d if d < a else a))

Measured memory_bytes: 3064
if true then
  fh=STDIN
else
  fh=open("in0102.txt")
end
while true
  n=fh.gets.to_i
  break  if n ==0
  g=[]
  m=0

  0.upto(n-1){|i|
    f = fh.gets.chomp.split.map{|x| x.to_i}
    m=f.length if m==0
    f.push(f.inject(0){|acc,x|acc+x})
    g.push(f)
  }

  gs=[]
  0.upto(m){|j|
    gs[j]=0
    0.upto(g.length-1){|i|
      gs[j] += g[i][j]
    }
  }
  g.push gs

  g.each{|v|
    puts v.map{|x| sprintf("%5d", x)}.join
  }

end

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

using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a))
#define mp make_pair
#define All(a) (a).begin(), (a).end()
template <typename T=long long>
inline T IN(){T x; cin>>x; return(x);}
inline void CIN(){}
template <class Head,class... Tail>
inline void CIN(Head&& head,Tail&&... tail){
    cin>>head;
    CIN(move(tail)...);
}
#define CINT(...) int __VA_ARGS__;CIN(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CIN(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CIN(__VA_ARGS__)
 
typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int,V,greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int N,Q,K;
const int NMAX=1e5;
struct edge{int to; ll cost;};
vector<vector<edge>> G(NMAX);
vector<ll> d(NMAX); 

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N;
    REP(i,N-1){
        CINT(a,b,c);
        G[--a].push_back({--b,c});
        G[b].push_back({a,c});
    }
    cin>>Q>>K;
    d.assign(N+1,LINF);
    d[--K]=0;
    priority_queue<PL, vector<PL>, greater<PL>>gq;
    gq.push({d[K],K});
    while(!gq.empty()){
        PL target=gq.top(); gq.pop();
        ll dt=target.first, t=target.second;
        if(d[t]<dt) continue;
        REP(i,G[t].size()){
            edge e=G[t][i];
            if(d[e.to]>d[t]+e.cost){
                d[e.to]=d[t]+e.cost;
                gq.push({d[e.to],e.to});
            }
        }
    }
    REP(i,Q){
        CINT(x,y);
        cout<<(d[--x]+d[--y])<<"\n";
    }
    return 0;
}

Measured memory_bytes: 11104
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
    string[] str=Console.ReadLine().Split(' ');
    int[] p=new int[N];
      for(int i=0;i<N;i++){
        p[i]=int.Parse(str[i]);
      }
      int count=0;
      
    for(int i=0;i<N;i++){
      if(p[i]!=i+1){
        count++;
      }
             
    }if(count>=3){
      Console.WriteLine("NO");
    }
      else{
        Console.WriteLine("YES");
      }
      
    }
    
  }

}


Measured memory_bytes: 27544
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, s, n) for(int i = s; i < n; i++)

using namespace std;

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

    if (n < 105) { cout << 0 << endl; return 0;}
    int cnt = 0;
    reps(i, 1, n+1) {
        int c = 0;
        reps(j, 1, n+1) {
            if (i % j == 0) c++;
        }
        if (c == 8) cnt++;
        i++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int check(int v) {
	return v >= 1 && v <= 9;
}
int main() {
	int a, b;
	cin >> a >> b;
	if(check(a) && check(b)) cout << (a*b) << endl;
	else cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
C = []
MOD = 10 ** 9 + 7
pre = -1
for i in range(n):
    a = int(input())
    if a != pre:
        C.append(a)
    pre = a

N = len(C)
dp = [0] * (N + 1)
col = {}
pre = -1
dp[0] = 1
for i in range(1, N + 1):
    if C[i - 1] not in col:
        dp[i] = dp[i - 1]
        col[C[i - 1]] = dp[i]
    else:
        dp[i] = dp[i - 1]
        dp[i] += col[C[i - 1]]
        dp[i] %= MOD
        col[C[i - 1]] += dp[i - 1]

print(dp[N])


Measured memory_bytes: 81496
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 21
#define mod 1000000007

int n, k, m, i, a, b, c, lim, conf;
int rest[maxN][maxN];

int bit;
ll dp[1 << maxN][maxN];

void add(ll &a, ll b) {
    a += b;
    if (a >= mod) a -= mod;
}

int set_one(int conf, int pos) {
    //! can be improved

    conf ^= 1 << pos;
    for (int i = pos + 1; i <= n - 2; i++) {
        if (conf & (1 << i)) {
            conf ^= 1 << i;
            return conf;
        }
    }

    return conf;
}

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%d%d%d", &n, &m, &k);
    for (i = 1; i <= k; i++) {
        scanf("%d%d%d", &a, &b, &c);
        rest[a][b] = c + 1;
    }

    lim = 1 << (n - 1);
    dp[0][0] = 1;
    for (int ray = 1; ray <= m; ray++) {

        for (i = 0; i <= n - 2; i++) {
            for (conf = 0; conf < lim; conf++) {
                if (dp[conf][i] == 0) continue;
                bit = (conf >> i) & 1;


                if (rest[ray][i + 1] == 0) {

                    if (bit == 1) {
                        add(dp[conf][i + 1], dp[conf][i]);
                    } else {
                        add(dp[conf][i + 1], dp[conf][i]);
                        add(dp[ set_one(conf, i) ][i + 1], dp[conf][i]);
                    }

                    continue;
                }

                if (rest[ray][i + 1] == 1) {

                    if (bit == 1) {
                        //! no way boss
                    } else {
                        add(dp[conf][i + 1], dp[conf][i]);
                    }

                    continue;
                }

                if (rest[ray][i + 1] == 2) {

                    if (bit == 1) {
                        add(dp[conf][i + 1], dp[conf][i]);
                    } else {
                        add(dp[ set_one(conf, i) ][i + 1], dp[conf][i]);
                    }

                    continue;
                }
            }
        }

        for (conf = 0; conf < lim; conf++) {
            dp[conf][0] = dp[conf][n - 1];
            //cerr << dp[conf][0] << ' ';
            for (i = 1; i < n; i++)
                dp[conf][i] = 0;
        }

        //cerr << '\n';
    }

    ll ans = 0;
    for (conf = 0; conf < lim; conf++)
        add(ans, dp[conf][0]);

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 88448
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = Tuple{Int,Int,Float64}[(0,0,0.0) for i in 1:n]
	for i in 1:n
		p,q = readline() |> split |> parseMap
		x = atan2(q,p)
		if p<0&&q<0||p>=0&&q<0
			x = 2*pi+x
		end
		a[i] = (p,q,x)
	end
	a = sort(a,by=x->x[3])
	mx = 0.0
	for i in 1:n
		for j in 1:n
			x = 0
			y = 0
			if i<=j
				for k in i:j
					x+=a[k][1]
					y+=a[k][2]
				end
			else
				for k in i:n
					x+=a[k][1]
					y+=a[k][2]
				end
				for k in 1:j
					x+=a[k][1]
					y+=a[k][2]
				end
			end
			mx = max(mx,sqrt(x^2+y^2))
		end
	end
	println(mx)
end

main()

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

namespace ABC164
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            int[] sw = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int s = sw[0], w = sw[1];
            if(w >= s)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}


Measured memory_bytes: 19020
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n,0);
    rep(i,n) cin >> h.at(i);
    sort(h.rbegin(),h.rend());
    ll ans = 0;
    for(int i=k;i<n;i++){
        ans += h.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define N 200010
int a[N],n,delta;
long long ans;
bool flag[N];
int main(){
	scanf("%d",&n);a[0]=-1;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]-a[i-1]>1)return puts("-1"),0;
	}
	for(int i=n;i;i--)if(a[i])ans+=(!flag[i-a[i]])*a[i],flag[i-a[i]]=1;
	printf("%lld\n",ans);
	return 0;
}


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

class Item {
  public:
    int cost;
    int score;
    Item(int _cost, int _score)
    {
      cost = _cost;
      score = _score;
    }
};

bool has_smaller_cost(const Item& a, const Item& b)
{
  return a.cost < b.cost;
}

int main()
{
  int n, t;
  cin >> n >> t;
  vector<Item> item;
  for (int i = 0; i < n; i++) {
    int cost, score;
    cin >> cost >> score;
    item.emplace_back(cost, score);
  }
  sort(item.begin(), item.end(), has_smaller_cost);
  vector<int> dp(t, 0);
  int maxi = 0;
  for (const auto& i : item) {
    for (int cap = 0; cap < (int)dp.size(); cap++) {
      if (i.cost <= cap) {
        dp.at(cap - i.cost) = max(dp.at(cap - i.cost), dp.at(cap) + i.score);
      } else {
        maxi = max(maxi, dp.at(cap) + i.score);
      }
    }
  }
  cout << max(maxi, *max_element(dp.begin(), dp.end())) << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int main() {
    int N;
    ll c = pow(10,9)+7;
    cin >> N;
    ll ans=1;
    rep(i,0,N) {
        ans*=(i+1);
        
        ans%=c;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int cnt = 0, rec[1000000] = {0};
int type[1000000] = {0};

int main()
{
    int n, k, k_n;
    cin >> n >> k;
    k_n = k;
    string s;
    cin >> s;
    char c = s[0];
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == c){
            rec[cnt]++;
            type[cnt] = c-'0' ;
        }
        else {
            rec[++cnt]++;
            if (c == '0') c = '1';
            else c = '0';
            type[cnt] = c-'0' ;
        }
    }
    // for(int i = 0; i <= cnt; ++i)cout << type[i] << ' ';
    // cout  << cnt;
    int now = 0, ans = 0;
    for (int i = 0; i <= cnt; ++i){
        if(type[i] == 1) now += rec[i];
        if (type[i] == 0 ) {
            if (k_n > 0){
                k_n--;
                now += rec[i];
            } else {
                now += rec[i];
                now -= rec[i-2*k];
                if (i - 2*k-1 >= 0) now -= rec[i-2*k-1];
            }
        }
        if (now > ans) ans = now;
        // cout << now << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> A(N),B(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    int plusCount=0,minusCount=0;
    rep(i,N){
        int dif = A[i]-B[i];
        if(dif>0) plusCount+=abs(dif);
        if(dif<0){ minusCount+=(abs(dif)/2LL); }
    }
    if(minusCount>=plusCount) cout << "Yes" << nn;
    else cout << "No" << nn;
    return 0;
}

Measured memory_bytes: 384
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 1e16, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int a[N];
vector <int> v[N];

int dfs(int x, int y) {
	vector <int> t;
	int sum = 0, num = 0, cnt = 0;
	for(auto u : v[x]) {
		if(u == y)
			continue;
		t.pb(dfs(u, x));
		sum += t.back();
		num += t.back();
	}
	int z = 2 * a[x] - sum;
	if((int)v[x].size() == 1)
		return a[x];
	sort(t.begin(), t.end());
	if(sum % 2 == 1)
		t[(int)t.size() - 1]--, sum--;
	sort(t.begin(), t.end());
	sum -= t.back();
	if(sum < t.back())
		cnt = sum;
	else
		cnt = (sum + t.back()) / 2;
	if(a[x] - z < 0 || cnt < (a[x] - z)) {
		cout << "NO" << endl;
		exit(0);
	}
	return z;
}

int32_t main() {
	use_fast;
	int n, rt = 1;
	cin >> n;
	for(int i = 1; i <= n; i++) 
		cin >> a[i];
 	for(int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
		if((int)v[x].size() > 1)
			rt = x;
		if((int)v[y].size() > 1)
			rt = y;
	}
	if(n == 2) {
		if(a[1] != a[2])
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
		return 0;
	}
	if(!dfs(rt, 0)) 
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



Measured memory_bytes: 27048
import sys
import math
input = sys.stdin.readline

N = int(input())
xy = []
sm = 0
for _ in range(N):
    xy.append(list(map(int, input().split())))
for i in range(N):
    now_x = xy[i][0]
    now_y = xy[i][1]
    for j in range(N):
        if j != i:
            sm += math.sqrt((now_x - xy[j][0])**2 + (now_y - xy[j][1])**2)
print(sm / N)


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 2005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int n,m;
int u[N][N],d[N][N],l[N][N],r[N][N];
string a[N];
int main()
{
    int i,j;
    cin>>n>>m;
    rep0(i,n)
        cin>>a[i];
    rep0(i,n)
    {
        int now=0;
        rep0(j,m)
        {
            if(a[i][j]=='#')
                now=0;
            else
                r[i][j]=++now;
        }
    }
//    rep0(i,n)
//    {
//        rep0(j,m)
//            cout<<r[i][j]<<" ";
//            nl
//    }
    rep0(i,n)
    {
        int now=0;
        for(j=m-1;j>=0;j--)
        {
            if(a[i][j]=='#')
                now=0;
            else
                l[i][j]=++now;
        }
    }
//    line
//    rep0(i,n)
//    {
//        rep0(j,m)
//            cout<<l[i][j]<<" ";
//            nl
//    }
    rep0(i,m)
    {
        int now=0;
        rep0(j,n)
        {
            if(a[j][i]=='#')
                now=0;
            else
                d[j][i]=++now;
        }
    }
//    line
//    rep0(i,n)
//    {
//        rep0(j,m)
//            cout<<d[i][j]<<" ";
//            nl
//    }
    rep0(i,m)
    {
        int now=0;
        for(j=n-1;j>=0;j--)
        {
            if(a[j][i]=='#')
                now=0;
            else
                u[j][i]=++now;
        }
    }
//    line
//    rep0(i,n)
//    {
//        rep0(j,m)
//            cout<<u[i][j]<<" ";
//            nl
//    }
    int mx=0;
    rep0(i,n)
    {
        rep0(j,m)
        {
            int res=u[i][j]+d[i][j]+l[i][j]+r[i][j]-3;
            if(res>mx)
            {
                mx=res;
//                 dbb(i,j);
//                 db(res);
            }
        }
    }
    pf("%d",mx);
}


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


struct edge {
  int u, v;
};

class UnionFindTree {
  vector<int> parent, rank, n;

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

public:

  UnionFindTree(int size) {
    parent = vector<int>(size);
    rank = vector<int>(size, 0);
    n = vector<int>(size, 1);
    for(int i = 0; i < size; i++) parent[i] = i;
  }

  ll unite(int x, int y) {
    ll res = 0;
    x = find(x);
    y = find(y);
    if(x == y) return -1;

    res = n[x] * n[y];
    if(rank[x] < rank[y]) {
      parent[x] = y;
      n[y] += n[x];
    } else {
      parent[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
      n[x] += n[y];
    }
    return res;
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main () {
  ll N, M;
  cin >> N >> M;
  vector<edge> edges(M);
  rep(i,M) {
    cin >> edges[i].u >> edges[i].v;
  }
  UnionFindTree t = UnionFindTree(N + 1);

  vector<ll> ans(M+1);
  ans[M] = N*(N-1) / 2;
  for(int i = M - 1; i >= 0; i--) {
    ll d = 0;
    if(!t.same(edges[i].u, edges[i].v)) {
      d = t.unite(edges[i].u, edges[i].v);
    }
    ans[i] = ans[i+1] - d;
  }

  rep(i,M) {
    cout << ans[i+1] << endl;
  }
  return 0;
}


Measured memory_bytes: 4096
using System;

public class Hello
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        var ret = 999999999;
        for (long i = 1; i * i <= n; i++)
            if (n % i == 0) ret = Math.Min(ret, getF(i, n / i));
        Console.WriteLine(ret);
    }
    public static int getF(long a, long b)
    {
        var wa = a.ToString().Length;
        var wb = b.ToString().Length;
        if (wa >= wb) return wa;
        else return wb;
    }
}

Measured memory_bytes: 11220
# coding: utf-8
# Your code here!
N=int(input())

S=list(map(int,input().split()))



D={}
for i in range(N):
    if str(S[i]) in D:
        D[str(S[i])]+=1
    else:
        D.update({str(S[i]):1})

count=0
for i in D.keys():
    
    if D[i]<int(i):
        
        count+=D[i]
    elif D[i]>int(i):
        count+=D[i]-int(i)
    
print(count)



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

int main(){
    int n,m;
    int count=0;
    cin >> n >> m;
    vector<vector<int>> data(m, vector<int>(2));

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < 2; ++j) {
            cin >> data.at(i).at(j);
        }
    }

    for(int i=1;i<=n;++i){
        for(int j=0;j<m;++j){
            for(int k=0;k<2;++k){
                if(i==data.at(j).at(k))
                    count += 1;
            }
        }
        cout << count << endl;
        count =0;
    }

    return 0;
}

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

using namespace std;

#define pb push_back
const int maxi = 1e6+10;
vector<int> v[maxi], l[2];
int n;
int rez[maxi], ob[maxi];

void dfs(int x, int pred, int lev)
{
    l[lev&1].pb(x);

    for (auto i:v[x])
        if (i!=pred) dfs(i, x, lev+1);
}
int main()
{
   cin>>n;

  for (int i=1;i<n;i++)
  {
      int x, y;
      scanf("%d%d",&x,&y);
      v[x].pb(y);
      v[y].pb(x);
  }

    dfs(1, 0, 0);

    if (l[0].size()>l[1].size()) swap(l[0], l[1]);

    int cur = 0;

    if (l[0].size()<=n/3)
    {
       for (int i = 3;i<=n && l[0].size()>cur;i+=3)
       {
           rez[l[0][cur]] = i;
           ob[i] = 1;
           cur++;
       }
    }
  else
  {
      for (int i = 1;i<=n && l[0].size()>cur;i+=3)
      {
          rez[l[0][cur]] = i;
          ob[i] = 1;
          cur++;
      }

      for (int i = 3;i<=n && l[0].size()>cur;i+=3)
      {
          rez[l[0][cur]] = i;
          ob[i] = 1;
          cur++;
      }
  }

      cur = 0;
      for (int i =1;i<=n;i++)
        if (!ob[i])
      {
          rez[l[1][cur]] = i;
          cur++;
      }

  for (int i=1;i<=n;i++)
    printf("%d ", rez[i]);
}


Measured memory_bytes: 46196
#include <algorithm>
#include <functional>

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int64;

typedef double float64;
typedef long double float128;

const int kInf = 0x3f3f3f3f;

int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> els(n);
    for (int i = 0; i < n; i += 1) {
        cin >> els[i];
        els[i]-=abs(i);
    }
    
    nth_element(els.begin(), els.begin() + n / 2, els.end());
    long long ans = 0;
    for (int i = 0; i < n; i += 1) {
        ans += abs(els[i] - els[n / 2]);
    }
    
    cout << ans << '\n';
    return 0;
}

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

int main(){
    int a,b;
    string op;
    while(1){
        cin >> a >> op >> b;
        if (op == "?")break;
        if (op == "+")cout << a+b << endl;
        else if(op == "-")cout << a-b << endl;
        else if(op == "*")cout << a*b << endl;
        else{cout << a/b << endl;}
    }
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <utility>
#include <set>
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define lli long long int
 
using namespace std;
 
int main() {
  
  int cnt[256];
  rep(i, 256) {
    cnt[i] = 0;
  }

  char c;

  while (cin >> c && c != EOF) {

    cnt[c] += 1;
    cnt[c + 0x20] += 1;
  }

  for (int i = 97; i < 123; i++) {
    cout << (char)i << " : " << cnt[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 3052