akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef unsigned long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
// #define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 2e5+5;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
// #define trace6(a, n,i;b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Constants //
 
/*** Template Ends ***/


void solve()
{
  ll ans=0;
  ll h;
  cin>>h;
  ll curr=1;
  while(h>0)
  {
    ans += curr;
    curr*=2;
    h/=2;
  }
  cout<<ans;
}
int main()
{ 
  // ios;
  // fxreopen("inputt.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
  return 0;
}

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



signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    ll n;
    cin>>n;
    ll a[n+1], b[n];
    for(int i=0;i<=n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans += min(a[i],b[i]);
        b[i] -= min(a[i],b[i]);
        ans += min(a[i+1],b[i]);
        a[i+1] -= min(a[i+1],b[i]);
    }
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int N,M;
	cin >> N >> M;
	int A[10][10];
	int k[10];
	for (int i = 0; i < M; ++i)
	{
		cin >> k[i];
		for (int j = 0; j < k[i]; ++j)
		{
			int t;
			cin >> t;
			A[i][j] = t-1;
		}
	}

	int p[10];
	for (int i = 0; i < M; ++i)
	{
		cin >> p[i]; 
	}

	int max = pow(2,N);
	int s[10];//スイッチのONOFFを01で表す
	int ans = 0;
	for (int i = 0; i < max; ++i)
	{
		bool flag = true;
		int tempi = i;		
		for (int j = 0; j < N; ++j)
		{
			s[j] = tempi % 2;
			tempi /= 2;
		}

		for (int j = 0; j < M; ++j)
		{
			int temp = 0;
			for (int l = 0; l < k[j]; ++l)
			{
				temp += s[A[j][l]];
			}

			if ((temp % 2) != p[j])
			{
				flag = false;
				break;
			}

		}

		if (flag)
		{
			ans++;
		}
	}

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

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

map<int,long long int> m;
long long int ar[200005],ans;
int cnt[200005];

int main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>ar[i],ar[i]+=(i?ar[i-1]:0);
    //cout<<0<<' ';
    for(int i=0;i<n;i++)
        cnt[i+1]=(i+1-(ar[i]%k)+k)%k;//,cout<<cnt[i+1]<<' ';
    cnt[0]=0;
    m[0]=1;
    //cout<<"\n   ";
    for(int i=1;i<=n;i++){
        if(i>=k)
            m[cnt[i-k]]--;
        ans+=m[cnt[i]];
        //cout<<m[cnt[i]]<<' ';
        m[cnt[i]]++;
        
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 15104
#include <iostream>
#include <string>

using namespace std;

main(){
  string in1, in2, out1;

  while(1){
    cin >> in1;
    if(in1=="-") break;

    cin >> in2 >> out1;

    int r=0, g=0, o=0;
    char now=in2[g];
    string out2="";
    g++;
    
    for(int i=0;;i++){
      //      printf("'%c'\n", now);
      if(now==out1[o]){
	o++;
	now=in1[r];
	r++;
      }
      else{
	out2+=now;
	now=in2[g];
	g++;
      }
      if(r==in1.size() && g==in2.size()) break;
    }

    if(now==out1[o]){
      o++;
      now=in1[r];
      r++;
    }
    else{
      out2+=now;
      now=in2[g];
      g++;
    }
    
    
    cout << out2 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n, m = map(int, input().split())
l = [[] for _ in range(n)]

ans = [None] * (n)
queue = [0]

ans[0] = 0

for i in range(m):
    a,b = map(int, input().split())
    l[a - 1].append(b - 1)
    l[b - 1].append(a - 1)

def bfs(r):
    for i in l[r]:
        if (ans[i] == None):
            queue.append(i)
            ans[i] = r + 1  #index との整合性
    queue.pop(0)

while (len(queue) > 0):
    bfs(queue[0])

if(None not in ans):
    print("Yes")
    for i in ans[1:]:
        print(i)
else:
    print("No")
#print(ans)





Measured memory_bytes: 37252
#include <iostream>
#include <algorithm>

using namespace std;

const int DIM = 2010;

int i,j,k,n,sum, v[DIM], *p;

int main(){
    long count = 0 ; 
    cin >> n;
    for (i = 1; i <= n; ++i) {
        cin >> v[i];
    }
    sort(v + 1, v + n + 1);
    for (i = 1; i<= n - 2; i++){
        for (j = i + 1; j <= n-1 ; j++){
            sum = v[i] + v [j]; 
            for(k = j + 1 ; k <= n; k++){
                if (v[k] < sum){
                    count ++;
                } else {
                    break;
                }
            } 
        }
    }
    cout << count << "\n";
    return 0; 
}

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

struct task {
    long long int duration;
    long long int deadline;

    bool operator<(const task& another) const {
        return deadline < another.deadline;
    }
};

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

    vector<task> tasks(N);
    for (int i = 0; i < N; i++) {
        cin >> tasks[i].duration >> tasks[i].deadline;
    }
    sort(tasks.begin(), tasks.end());

    long long int now = 0;

    for (int i = 0; i < N; i++) {
        now += tasks[i].duration;
        // cout << tasks[i].duration << " " << tasks[i].deadline << endl;
        if (tasks[i].deadline < now) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n;
  cin >> n;
  vector<ll> a;
  REP(i,n) {
    ll tmp;
    cin >> tmp;
    a.pb(tmp);
  }
  sort(a.begin(), a.end());
  ll mx = a[n-1];
  ll mi = a[0];

  ll before = mi;
  vector<pair<ll,ll>> ans;
  int bk = n-2;
  while (bk > 0 && a[bk] >= 0) {
    ans.pb({before,a[bk]});
    before -= a[bk];
    bk--;
  }
  ans.pb({mx,before});
  mx -= before;
  while (bk > 0) {
    ans.pb({mx,a[bk]});
    mx -= a[bk];
    bk--;
  }
  cout << mx << endl;
  REP(i,sz(ans)) {
    cout << ans[i].fi << " " << ans[i].se << endl;
  }
}

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

  /*Regular*/
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }

  // /*ICPC*/
  // while (cin >> t >> d >> l, t) {
  //   solve();
  // }

  //solve();
  return 0;
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}

map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
vector<ll> dijkstra(vector<vector<P>> graph, ll s) {
    vector<ll> ans(graph.size(), -1);
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, s});
    while (pq.size() > 0) {
        ll cur1 = 0;
        ll cur2 = 0;
        if (ans[pq.top().second] != -1) {
            pq.pop();
        } else {
            cur1 = pq.top().first;
            cur2 = pq.top().second;
            pq.pop();
            ans[cur2] = cur1;
            for (ll i = 0; i < graph[cur2].size(); i++) {
                pq.push({cur1 + graph[cur2][i].first, graph[cur2][i].second});
            }
        }
    }
    return ans;
}
vector<string> maze;
ll h, w;
bool check(ll y, ll x) {
    if (x < 0 || x >= w || y < 0 || y >= h || maze[y][x] == '#') {
        return false;
    }
    return true;
}
signed main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, b * d), max(a * d, b * c)) << endl;
}

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

typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define test cout<<"#"
#define INF 1e9+5
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(ll x = 0; x < n; x++)
		cin>>v[x];
	vector<ll> ans(n,INF);
	ans[0] = 0;
	for(ll x = 0; x < n; x++)
	{
		for(auto u: {x+1,x+2})
		{
			if(u<n)
				ans[u] = min(ans[u], ans[x]+abs(v[x]-v[u]));
		}
	}
	cout<<ans[n-1]<<"\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) begin(v), end(v)
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,b) FOR(i,0,b)

const int mod = 1e9+7;

int a[100010];
int b[100010];
int ans;
signed main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++)cin>>a[i];

  for(int i=0;i<N-1;i++){
    if(a[i+1]-a[i]<0)b[i]=-1;
    if(a[i+1]-a[i]>0)b[i]=1;
  }

  int prev=b[0];
  for(int i=1;i<N-1;i++){
    if(prev==0){
      prev=b[i];
    }
    if(b[i]!=prev && b[i]!=0){
      prev=b[i+1];
      i++;
      ans++;
    }

  }

  cout<<ans+1<<endl;

  return 0;
}


Measured memory_bytes: 1792
module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = loop

loop :: IO()
loop = do
  { [n, x] <-getInts
  ; if n == 0 && x == 0 then return ()
    else print (length (filter (( x == ) . sum) (comb [1 .. n] 3))) >> loop
  }

comb :: [Int] -> Int -> [[Int]]
comb ns 0 = [[]]
comb ns k = if length ns == k then [ns]
            else map (head ns :) (comb (tail ns) (k - 1)) ++ comb (tail ns) k

--

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 5704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  int n=26;
  int arr[n];
  for(int i=0;i<n;i++)
    arr[i]=0;
  string str;
  cin >> str;
  int p=0;
  for(int i=0;i<str.length();i++)
  {
    arr[str[i]-'a']++;
    if(arr[str[i]-'a']>1)
    {
      p=1;
      break;
    }
  }
  if(p==0)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int memo[10];

int getPos() {
  vector<int> d;
  for(int i = n; i>0; i--) {
    d.push_back(i);
  }

  int qp = 1;
  REP(i, n) {
    int q;
    cin >> q;
    REP(j, d.size()) {
      if(d[j] == q) {
        qp += (d.size() - (j + 1)) * memo[n - (i + 1)];
        d.erase(d.begin() + j);
        break;
      }
    }
  }
  return qp;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  memo[0] = 0; memo[1] = 1;
  FOR(i, 2, n + 1) {
    memo[i] = memo[i - 1] * i;
  }

  int p = getPos();
  int q = getPos();

  cout << abs(p - q) << endl;
}


Measured memory_bytes: 256
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations

import bisect
# ----------

INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

N = int(input())
C = defaultdict(int)
for x in range(1, 10**2+1):
    for y in range(1, 10**2+1):
        for z in range(1, 10**2+1):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            C[n] += 1

for i in range(N):
    print(C[i+1])

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 111

typedef long long ll;
typedef long double ld;

ll arr[maxn], c[maxn], n;
int cnt[maxn];
ll ans;

void DFS(int x, ll sum, ll maks){
	if(sum + maks <= ans)
		return;

	if(x == n + 1){
		ans = max(ans, sum);
		return;
	}

	if(cnt[x]){
		DFS(x + 1, sum, maks);
		return;
	}

	if(x + x > n){
		DFS(x + 1, sum + c[x], maks - c[x]);
		return;
	}

	DFS(x + 1, sum + arr[x], maks - c[x]);	// take this element

	for(int i = x; i <= n; i += x){			// smash this index
		if(cnt[i] == 0)
			maks -= c[i];

		cnt[i]++;
	}

	DFS(x + 1, sum, maks);
	for(int i = x; i <= n; i += x)
		cnt[i]--;	
}

int main(){
	ll maks = 0;
	scanf("%lld", &n);
	for(int i = 1; i <= n; i++){
		scanf("%lld", arr + i);
		c[i] = max(0LL, arr[i]);
		maks += c[i];
	}

	DFS(1, 0, maks);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A_s = list(map(int,input().split()))
X_s = []
X_s.append(sum(A_s)-2*sum(A_s[1::2]))
for i,a in enumerate(A_s):
  X_s.append(2*A_s[i]-X_s[i])
X_s.pop()
print(' '.join(map(str,X_s)))


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

string s;

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	cin >> s;
	int ans = 0;
	char cur = 'g';
	for (char c: s) {
		if (c == 'g' && cur == 'p') ++ans;
		else if (c == 'p' && cur == 'g') --ans;
		cur = cur == 'g' ? 'p' : 'g';
	}
	cout << ans;
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

ll knapsack(int W,ll wt[],ll val[],int n){
	ll k[n+1][W+1];

	for(int i=0;i<=n;i++){
		for(int j=0;j<=W;j++){
			if(i==0 || j==0)
				k[i][j]=0;
			else if(wt[i-1]<=j)
				k[i][j]=max(val[i-1]+k[i-1][j-wt[i-1]],k[i-1][j]);
			else
				k[i][j]=k[i-1][j];
		}
	}
	return k[n][W];
}


int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n,w;
    cin >> n >> w;
    ll A[100005],B[100005];

    FOR(i,0,n)
        cin >> A[i] >> B[i];

    cout << knapsack(w,A,B,n) << endl;

    return 0;
}


Measured memory_bytes: 79232
N_list = [int(i) for i in list(input())]
N_list = N_list[::-1] + [0]

for index in range(0, len(N_list)):
  if N_list[index] >= 6 or (N_list[index] == 5 and N_list[index+1] >= 5) :
    N_list[index] = 10 - N_list[index]
    N_list[index+1] += 1

print(sum(N_list))

Measured memory_bytes: 26512
from collections import defaultdict

n, m = map(int, input().split())
d = defaultdict(list)
py = [tuple(map(int,input().split())) for i in range(m)]

# data_list = []
# i = 0
# for p,y in py:
#     data_list.append([i,p,y])
#     i += 1
ans = [0]*m

p_yi_table = [[] for i in range(n+1)]
for i,(p,y) in enumerate(py):
    p_yi_table[p].append((y,i))
for p, yi_list_by_p in enumerate(p_yi_table):
    yi_list_by_p.sort()
    for j,(y,i) in enumerate(yi_list_by_p):
        s = str(p).zfill(6) + str(j+1).zfill(6)
        ans[i] = s

print(*ans, sep='\n')

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

x = 1
leng = 0

while True:
    if n-x < 0: break
    n -= x
    leng += 1
    x *= 26

ans = ["a"] * leng

for i in range(leng):
    ans[i] = chr(n % 26 + ord("a"))
    n //= 26

print("".join(ans[::-1]))


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


int main(){
	long L0=2,L1=1,N;

	std::cin >> N;
	long ans;
	for(int i=0;i<N-1;i++)
	{
		ans= L0+L1;
		L0=L1;
		L1=ans;
	}
	std::cout << L1 << std::endl;

} 

Measured memory_bytes: 256
N, T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0

for i in range(N):
    if i == N-1:
        ans += T
    else:
        if t[i+1] - t[i] < T:
            ans += t[i+1] - t[i]
        else:
            ans += T
print(ans)


Measured memory_bytes: 26708
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
int x[200000 + 10];
int y[200000 + 10];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(x + 1, x + 1 + n);
    int maxx = x[n];
    int cnt = 0;
    if (x[n] == x[n - 1])
        cnt = 2;
    else
        cnt = 1;
    for (int i = 1; i <= n; i++)
    {
        if (y[i] == maxx)
            if (cnt == 2)
                cout << maxx << endl;
            else
                cout << x[n - 1] << endl;
        else
            cout << maxx << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
       long long a,b,c;
       while(cin>>a>>b>>c)
       {
           if(a==0)
             cout<<b/c+1<<"\n";
             else if(a==1)
                cout<<b/c<<"\n";
            else
            cout<<b/c-(a-1)/c<<"\n";
       }

        return 0;

}




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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

vector<string> a;

int hor_best[2001][2001], ver_best[2001][2001];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;

    cin >> n >> m;

    for(int i = 0; i < n; ++i){
        string c;
        cin >> c;
        a.push_back(c);
    }

    // Horizontal

    for(int x = 0; x < n; ++x){
        int cur = 0;
        for(int y = 0; y < m; ++y){
            if(a[x][y] == '#'){
                // Update
                for(int py = y - cur; py < y; ++py){
                    hor_best[x][py] = cur;
                }
                cur = 0;
            } else {
                ++cur;
            }
        }
        // Update
        for(int py = m - cur; py < m; ++py){
            hor_best[x][py] = cur;
        }
    }

    // Vertical

    for(int y = 0; y < m; ++y){
        int cur = 0;
        for(int x = 0; x < n; ++x){
            if(a[x][y] == '#'){
                // Update
                for(int px = x - cur; px < x; ++px){
                    ver_best[px][y] = cur;
                }
                cur = 0;
            } else {
                ++cur;
            }
        }
        // Update
        for(int px = n - cur; px < n; ++px){
            ver_best[px][y] = cur;
        }
    }

    int best = 0;

    for(int x = 0; x < n; ++x){
        for(int y = 0; y < m; ++y){
            //cout << hor_best[x][y] << " ";
            best = max(best, hor_best[x][y] + ver_best[x][y] - 1);
        }
        cout << endl;
    }

    cout << best;

    return 0;
}


Measured memory_bytes: 35840
#include <iostream>
#include <utility>
#include <map>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;

int main(void) {
    map<Int, Int> mp;
    Int n;
    cin >> n;
    Int a;
    for (Int i = 0; i < n; ++i) {
        cin >> a;
        if (mp.count(a) == 0) {
            mp.insert(make_pair(a, 1));
        } else {
            mp.erase(a);
        }
    }
    cout << mp.size() << endl;
    return 0;
}



Measured memory_bytes: 9612
n, x, y = map(int, input().split())
x -= 1
y -= 1
distances = [0] * (n - 1)
for i in range(n-1):
  for j in range(i+1, n):
    dist = min(
      j - i,
      abs(x - i) + abs(y - j) + 1,
      abs(y - i) + abs(x - j) + 1)
    distances[dist-1] += 1
for dist in distances:
  print(dist)

Measured memory_bytes: 3444
import sys

input = sys.stdin.readline

def main():
    ans = ''
    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))
    M, M2 = sorted(A)[-1], sorted(A)[-2]
    for i in range(N):
        if A[i] == M:
          ans += str(M2) + '\n'
        else:
          ans += str(M) + '\n'
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14992
#include <stdio.h>
#define MAX 101
#define INFINITY 1048576
#define WHITE -1
#define GRAY 0
#define BLACK 1
#define true 1

void serch(int,int *);

int M[MAX][MAX];

int main(){
  int n,i,j,k,v,a,d[MAX];

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

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

  serch(n,d);

  for(i = 0; i < n; i++){
    printf("%d ",i);
    if(d[i] == INFINITY) printf("%d",-1);
    else printf("%d\n",d[i]);
  }
  return 0;
}

void serch(int n,int *d){
  int u, v, min, i, j, p[MAX], c[MAX];

  for(i = 0; i < n; i++){
    c[i] = WHITE;
    d[i] = INFINITY;
  }

  d[0] = 0;
  c[0] = GRAY;

  while(true){
    min = INFINITY;
    u = -1;

    for(i = 0; i < n; i++){
      if(min > d[i] && c[i] != BLACK){
        u = i;
        min = d[i];
      }
    }

    if(u == -1) break;

    c[u] = BLACK;

    for(v = 0; v < n; v++){
      if(c[v] != BLACK && M[u][v] != INFINITY){
        if(d[v] > M[u][v] + d[u]){
          d[v] = M[u][v] + d[u];
          c[v] = GRAY;
        }
      }
    }
  }

  return;
}



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

int main() {
  int N;
  bool four = 0;
  cin >> N;
  
  for (int i=0; i<N; i++){
    string s;
    cin >> s;
    if (s == "Y"){
      four = 1;
    }
    else {
    }
  }
  if (four == 1){
    cout << "Four" <<endl;
  }
  else {
    cout << "Three" <<endl;
  }
}

Measured memory_bytes: 256
Module _20190427

    Sub Main()

        Dim iCount As Integer = Console.ReadLine()

        Dim sValue() As String = Console.ReadLine().Split(" ")
        Dim sCost() As String = Console.ReadLine().Split(" ")

        Dim iMax As Integer = 0

        For i As Integer = 0 To iCount - 1

            If CInt(sValue(i)) - CInt(sCost(i)) > 0 Then

                iMax = iMax + CInt(sValue(i)) - CInt(sCost(i))

            End If

        Next

        Console.WriteLine(iMax)

    End Sub

End Module

Measured memory_bytes: 11220
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W, ans, mi1,mi2,sum;
string s;
LL alp[100000][125];
int main() {
	cin >> N;
	map<string, int> m;
	ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> s;
		sort(s.begin(),s.end());
		if (m.find(s) != m.end()) {
			ans+=m[s];
			m[s]++;
		}
		else m[s] = 1;
	}

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



Measured memory_bytes: 11136
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e8);
const int mod = 16714589;
const int N = 2e6 + 555; // TL MB
const double PI = acos(-1.0);
double eps = 1e-6;

// {l, r}

int n;
void solve(){   
	vector<int> v;
	ll n, k;
	cin >> n >> k;
	ll a[n + 1];
	rep(i, n){
		cin >> a[i + 1];
	}
	map<int, int> used;
	int x = 1;
	while(!used[x]){
		v.pb(x);
		used[x] = 1;
		x = a[x];
	}
	if(k < sz(v)) cout << v[k] << '\n';
	else{
		int cnt = 0;
		reverse(all(v));
		while(v.back() != x) v.pop_back(), ++cnt;
		reverse(all(v));
		cout << v[(k - cnt) % sz(v)];
	}
}	// 0 1 2 2 3 3


 
 
int main()
{
	Red;
	//freopen("input.txt", "r", stdin);s
	//freopen("output.txt", "r", stdin);
  	int T = 1; 
 	//cin >> T; 
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
    return 0;
}

Measured memory_bytes: 14760
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
	int N, A, c, ans=INT_MAX; 
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		for (c = 0; A % 2 == 0; c++) A /= 2;
		ans = min(c, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3568
#include <stdio.h>
#define MAX 100000
#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);
}

//接点uの兄弟を返す
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){
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg=0;
    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,m, r ,root=0;
    scanf("%d",&n);

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

        for ( int 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(int i=0; i<n; i++){
    if(T[i].parent == NIL) root=i;
        }
setDepth(root,0);
setHeight(root);

for(int i=0; i<n; i++) print(i);
return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((abs(b - a) <= d && abs(c - b) <= d) || abs(a - c) <= d) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int r; cin >> r;
		cout << 3 * (r * r) << endl;
    return;
}

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



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    char c;
    cin,c;
    print(('A' <= c && c <= 'Z') ? 'A' : 'a');
    return 0;
}


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

int N, K;
vector<int> adj[100000];
long long ret = 1;
long long mod = 1e9 + 7;

void walk(int now, int prev){
  int k = K - 1;
  if(prev != -1){
    k--;
  }

  for(int i = 0; i < adj[now].size(); i++){
    int next = adj[now][i];
    if(next == prev){
      continue;
    }
    ret *= k;
    ret %= mod;
    k--;
    walk(next, now);
  }
}

int main(){
  cin >> N >> K;
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  ret *= K;
  walk(0, -1);

  cout << ret << endl;
}


Measured memory_bytes: 10368
N = gets.to_i
heights = gets.split.map(&:to_i)
answer = true
previous = heights.shift
heights.each do |current|
  if previous < current
    # OKなパターン
    # 念の為、一つ下げておく（下げてもpreviousと同じかそれより上）
    previous = current - 1
  elsif previous == current
    # これもOKなパターン。
    #　高さはpreviousのまま。
  elsif previous == current - 1
    # 1減らして同じ高さになったパターン
    # この場合には高さはpreviousのまま
  else # previous > current - 1
    # Failedパターン
    answer = false
    break
  end
end
puts answer ? "Yes" : "No"


Measured memory_bytes: 10500
from decimal import Decimal, ROUND_DOWN
import heapq
from fractions import gcd
from functools import reduce
from collections import deque
# from math import factorial
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import statistics
# import numpy as np
# n = int(input())
# a, b, c, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
# n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
a, b = list(map(float, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
# p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
ans = (Decimal(str(a)) * Decimal(str(b))
       ).quantize(Decimal('0'),  rounding=ROUND_DOWN)
print(ans)


Measured memory_bytes: 10476
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>



int main() {
	ll n;
	cin >> n;
	vector<ll> s(n);
	REP(i, n) {
		cin >> s[i];
		s[i] -= i;
	}
	map < ll, ll > m;
	ll ans = 0;
	REPR(i, n - 1) {
		ans += m[- s[i] - i * 2];
		m[s[i]]++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 27316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
typedef long long ll;
ll cnt[maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;ll p;
    cin>>n>>p;
    string s;cin>>s;int len=s.size();
    ll ans=0;
    if(p==2||p==5){
        rep(i,0,len-1)if((s[i]-'0')%p==0)ans+=i+1;
    }else{
        ll cur=0;
        cnt[0]=1;
        ll bit=1;
        rep(i,1,len){//bug 123 算成321
            int j=len-i;           
            cur+=(s[j]-'0')*bit;
            cur%=p;
            bit=bit*10%p;
            ans+=cnt[cur];
            cnt[cur]++;
        }
    }
    cout<<ans<<endl;
}
/* 

 */

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

int main(){
    int n;
    cin>>n;
    int ans=100000+1;
    for(int i=1;i<n;i++){
        string s=to_string(i),t=to_string(n-i);
        int a=s.size(),b=t.size();
        int cnt=0;
        for(int j=0;j<a;j++) cnt+=s[j]-'0';
        for(int j=0;j<b;j++) cnt+=t[j]-'0';
        if(cnt<ans) ans=cnt;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

signed main() {
    capi(n);

    if (n % 2 == 1) {
        cout << 0;
    } else {
        int ans = 0;
        for (; n >= 1;) {
            n /= 5;
            ans += n / 2;
        }
        cout << ans;
    }

    return 0;
}


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

const int maxn = 105;
int n;
double arr[maxn];
double ans = 0;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lf",&arr[i]);
	for(int i=1;i<=n;i++) ans += 1/arr[i];
	ans = 1/ans;
	printf("%lf",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cfloat>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
  
using namespace std;
  
#define fi first
#define se second
typedef pair<double,double> P;
  
#define MAX (21)
#define INF (DBL_MAX/4)
  
double G[MAX][MAX];
  
int n;
vector<P> crys;
P h, d;
  
double dist(P p1, P p2){
  return sqrt(pow(p1.fi-p2.fi, 2.) + pow(p1.se-p2.se, 2.));
}
  
void makeEdge() {
  for(int i=0; i<n; i++) {
    G[i][i] = 0;
    for(int j=i+1; j<n; j++) {
      G[i][j] = G[j][i] = dist(crys[i], crys[j]);
    }
  }
}
  
//map<int, double> dp;
// 速度テストさせてください
unordered_map<unsigned long long, double> dp;
 
bool dfs(int S, int idx, double cost) {
   
  if(S==(1<<n)-1) {
    return true;
  }
   
  dp[S] = cost;
   
  for(int i=0; i<n; i++) {
    if((S>>i)&1) continue;
    if(cost + G[idx][i] >= dist(crys[i], d)) return false;
  }
   
  for(int i=0; i<n; i++){
    if((S>>i)&1) continue;
    double ncost = cost + G[idx][i];
    double nS = S|(1<<i);
    if(ncost >= dist(crys[i], d)) return false;
    else {
      if(dp.count(nS) && dp[nS] < ncost) continue;
      if(dfs(nS, i, ncost)) return true;
    }
  }
   
  return false;
}
  
bool solve() {
    
  makeEdge();
   
  dp.clear();
  for(int i=0; i<n; i++) {
    if(dist(h, crys[i]) >= dist(crys[i], d)) continue;
    if(dfs(1<<i, i, dist(h, crys[i]))) {
      return true;
    }
  }
  return false;
}
  
int main(){
  while(true){
    crys.clear();
    cin >> n >> h.fi >> h.se >> d.fi >> d.se;
    if(!n && !h.fi && !h.se && !d.fi && !d.se){
      break;
    }
    crys.resize(n);
    for(int i=0; i<n; i++){
      cin >> crys[i].fi >> crys[i].se;
    }
    cout << (solve() ? "YES" : "NO") << endl;
  }
  return 0;
}

Measured memory_bytes: 15296
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans;
int n,m;
int dp[100034];//i円にできる数
signed main(){
	
	cin>>n;
	dp[0]=1;
	rep(i,n+1){
		rep(j,6){
			if(i-(100+j)<0)continue;
			dp[i]=max(dp[i],dp[i-(100+j)]);
		}
	}
	cout<<(dp[n]!=0)<<endl;

}


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

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

int SURP = 1000000007;

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

	bool ret = true;
	if(N%500 > A) ret = false;

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


Measured memory_bytes: 256
# your code goes here
N, K, Q = gets.split.map(&:to_i)
As = Q.times.map{gets.to_i}

ans = Array.new(N, 0)

for A in As do
  ans[A-1] += 1
end

for i in 0...N do
  if i != N-1 then
	  puts (Q - ans[i] >= K) ? "No" : "Yes"
  else
  	  print (Q - ans[i] >= K) ? "No" : "Yes"
  end
end

Measured memory_bytes: 4660
/*
/// https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_a
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
const int N =2e6+6;
const int mod = 1e9+7;
void solve(){
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    while(t--)solve();
    return 0;
}
*/
/*
/// https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_b
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
const int N =2e6+6;
const int mod = 1e9+7;
void solve(){
    ll a,v;
    ll b,w;
    ll T;
    cin>>a>>v>>b>>w>>T;
    ll d1 = v*T;
    ll d2 = w*T;
    d2+= abs(b-a);
//    cout<<d1<<" "<<d2<<endl;
    if(d2>d1)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    while(t--)solve();
    return 0;
}

*/
///*
/// https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_c
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
const int N =2e6+6;
const int mod = 1e9+7;
int a[N];
int b[N];
void solve(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int it = 1;it<=min(k,50);it++){
        for(int i=1;i<=n;i++){
            int x = max(1,i-a[i]);
            int y = min(n+1,i+a[i]+1);
            b[x] ++;
            b[y]--;
        }
        for(int i=1;i<=n;i++){
            b[i]+=b[i-1];
            a[i] = b[i];
        }
        for(int i=0;i<=n+1;i++)b[i] = 0;
    }
    for(int i=1;i<=n;i++)cout<<a[i]<<" ";
    cout<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    while(t--)solve();
    return 0;
}
//*/


Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	long long l = s.length();
	long long res = 0,i = 0;
	while(i<l)
	{
		long long p = 0, q = 0;
		while(s[i]=='<' && i<l)
		{
			i++;
			p++;
		}
		while(s[i]=='>' && i<l)
		{
			i++;
			q++;
		}
		if(p<q)
			swap(p,q);
		p = p*(p+1)/2;
		q = q*(q-1)/2;
		res+= p + q;
	}
	cout<<res<<'\n';
}

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

using namespace std;
typedef long long ll;

int main()
{
    int N;

    cin >> N;

    queue<string> A;

    A.push("a");

    if (N == 1)
    {

        cout << 'a' << endl;
        return 0;
    }

    while (1)
    {

        string s = A.front();

        if (s.size() == N)
        {
            break;
        }

        A.pop();

        char c = s.back();

        char d = c + 1;



        char largest = 'a';


        for(int i=0;i<s.size();i++){

            largest = max(largest,s[i]);
        }

        for (char k = 'a'; k <= largest+1; k++)
        {

            string f = s + k;

            A.push(f);

            if (f.size() == N)
            {

                cout << f << endl;
            }
        }

       
    }

    return 0;
}


Measured memory_bytes: 6964
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
using namespace std;
template <class T>

bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}

int main()
{
    ll n, X;
    cin >> n >> X;
    vector<ll> x(n), dif(n);
    rep(i, n)
    {
        cin >> x[i];
    }
    x.push_back(X);

    sort(all(x));
    rep(i, n)
    {
        dif[i] = x[i + 1] - x[i];
    }
    int ans = dif[0];

    rep(i, n - 1)
    {
        ans = gcd(ans, dif[i + 1]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int n,d,x;
	cin >> n >> d >> x;
	int a,ans=0;
	for(int i=0; i<n; i++){
		cin >> a;
		for(int j=0; j*a+1<=d; j++)ans++;
	}
	cout << ans+x << endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input)
{
    const temp = input.trim().split("\n");
    const k = parseInt(temp[0], 10);
    const s = String(temp[1]);

    if (s.length > k) {
        let ans = s.slice(0, k);
        console.log(ans + "...");
    } else {
        console.log(s)
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29952
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
using namespace std;

int main(void){
	int A[3],K,select=0,ans=0;
	cin>>A[0]>>A[1]>>A[2]>>K;
	sort(A,A+3);
	for(int i=0;i<K;i++)A[2]=A[2]*2;
	ans = A[0]+A[1]+A[2];
	cout << ans << endl;
}


Measured memory_bytes: 256