akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;

int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N);
  for(ll i=0;i<N;i++)cin>>A.at(i);
  for(ll i=0;i<N;i++)cin>>B.at(i);
  for(ll i=0;i<N;i++)cin>>C.at(i);
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());  
  ll left=-1;
  ll lefta=-1;
  ll right=N;
  ll righta=N;
  ll ans=0;
  for(ll i=0;i<N;i++){
    left=-1;
    right=N;
    lefta=-1;
    righta=N;
    while(right-left>1){
      ll mid=(right+left)/2;
      if(A.at(mid)<B.at(i))left=mid;
      else right=mid;
    }
    while(righta-lefta>1){
      ll mid=(righta+lefta)/2;
      if(C.at(mid)>B.at(i))righta=mid;
      else lefta=mid;
    }
    ans=ans+(N-righta)*(left+1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
p que[100005];
ll parent[100005], si[100005];
ll ans[100005];
void init(int n)
{
	for (int i = 1; i <= n; ++i) {
		parent[i] = i;
		si[i] = 1;
	}
}
int find_root(int a)
{
	while (parent[parent[a]] != a)
		a = parent[parent[a]];
	return a;
}
void merge(int ra, int rb)
{
	if (si[ra] > si[rb]) {
		parent[rb] = ra;
		si[ra] += si[rb];
	}
	else {
		parent[ra] = rb;
		si[rb] += si[ra];
	}
}
ll Crn(ll a)
{
	if (a < 2)
		return 0;
	else
		return a * (a - 1) / 2;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	init(n);
	ll con = n * (n - 1) / 2;
	for (int i = 0; i < m; ++i)
		cin >> que[i].first >> que[i].second;
	for (int i = m - 1; i >= 0; --i) {
		ans[i] = con;
		int pa = find_root(que[i].first);
		int pb = find_root(que[i].second);
		if (pa != pb) {
			con -= si[pa] * si[pb];
			merge(pa, pb);
		}
	}
	for (int i = 0; i < m; ++i)
		cout << ans[i] << '\n';
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

vector<pair<ll,ll>> v[mx];
vector<bool> used(mx,false);
vector<ll> d(mx,0);

void dfs(int x){
  rep(i,v[x].size()){
    if(!used[v[x][i].F]){
      used[v[x][i].F] = true;
      d[v[x][i].F] = d[x]+v[x][i].S;
      dfs(v[x][i].F);
    }
  }
}


int main(){
  int n,m; cin >> n >> m;
  vector<int> l(m),r(m),dis(m);
  rep(i,m){
    cin >> l[i] >> r[i] >> dis[i];
    v[l[i]].emplace_back(pair<ll,ll>(r[i],dis[i]));
    v[r[i]].emplace_back(pair<ll,ll>(l[i],-dis[i]));
  }
  rep(i,n){
    if(!used[i+1]){ used[i+1]=true; dfs(i+1);}
  }
  
  bool ans=true;
  rep(i,m){
    if(d[r[i]]-d[l[i]]!=dis[i]){ ans=false; }
  }

  if(ans){ cout << "Yes" << endl; } else { cout << "No" << endl; }
  return 0;
}

Measured memory_bytes: 22016
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  stack<char> stk;
  string ans;
  rep(i, n){
    if(s.at(i) == '('){
      stk.push('(');
    }else{
      if(stk.empty()){
        ans.push_back('(');
      }else{
        stk.pop();
      }
    }
  }
  cout << ans << s << string(stk.size(), ')') << endl;
  return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Console.ReadLine().Split(' ');
            var atcoder = aaa[0];
            var topcoder = aaa[1];

            if((atcoder == "H" && topcoder == "H") || (atcoder == "D" && topcoder == "D") )
            {
                Console.WriteLine("H");
            }
            else
            {
                Console.WriteLine("D");
            }
        }
    }
}


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

int main() {
    int a,b,c,k;
int i=0;
    cin >> a >> b >> c;
    cin >> k;

while(i<k){
 if (a >= b){
    b = b * 2;
 }else if(b >= c){
    c = c * 2;
 }else{
    c = c * 2;
 }

i++;
}

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

Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <cstdlib>
#include <iterator>
using namespace std;
struct A {
	long long L, v;
	double R; //单价
	bool operator < (const A tmp) const {
		return R == tmp.R ? L < tmp.L : R < tmp.R;
	}
}a[5];
//#define TEST
int main()
{
#ifdef TEST
	freopen("data.in", "r", stdin);
	freopen("data.out", "w", stdout);
#endif
	//ios::sync_with_stdio(false);
	long long n;
	while (cin >> a[1].v >> a[2].v >> a[3].v >> a[4].v >> n) {
		n *= 100;
		a[1].L = 25, a[1].R = a[1].v / (double) a[1].L; // 日元/升
		for (int i = 2; i <= 4; ++i) {
			a[i].L = a[i - 1].L * 2;
			a[i].R = a[i].v / (double)a[i].L;
		}
		sort(a + 1, a + 5);
		long long sum = 0;
		for (int i = 1; i <= 4; ++i) {
			sum += a[i].v * (n / a[i].L);
			n = n % a[i].L;
			if (n == 0) break;
		}
		cout << sum  << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 1e6+6;
ll val[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	ll res = 0;
	for(int i=1;i<n;i++)
	{
		for(int j=i;j<n;j+=i)
			val[j]++;
		res += val[i];
	}
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 11412
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

ll sumdigit(ll n)
{
  int check = 0;
  while (n > 0)
  {
    check += (n % 10);
    n /= 10;
  }
  return check;
}

ll power_ll(ll a, int b)
{
  ll x = 1;
  while (b > 0)
  {
    x *= a;
    b--;
  }
  return x;
}

int main()
{
  ll n;
  cin >> n;
  ll ans = sumdigit(n);

  for (int i = 0; i < 20; i++)
  {
    ll num = (n / power_ll(10, i)) * power_ll(10, i) - 1;
    ans = max(ans, sumdigit(num));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
console.log((args=>{
  const [[N],A] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  let s = 0, max = A[0];
  for ( let i = 1; i < N; i++ ) if ( A[i] < max ) {
    s += max - A[i];
  } else max = A[i];
  return s;
})(require('fs').readFileSync('/dev/stdin','utf8')));


Measured memory_bytes: 50224
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	string s;
	cin >> s;
	string s1 = "";
	rep(i, s.size()){
		int n1 = n;
		char cur = s[i];
		while(n1--){
			if(cur == 'Z') cur = 'A';
			else cur++;
		}
		s1 += cur;
	}
	cout << s1 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll l,r,i,j,k,n,m,x;
	cin>>n;
	ll ctr=0;
	for(i=0;i<n;i++)
	{
		cin>>j;
		if(j%2==1 and i%2==0) ctr++;
	}
	cout<<ctr;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static boolean column(boolean T[][]) {
		for (int i = 0; i < 3; i++) {
			if (T[i][0] == true && T[i][1] == true && T[i][2] == true) {
				return true;
			}
		}
		return false;

	}

	public static boolean row(boolean T[][]) {
		for (int i = 0; i < 3; i++) {
			if (T[0][i] == true && T[1][i] == true && T[2][i] == true) {
				return true;
			}
		}
		return false;

	}

	public static boolean dia(boolean T[][]) {
		if ((T[0][0] == true && T[1][1] == true && T[2][2] == true)
				|| ((T[0][2] == true && T[1][1] == true && T[2][0] == true))) {
			return true;
		}

		return false;

	}

	public static void main(String[] args) {
		int A[][] = new int[3][3];
		boolean T[][] = new boolean[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				T[i][j] = false;
			}
		}
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		int N = sc.nextInt();
		int count = 0;
		while (count < N) {
			int b = sc.nextInt();
			out: for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					if (A[i][j] == b) {
						T[i][j] = true;
						break out;
					}

				}
			}
			count++;
		}

		boolean bo = false;
		boolean bo1 = false;
		boolean bo2 = false;
		//		if (N > 6) {
		//			bo = true;
		//		} else {
		//縦
		bo = column(T);
		//横
		bo1 = row(T);
		//斜め
		bo2 = dia(T);
		//		}
		if (bo1 == false && bo2 == false && bo == false) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}
}


Measured memory_bytes: 21844
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N; cin >> N;
  cout << 180 * (N-2) << endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long K, std::vector<long long> x){
    LL ans = INFL;

    REP(i, N){
        if(N <= i+K-1) break;
        LL l = x[i];
        LL r = x[i+K-1];

        if((l <= 0 && r <= 0) || (l >= 0 && r >= 0)){
            ans = min(ans, max(abs(l), abs(r)));
        } else {
            ans = min(ans, min(abs(l), abs(r)) * 2 + max(abs(l), abs(r)));
        }
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    solve(N, K, std::move(x));
    return 0;
}


Measured memory_bytes: 1024
k = int(input())
lunlun = []
def dfs(A):
    if len(A) > 10:
        return 
    else:
        num = A[-1]
        lunlun.append(int("".join(A)))
        if num == "0":
            for i in range(0, 2):
                A.append(str(i))
                dfs(A)
                A.pop()
        elif num == "9":
            for i in range(8, 10):
                A.append(str(i))
                dfs(A)
                A.pop()
        else:
            for i in range(int(num)-1, int(num)+2):
                A.append(str(i))
                dfs(A)
                A.pop()

for i in range(1, 10):
    dfs([str(i)])
lunlun.sort()
print(lunlun[k-1])

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    set<string> sv;
    map<string,int> m;

    int n; cin >> n;
    rep(i,n){
        string s;cin >> s;
        sv.insert(s);
        m[s]++;
    }
    
    int ma = 0;
    for(string si: sv){
        ma = max(ma, m[si]);
    }

    // sort(sv.begin(), sv.end());
    for(string si: sv){
        if(m[si] == ma) cout << si << endl;
    }
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, ans, X[55], Y[55];
map <Pii, int> mp;

int Solve(int i, int j){
  int p = X[i] - X[j], q = Y[i] - Y[j]; 
  
  vector <int> Graph[55];
  for (int k = 1; k <= N; k++){
    int x = X[k] + p;
    int y = Y[k] + q;
    if (mp[{x, y}] == 0) continue;

    Graph[k].push_back(mp[{x, y}]);
    Graph[mp[{x, y}]].push_back(k);
  }

  bool visited[55] = {};
  int cnt = 1;
  queue <int> que; 
  que.push(1); visited[1] = true;
  while (!que.empty()){
    int Q = que.front(); que.pop();

    for (int i = 0; i < Graph[Q].size(); i++){
      int next = Graph[Q][i];
      if (visited[next]) continue;
      visited[next] = true;
      que.push(next);
    }
    if (!que.empty()) continue;
    for (int i = 1; i <= N; i++){
      if (!visited[i]){
        visited[i] = true; cnt++;
        que.push(i);
        break;
      }
    }
  }
  ans = min(ans, cnt);

  return 0;
}

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++){
    cin >> X[i] >> Y[i];
    mp[{X[i], Y[i]}] = i;
  }
  ans = N;
  for (int i = 1; i <= N; i++){
    for (int j = 1; j <= N; j++){
      Solve(i, j);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7472
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
  int N, R;
  cin >> N >> R;
  if(N>=10) {
    cout << R << endl;
  } else {
    cout << R + (10-N) * 100 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 n;
  cin >> n;
  double ans = 0;
  rep(i,0,n) {
    double a;
    cin >> a;
    ans += 1 / a;
  }

  cout << fixed << setprecision(10) << 1 / ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <numeric>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

int main() {
    unsigned n, x;
    cin >> n >> x;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    x = x - accumulate(v.begin(), v.end(), 0);
    int ans = n;
    ans += (x / v[0]);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    int ans=0;
    vector<int>v(N,0);
    vector<int>c(N,0);
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    for(int i=0;i<N;i++){
        cin>>c[i];
    }
    for(int i=0;i<N;i++){
        int diff=v[i]-c[i];
        if(0<diff){
            ans+=diff;
        }
    }
    cout<<ans<<endl;
    return 0;

}

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

int main() {
  int N, K, L;
  cin >> N >> K;
  L = 0;
  
  for (int i = 0; i < N; i++){
    int x, l1, l2;
    cin >> x;
    l1 = x;
    l2 = K - x;
    if (l1 <= l2) L += l1 * 2;
    else L += l2 * 2;
  }
  
  cout << L << endl;
}


Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() { 
  int k,x;
  cin>>k>>x;

  if(k*500>=x){
      cout<<"Yes"<<endl;
  } else{
      cout<<"No"<<endl;
  }
}



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

int main()
{
    int n;
    while (cin>>n, n) {
        vector<string> a(n);
        vector<vector<int>> x(1024);
        int f=10000;
        for(int i=0;i<n;++i) {
            cin>>a[i];
            int k=a[i].find_last_of('.');
            if (k>=0) {
                if (k<=f and x[k].size()) {
                    for(int j=x[k].back()+1;j<i;++j) a[j][k]='|';
                }
                x[k].push_back(i);
                a[i][k]='+';
                f=k;
            }
        }
        for(auto& s: a) {
            for(char& c: s) if (c=='.') c=' ';
            cout<<s<<endl;
        }
    }
}

Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <stack>
#include <limits.h>


using namespace std;

typedef long long ll;

struct edge {
    int to, cost;
    edge(int _to, int _cost) : to(_to), cost(_cost) {};
};

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

    long x[N+1];
    bool visit[N+1];
    for (int i = 1; i <= N; ++i)
    {
        x[i] = LONG_MAX;
        visit[i] = false;
    }


    vector<edge> G[N+1];
    for (int i = 0; i < M; ++i)
    {
        int L, R, D;
        cin >> L >> R >> D;
        G[R].push_back(edge(L,D));
        G[L].push_back(edge(R,-D));
    }

    for (int i = 1; i <= N; ++i)
    {
        if (G[i].empty()) continue;

        if (x[i] == LONG_MAX) x[i] = 0;

        stack<int> s;
        s.push(i);
        while (!s.empty())
        {
            int t = s.top();
            s.pop();

            visit[t] = true;

            for (int j = 0; j < G[t].size(); ++j)
            {
                edge e = G[t][j];
                if (x[e.to] == LONG_MAX) x[e.to] = x[t] + e.cost;

                if (x[e.to] != x[t] + e.cost) {
                    cout << "No" << endl;
                    return 0;
                }

                if (!visit[e.to]) s.push(e.to);
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  bool ok = false;
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++) {
      swap(a[i], a[j]);
      bool order = true;
      for (int k = 0; k < N-1; k++) {
        if (a[k] >= a[k+1]) {order = false;}
      }
      swap(a[i], a[j]);
      if (order) {ok = true;}
    }
  }
  
  bool woswap = true;
  for (int k = 0; k < N-1; k++) {
    if (a[k] >= a[k+1]) {woswap = false;}
  }
  if (woswap) {ok = true;}
  
  if (ok) {cout << "YES" << endl;}
  else {cout << "NO" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define chmin(x,y) x=min(x,y)

int main(){
	int N,K; cin>>N>>K;
	int INF = 1e+9;
	vector<int> H(N), dp(N, INF);
	rp(i, 0, N) cin>>H[i]; // i:[0,N-1]
	dp[0] = 0;
	rp(i, 1, N){ // i:[1,N-1]
		rp(k, 1, K+1) // k:[1,K]
			if(0 <= i-k)
				chmin(
					dp[i],
					dp[i-k] + abs(H[i-k] - H[i])
				);
	}
	cout<< dp[N-1] <<endl;
}


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

int main() {
  int Q;
  cin>>Q;
  vector<int> l(Q);
  vector<int> r(Q);
  vector<int> p(100005);
  for(int i=0;i<Q;i++) cin>>l[i]>>r[i];
  //p[3]=1;
  for(int i=3;i<100005;i++){
    if(i%2==0){
      p[i]=p[i-1];
      continue;
    }
    int s=i, t=(i+1)/2;
    bool flgs=true,flgt=true;
    for(int j=2;j<=sqrt(s);j++){
      if(s%j==0){
        flgs=false;
        break;
      }
    }
    for(int j=2;j<=sqrt(t);j++){
      if(t%j==0){
        flgt=false;
        break;
      }
    }
    if(flgs&&flgt){
      p[i]=p[i-1]+1;
    }
    else{
      p[i]=p[i-1];
    }
  }
  //cout<<p[3]<<endl;
  //cout<<p[5]<<endl;
  //cout<<p[7]<<endl;
  for(int i=0;i<Q;i++){
    cout<<p[r[i]]-p[l[i]-1]<<endl;
  }

}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int main(){
    double g[110][110];
    rep(i,110)rep(j,110)g[i][j]=-1;
    int n,m;
    while(cin>>n>>m){
        if(n==0&&m==0)break;
        rep(i,n){
            rep(j,n){
                cin>>g[i][j];
            }
        }
    
    
        double dp[110][110];
        rep(i,110)rep(j,110)dp[i][j] = -1;
        rep(i,n)dp[1][i]=1.0;
    
        for(int i=2;i<=m;i++){
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    dp[i][j] = max(dp[i][j],dp[i-1][k]*g[k][j]);
                }
            }
        }
        double ans = -1;
        rep(i,n){
            ans = max(ans,dp[m][i]);
        }
        printf("%.2lf\n",ans);
    }
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

vector<pair<ll, ll>> v;

int main()
{
	int n;
	cin>>n;
	rep(i, 0, n)
	{
		ll x, y;
		cin>>x>>y;
		v.pb({y, x});
	}
	sort(all(v));
	ll curr = 0;
	bool flag = true;
	rep(i, 0, n)
	{
		curr += v[i].s;
		if(curr > v[i].f)
		{
			flag = false;
			break;
		}
	}
	if(flag) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, T;
string S;
signed main(){
  cin >> N >> T;
  int cost = 1500;
  rep(i,N){
    int a, b; cin >> a >> b;
    if(b<=T) cost = min(cost, a);
  }
  
  if(cost == 1500) cout << "TLE" << endl;
  else cout << cost << endl;
  return 0;
}


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

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

    static class DTriangles {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            long[] L = new long[n];
            for (int i = 0; i < n; i++) {
                L[i] = Integer.parseInt(in.next());
            }
            long ans = 0;

            Arrays.sort(L);
            // O(N^3)
            for (int a = 0; a < n - 2; a++) {
                for (int b = a + 1; b < n - 1; b++) {
                    for (int c = b + 1; c < n; c++) {
                        if (L[a] < L[b] + L[c] && L[b] < L[c] + L[a] && L[c] < L[a] + L[b]) ans++;
                        else break;
                    }
                }
            }


            // 出力
            out.println(ans);

        }

    }
}



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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<ll, ll> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<P> ba;
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		ba.push_back(make_pair(b, a));
	}
	
	sort(ALL(ba));
	
	ll sum = 0;
	for (auto &e: ba) {
		sum += e.second;
		if (sum > e.first) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 6256
a,b=map(int,input().split())
a1=a/0.08
a2=(a+1)/0.08
b1=b/0.1
b2=(b+1)/0.1
ans=20000
for i in range(1,10001):
    if a1<=i and b1<=i and a2>i and b2>i:
        ans=min(ans,i)
if ans==20000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 63100
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end();
#define rall(x) x.rbegin(),x.rend();
#define ld long double
#define pll pair < long long , long long >
#define endl "\n"
using namespace std;
vector < ll > comp(100500);
vector < ll > sz(100500);
vector < ll > g[100500];
ll chs = 0;
void dfs( int v , ll cmp)
{
    chs++;
    comp[v] = cmp;
    for( int i = 0; i < g[v].size(); i++)
    {
        int to = g[v][i];
        if(comp[to]==0)
        {
            dfs(to,cmp);
        }
    }
}
int main()
{
    ios_base :: sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int n,m,k;
    cin >> n >> m >> k;
    vector < ll > answ(n+1,0);
    for( int i = 0; i < m; i++)
    {
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    ll ch = 1;
    for( int i = 1; i <= n; i++)
    {
        if(comp[i]==0)
        {
            dfs(i,ch);
            sz[ch] = chs;
            ch++;
            chs = 0;
        }
    }
    for( int i = 1; i <= n; i++)
    {
        answ[i] = sz[comp[i]]-g[i].size()-1;
    }
    for( int i = 0; i < k; i++)
    {
        int a,b;
        cin >> a >> b;
        if(comp[a]^comp[b])
        {
            continue;
        }
        answ[a]--;
        answ[b]--;
    }
    for( int i = 1; i <= n; i++)
    {
        cout << answ[i] << ' ';
    }
}


Measured memory_bytes: 10240
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};
struct Node T[MAX];
int n,D[MAX],H[MAX];


void setDepth(int u,int d){
  if(u==NIL)return ;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}


int setHeight(int u){
  int h1=0,h2=0;

  if(T[u].left != NIL)
    h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL)
    h2=setHeight(T[u].right)+1;
  return H[u]=(h1>h2 ? h1:h2);
}

int getSibling(int u){
  if(T[u].parent==NIL)return NIL;

  if(T[T[u].parent].left != u && T[T[u].parent].left!=NIL)
    return T[T[u].parent].left;

  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;

  return NIL;
}


void print(int u){
  int deg=0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  if(T[u].left != NIL)deg++;
  if(T[u].right != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }
  else if (T[u].left == NIL && T[u].right == NIL ){
    printf("leaf\n");
      }
  else printf("internal node\n");
}



int main(){
  int v,l,r,root=0,i;

  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].parent=NIL;

  for(i=0;i<n;i++){

    scanf("%d%d%d",&v,&l,&r);

    T[v].left = l;
    T[v].right = r;
    if(l != NIL)T[l].parent = v;
    if(r != NIL)T[r].parent = v;
  }

  for(i=0;i<n;i++)if(T[i].parent==NIL) root=i;

  setDepth(root,0);	
  setHeight(root);

  for(i=0;i<n;i++)print(i);

  return 0;
}

Measured memory_bytes: 624
n=int(input())
tou=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for _ in range(n):
   b,f,r,v=map(int, input().split())
   tou[b-1][f-1][r-1]+=v
 
for i in range(4):
   for j in range(3):
       print(' ', end='')
       print(*tou[i][j])
   if i!=3: print('#'*20)


Measured memory_bytes: 5624
n=int(input())
def f(s):
  if int(s)>n:
    return 0
  t=0
  if s.count("3")>0 and s.count("5")>0 and s.count("7")>0:
    t=1
  return f(s+"7")+f(s+"5")+f(s+"3")+t
print(f("0"))

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

constexpr int MAX_N = 1e5;
int T[MAX_N];

int main() {
  string S; cin >> S;
  int N = S.length();

  for (int i{}; i < N;) {
    if (S[i] == 'R') {
      int j{i + 1};
      while (j < N && S[j] == 'R') {
        ++j;
      }
      for (int k{i}; k < j; ++k) {
        if ((j - k) % 2 == 0)
          ++T[j];
        else
          ++T[j - 1];
      }
      ++T[j];
      int k{j + 1};
      while (k < N && S[k] == 'L') {
        ++k;
        if ((k - j) % 2 == 0)
          ++T[j-1];
        else
          ++T[j];
      }
      i = k;
    }
  }

  cout << T[0];
  for (int i{1}; i < N; ++i)
    cout << ' ' << T[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 1024
s = list(input())
a = 'hi'
if len(s) % 2 != 0:
  print('No')
  exit()
for i in range(len(s)//2):
  if s[2*i] == 'h' and s[i*2+1] == 'i':
    pass 
  else:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 3060
cnt_al = {"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}

word_list = list()
while True:
    try:
        words = input().lower()
        word_list.append(words)
    except:
        break

for words in word_list:
    for word in words:
        if word in cnt_al:
            cnt_al[word] += 1

for al,cnt in cnt_al.items():
    print(al,':',cnt)



Measured memory_bytes: 5576
import sys

input = sys.stdin.readline

def main():
    ans = 0
    x = int(input())
    if 400<=x<=599:
        print(8)
    elif 600<=x<=799:
        print(7)
    elif 800<=x<=999:
        print(6)
    elif 1000<=x<=1199:
        print(5)
    elif 1200<=x<=1399:
        print(4)
    elif 1400<=x<=1599:
        print(3)
    elif 1600<=x<=1799:
        print(2)
    elif 1800<=x<=1999:
        print(1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(Math.min(a, b));

        if (a + b < n) {
            System.out.println(0);
        } else {
            System.out.println(Math.abs(a + b - n));
        }


    }

}







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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

struct edge{int to,cost;};
vector<edge> G[100];

const int INF=123456789;
int dist[11][100];

int main()
{
    int c,n,m,s,d;
    while(cin >>c >>n >>m >>s >>d,c)
    {
        rep(i,100) G[i].clear();

        --s;
        --d;
        rep(i,m)
        {
            int a,b,f;
            scanf(" %d %d %d", &a, &b, &f);
            --a;
            --b;
            G[a].pb(edge{b,f});
            G[b].pb(edge{a,f});
        }

        fill(dist[0],dist[11],INF);
        dist[0][s]=0;
        queue<pi> que;
        que.push(pi(0,s));
        while(!que.empty())
        {
            pi p=que.front(); que.pop();
            int ticket=p.fi;
            int now=p.se;
            rep(i,G[now].size())
            {
                edge e=G[now][i];
                if(dist[ticket][e.to]>dist[ticket][now]+e.cost)
                {
                    dist[ticket][e.to]=dist[ticket][now]+e.cost;
                    que.push(pi(ticket,e.to));
                }
                if(ticket<c)
                {
                    if(dist[ticket+1][e.to]>dist[ticket][now]+e.cost/2)
                    {
                        dist[ticket+1][e.to]=dist[ticket][now]+e.cost/2;
                        que.push(pi(ticket+1,e.to));
                    }
                }
            }
        }

        int ans=INF;
        rep(i,c+1) ans=min(ans,dist[i][d]);
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
typedef pair<long,long> pairll;
typedef pair<long,pair<long,long>> pairlll;
pairll neighbor[2]={{0,1},{1,0}};
int main(){
  long H,W;cin>>H>>W;
  vector<string>S(H);
  for(long i=0;i<H;i++)cin>>S[i];
  vector<vector<long>>D(H,vector<long>(W,100000));D[0][0]=0;
  priority_queue<pairlll,vector<pairlll>,greater<pairlll>>q;
  q.push(pairlll(0,pairll(0,0)));
  while(q.size()){
    pairlll p=q.top();q.pop();
    long y=p.second.first,x=p.second.second;
    if(D[y][x]<p.first)continue;
    for(long i=0;i<2;i++){
      long y2=y+neighbor[i].first,x2=x+neighbor[i].second;
      if(y2>=H||x2>=W)continue;
      long cost=(S[y][x]!=S[y2][x2]);
      if(D[y2][x2]>D[y][x]+cost){
        D[y2][x2]=D[y][x]+cost;
        q.push(pairlll(D[y2][x2],pairll(y2,x2)));
      }
    }
  }
  //for(long i=0;i<H;i++){for(long j=0;j<W;j++)cout<<D[i][j]<<" ";cout<<endl;}
  cout<<(D[H-1][W-1]+1+(S[0][0]=='#'))/2;
}

/*


みぎかした
選び, 全部色を反転させる


*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
int main(){
    int x;
    cin >> x;
    if (x == 1)
    {
        cout << 0 << endl;
    }
    if (x == 0)
    {
        cout << 1 <<endl;
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;int main(void){int i,n,m;while(cin>>n>>m&&n!=0&&m!=0){
vector<char> z(n,'#');for(int l=0;l<m;l++){char a;cin>>a;if(a=='A'){for(i=0;i<m;i++){if(z[i]=='#'){z[i]=a;break;}}}
else if(a=='B'){int su=0;for(i=n-1;i>=0;i--){if(z[i]!='#')continue;if(i>=1&&z[i-1]=='A')continue;
if(i<=n-2&&z[i+1]=='A')continue;z[i]=a;su=1;break;}if(!su){for(i=0;i<n;i++){if(z[i]=='#'){z[i]=a;break;}}}}
else if(a=='C'){int su=0;for(i=0;i<n;i++){if(z[i]=='#')continue;
if(i<=n-2&&z[i+1]=='#'){z[i+1]=a;su=1;break;}if(i>=1&&z[i-1]=='#'){z[i-1]=a;su=1;break;}}
if(!su){if(n%2==0){z[(n/2)] = a;}else{z[(n/2)]=a;}}}else if(a=='D'){int ef=1;
for(i=0;i<n;i++){if(z[i]!='#'){ef=0;break;}}if(ef){z[0]=a;continue;}
vector<int> C(n,0);for(i=0;i<n;i++){if(z[i]!='#'){int Y=1;while(i+Y<n&&z[i+Y]=='#'){
if(C[i+Y]==0)C[i+Y] = Y;else C[i+Y]=min(Y,C[i+Y]);Y++;}}}for(i=n-1;i>=0;i--){if(z[i]!='#'){int Y=1;
while(i-Y>=0&&z[i-Y]=='#'){if(C[i-Y]==0)C[i-Y]=Y;else C[i-Y]=min(Y,C[i-Y]);Y++;}}}int su=0,mn,mv=0;for(i=0;i<n;i++){if(C[i]>mv){mn=i;mv=C[i];}}if(mv>1){z[mn]=a;su=1;}if(!su){for(i=0;i<n;i++){if(z[i]=='#'){z[i]=a;break;}}}}}for(i=0;i<n;i++)cout<<z[i];cout<<endl;}return 0;}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll stack[LIMIT2],queue[LIMIT2*10];//stack[0]=count;queue[0]=start,queue[1]=length;
int enqueue(ll n){
    if(queue[0]+queue[1]>=LIMIT2) return -1;
    queue[queue[0]+queue[1]] = n;
    queue[1]++;
    return 1;
}
ll dequeue(){
    ll result;
    if(queue[1]<=0) return -1;
    result = queue[queue[0]];
    queue[0]++;
    queue[1]--;
    if(queue[1]==0){
        queue[0] = 2;
    }
    return result;
}
void initialize(){
    stack[0] = 0;
    queue[0] = 2;
    queue[1] = 0;
}
int main(void){
  initialize();
  ll n,m,k,i,j,result=0,sum=0;
  int a[LIMIT1];
  char s[LIMIT1];

  scanf("%lld",&n);
  for(i=1;i<=sqrtl((ld)(n-1));i++){//n-1の約数
    if((n-1)%i==0){
      if(i>=2&&i!=sqrtl((ld)(n-1))){
        result+=2;
        //printf("%lld %lld ",i,(n-1)/i);
      }else{
        if(n-1<=1) continue;
        result++;
        //if(i==1) printf("%lld ",n-1);
        //else printf("%lld ",i);
      }
    }
  }
  for(i=1;i<=sqrtl((ld)n);i++){
    if((n-1)%i==0&&i>=2){
      
    }else{
      if(i>=2){
        k=i;
        j=n;
        while(j%k==0) j/=k;
        if(j%k==1){
          //printf("%lld ",i);
          result++;
        }
      }
      k=n/i;
      if(k<=1||k==i) continue;
      j=n;
      while(j%k==0) j/=k;
      if(j%k==1){
        //printf("%lld ",n/i);
        result++;
      }
    }
  }
  //printf("\n");
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll INF = (1LL << 61) - 1;
int MOD = 1e9+7;
int N;
vector<ll> V,accum;
// [l,r)を差の絶対値が小さくなるように二分割したときにそれぞれの和を返す
P split(int l, int r){
    ll sum = accum[r] - accum[l];
    //cout << "sum:" << sum << endl;
    auto itr = lower_bound(accum.begin() + l, accum.begin() + r,accum[l] + sum/2);
    auto itr2 = itr;
    itr2--;
    ll l1 = *itr - accum[l], r1 = accum[r] - *itr;
    ll l2 = *itr2 - accum[l], r2 = accum[r] - *itr2;
    //cout << l1 << "," << r1 << endl;
    //cout << l2 << "," << r2 << endl;
    ll ans1, ans2;
    if(abs(r1 - l1) < abs(r2 - l2)){
        ans1 = r1, ans2 = l1;
    }else{
        ans1 = r2, ans2 = l2;
    }
    if(ans1 > ans2)swap(ans1, ans2);
    return P(ans1, ans2);
}
void tmp(){
    
    ll mini = INF;
    ll minmax = INF;
    vector<ll> ans(4);
    rep(i,0,N)rep(j,i+1,N)rep(k,j+1,N){
        vector<ll> nums = {accum[i] - accum[0], accum[j] - accum[i], accum[k] - accum[j], accum[N] - accum[k]};
        sort(nums.begin(), nums.end());
        if(mini > nums[3] - nums[0]){
            ans = {accum[i] - accum[0], accum[j] - accum[i], accum[k] - accum[j], accum[N] - accum[k]};
        }
        minmax = min(minmax, nums[3]);
        mini = min(mini, nums[3] - nums[0]);

    }
    cout << mini << endl;
    rep(i,0,4)cout << ans[i] << " ";
    cout << endl << minmax << endl;

}
main(){
    
    cin >> N;
    V.resize(N);
    accum.resize(N+1);
    rep(i,0,N)cin >> V[i];
    rep(i,0,N)accum[i+1] = accum[i] + V[i];

    ll mini = INF;
    //[0,i), [i,N)に分割
    rep(i,2,N-1){
        auto p1 = split(0, i);
        auto p2 = split(i, N);
        ll mi = min(p1.first, p2.first);
        ll ma = max(p1.second, p2.second);
        //cout << mi << " " << ma << endl;
        mini = min(mini, ma - mi);
    }
    cout << mini << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
ll a[N],b[N];
int main()
{
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1; i<=n; i++)
    {
        int x;
        cin>>x;
        a[i]=a[i-1]+x;//加法前缀和
        b[i]=b[i-1]^x;//异或前缀和
    }
    for(int r=1,l=1;r<=n;r++)
    {
        for(;a[r]-a[l-1]!=(b[r]^b[l-1]);l++)
        {

        }
        sum+=r-l+1;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 6752
K = int(input())

out=-1

if K%7==0:
    dammy = K//7
    # print(dammy)
    for i in range(1,10**6):
        #if (10**i -1) % 9 ==0:
        if pow(10,i,9*dammy)==1:
             out=i
             break

else:
    for i in range(1,10**6):
        #if (10**i -1) % (9*K)==0:
        if pow(10,i,9*K)==1:
            out=i
            break

print(out)


Measured memory_bytes: 63244
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[200010];
int main(){
    ll n, k;
    while(cin>>n>>k){
        ll ans=0, sm=0;
        for(int i=0; i<n; ++i){
            scanf("%lld",a+i);
        }
        sort(a, a+n);
        reverse(a, a+n);
        for(int i=k; i<n; ++i){
            sm+=a[i];
        }
        cout<<sm<<endl;
    }
    return 0;
}




Measured memory_bytes: 1792
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=305;
char mp[N][N],s[N][N];int f[N][N],n,m,res;
int calc(R int id){
	fp(i,1,m)fp(j,1,m)f[i][j]=(s[id][i]==s[id+1][j]);
	fp(i,1,m)fp(j,1,m)f[i][j]+=f[i-1][j-1];
	fp(i,1,m)fp(j,1,m)f[i][j]+=min(f[i-1][j],f[i][j-1]);
	return f[m][m];
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&m);
	fp(i,1,n)scanf("%s",mp[i]+1);
	fp(i,1,n)fp(j,1,m)s[j][i]=mp[i][j];
	swap(n,m);
	fp(i,1,n-1)res+=calc(i);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 768