akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a*c <= b){
        cout << c << endl;
    }
    else{
        cout << b/a << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int n = N;
  int S = 0;
  while (n > 0) {
    S += n % 10;
    n /= 10;
  }
  if (N % S == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
  int N, M; cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];
  
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    bool is_good = true;
    for (int j = 0; j < G[i].size(); j++) {
      if (H[i] <= H[G[i][j]]) is_good = false;
    }
    if (is_good) ans++;
  }
  cout << ans << endl;   
}

Measured memory_bytes: 8800
#include <stdio.h>
int main()
{
	int i, n;
	long int power;

	power = 1;
	scanf("%d", &n);
	for(i = 1; i <= n; i++) {
		power = power * i;
	power = power % (1000000000 + 7);
	}
	printf("%ld", power);
}	

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		int M = GetInt();
		int[] p = new int[N+1];
		for(int i = 1; i <= N; i++)
			p[i] = GetInt();
		UnionFind uftree = new UnionFind(N+1);
		for(int i = 0; i < M; i++)
			uftree.unite(GetInt(), GetInt());

		int ans = 0;
		for(int i = 1; i <= N; i++)
			if(uftree.same(i, p[i]))
				ans++;

		Console.WriteLine(ans);
	}
}


public class UnionFind
{
	public int N { get; private set; } = 0;
	private int[] par = null;
	private int[] rank = null;
	
	public UnionFind(int n)
	{
		if(n <= 0)
			throw new Exception();
		N = n;
		par = new int[N];
		rank = new int[N];
		for(int i = 0; i < N; i++)
		{
			par[i] = i;
			rank[i] = 0;
		}
	}
	
	public int find(int x)
	{
		if(par[x] == x)
		{
			return x;			
		}
		else
		{
			return (par[x] = find(par[x]));
		}
	}
	
	public void unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if(x == y)
			return;
		
		if(rank[x] < rank[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if(rank[x] == rank[y])
				rank[x]++;			
		}
	}
	
	public bool same(int x, int y)
	{
		return (find(x) == find(y));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, double> P;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

// https://tokumini.hatenablog.com/entry/2018/07/23/182500

ll dfs(int to, vector<vector<int>> &loser) {
    if (loser[to].empty()) return 0;
    vector<int> nums;
    for (int l : loser[to]) nums.push_back(dfs(l, loser));
    sort(nums.rbegin(), nums.rend());
    rep(i, nums.size()) nums[i] += (i + 1);
    return *max_element(nums.begin(), nums.end());

}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) if (i != 0) cin >> a[i], a[i]--;
    vector<vector<int>> loser(n);
    rep(i, n) if (i != 0) loser[a[i]].push_back(i);

    cout << dfs(0, loser) << endl;

}


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

ll solve() {
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = 0;
    ll h = min(X,Y);
    X -= h;
    Y -= h;
    if ( A + B <= 2 * C ) {
        ans += (A+B) * h;
    } else {
        ans += 2 * C * h;
    }
    if ( X != 0 ) {
        if ( A <= 2 * C ) ans += A * X;
        else ans += 2 * C * X;
    } else if ( Y != 0 ) {
        if ( B <= 2 * C ) ans += B * Y;
        else ans += 2 * C * Y;
    }

    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
 
typedef signed long long ll;
const int MX = 1e6 + 5;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	((a + b + c) >= 22) ? cout << "bust\n" : cout << "win\n"; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ll MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N,M,X;
    cin>>N>>M>>X;
    
    ll rm=0,lm=0;
    REP(i,M){
        ll t;
        cin>>t;
        if(t<X){
            rm++;
        }else{
            lm++;
        }
    }
    cout<<min(rm,lm);
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-29
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    ll sum1 = 0, sum2 = 0;
    ll ans1 = 0, ans2 = 0;
    for (int i = 0; i < N; ++i) {
        ll t; cin >> t;
        if (i == 0) {
            if (t == 0) {
                sum1 = 1; ans1 = 1;
                sum2 = -1; ans2 = 1;
            }else {
                sum1 = t;
                sum2 = t > 0 ? -1 : 1;
                ans2 += abs(t) + 1;
            }
        }
        else {
            if (sum1 < 0 && sum1 + t <= 0){
                ans1 += 1 - sum1 - t;
                sum1 = 1;
            }else if (sum1 > 0 && sum1 + t >= 0){
                ans1 += abs(-1 - sum1 - t);
                sum1 = -1;
            }else{
                sum1 += t;
            }

            if (sum2 < 0 && sum2 + t <= 0){
                ans2 += 1 - sum2 - t;
                sum2 = 1;
            }else if (sum2 > 0 && sum2 + t >= 0){
                ans2 += abs(-1 - sum2 - t);
                sum2 = -1;
            }else{
                sum2 += t;
            }
        }
    }
    cout << min(ans1, ans2) << "\n";

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll ret = 0;
string s;
ll w[101];
ll v[101];
ll dp[101][ARRAY];

ll knapsack(ll i, ll j) {
  if (j <= 0) return 0;
  if (i < 0 && j > 0) return INF;
  if (dp[i][j] != -1) return dp[i][j];
  ll ans = min(knapsack(i-1, j), w[i] + knapsack(i-1, j-v[i]));
  dp[i][j] = ans;
  return ans;
}

int main(void){
  
  ll N, W;
  IN(N);
  IN(W);
  REP(i, N) {
    IN(w[i]);
    IN(v[i]);
  }

  REP(i, 101) {
    REP(j, ARRAY) {
      dp[i][j] = -1;
    }
  }

  REP(i, ARRAY) {
    ll weight = knapsack(N-1, i);
    // DEBUG(N-1);
    // DEBUG(i);
    // DEBUG("=>");
    // DEBUG(weight);
    // LN();
    if (weight > W) {
      ret = i-1;
      break;
    }
  }

  PRINT(ret);

}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define endl '\n'
#define all(v) v.begin(), v.end()
#define pb push_back
#define ll long long
#define OO 0x3f3f3f3f
double EPS = 1e-12;
double INF = 1e100;
const int MAXN = 1e5 + 5;


int32_t main()
{
 	ll n, x;
 	ll ans = 0;
 	cin >> n;
 	vector<ll> vec, dp(n+2, 0); vec.pb(0);
 	for(int i = 0; i < n; i++) cin >> x, vec.pb(x);
	dp[2] = abs(vec[2] - vec[1]);
 	for(int i = 3; i <= n; i++)
 		dp[i] = min(abs(vec[i] - vec[i-1]) + dp[i-1], abs(vec[i] - vec[i-2]) + dp[i-2]);
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 2168
N, K = map(int, input().split())
D = list(map(int, input().split()))
UN = [i for i in range(10)]
for i in D:
    UN.remove(i)

n = str(N)
N_keta = len(n)

for i in n:
    if int(i) not in UN:
        break
else:
    print(N)
    exit()

ex_0 =  [i for i in UN if i > 0]

if N_keta == 1:
    if N < max(UN):
        _11 =[i for i in UN if i > N]
        print(min(_11))
    else:
        print(min(ex_0) * 10 + min(UN))

if N_keta == 2:
    if N < max(UN) * 11:
        for i in UN:
            for j in UN:
                _2 = i * 10 + j
                if  _2 > N:
                    print(_2)
                    exit()
    else:
        print(min(ex_0) * 100 + min(UN) * 11)

if N_keta == 3:
    if N < max(UN) * 111:
        for i in UN:
            for j in UN:
                 for k in UN:
                     _3 = i * 100 + j * 10 + k
                     if _3 > N:
                         print(_3)
                         exit()
    else:
        print(min(ex_0) * 1000 + min(UN) * 111)

if N_keta == 4:
    if N < max(UN) * 1111:
        _4 = [i for i in UN if i >= int(n[0])]
        for i in _4:
            for j in UN:
                for k in UN:
                    for l in UN:
                        _41 = i * 1000 + j * 100 + k * 10 + l
                        if _41 > N:
                            print(_41)
                            exit()
    else:
        print(min(ex_0) * 10000 + min(UN) * 1111)


Measured memory_bytes: 3064
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL fac[SIZE],inv[SIZE];
LL mypow(LL x,LL y){
    LL res=1;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
LL C(int x,int y){
    if(y<0||y>x)return 0;
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void build(){
    assert(MOD>=SIZE);
    fac[0]=1;
    REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD;
    inv[SIZE-1]=mypow(fac[SIZE-1],MOD-2);
    for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}
//TODO: build();
int main(){
    build();
    int X,Y;
    R(X,Y);
    if(X>2*Y||Y>2*X||(X+Y)%3)W(0);
    else{
        int v=(X+Y)/3;
        W(C(v,X-v));
    }
    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
	long long int tmp;
	long long int r = 1;
	if (b > a) {
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0) {


		a = b;
		b = r;
		r = a % b;

	}
	return b;
}


int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m,v[200005],c[200005];
	long long dp[200005] = {}, dp2[200005] = {}, res = 0, cou = 0, memo, memo2;
	string str, str2;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> v[i];
		
	}
	memo = v[0];
	memo2 = v[1];
	if (n == 2) {
		cout << max(v[0], v[1]);
		return 0;
	}

	for (int i = 0; i < n; i++) {
		if (v[i] == memo) {
			cou++;
		}

	}

	if (cou== n-1) {
		cout << v[0];
		return 0;
	}
	cou = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] == memo2) {
			cou++;
		}

	}

	if (cou == n - 1) {
		cout << v[1];
		return 0;
	}


	dp[0] = v[0];
	dp2[n - 1] = v[n - 1];
	for (int i = 1; i < n; i++) {
		dp[i] = gcd(dp[i - 1], v[i]);
		dp2[n - i - 1] = gcd(dp2[n - i], v[n - i-1]);
	}
	res = max(dp[n-2],dp2[1]);
	for (int i = 0; i < n-2; i++) {
		res = max(gcd(dp[i], dp2[i + 2]),res);
	}



	cout << res;
}


Measured memory_bytes: 4992
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

if N <= 999
  puts 'ABC'
else
  puts 'ABD'
end


Measured memory_bytes: 14508
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin>>n>>k;
  set<int> d;
  rep(i,n)
  {
    int a;
    cin>>a;
    d.insert(a);
  }
  auto ok=[&](int n){while(n>0){if(d.count(n%10))return 0;n/=10;}return 1;};
  while(!ok(n))n++;
  cout<<n<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>

using namespace std;


int main() {
	long a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) {
		cout << "Zero";
	}
	else if (a > 0) {
		cout << "Positive";
	}
	else {
		long r = b - a;
		r = r % 2;
		if (r == 0) {
			cout << "Negative";
		}
		else {
			cout << "Positive";
		}
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

ll modinv(ll a){
    ll b=MOD-2, r=1;
    while(b){
        if(b&1)r=r*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return r;
}

int k,m,n;

int main(){
    scanf("%d%d%d",&n,&m,&k);
    ll iv = modinv((ll)n*m * (n*m-1) % MOD);
    ll ans = 0;
    REP(sax,n)REP(say,m){
        if(sax==0 && say==0)continue;
        ll pr = (ll)k*(k-1)%MOD*iv%MOD;
        pr = pr * (n-sax) % MOD * (m-say) % MOD;
        pr = pr * (sax==0 || say==0 ? 1 : 2) % MOD;
        ans += pr * (sax+say) % MOD;
        ans %= MOD;
    }
    // REP(x,n)REP(y,m)REP(xx,n)REP(yy,m){
    //     if(x*m+y >= xx*m+yy)continue;
    //     ll pr = (ll)k*(k-1)%MOD*iv%MOD;
    //     ans += pr * (abs(xx-x) + abs(yy-y)) % MOD;
    //     ans %= MOD;
    // }
    ll co = 1;
    REP(i,k)co = co * (i+1) % MOD;
    co = modinv(co);
    REP(i,k)co = co * (n*m-i) % MOD;
    printf("%lld\n",ans*co%MOD);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int gcd(int a, int b){
	if( b == 0 )
		return a;
	else
		return gcd( b , a % b );
}
struct Rational{
	int p,q;
	Rational():p(1),q(1){}
	Rational(int p, int q):p(p),q(q){}
	Rational operator+(const Rational &t){
		Rational r;
		r.p = p * t.q + t.p * q;
		r.q = q*t.q;
		r.Simplify();
		return r;
	}
	Rational operator*(const Rational &t){
		Rational r(p*t.p,q*t.q);
		return r.Simplify();
	}
	bool operator<(const Rational &t){
		return p * t.q - q * t.p < 0;
	}
	bool operator==(const Rational &t){
		return p == t.p && q == t.q;
	}
	Rational Simplify(){
		int r = gcd(p,q);
		p /= r;
		q /= r;
		return *this;
	}
};
ostream &operator<<(ostream &os, const Rational &r){
	os << r.p << '/' << r.q;
	return os;
}
struct Denoms{
	vector<int> v;
	Denoms():product(1){}
	void push(int a){
		product *= a;
		v.push_back( a );
	}
	void pop(){
		product /= v[v.size()-1];
		v.pop_back();
	}
	int product;
};
ostream &operator<<(ostream &os, const Denoms &v){
	for(unsigned int i = 0; i < v.v.size(); ++i)
		os << v.v[i] << ' ';
	os << "PRODUCT: " << v.product;
	return os;
}
int ans;
void solve(Rational target, int a, int n, int denom_now, Rational now, Denoms &v){
	now.Simplify();
	//cout << "TARGET :" << target << " NOW: " << now << endl;
	if( target == now ){
		/*cout << "N: "<< n << "NOW: " << now << endl;
		cout << v << "\n--------------------------------" << endl;*/
		ans++;
	}
	if( n == 0 )
		return ;
	for(int i = denom_now + 1; i <= a / v.product + 1; ++i){
		if( (now + Rational(n,1) * Rational(1,i)).Simplify() < target ){
			break;
		}
		v.push( i );
		if( v.product > a || target < (now + Rational(1,i)).Simplify() ){
			v.pop();
			continue;
		}
		solve( target, a, n - 1, i - 1, now + Rational(1,i), v );
		v.pop();
	}
}
int main(){
	while(true){
		int p,q;
		int a,n;
		Rational target;
		Denoms tmp;
		
		scanf("%d%d%d%d", &p, &q, &a, &n);
		
		if( !(p||q||a||n) ) break;
		
		target.p = p;
		target.q = q;
		target.Simplify();
		ans = 0;
		solve( target, a, n, 0, Rational(0,1), tmp);
		
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 920
/**
 *    author: codeforces-yuhongtao 
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;
const int mod=1e9+7;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt[205];
//pair<int,int> p;
//map<string,int> m;
int main(){
	ios::sync_with_stdio(false);
	iint a,b,c;
	cin>>a>>b>>c;
	iint x = min(b-1,c);
	iint ans = floor(a*x/b);
	cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (233)
#define P ()
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,a[N];
LL dfs(int l,int r,LL wl,LL wr){
	if(l+1==r)return 0; LL mn=1e18;
	for(int i=l+1;i<r;i++)mn=min(mn,dfs(l,i,wl,wl+wr)+dfs(i,r,wl+wr,wr)+(wl+wr)*a[i]);
	return mn;
}
int main(){
	read(n);
	for(int i=1;i<=n;i++)read(a[i]);
	printf("%lld\n",dfs(1,n,1,1)+a[1]+a[n]);
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, m;
    cin >> n >> m;
    vector<bool> acf(n, false);
    vector<int> pcnt(n, 0);

    lli ac = 0, pn = 0;
    rep(i, m){
        int p;
        string s;
        cin >> p >> s;

        if(s == "AC"){
            // AC
            if(!acf[p]){
                ac++;
                acf[p] = true;
            }
        }
        else{
            // WA
            if(!acf[p]){
                pcnt[p]++;
            }
        }
    }
    repf(i, n){
        if(acf[i]) pn += pcnt[i];
    }
    cout << ac << " " << pn << endl;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, i, j, k, sum = 0;
	
	cin>>n;
	
	if (n == 3)
	{
		cout<<"2 5 63\n";
		return 0;
	}
	
	for (i = 2; n > 2; ++i)
	{
		if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0)
		{
			cout<<i<<' ';
			sum += i;
			sum %= 30;
			--n;
		}
	}
	for (k = i + 2; ; ++k) for (j = i + 1; j < k; ++j) if ((j % 2 == 0 || j % 3 == 0 || j % 5 == 0) && (k % 2 == 0 || k % 3 == 0 || k % 5 == 0) && (sum + j + k) % 30 == 0)
	{
		cout<<j<<' '<<k<<'\n';
		return 0;
	}
	assert(false);
}


Measured memory_bytes: 384
using namespace std;

#define visual

#ifdef visual
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>
#endif
#ifndef visual
#include <bits/stdc++.h>
#endif

typedef long long ll;


struct twosat {

	vector<bool> vis = {};
	vector<int> cc, L;
	vector<vector<int> > G;
	vector<bool> ans;
	int n, cz;

	void visit(int v) {
		if (vis[v]) return;
		vis[v] = 1;
		for (auto u : G[v])
			visit(u);
		L.push_back(v);
	}

	inline void assign(int v, int r) {
		if (cc[v]) return;
		cc[v] = r;
		for (auto u : G[v ^ 1])
			assign(u ^ 1, r);
		ans[v / 2] = v & 1;
	}

	twosat(int n) { this->n = n, cz = 0, G.resize(2 * n), ans.resize(n), vis.resize(2 * n), cc.resize(2 * n); }

	inline void either(int x1, bool v1, int x2, bool v2) {
		x1 = x1 << 1 | v1, x2 = x2 << 1 | v2;
		G[x1 ^ 1].push_back(x2);
		G[x2 ^ 1].push_back(x1);
	}

	inline void implies(int x1, bool v1, int x2, bool v2) {
		either(x1, false, x2, true);
	}

	vector<bool> solve() {
		int n = G.size() / 2;


		for (int i = 0; i < 2 * n; ++i)
			visit(i);
		vis = vector<bool>(n);
		for (int i = L.size() - 1; i >= 0; --i) {
			if (!cc[L[i]])
				assign(L[i], ++cz);
		}
		for (int i = 0; i < n; ++i)
			if (cc[2 * i] == cc[2 * i + 1])
				return {};
		return ans;
	}

};


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

    int n, d;
	cin >> n >> d;
	twosat t(n);

	vector<pair<int, int>> v;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		v.push_back({x, y});
	}
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			
			if (abs(v[i].first - v[j].first) < d) {
				t.either(i, true, j, true);
			}
			if (abs(v[i].second - v[j].first) < d) {
				t.either(i, false, j, true);
			}
			if (abs(v[i].first - v[j].second) < d) {
				t.either(i, true, j, false);
			}
			if (abs(v[i].second - v[j].second) < d) {
				t.either(i, false, j, false);
			}
		}
	}
	auto ans = t.solve();
	if (!ans.size()) {
		cout << "No";
		return 0;
	}
	cout << "Yes" << endl;
	for (int i = 0; i < ans.size(); i++) {
		if(ans[i]) cout << v[i].second << endl;
		if (!ans[i]) cout << v[i].first << endl;
	}


}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  string res = "";
  for (char c : s) {
    if (c == 'B') {
      if (!res.empty()) {
        res.pop_back();
      }
    } else {
      res.push_back(c);
    }
  }
  cout << res << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  if (s == "SUN"){
    cout << 7 << endl;
  }
  if (s == "MON"){
    cout << 6 << endl;
  }
  if (s == "TUE"){
    cout << 5 << endl;
  }
  if (s == "WED"){
    cout << 4 << endl;
  }
  if (s == "THU"){
    cout << 3 << endl;
  }
  if (s == "FRI"){
    cout << 2 << endl;
  }
  if (s == "SAT"){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3576
// #include "frog_2.h"
#include <iostream>
#include <limits>
#include <vector>

int min_jump_cost(const std::vector<int>& stones, size_t max_jump)
{
    std::vector<int> dp(stones.size(), std::numeric_limits<int>::max());
    dp.front() = 0;

    for (size_t i = 0; i < stones.size(); ++i) {
        for (size_t dist = i + 1; dist - i <= max_jump && dist < stones.size();
             ++dist) {
            dp[dist] =
                std::min(dp[dist], dp[i] + std::abs(stones[i] - stones[dist]));
        }
    }
    return dp.back();
}

int main(int argc, char* argv[])
{
    size_t n, k;
    std::cin >> n >> k;
    std::vector<int> stones(n);
    for (size_t i = 0; i < n; ++i) {
        int height;
        std::cin >> height;
        stones[i] = height;
    }
    std::cout << min_jump_cost(stones, k) << std::endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
   int n,m;
   cin>>n>>m;
   vector<pair<int,int> > v,v1; 
   for(int i=1;i<=n;i++)
   {  
    int a,b;
    cin>>a>>b;
      v.push_back(make_pair(a,b));
   }
   for(int i=1;i<=m;i++)
   {
    int a,b;
    cin>>a>>b;
    v1.push_back(make_pair(a,b));
   }
   for(int i=0;i<n;i++)
   { 
          int cmin=INT_MAX;
          int idx;
         for(int j=0;j<m;j++)
         {
            int diff=abs(v1[j].first - v[i].first) + abs(v1[j].second - v[i].second);
            if(cmin>diff)
            {
                cmin=diff;
                idx=j+1;
            }
         }
         cout<<idx<<endl;
   }




 return 0;
}








Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define pb push_back


int N, M, K;
P f, b;
vector<P> friends(100010);
vector<int> f_degree(100010, 0);  //各頂点の次数
vector<P> block(100010);
vector<int> b_degree(100010, 0);  //同一グラフ内のブロック人数


struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

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

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

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

};

int main(){
    cin >> N >> M >> K;
    UnionFind uf(N+1);  //ユニオンファインド作成

    for(int i = 0; i < M; i++){ 
        cin >> f.first >> f.second; 
        friends[i] = f;
        ++f_degree[f.first]; ++f_degree[f.second];
        uf.merge(f.first, f.second);  //first-secondの辺を作成
    }

    for(int i = 0; i < K; i++){ 
        cin >> b.first >> b.second; 
        block[i] = b;
        if(uf.issame(b.first,b.second)){ ++b_degree[b.first]; ++b_degree[b.second]; }
    }

    /*iの友達候補=(i含グラフサイズ)-1-(i次数)-(i含グラフ内ブロック人数)*/
    for(int v = 1; v <= N; v++) cout << uf.size(v)-1-f_degree[v]-b_degree[v] << " ";
    cout << endl;

    return 0;

}

    

Measured memory_bytes: 5880
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define kakkei vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{return f<p.f;};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{
		return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);
	};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
ten shaei(ten p,chokusen l){
	v2 a=l.p2-l.p1;
	return l.p1+a*a.naiseki(p-l.p1)/a.abs2();
}
void solve(){
	chokusen l;
	cin>>l.p1.x>>l.p1.y>>l.p2.x>>l.p2.y;
	ll n;cin>>n;
	cout<<sep(10);
	rep(i,0,n){
		ten p;cin>>p.x>>p.y;
		ten k=shaei(p,l);
		cout<<k.x<<' '<<k.y<<kai;
	}
}


Measured memory_bytes: 3312
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    int min = 10;
    int A = 0;
    int B = 0;
    for(int i = 1; i <= Math.sqrt(N); i++){
      if(N % i == 0){
        A = i;
        B = (int)(N/i);
      }
    }
    System.out.println(func(A, B));
  }
  public static int func(int A, int B){
    int C = (A > B ? A : B);
    int count = 0;
    while(C > 0){
      C /= 10;
      count++;
    }
    return count;
  }
}

Measured memory_bytes: 22608
#include<stdio.h>

int main(void)
{
    int a;
    int b;
    int c;

    scanf("%d%d%d",&a,&b,&c);

    if ((a < b) && (b < c)) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
set<int > se;

int main(){
	int a;
	cin >> a;
	map<string, int> mp;
	while(a--){
		string temp;
		cin >> temp;
		mp[temp]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3636
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
  ll n;
  cin >> n;
  ll a = 26;
  string s = "";
  while(n) {
    n--;
    s += (char)((n%26)+'a');
    n /= a;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 3600
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT8 S[1000000];
	SINT32 ANS = 1000000001;

	cin >> N;
	cin >> S;

	vector<SINT32> SDATA(N);
	vector<SINT32> KDATA(N);
	vector<SINT32> henka(N);
	if (S[0] == '.') {
		SDATA[0] = 1;
	} else {
		KDATA[0] = 1;
	}
	henka[0] = 0;
	
	for (SINT32 i = 1; i < N; i++) {
		if (S[i] == '.') {
			SDATA[i] = 1 + SDATA[i-1];
			KDATA[i] = KDATA[i-1];
		} else {
			SDATA[i] = SDATA[i-1];
			KDATA[i] = 1 + KDATA[i-1];
		}
		if (S[i] != S[i-1]) {
			henka[i-1] = 1;
		}
	}

/*
	for (SINT32 i = 0; i < N; i++) {
		cout << SDATA[i] << " ";
	}
	cout << endl;
	for (SINT32 i = 0; i < N; i++) {
		cout << KDATA[i] << " ";
	}
	cout << endl;
	*/


	for (SINT32 i = 0; i < N; i++) {
		SINT32 BUF = MIN(KDATA[N-1],SDATA[N-1]); 
		if (henka[i] == 1) {
			BUF = MIN(BUF,KDATA[i] + SDATA[N-1] - SDATA[i]);
			BUF = MIN(BUF,KDATA[i] + KDATA[N-1] - KDATA[i]);
			BUF = MIN(BUF,SDATA[i] + SDATA[N-1] - SDATA[i]);

			/*
			if (SDATA[i] >= KDATA[i]) {
				if (SDATA[N-1] - SDATA[i] <= KDATA[N-1] - KDATA[i]) {
					BUF = KDATA[i] + SDATA[N-1] - SDATA[i];
				} else {
					BUF = KDATA[i] + KDATA[N-1] - KDATA[i];
				}
			} else {
				if (SDATA[N-1] - SDATA[i] <= KDATA[N-1] - KDATA[i]) {
					BUF = SDATA[i] + SDATA[N-1] - SDATA[i];
				} else {
					BUF = MIN(KDATA[N-1],SDATA[N-1]);
				}				
			}
			*/
		}
		ANS = MIN(ANS,BUF);
//		cout << ANS << endl;
	}

	

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

Measured memory_bytes: 2816
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e9
using namespace std;
typedef long long ll;

ll min(ll a,ll b){
	if(a>b)return b;
	else return a;
}


int main(){
	int n,m,a,b,cost,time,l,p,q,r;
	while(cin>>n>>m,n||m){
		ll mt[m][m],mc[m][m];
		rep(i,m)rep(j,m)mt[i][j]=mc[i][j]=INF;
		rep(i,n){
			cin>>a>>b>>cost>>time;
			mt[a-1][b-1]=mt[b-1][a-1]=time;
			mc[a-1][b-1]=mc[b-1][a-1]=cost;
		}
		rep(k,m){
			rep(i,m){
				rep(j,m){
					mt[i][j]=min(mt[i][j],mt[i][k]+mt[k][j]);
					mc[i][j]=min(mc[i][j],mc[i][k]+mc[k][j]);
				}
			}
		}
		cin>>l;
		rep(i,l){
			cin>>p>>q>>r;
			if(r==0)cout<<mc[p-1][q-1]<<endl;
			else cout<<mt[p-1][q-1]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1312
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

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

typedef vector<vector<int>> Graph;

vector<long long>point;
void dfs(const Graph& g, int a, int b, long long num) {
	point[a] = num;
	
	for (auto n : g[a]) {
		if (n == b)
			continue;
		dfs(g, n, a, num + point[n]);
	}
}

int main() {
	int n, q;
	cin >> n >> q;
	Graph g(n);

	point.assign(n, 0);

	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		point[a] += b;
	}

	dfs(g, 0, -1, point[0]);

	rep(i, n)
		cout << point[i] << endl;
	
	return 0;
}

Measured memory_bytes: 27392
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();

        String[][] grid = new String[H][W];
        String line = "";
        for (int i = 0; i < H; i++) {
            line = sc.next();
            for (int j = 0; j < W; j++) {
                grid[i] = line.split("");
            }
        }
        sc.close();

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (".".equals(grid[i][j])) {
                    grid[i][j] = "0";
                } else if ("#".equals(grid[i][j])) {
                    for (int k = i - 1; k <= i + 1; k++) {
                        for (int l = j - 1; l <= j + 1; l++) {
                            if (k < 0 || k >= H || l < 0 || l >= W) {
                                continue;
                            }

                            switch (grid[k][l]) {
                            case "#":
                                break;
                            case ".":
                                grid[k][l] = "1";
                                break;
                            default:
                                grid[k][l] = Integer.toString(Integer.parseInt(grid[k][l]) + 1);
                            }
                        }
                    }
                }
            }
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                System.out.print(grid[i][j]);
            }
            System.out.println();
        }

    }
}

Measured memory_bytes: 35924
n,l=map(int,input().split())
s=[]
i=0
while i!=n:
    x=[abs(l+i),l+i]
    s.append(x)
    i+=1
s.sort()
i=1
ans=0
while i!=n:
    ans+=s[i][1]
    i+=1
#print(s)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    ll n,k;   
    cin >> n >> k;
    if(k==1){
        cout << 0 << endl;
        return 0;
    }
    vector<ll>a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
        a[i] %= k;
    }
    vector<ll>s(n+1);
    rep(i,n){
        s[i+1] = s[i]+ a[i];
        s[i+1] %= k;
    }
    map<ll,vector<ll> > mp;
    rep(i,n+1){
        mp[s[i]].push_back(i);
    }
    ll sm = 0;
    for(auto &a:mp){
        for(int i=0;i<a.second.size();i++){
            int x = a.second[i];
            sm += (ll)(upper_bound(a.second.begin(),a.second.end(),x+k-1) - (a.second.begin()+i)-1);
            //cerr << sm <<endl;
        }
        // cerr << a.first << " " << sm << endl;
        // for(auto x:a.second){
        //     cerr <<x << " " ;
        // }
        // cerr << endl;
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 25216
import math
n,d=[int(i) for i in input().split()]
x=[[int(i) for i in input().split()] for j in range(n)]
cnt=0
for i in range(n):
    for j in range(i+1,n):
        sum=0
        for k in range(d):
            sum+=abs(x[i][k]-x[j][k])**2
        if math.sqrt(sum)==int(math.sqrt(sum)):
            cnt+=1
print(cnt)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  for(int i=0;i<a;i++)
  if(!(s[i]>='0' && s[i]<='9'))
  {
    cout<<"No"; return 0;
  }
  if(s[a]!='-')
  {
    cout<<"No"; return 0;
  }
  for(int i=a+1;i<=a+b;i++)
  if(!(s[i]>='0' && s[i]<='9'))
  {
    cout<<"No"; return 0;
  }
  cout<<"Yes";
}


Measured memory_bytes: 256