akhauriyash/Code-Regression huggingface dataset:
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream cin("input.txt")
//#define of1 ofstream cout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,l;
	cin>>n>>l;
	ll val=-1;
	ll diff=INT_MAX;
	for(ll i=1;i<=n;i++)
	{
		if(abs(l-1+i)<diff)
		{
			diff=abs(l-1+i);
			val=i;
		}
	}
	ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        if(i==val)
            continue;
        ans+=(l+i-1);
    }
	cout<<ans;
    return 0;
}

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

long long int arr[200005];
long long int dp[200005];
vector<int> vec;

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

	unordered_map<int, int> mp; 

	dp[0] = 1;

	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}

	vec.push_back(-1);
	vec.push_back(arr[1]);

	for(int i=2;i<=n;i++)
	{
		if(arr[i]!=arr[i-1])
		{
			vec.push_back(arr[i]);
		}
	}

	for(int i=1;i<vec.size();i++)
	{
		dp[i] = dp[i-1];
		int val = vec[i];
		// cout<<val<<" "<<dp[i]<<" ";
		if(mp.find(val)!=mp.end())
		{
			int pos = mp[val];
			dp[i]+=dp[pos];
			dp[i] = dp[i]%MOD;
			// cout<<dp[i]<<" ";
		}
		
		mp[val] = i;
		
		// cout<<endl;
	}

	cout<<dp[vec.size()-1]<<endl;

	return 0;
}

Measured memory_bytes: 12440
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF (int)1e18

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

string str;
signed main() {
  IO;
  cin >> str;
  int n = str.size();
  for(int i = 0 ; i < n ; i++){
    if(str[i] == '?'){
      if(i - 1 > 0 && str[i - 1] == 'P') str[i] = 'D';
      else if(i + 1 < n && str[i + 1] == 'D') str[i] = 'P';
      else str[i] = 'D';
    }
  }
  cout << str << '\n';
  return 0;
}

Measured memory_bytes: 3784
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main () {
	ll a, b, x;
	cin >> a >> b >> x;

	if (a%x) {
		a += (x-(a%x));
	}
	if (b%x) {
		b -= (b%x);
	}

	ll ans = 0;
	if (a <= b) {
		ans = (b - a) / x + 1;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100

int min(int a, int b){ return a < b ? a : b; }

int main(){
	int i, j, k, l;
	int n, box[MAX+1], m[MAX+1][MAX+1];

	scanf("%d", &n);
	for ( i = 1; i <= n; i++ ){
  		scanf("%d %d", &box[i-1], &box[i]);
	}

	for ( i = 1; i <= n; i++ ) m[i][i] = 0;
	for ( l = 2; l <= n; l++ ){
		for ( i = 0; i <= n-l+1; i++ ){
			j = i+l-1;
			m[i][j] = (1<<21);
			for ( k = i; k <= j-1; k++ ){
				m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + box[i-1]*box[k]*box[j]);
			}
		}			
	}	

	printf("%d\n", m[1][n]);
  
	return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 555;
const int MX = 1000000000;

int A[MAX][MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n, m;
	int n1, m1;

	scanf("%d%d%d%d", &n, &m, &n1, &m1);

	if (n % n1 == 0 && m % m1 == 0)
	{
		cout<<"No"<<endl;
		return 0;
	}

	FOR (i, 0, n)
	{
		FOR (j, 0, m)
		{
			if ((i + 1) % n1 == 0 && (j + 1) % m1 == 0)
			{
				A[i][j] = -MX;
			}

			if (m % m1 != 0)
			{
				if ((i + 1) % n1 == 0 && j % m1 == 0) A[i][j] = MX - 1;
			}
			else
			{
				if (i % n1 == 0 && (j + 1) % m1 == 0) A[i][j] = MX - 1;
			}
		}
	}

	LL sum = 0;
	FOR (i, 0, n)
	{
		FOR (j, 0, m)
		{
			sum += A[i][j];
		}
	}


/*	FOR (i, 0, n)
	{
		FOR (j, 0, m)
		{
			printf("%d ", A[i][j]);
		}
		printf("\n");
	}*/\

	if (sum > 0)
	{
		printf("Yes\n");
		FOR (i, 0, n)
		{
			FOR (j, 0, m)
			{
				printf("%d ", A[i][j]);
			}
			printf("\n");
		}
	}
	else
	{
		printf("No\n");
	}
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<((f)?YES:NO)<<"\n";


int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    if(K==1){
        for (long long i = 1; i < N; i++) {
            judge(A[i]>A[i-1])
        }
        return 0;
    }
    vector<ll> v(N);
    vector<ll> w(N);
    v[0]=A[0];
    // if(A[0]==1) v[0]=0;
    for (long long i = 1; i < N; i++) {
        // if(A[i]==1){
        //     v[i]=v[i-1];
        //     continue;
        // }
        v[i]=v[i-1]+A[i];
        // if(i-K>=0){
        //     v[i]=v[i]-v[i-K];
        // }
    }
    // vout(v)
    w[K-1]=v[K-1];
    for (long long i = K; i < N; i++) {
        // v[i]=v[i]-v[i-K];
        w[i]=v[i]-v[i-K];
    }
    // vout(v)
    // vout(w)
    for (long long i = 0; i < N-K; i++) {
        // judge(v[K+i-1]<v[K+i])
        judge(w[K+i-1]<w[K+i])
    }
    return 0;
}


Measured memory_bytes: 8028
n = int(input())
t,x,y = [0]*(n+1),[0]*(n+1),[0]*(n+1)

for i in range(1,n+1):
    t[i],x[i],y[i] = map(int,input().split())

for i in range(1,n+1):
    cnt = (t[i]-t[i-1])-abs(x[i]-x[i-1])-abs(y[i]-y[i-1])
    if cnt>=0 and cnt%2==0:
        pass
    else:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 11636
import sys
r=sys.stdin.readline
N=int(r())
def md(x,y,a,b):
    return abs(x-a)+abs(y-b)
left_top=(0,0)
left_down=(0,0)
right_top=(0,0)
right_down=(0,0)
for i in range(N):
    x,y = map(int,r().split())
    if i==0:
        left_top=(x,y)
        left_down=(x,y)
        right_top=(x,y)
        right_down=(x,y)
    else:
        if md(0,0,left_down[0],left_down[1])>md(0,0,x,y):
            left_down=(x,y)
        if md(0,0,right_top[0],right_top[1])<md(0,0,x,y):
            right_top=(x,y)
        if right_down[0]-right_down[1]<x-y:
            right_down=(x,y)
        if left_top[1]-left_top[0]<y-x:
            left_top=(x,y)
a=md(left_down[0],left_down[1],right_top[0],right_top[1])
b=md(left_top[0],left_top[1],right_down[0],right_down[1])
print(max([a,b]))

Measured memory_bytes: 9292
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    string s; cin >> s;
    int cnt = 0;
    rep(i, 0, s.size()) if(s[i] == 'o') cnt++;
    cnt += 15 - s.size();
    if(cnt >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    char s[1002];
    int i,h,len,j,n,k;
        scanf(" %[^\n]", s);
    len=strlen(s);
    for(i=0;i<len;i++){
       if(i==0) {
           k = s[i];
           printf("%c",k);
       }
    }

        len=strlen(s);
        for(j=0;j<len;j++) {
            if (s[j] == ' ') {
                s[j] = s[j + 1];
            n=s[j];
            printf("%c", n);}
        }
printf("\n");
    return 0;
}


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

using namespace std;
using ll = long long;

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

bool solve(int A, int B, int C) {
  return A + B >= C;
}

int main(int argc, char* argv[]) {
  int A, B, C;
  cin >> A >> B >> C;
  cout << (solve(A, B, C) ? "Yes" : "No") << '\n';
  return 0;
}

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

class FC{
public:
    int p[31];
    int n;
        
    bool is_over(){
     	return p[1]==p[2] && p[2]==p[3] && p[3]==p[4] && p[4]==p[5] &&
        	p[5]==p[6] && p[6]==p[7] && p[7]==p[8] && p[8]==p[9] &&
        	p[10]==p[11] && p[11]==p[12] &&
      		p[13]==p[14] && p[14]==p[15] &&
      		p[16]==p[17] && p[17]==p[18] &&
      		p[19]==p[20] && p[20]==p[21];
     }
          
    void rot1()
    {
        swap(p[7], p[22]);  swap(p[8], p[23]);  swap(p[9], p[24]);
        swap(p[10], p[12]);  swap(p[13], p[18]);
    }
 
    void rot2()
    {
        swap(p[1], p[28]);  swap(p[2], p[29]);  swap(p[3], p[30]);
        swap(p[19], p[21]);  swap(p[15], p[16]);
    }
 
    void rot3()
    {
        swap(p[1], p[24]);  swap(p[4], p[27]);  swap(p[7], p[30]);
        swap(p[16], p[18]);  swap(p[10], p[21]);
    }
 
    void rot4()
    {
        swap(p[3], p[22]);  swap(p[6], p[25]);  swap(p[9], p[28]);
        swap(p[13], p[15]);  swap(p[12], p[19]);
    }
};
 
int main()
{
    int N;
    cin >> N;
 
    for(int i=0; i<N; i++){
        FC now;
        for(int j=1; j<=30; j++){
            cin >> now.p[j];
        }
        now.n = 0;
 
        queue<FC> que;
        que.push(now);
 
        while(!que.empty()){
            now = que.front();
            que.pop();
 
            if(now.is_over()){
                cout << now.n << endl;
                break;
            }
 
            FC nex1 = now;  nex1.rot1();  nex1.n++;  que.push(nex1);
            FC nex2 = now;  nex2.rot2();  nex2.n++;  que.push(nex2);
            FC nex3 = now;  nex3.rot3();  nex3.n++;  que.push(nex3);
            FC nex4 = now;  nex4.rot4();  nex4.n++;  que.push(nex4);
        }
    }
 
    return 0;
}  

Measured memory_bytes: 13876
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long unsigned x,y,anti_rem;
    cin>>x>>y;
    if(x%y==0)
    {
        cout<<0<<endl;
    }
    else if(x<y){
        anti_rem=labs(x-y);
        cout<<min(x,anti_rem)<<endl;
    }
    else
    {
            x=x%y;
        long long unsigned xx=labs(x-y);
        cout<<min(x,xx)<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long X = nx[1];
        //ちゅーごくじょーよてーり
        //オーダーによってSの終端が決定する
        //まず影響するのは降順のみなことは自明に分かって、
        //で、「次」を選ぶことができる順番は
        //「確率」「期待値」
        //aを取り除いた場合、その後に適用できるのはそれ以前全て。

        int[] s = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();

        long[] dp = new long[X + 1];
        dp[X] = 1;
        int remain = s.Length - 1;
        foreach (var mod in s)
        {
            for (int i = 0; i < dp.Length; i++)
            {
                var tem = dp[i];
                dp[i % mod] += tem;
                dp[i % mod] %= 1000000007;
                dp[i] += tem * (remain - 1);
                dp[i] %= 1000000007;
            }
            remain--;
        }

        ModInt res = 0;
        for (int i = 0; i < dp.Length; i++)
        {
            res += dp[i] * i;
        }
        Console.WriteLine(res);
    }
}

struct ModInt
{
    const int MOD = 1000000007;
    long Data;
    public ModInt(long data) { Data = data; Eval(); }

    private long Eval() => (Data %= MOD) < 0 ? Data += MOD : Data;
    public static implicit operator long(ModInt modInt) => modInt.Eval();
    public static implicit operator ModInt(long val) => new ModInt(val);
    public static ModInt operator +(ModInt a, ModInt b) => new ModInt(a.Eval() + b.Eval());
    public static ModInt operator -(ModInt a, ModInt b) => new ModInt(a.Eval() - b.Eval());
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt(a.Eval() * b.Eval());
    public static ModInt operator /(ModInt a, ModInt b) => a * Power(b.Eval(), MOD - 2);

    public override string ToString() => Data.ToString();

    static ModInt Power(ModInt n, long m)
    {
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= n;
            n *= n;
            m >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 13920
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b = readline().split()

    if a == b:
        print('H')
    else:
        print('D')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8828
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N;
	static int T;


	public static void main(String[] args) {
		N = sc.nextInt();
		T = sc.nextInt();

		int min = Integer.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			int c = sc.nextInt();
			int t = sc.nextInt();

			if (t <= T) {
				min = Math.min(min, c);
			}
		}

		System.out.println(min == Integer.MAX_VALUE ? "TLE" : min);
	}

}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

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

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

vector <P> p;

struct UnionFind {
    //number of parents(par[i] = i => root)
    vector <int> par;
    //rank of tree
    vector <int> rank;

    UnionFind(int n) : par(n), rank(n, 1) {
        //initialize
        rep(n, i) par[i] = i;
    }

    //find root (keiroasshuku at the same time)
    int root(int x){
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    //unite
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) swap(x, y);
        par[x] = y;
        if (rank[x] == rank[y]) rank[y]++;
    }

    //same tree?
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

struct Edge
{
  int from, to; ll cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

struct Kruskal
{
    int V;  // number of nodes
    vector<Edge> edges;

    void input(){
        cin >> V;
        rep(V, i) {
            ll x, y;
            scanf("%lld %lld\n", &x, &y);
            p.pb(P(llP(x, y), i));
        }
        sort(all(p));
        rep(V-1, i) {
            Edge e = {p[i].second, p[i+1].second, min(abs(p[i].first.first-p[i+1].first.first), abs(p[i].first.second-p[i+1].first.second))};
            edges.pb(e);
        }
        rep(V, i) swap(p[i].first.first, p[i].first.second);
        sort(all(p));
        rep(V-1, i) {
            Edge e = {p[i].second, p[i+1].second, min(abs(p[i].first.first-p[i+1].first.first), abs(p[i].first.second-p[i+1].first.second))};
            edges.pb(e);
        }
    }

    // グラフが非連結のときは最小全域森のコストの和となる
    ll kruskal() {
        //init
        UnionFind uf(V);
        sort(all(edges));
        ll min_cost = 0LL;

        for (Edge e : edges) {
            if (!uf.same(e.from, e.to)) {
                min_cost += e.cost;
                uf.unite(e.from, e.to);
            }
        }
        return min_cost;
    }
};


void solve(void){
    Kruskal k;
    k.input();
    cout << k.kruskal() << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 10608
//https://atcoder.jp/contests/abc117/tasks/abc117_b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};


int main(){
    int N;
    cin>>N;
    vector<int> L(N);
    cin>>L;
    if(2**max_element(ALL(L))<accumulate(ALL(L),0)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[])
{

    // insert code here...
    int n;
    std::cin >> n;
    long int min = 1000001;
    long int max = -1000001;
    long long int sum = 0;
    
    for (int i=0; i<n; i++){
        int val;
        std::cin >> val;
        if (min > val){
            min = val;
        }
        if (max < val){
            max = val;
        }
        sum += val;
    }
    std::cout << min << " " << max << " " << sum << std::endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define double long double

int n,a[110],ans;
bool dp[110][10010];

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

void solve(){
	dp[0][0]=true;
	for(int i=0;i<n;i++){
		for(int j=0;j<=10000;j++){
			if(!dp[i][j])continue;
			dp[i+1][j]=true;
			dp[i+1][j+a[i]]=true;
		}
	}
	for(int i=0;i<10000;i++){
		if(dp[n][i]&&i%2==0)ans=i/2;
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}


Measured memory_bytes: 3736
tot = 0
m = 0
for i in range(5):
    s = int(input())
    if s % 10 == 0:
        rem = 0
    else:
        rem = s%10 - 10
        s = 10*(s//10 + 1)
    m = min(m, rem)
    tot += s

print(tot+m)


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

int main(){
	int n,a,b,c;
	cin >> n >> a >> b >> c;
	vector<string> q(n);
	for(int i=0; i<n; i++){
		cin >> q[i];
	}

	string ans = "";
	for(int i=0; i<n; i++){
		int &x = (q[i]=="AB")?a: (q[i]=="BC")?b: a;
		int &y = (q[i]=="AB")?b: (q[i]=="BC")?c: c;
		if(x==0 and y==0){
			cout << "No" << endl;
			return 0;
		}
		if(x==1 and y==1 and i<n-1){
			int &xx = (q[i+1]=="AB")?a: (q[i+1]=="BC")?b: c;
			int &yy = (q[i+1]=="AB")?b: (q[i+1]=="BC")?c: a;
			x++;
			y--;
			if(xx==0 and yy==0){
				x-=2;
				y+=2;
				ans += q[i][1];
			}else{
				ans += q[i][0];
			}
		}else if(x < y){
			ans += q[i][0];
			x++;
			y--;
		}else{
			ans += q[i][1];
			y++;
			x--;
		}
	}
	cout << "Yes" << endl;
	for(char c: ans){
		cout << c << endl;
	}
	return 0;
}


Measured memory_bytes: 6692
n=int(input())
a=sorted(list(map(int,input().split())))
d=[1]*(a[-1]+1)
for i in a:
  if d[i]==1:
    for j in range(a[-1]//i):
      d[i*(j+1)]=0
    d[i]=1
dic={}
for i in a:
  if i not in dic:
    dic[i]=1
  else:
    d[i]=0
ans=0
for i in a:
  if d[i]==1:
    ans+=1
print(ans)

Measured memory_bytes: 43348
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top,S[1000];

void push(int x){
	S[++top]=x;
}

int pop(){
	top--;
	return S[top+1];
}

int main(void){
	int a,b;
	top=0;
	char s[100];
	
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}


Measured memory_bytes: 2092
def triangle?(a, b, c)
  a <= b + c && b <= c + a && c <= a + b
end

def calc(rear, front, west, east, north, south, best)
  path = ''
  loop do
    a = rear + front
    b = west + east
    c = north + south

    return path if a + b + c == 0

    f = triangle?(a, b, c)
    if east > 0 && (f || triangle?(b - 1, c, a))
      rear, front, west, east = east - 1, west, rear, front
      y = 'E'
    elsif north > 0 && (f || triangle?(c - 1, a, b))
      rear, front, north, south = north - 1, south, front, rear
      y = 'N'
    elsif south > 0 && (f || triangle?(c - 1, a, b))
      rear, front, north, south = south - 1, north, rear, front
      y = 'S'
    elsif west > 0 && (f || triangle?(b - 1, c, a))
      rear, front, west, east = west - 1, east, front, rear
      y = 'W'
    else
      throw 'error'
    end
    
    if best
      x = best[path.size]
      return best if x < y
      best = nil if x > y
    end
    path << y  
  end
end

def find(target)
  best = nil
  target.permutation(6).to_a.uniq.each do |rear, front, west, east, north, south|
    a = rear + front
    b = west + east
    c = north + south
    if triangle?(a, b, c) || triangle?(a + 1, b, c)
      best = calc(rear, front, west, east, north, south, best)
    end
  end
  best
end

loop do
  target = gets.split.map!(&:to_i)
  break if target.max == 0
  p, q = gets.split.map!(&:to_i)
  result = find(target)
  puts result ? result[p-1...q] : 'impossible'
end

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

int main(void){
    int N,K,sum=0;
    cin>>N>>K;
    vector<int> l(N);
    for(int i=0;i<N;i++)
        cin>>l[i];

    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    for(int i=0;i<K;i++)
        sum+=l[i];
    cout<<sum<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  if (N == 3) return cout << "YES" << "\n", 0;
  if (N == 5) return cout << "YES" << "\n", 0;
  if (N == 7) return cout << "YES" << "\n", 0;
  cout << "NO" << "\n";
}

Measured memory_bytes: 256
import math
class MathAlgo(object):

    @classmethod
    def gcd(cls, a, b):
        if b == 0:
            return a
        else:
            return cls.gcd(b, a%b)

    @classmethod
    def lcm(cls, a, b):
        return a // cls.gcd(a, b) * b

N = int(input())
ans = int(input())
for i in range(N-1):
    ans = MathAlgo.lcm(ans, int(input()))
print(ans)


Measured memory_bytes: 3060
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;
int dp[100007];
int main()
{
    int n,k,i,j;
    cin>>n>>k;
    int arr[n];
    for(i=0;i<n;i++){cin>>arr[i];}
    for(i=0;i<=k;i++){dp[i]=0;}
    for(i=arr[0];i<=k;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i>=arr[j]&&dp[i-arr[j]]==0){dp[i]=1;break;}
            else if(i>=arr[j]){;}
            else{break;}
        }
    }
    if(dp[k]){cout<<"First";}
    else{cout<<"Second";}
    return 0;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

int main(){
  int n,m;cin >> n >> m;
  vi C(n);

  rep(i, 2*m){
    int x; cin >> x; x--;
    C[x]++;
  }

  bool ok = true;
  rep(i, n){
    if(C[i]%2 == 1) ok = false;
  }

  std::cout << (ok ? "YES" : "NO") << '\n';
}


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

typedef unsigned long long int lli;

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

    vector<char> v;

    lli n;
    cin >> n;

    if(n <= 26)
    {
        if(n != 26)
        {
            cout << (char)('a' + n - 1) << endl;
        }
        else
        {
            cout << 'z' << endl;
        }
        return 0;
    }
    else
    {
        while(n>0)
        {
            int rem = n%26;
            if(rem == 0)
            {
                v.push_back('z');
                n--;
            }
            else
            {
                char ch = (char)('a' + rem - 1);
                v.push_back(ch);
            }
            n = n/26;
        }
    }


    for(int i = v.size() - 1; i >= 0 ; i--)
    {
        cout << v[i];
    }
}


Measured memory_bytes: 3632
#include <cstdio>

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

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

signed main() {
  int N = rint();
  wint(N * (N - 1) / 2);
  return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
l = [-1]*m
def root(a):
    if l[a] < 0:return a
    l[a] = root(l[a])
    return l[a]
def unite(a,b):
    ra, rb = root(a), root(b)
    if ra == rb:
        return
    if l[ra] > l[rb]:
        ra, rb = rb, ra
    l[ra] += l[rb]
    l[rb] = ra

d = set()
for i in range(n):
    _, *k = list(map(int, input().split()))
    from_ = k[0]-1
    if from_ not in d:
        d.add(from_)
    for j in range(1,len(k)):
        unite(from_, k[j]-1)
        if k[j]-1 not in d:
            d.add(k[j]-1)

if sum(l[i] < 0 for i in d) > 1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 9408
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=3e5+10;
int n,m,w;
int x,y;
map<pair<int,int>,bool> mp;
vector<int> cnt1,cnt2;
int row[N],col[N];
int maxr,maxc;

int main() {
    cin>>n>>m>>w;
    for(int i=1;i<=w;++i){
        cin>>x>>y;
        mp[{x,y}]=true;
        row[x]++;
        col[y]++;
        maxr=max(maxr,row[x]);
        maxc=max(maxc,col[y]);
    }

    for(int i=1;i<=n;++i){
        if(row[i]==maxr) cnt1.pb(i);
    }
    for(int i=1;i<=m;++i){
        if(col[i]==maxc) cnt2.pb(i);
    }

    for(int i=0;i<cnt1.size();++i){
        for(int j=0;j<cnt2.size();++j){
            if(!mp[{cnt1[i],cnt2[j]}]){
                printf("%d\n",maxr+maxc);
                return 0;
            }
        }
    }

    printf("%d\n",maxr+maxc-1);

    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n - 1] << '\n';
  return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define ascii_A 65
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
	rep(i, S.length()) {
		int c = (int)S[i];
		c += N;
		if (c >= ascii_A + 26) {
			c -= 26;
		}
		S[i] = (char)c;
	}
	cout << S << endl;

	return 0;
}

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

int dp[3009][3009];
string ans="";
string s,t;

void get_lcs(int i,int j){

	if(i==0||j==0)
		return;

	if(s[i]==t[j]){
		ans+=s[i];
		get_lcs(i-1,j-1);	
	}
	else{
		if(dp[i-1][j]>dp[i][j-1])
			get_lcs(i-1,j);
		else
			get_lcs(i,j-1);
	}
}

int main(){
	cin>>s>>t;
	s=" "+s;
	t=" "+t;

	for(int i=1;i<s.length();++i){
		for(int j=1;j<t.length();++j){
			if(s[i]==t[j])
				dp[i][j]=dp[i-1][j-1]+1;
			else 
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	get_lcs(s.length()-1,t.length()-1);
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;	
	return 0;
}


Measured memory_bytes: 35584
#include<iostream>
using namespace std;
#include<string>
#include<strstream>
#include<sstream>
#include<algorithm>
#include<math.h>
int main()
{
	string s, m;
	cin >> s >> m;
	reverse(s.begin(), s.end());
	if (s == m)
		cout << "YES";
	else
		cout << "NO";

}


Measured memory_bytes: 3488
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <algorithm>
#include <climits>

using namespace std;

string s;
char ans[100005];
int n;

bool isValidAtPos(int x){
	int y = (x+1)%n;
	if(ans[x] == 'S'){
		if(s[x] == 'o' && ans[y] == ans[x-1])
			return true;
		else if(s[x] == 'x' && ans[y] != ans[x-1])
			return true;
	}else{
		if(s[x] == 'o' && ans[y] != ans[x-1])
			return true;
		else if(s[x] == 'x' && ans[y] == ans[x-1])
			return true;
	}
	return false;
}

bool isValid(){
	int i;
	for(i = 1; i<n-2; i++){
		if(ans[i] == 'S'){
			if(s[i] == 'o')
				ans[i+1] = ans[i-1];
			else
				ans[i+1] = ans[i-1]=='W'?'S':'W';
		}else if(ans[i] == 'W'){
			if(s[i] == 'o')
				ans[i+1] = ans[i-1]=='S'?'W':'S';
			else
				ans[i+1] = ans[i-1];
		}
	}
	return isValidAtPos(n-2) && isValidAtPos(n-1);
}

bool makeCase(char a, char b){
	int i;
	for(i = 0; i<n; i++)
		ans[i] = '0';
	ans[0] = a;
	ans[1] = b;
	if(ans[0] == 'S'){
		if(s[0] == 'o')
			ans[n-1] = ans[1];
		else ans[n-1] = b=='W'?'S':'W';
	}else{
		if(s[0] == 'o')
			ans[n-1] = b=='W'?'S':'W';
		else ans[n-1] = ans[1];
	}
	return isValid();
}

int main(){
	int i;
	cin>>n;
	cin>>s;
	if(makeCase('S','W') || makeCase('S','S') || makeCase('W','S') || makeCase('W', 'W')){
		for(i = 0; i<n; i++)
			cout<<ans[i];
		cout<<endl;
	}else cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

ans = 0
plus = ""
for i in range(N):
  if plus != "":
    if plus:
      if A[i-1] > A[i]:
        ans += 1
        plus = ""
    else:
      if A[i-1] < A[i]:
        ans += 1
        plus = ""
  if i < N-1 and plus == "":
    if A[i] < A[i+1]:
      plus = True
    elif A[i] > A[i+1]:
      plus = False
print(ans+1)

Measured memory_bytes: 14228
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 10;

bool used[MAX_N];
int n;
vector<int> G[MAX_N];

void add_edge(int s, int t){
	G[s].push_back(t);
	G[t].push_back(s);
}

int dfs(int v) {
	bool tf = true;
	used[v] = true;
	for (int i = 0; i < n && tf; ++i)
	{
		if (used[i]==false) tf = false;
	}
	if (tf) return 1;

	int ans = 0;

	for (int i = 0; i < G[v].size(); ++i)
	{
		int u = G[v][i];
		if (used[u]) continue;
		ans += dfs(u);
		used[u] = false;
	}
	return ans;
}

int main(int argc, char const *argv[])
{
	int m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		add_edge(a, b);
	}

	fill(used, used + n, 0);

	cout << dfs(0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d,n,i,j,jun=1;
	int tp[101]={0},tm[101];
	scanf("%d",&n);
	for(i=1;i<=n*(n-1)/2;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(c>d)tp[a]+=3;
		else if(c<d)tp[b]+=3;
		else{
			tp[a]++;
			tp[b]++;
		}
	}
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++)if(tp[i]<tp[j])jun++;
		if(i>=2)for(j=i;j>=1;j--)if(tp[i]<tp[j])jun++;
		tm[i]=jun;
		jun=1;
	}
	for(i=1;i<=n;i++)printf("%d\n",tm[i]);
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int x; cin >> x;
    cout << (x<1200?"ABC":"ARC") << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long int
#define mp(a,b) make_pair(a,b)

using namespace std;

map<ll,ll> M;
ll heights[200010];

int main(){
    ll i,n,j,h;
    cin>>n;
    for(i = 1; i<=n; i++){
        cin>>heights[i];
        if(M.count(i + heights[i]) > 0) M[i + heights[i]]++;
        else M.insert(mp(i + heights[i], 1));
    }
    ll count = 0;
    for(i = 1; i<=n; i++){
        if(M.count(i - heights[i]) > 0) count += M[i - heights[i]];
    }
    cout<<count<<endl;
}


Measured memory_bytes: 17568
using System;

namespace Watch
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());

            int h = a / 3600;
            int x = a % 3600;

            int m = x / 60;
            int s = x % 60;

            Console.WriteLine(h + ":" + m + ":" + s);
        }
    }
}

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

map<ll,ll> memo;
ll luka(ll N) {
    if (memo.count(N) > 0) return memo.at(N);
    if (N == 0) return 2;
    if (N == 1) return 1;
    ll res = luka(N-1) + luka(N-2);
    memo[N] = res;
    return res;
}
int main() {
    ll N;
    cin >> N;
    cout << luka(N) << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args)throws IOException{
    //BufferedReader br = new BufferedReader(System.in);
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    
    int num = sc.nextInt();
		String[] line = sc.next().split("");
    int cnt = 0;
		int min = num;
		
		for(int i=0; i<num; i++)
		  if(line[i].equals("."))
		  	cnt++;
		
		int sum = cnt;
		for(int i=0; i<num; i++){
		  if(sum < min)
		  	min = sum;
		  if(line[i].equals("#"))
		  	sum++;
		  else sum--;
		}
		
		if(sum < min)
			min = sum;
		
		out.println(min);
    
    out.flush();
  }
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) cin >> v[i];
  int cnt = 1;
  int pos = 0;
  int res = -1;
  for (int i = 0; i < N; ++i) {
    if (v[pos] == 2) {
      res = cnt;
      break;
    }
    cnt++;
    pos = v[pos] - 1;
  }
  cout << res << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



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

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

   rep(i,n){
      cin>>a[i]>>b[i];
   }

   bool f=false;

   rep(i,n-2){
      if(a[i]==b[i]){
         if(a[i+1]==b[i+1]){
            if(a[i+2]==b[i+2]){
               f=true;
               break;
            }
         }
      }
   }

   if(f) cout<<"Yes";
   else cout<<"No";
   


return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

using namespace std;

int main(void){
    long long L[87];
    int N;
    
    cin >> N;
    
    L[0] = 2;
    L[1] = 1;
    
    for(int i = 2; i <= N; i++){
        L[i] = L[i - 1] + L[i - 2];
    }
    
    cout << L[N] << endl;
    
    return 0;
        }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, A, B;
    cin >> N >> A >> B;
    if (N % 6 == 0) {
        if (N % 12 != 0) {
            A *= -1;
            B *= -1;
        }
        cout << A << " " << B << endl;
    }
    if (N % 6 == 1) {
        if (N % 12 != 1) {
            A *= -1;
            B *= -1;
        }
        cout << A - B << " " << B << endl;
    }
    if (N % 6 == 2) {
        if (N % 12 != 2) {
            A *= -1;
            B *= -1;
        }
        cout << A - B << " " << A << endl;
    }
    if (N % 6 == 3) {
        if (N % 12 != 3) {
            A *= -1;
            B *= -1;
        }
        cout << -1 * B << " " << A << endl;
    }
    if (N % 6 == 4) {
        if (N % 12 != 4) {
            A *= -1;
            B *= -1;
        }
        cout << -1 * B << " " << A - B << endl;
    }
    if (N % 6 == 5) {
        if (N % 12 != 5) {
            A *= -1;
            B *= -1;
        }
        cout << -1 * A << " " << A - B << endl;
    }


}




Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
const ll MOD = 1000000007ll;
int N;
int a[100100],b[100100];
int sa[100100],sb[100100];
struct event{
	int type;
	int sign;
	int pos;
	event(){}
	event(int t,int s,int x):type(t),sign(s),pos(x){}
	bool operator < (const event& a) const{
		return pos < a.pos;
	}
};
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<N;i++){
		scanf("%d",&b[i]);
	}
	sort(a,a+N);
	sort(b,b+N);
	vector<event> es;
	for(int i=0;i<N;i++){
		if(a[i]<b[i]){
			sb[i] = 1 ;
		}else{
			sa[i] = 1;
		}
		es.pb(event(0,sa[i],a[i]));
		es.pb(event(1,sb[i],b[i]));
	}
	sort(es.begin(),es.end());
	ll A = 0ll, B = 0ll;
	ll ans = 1ll;
	for(int i=0;i<es.size();i++){
		event e = es[i];
		if(e.type==0){
			if(e.sign==0){
				A++;
			}else{
				ans = ans*B%MOD;
				B--;
			}
		}else{
			if(e.sign==0){
				B++;
			}else{
				ans = ans*A%MOD;
				A--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int a,b,c,d;
  a=N/1000;
  b=(N-a*1000)/100;
  c=(N-a*1000-b*100)/10;
  d=(N-a*1000-b*100-c*10);
  if ((a==b && b==c) || (b==c && c==d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int x;
  cin >> x;
  auto calc = [&](ll a) {
    return a * a * a * a * a;
  };
  for (int a = -200; a <= 200; a++) {
    for (int b = -200; b <= 200; b++) {
      ll aa = calc(a), bb = calc(b);
      if (aa - bb == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
} 

Measured memory_bytes: 3556
nData = []
nData  = input().rstrip().split(' ')

nAns=0
nK = int(nData[0])
nA = int(nData[1])
nB = int(nData[2])

if (nA>=nB-1) or (nA>=nK):
 nAns=nK+1
else:
 nTmp=nK - (nA-1)
 nTmp1=nTmp//2
 nTmp2=nTmp%2
 nAns=nA+(nB-nA)*(nTmp1)+nTmp2

print(nAns)



Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include<fstream>
using namespace std;
    
#define NUM 10000
stack<int> s[NUM];

int main(){

    int n, q, order, t;
    cin >> n >> q;
    for(int i=0;i<q;i++){
        cin >> order >> t;
        switch (order)
        {
        case 0:
            int num;
            cin >> num;
            s[t].push(num);
            break;
        case 1:
            if(!(s[t].empty())) cout << s[t].top() << endl;
            break;
        case 2:
            if(!(s[t].empty()))s[t].pop();
            break;
        default:
            break;
        }
    }
    return 0;
}


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

int main () {
  string S ;
  cin >> S ;
  int ans = 0 ;
  int pre = 0 ;
  for(int i = 0 ; i < S.size() ; i++ ){
    if(S.at(i)=='A'||S.at(i)=='T'||S.at(i)=='G'||S.at(i)=='C'){
      pre ++ ;
    } else {
      ans = max(ans,pre) ;
      pre = 0 ;
    }
  }
  ans = max(ans,pre) ;
  cout << ans << endl ;
}

Measured memory_bytes: 256
# なんとなく薄目でみていると素因数分解したやつの底の共通するうちから2つ選ぶのが浮かんでくる
# と思ったけど共通するやつの数でいいのか？サンプルケース2おかしないか
# 素因数分解の方法が間違っていた

a, b = map(int, input().split())


def ff(x):
    if x == 1 or x == 2:
        return True
    for i in range(2, int(x ** 0.5) + 1):
        if x % i == 0:
            return False
    return True


def f(x):
    ret = []
    i = 1
    while i * i <= x:
        if x % i == 0:
            if ff(i):
                ret.append(i)
            # 最初と最後が重複しないか確認
            if i != 1 and i * i != x:
                if ff(x // i):
                    ret.append(x // i)
        i += 1
    if ff(x):
        ret.append(x)
    return set(ret)


a_lis, b_lis = f(a), f(b)
common_lis = a_lis & b_lis
print(len(common_lis))


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <string>
#include <set>

using namespace std;
 
int N;
string st;

int main (){
	std::set<string> c1;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> st;
		c1.insert(st);
	}
	cout << c1.size() << endl;
}

Measured memory_bytes: 19224
n = int(input())

if 1 <= n <= 9:
    print(n)
elif 10 <= n <= 99:
    print(9)
elif 100 <= n <= 999:
    print(n-99+9)
elif 1000 <= n <= 9999:
    print(909)
elif 10000 <= n <= 99999:
    print(n-9999+909)
elif n == 100000:
    print(90909)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n ,i ,j ,res;
struct m
{
    ll x;
    ll y;
}a[1003],b[1003];
bool cmp(m a,m b )
{
    return a.x < b.x;
}
set< ll > s;
int main()
{
    cin >> n ;
    for (i=0 ; i<n ; i++)
        scanf("%I64d %I64d" , & a[i].x , & a[i].y) ;
    for (i=0 ; i<n ; i++)
        scanf("%I64d %I64d" , & b[i].x , & b[i].y) ;
    sort(a ,a+n ,cmp);
    sort(b ,b+n ,cmp);
    i=0 ;
    set< ll >::iterator it;
    while( j < n )
    {
        while( a[i].x < b[j].x && i < n )
            s.insert( a[i].y ) ,i++ ;
        if( ! s.empty() )
        {
            it=s.lower_bound( b[j].y ) ;
            if (it != s.begin() ) it-- ;
            if(*it < b[j].y) res++ ,s.erase(*it) ;
        }
        j++;
    }
    cout << res;
    return 0;
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> A(n);
	for(int i = 0; i < n; i++)
		cin >> A[i];
	sort(A.begin(), A.end());
	cout << accumulate(A.begin(), A.begin() + k, 0) << endl;
	return 0;
}


Measured memory_bytes: 3632