akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	double n = 0, a,b,m = 0,counter = 0;
	string in,in2;
	vector<double>vec;
	cin >> n;
	rep(i, n) {
		cin >> a;
		vec.push_back(a);
}
	sort(vec.begin(), vec.end());
	rep(i, n - 1) {
		vec[i + 1] = (vec[i] + vec[i + 1]) / 2;
	}
	cout << vec[n-1] << endl;
}




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

int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    while(A > 0 && C > 0) {
        C -= B;
        if (C <= 0) break;
        A -= D;
    }
    if (A > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {

	int n;
	cin >> n;
	int a[205][205];
	rep(i, n) {
		rep(j, n) {
			char c;
			cin >> c;
			a[i][j] = c - '0';
		}
	}

	int ans = -1;
	rep(i, n) {
		int nowcnt = 0;
		int dat[205];
		rep(j, n) dat[j] = -2;
		dat[i] = nowcnt;
		while (1) {
			rep(j, n) {
				if (dat[j] == nowcnt) {
					rep(k, n) {
						if (a[j][k] && dat[k] != nowcnt && dat[k] != nowcnt - 1&&dat[k]!=nowcnt+1) {
							if (dat[k] != -2) {
								goto bou;
							}
							dat[k] = nowcnt + 1;
						}
					}
				}
			}
			rep(j, n) {
				rep(k, n) {
					if (dat[j] == dat[k] && dat[j] != -2 && a[j][k]) {
						goto bou;
					}
				}
			}
			nowcnt++;
			bool finish = true;
			rep(j, n) {
				if (dat[j] == -2) {
					finish = false;
					break;
				}
			}
			if (finish) break;
		}
		ans = max(ans, nowcnt + 1);
	bou:;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long double N, K;
    cin >> N >> K;

    long double ex = 0;
    FOR(sai, 1, N + 1) {
        if (sai >= K) {
            ex++;
        } else {
            ll n_trial = ceil(log2(K / sai));
            // if (n_trial < 1) n_trial = 1;
            ex += pow(0.5, n_trial);
            debug(sai, n_trial);
        }
    }
    long double ans = ex / N;
    cout << setprecision(20) << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import sys


# import math
import heapq

# input = sys.stdin.readline
from collections import deque

def main():
    n, m = map(int,input().split())
    room =[[]for _ in range(n+1)]
    for i in range(m):
        a,b = map(int,input().split())
        room[a].append(b)
        room[b].append(a)

    point = [0] *(n+1) #未踏0 その他　親
    d = deque([1])

    while len(d) > 0:
        p = d.popleft()
        for v in room[p]:
            if point[v] ==0:
                d.append(v)
                point[v] =p

    if 0 in point[1:]:
        print('No')
    else:
        print("Yes")
        print("\n".join(map(str,point[2:])))












if __name__ == "__main__":
    main()


Measured memory_bytes: 104364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n,m;
    cin>>n>>m;
    int l[m],r[m];
    for(int i=0;i<m;i++){
        cin>>l[i]>>r[i];
    }
    int maxL=1;
    int minR=n;
    for(int i=0;i<m;i++){
        maxL=max(maxL,l[i]);
        minR=min(minR,r[i]);
    }
    int ans=max(0,minR-maxL+1);
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - Grid Repainting 2
int H, W;
char grid[55][55];
string ans;

int main(){
    cin >> H >> W;

    ans = "Yes";
    repeq(i, 1, H){
        repeq(j, 1, W){
            cin >> grid[i][j];
        }
    }
    repeq(i, 1, H){
        repeq(j, 1, W){
            char tmp;
            if(grid[i][j] == '#'){
                tmp = '.';
                if(grid[i-1][j] == tmp && grid[i][j-1] == tmp && grid[i+1][j] == tmp && grid[i][j+1] == tmp){
                    ans = "No";
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

def solve():
    a, b = MI()

    print(max(0, a - 2 * b))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
from operator import itemgetter

N, M = list(map(int, input().split()))
A = [[0] * 4 for i in range(M)]
for i in range(M):
    A[i][0], A[i][1] = list(map(int, input().split()))
    A[i][2] = i

sorted_A = sorted(A, key=itemgetter(1))

P_num = [1]*N
for a in sorted_A:
    y = a[0]
    a[3] = P_num[y-1]
    P_num[y-1] += 1

B = sorted(sorted_A, key=itemgetter(2))
for b in B:
    print("%06d%06d" % (b[0], b[3]))


Measured memory_bytes: 31372
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        for(int i = a;i <= b;i++){
            if(i%k == 0){
                System.out.println("OK");
                return;
            }
                
        }
        System.out.println("NG");
    }
}

Measured memory_bytes: 35808
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1000000000000000000;
typedef pair<int, int> P;
typedef unsigned int ui;
typedef long long ll;
int h, w;
char S;
char s[50][50];
int d[50][50];
int dx[4] = { 1,0,-1,0 }; int dy[4] = { 0,1,0,-1 };
int bfs() {
	queue<P> que;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			d[i][j] = MOD;
		}
	}
	d[0][0] = 1;
	que.push(P(0, 0));
	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == h - 1 && p.second == w - 1)break;
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i]; int ny = p.second + dy[i];
			if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&s[nx][ny] != '#'&&d[nx][ny] == MOD) {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h-1][w-1];
}
int main(){
	cin >> h >> w;
	int sum = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> S;
			s[i][j] = S;
			if (S == '.')sum++;
		}
	}
	int res = bfs();
	if (res != MOD) {
		cout << sum - res << endl;
	}
	else {
		cout << -1 << endl;
	}
	char nyaa;
	cin >> nyaa;
	return 0;
}


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

int n, k;
vector<int> h(MAX);

int64_t attack() {
    if (n <= k) {
        return 0;
    } else {
        int64_t sum = 0;
        sort(h.begin(), h.end(), greater<int>());
        for (int i = k; i < n; i++) {
            sum += (int64_t)h.at(i);
        }

        return sum;
    }
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        scanf("%d", &h.at(i));
    }

    cout << attack() << endl;
}

Measured memory_bytes: 1152
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    int minimum = 2 * pow(10, 5) + 1;
    for(int i = 0; i < N; i++) {
        int p;
        cin >> p;
        ans += p < minimum ? 1 : 0;
        minimum = min(minimum, p);
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int main(){
    int N1, N2, N3, N4;
    cin >> N1 >> N2 >> N3 >> N4;
    set<int> Nset;

    Nset.insert(N1);
    Nset.insert(N2);
    Nset.insert(N3);
    Nset.insert(N4);

    if(Nset.find(1) != Nset.end()){
        if(Nset.find(9) != Nset.end()){
            if(Nset.find(7) != Nset.end()){
                if(Nset.find(4) != Nset.end()){
                    cout << "YES" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int chec(char *str,int l,int r)
{
	int i=l,j=r;
	for(i,j;i<=r,j>=l;i++,j--)
	{
		if(str[i]!=str[j]) return 0;
	}
	return 1;
}
int main()
{
	char str[100];
	cin>>str+1;
	int len=strlen(str+1);
	int f1=chec(str,1,len);//han len
	if(f1==1)
	{
		int f2=chec(str,1,(len-1)/2);
		int f3=chec(str,(len+3)/2,len);
		if(f2&&f3) cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	else
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

static const int NMAX = 1000003; // prime

char D[NMAX][13];

int h1(long long x) {
	return x % NMAX;
}

int h2(long long x) {
	return 1 + (x % (NMAX - 1));
}

long long convert(char c[]) {
	long long cc = 0;
	for (unsigned int i = 0; i < strlen(c); i++) {
		cc *= 4;
		if (c[i] == 'A') cc += 0;
		else if (c[i] == 'C') cc += 1;
		else if (c[i] == 'G') cc += 2;
		else if (c[i] == 'T') cc += 3;
		else return -1;
	}

	return cc;
}

int myHash(long long cc, int ix) {
	int idx;

	idx = (h1(cc) + (ix * h2(cc))) % NMAX;

	return idx;
}

void insert(char c[]) {
	long long cc;
	int idx;

	cc = convert(c);
	idx = myHash(cc, 0);

	int ix = 0;
	while (strlen(D[idx]) != 0) {
		if (!strcmp(D[idx], c)) return;
		idx = myHash(cc, ++ix);
	}

	strcpy(D[idx], c);
}

bool find(char c[]) {
	long long cc;
	int idx;

	cc = convert(c);
	idx = myHash(cc, 0);

	int ix = 0;
	while (strlen(D[idx]) != 0) {
		if (!strcmp(D[idx], c)) {
			return true;
		}
		else {
			idx = myHash(cc, ++ix);
		}
	}
	return false;
}

int main() {
	int n;
	char c1[6+1], c2[12+1];

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s %s", c1, c2);
		if (c1[0] == 'i') {
			insert(c2);
		}
		else if (c1[0] == 'f') {
			if (find(c2)) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
		else return -1;
	}

	/*
	for (int i = 0; i < NMAX; i++) {
	if (strlen(D[i]) > 0) cout << i << " : " << D[i] << endl;
	}
	*/

	return 0;
}

Measured memory_bytes: 15844
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

const int INF = 1000000000;
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void solve() {
    int H, W; cin >> H >> W;
    int x0, y0; cin >> x0 >> y0, x0--, y0--;
    int x1, y1; cin >> x1 >> y1, x1--, y1--;
    vector<string> s(H);
    for (int i = 0; i < H; i++) cin >> s[i];

    vector<vector<int>> d(H, vector<int>(W, INF));
    d[x0][y0] = 0;
    deque<pair<int, int>> deq;
    deq.push_back(make_pair(x0, y0));

    while (!deq.empty()) {
        pair<int, int> p = deq.front(); deq.pop_front();
        int x = p.first, y = p.second;

        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (0 <= nx && nx < H && 0 <= ny && ny < W) {
                if (s[nx][ny] == '.') {
                    if (d[nx][ny] > d[x][y]) {
                        d[nx][ny] = d[x][y];
                        deq.push_front(make_pair(nx, ny));
                    }
                }
            }
        }

        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (i == 0 && j == 0) continue;
                int nx = x + i, ny = y + j;
                if (0 <= nx && nx < H && 0 <= ny && ny < W) {
                    if (s[nx][ny] == '.') {
                        if (d[nx][ny] > d[x][y] + 1) {
                            d[nx][ny] = d[x][y] + 1;
                            deq.push_back(make_pair(nx, ny));
                        }
                    }
                }
            }
        }
    }

    if (d[x1][y1] == INF) cout << -1 << '\n';
    else cout << d[x1][y1] << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 8676
c = []
for i in range(3):
  c.append(list(map(int, input().split())))
diff = c[1][2] - c[2][2]
c[1][1] -= diff
c[1][0] -= diff

diff = c[0][2] - c[2][2]
c[0][1] -= diff
c[0][0] -= diff

if c[1][1] == c[2][1] and c[0][1] == c[2][1] and c[1][0] == c[2][0] and c[1][0] == c[0][0]:
  print('Yes')
else:
  print('No')
  


Measured memory_bytes: 3064
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    a,b,c = map(int, input().split())
    ans = len(set([a,b,c]))
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
int n,m;
int vis[maxn],num[maxn];
int main(){
	scanf("%d%d",&n,&m);
	vis[1]=1;
	fill(num+1,num+n+1,1);
	for(int i=1;i<=m;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		if(vis[x])vis[y]=1;
		num[x]--;num[y]++;
		if(num[x]==0)vis[x]=0;
	}
	int cnt=0;
	for(int i=1;i<=n;++i){
		if(vis[i]&&num[i])cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	ll n; cin >> n;
	n = (n + 1) % 2;
	cout << n;
}
int main()
{
	fast;
	//cp();
	ll t = 1;
	//cin >> t;
	while (t--)
		solve();


	return 0;
}

Measured memory_bytes: 3648
numbers_a = []
numbers_b = []
character = []

while True:
  a,op,b = input().split()
  if op == "?":
    break
  a = int(a)
  b = int(b)
  numbers_a.append(a)
  numbers_b.append(b)
  character.append(op)

for i in range(len(character)):
  
  if character[i] == "+" :
    x = numbers_a[i] + numbers_b[i]
    
  if character[i] == "-":
    x = numbers_a[i] - numbers_b[i]
    
  if character[i] == "*":
    x = numbers_a[i] * numbers_b[i]
    
  if character[i] == "/":
    x = numbers_a[i] // numbers_b[i]
    
  print(x)


Measured memory_bytes: 5592
while True:
    try:
        a, b, c, d, e, f = [float(x) for x in input().split()]
    except:
        exit()
    m = [[a,b,c],[d,e,f]]
    row = len(m)
    col = len(m[0])
    for k in range(row):
        for j in range(k+1,col):
            m[k][j] /=m[k][k]
        for i in range(row):
            if(i != k):
                for j in range(k+1,col):
                    m[i][j] -= m[i][k] * m[k][j]
    print ("%.3f %.3f" % (m[0][2],m[1][2]))

Measured memory_bytes: 7444
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N = int(raw_input())
a = map(int, raw_input().split())

aso = [N]*N
q = [a[0]]
for i in xrange(1, N):
    while q and q[-1] > a[i]:
        aso[q[-1] - 1] = i
        q.pop()
    q.append(a[i])
dso = [-1]*N
q = [a[-1]]
for i in xrange(N - 2, -1, -1):
    while q and q[-1] > a[i]:
        dso[q[-1] - 1] = i 
        q.pop()
    q.append(a[i])

ans = 0
for i in xrange(N):
    ans += a[i] * (aso[a[i] - 1] - i)*(i - dso[a[i] - 1])
print ans


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

int main() {
  string a , b ;
  cin >> a >> b ;
  
  if((a=="H" && b=="H") || (a=="D" && b=="D")){
    cout << "H" << endl;
  }
  else {
    cout << "D" << endl;
  }

  
}



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

using namespace std ;
typedef long long ll;

int n, k;
int a, b;
vector < vector < int > > V;
bool vis[2020];
int dfs(int u, int d = 0)
{
    if (vis[u]) return 0;
    int cur = d > k/2;
    vis[u] = 1;
    for (auto v: V[u])
        cur += dfs(v, d+1);
    vis[u] = 0;
    return cur;
}
int dfsOdd(int u, int u2, int d = 0)
{
    if (u == u2) return 0;
    if (vis[u]) return 0;
    int cur = d > (k-1)/2;
    vis[u] = 1;
    for (auto v: V[u])
        cur += dfsOdd(v, u2, d+1);
    vis[u] = 0;
    return cur;
}
int main()
{
    scanf("%d%d", &n, &k);
    V.resize(n);
    for (int i = 1; i < n; ++i)
    {
        scanf("%d%d", &a, &b);
        --a; --b;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    int ans = INT_MAX;
    for (int i = 0; i < n; ++i)
    {
        if (k&1)
        {
            for (auto u: V[i])
                ans = min(ans, dfsOdd(i, u) + dfsOdd(u, i));
        }
        else
            ans = min(ans, dfs(i));
    }
    printf("%d\n", ans);

    return 0 ;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

int main(int argc, char** argv) {
  int N, K;
  cin >> N >> K;
  int max_cnt = (N-1)*(N-2)/2;
  // Now, we can make (N-1)*(N-2)/2 pairs by connecting 1 and others.
  // By selecting (N-1)*(N-2)/2 - K pairs, we can decrease the count to K.
  if (K > max_cnt) {
    cout << -1 << endl;
    return 0;
  }

  cout << (N-1) + max_cnt - K << endl;
  for (int i = 2; i <= N; ++i) {
    cout << "1 " << i << endl;
  }
  int cnt = 0;
  for (int i = 2; i <= N; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      if (cnt < max_cnt - K) {
        cout << i << " " << j << endl;
      }
      cnt += 1;
    }
  }
}


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

int main() {
	int flag=0;
	char c;cin>>c;
	if(c=='a')flag=1;
	if(c=='i')flag=1;
	if(c=='u')flag=1;
	if(c=='e')flag=1;
	if(c=='o')flag=1;
	if(flag){
		cout<<"vowel"<<endl;
	}else{
		cout<<"consonant"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    register int i,j;
    int d,c[26],s[365][26];
    scanf("%d",&d);
    for(i = 0;i < 26;i++)scanf("%d",&c[i]);
    for(i = 0;i < 26;i++)for(j = 0;j < d;j++)scanf("%d",&s[j][i]);
    int max[365] = {0};
    int maxi[365];
    for(i = 0;i < 26;i++)for(j = 0;j < d;j++)if(s[j][i] > max[j]){
        max[j] = s[j][i];
        maxi[j] = i;
    }
    for(int i = 0;i < d;i++)printf("%d\n",maxi[i]+1);
}

Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans = 1e18;
    if((B-A)%2==0){
        ans = min({(B-A)/2,max(A-1,B-1),max(N-B,N-A)});
    }else{
        ans = min({A-1+(B-A+1)/2,N-B+(B-A+1)/2,max(A-1,B-1),max(N-B,N-A)});
    }
    cout << ans << endl;
}

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

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

    int a[N];
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    
    sort(a, a + N, greater<int>());

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

    cout << res + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    string s,t;
    cin>>s>>t;
    int k=0;
    int ind=-1;
    for(int i=0;i<s.length();i++){
        k=0;
        if(t[k]==s[i] || s[i]=='?'){
                if(i+t.length()<=s.length()){
                    for(int j=i;j<i+t.length();j++){
                        if(s[j]==t[k] || s[j]=='?')k++;
                        else break;
                    }
                    if(k==t.length())ind=i;
                }else break;
        }
    }
    if(ind==-1)cout<<"UNRESTORABLE";
    else{
        int z=0;
        for(int i=ind;i<ind+t.length();i++){
            s[i]=t[z];
            z++;
        }
        for(int i=0;i<s.length();i++){
            if(s[i]=='?')cout<<"a";
            else cout<<s[i];
        }
    }
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define v(d_type) vector<d_type>
#define p(d_type1, d_type2) pair<d_type1, d_type2>
#define F first
#define S second
#define loop(i, s, n) for(int i = s; i < n; i++)
#define nl "\n"
#define fat 1000000007

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

    string s;
    cin >> s;

    ll ans = 1;
    for(int i = 1; i < s.size(); i++)
    {
        if(s[i] == s[i - 1]) continue;
        else ans++;
    }

    cout << ans << nl;
    return 0;
}

Measured memory_bytes: 512
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Map <Integer,Integer> mapX = new HashMap<Integer,Integer> ();
		int x[][];
		Scanner sc = new Scanner(System.in);
			// 整数の入力
			int n,d,index,index2,j;
			int sum,result,xd,r;
			double rd;;
			
			n = sc.nextInt();
			d = sc.nextInt();
			x=new int[10][10];
			for(index=0;index<n;index++) {
				for(index2=0;index2<d;index2++) {
					x[index][index2]=sc.nextInt();
				}
			}
			sc.close();
			result=0;
			for(index=0;index<n-1;index++) {
				for(index2=index+1;index2<n;index2++) {
					sum=0;
					for(j=0;j<d;j++) {
						xd=(x[index][j]-x[index2][j]);
						sum+=xd*xd;
					}
					rd=Math.sqrt(sum);
					r=(int)rd;
					if(r*r==sum) {
						result=result+1;
					}
				}
			}
			System.out.println(result);

			
 
			// 出力
 
	}
}

Measured memory_bytes: 21844
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  // #define MAX 100001
  #define md 998244353
  #define add accumulate
  #define ll long long int
  #define ld long double
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define repa(a,n) for(int i=a;i<n;i++)
  const int MAX=1e5+5;
  const int mod=1e9+7;
  const int N=3e5+9;
  const long double eps=1e-9;
  const ld PI=acos(-1.0);
  //
  //
  int main(){
    ll n,w; cin>>n>>w;
    ll arr[w+1];
    rep(i,0,w+1)
      arr[i]=0;
    ll wt,prc;
    rep(i,0,n){
      cin>>wt>>prc;
      for(ll j=w;j>=wt;j--)
        arr[j]=max(arr[j],arr[j-wt]+prc);
    }
    ll ans=0;
    rep(i,0,w+1)
      ans=max(ans,(ll)arr[i]);
    cout<<ans;
    // rep
    // cout<<arr[i]<<" ";
  	return 0;
 }

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

int main(){
  long long a,b,bs;
  string s;
  
  cin >> a >> s;
  int pos = s.find(".");
  b = stoi(s.substr(0,pos));
  bs = stoi(s.substr(pos+1));
  
  bs *= a;
  bs /=100;
  b *= a;
  
  cout << b+bs << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstring>
int main()
{
	int N;
	std::cin >> N;
	std::vector<int64_t> L(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> L[i];
	}
	int count = 0;
	for (int i = 0; i < N; ++i) {
		const int64_t Li = L[i];
		for(int j = i + 1; j < N; ++j) {
			const int64_t Lj = L[j];
			if (Lj == Li) {
				continue;
			}
			for (int k = j + 1; k < N; ++k) {
				const int64_t Lk = L[k];
				if ((Lk == Li) || (Lk == Lj)) {
					continue;
				}
				if ((Li + Lj > Lk) && (Li + Lk > Lj) && (Lj + Lk > Li)) {
					++count;
				}
			}
		}
	}
	std::cout << count << std::endl;
	return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int A,B;
	scanf("%d%d",&A,&B);
	printf("%d\n",(A+B)%24);
	return 0;
}


Measured memory_bytes: 256
//                        DushtuBunny
//                        Rahul Halder    
//    Indian Institute of Engineering Science & Technology,Shibpur


#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll int64_t
#define f first
#define se second
#define LB lower_bound
#define UB upper_bound
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define vi vector<int>
#define vc vector<char>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
const unsigned int MOD = 1000000007;

using namespace std;

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    IOS;
    int T;
    // cin>>T;
    T=1;

    while(T--)
    {
        ll n,k;cin>>n>>k;
        ll a[n+1];
        for(int i=1;i<=n;i++)cin>>a[i];

        map<int,int>m;
        vll v,rotate;
        ll index = -1,i=a[1];
        m[1]=1;
        v.pb(1);
        while(m[i]!=1)
        {
            m[i]=1;
            v.pb(i);
            i = a[i];
        }

        rotate.pb(i);
        ll count = 0;
        i=a[i];

        while(i!=rotate[0])
        {
            rotate.pb(i);
            i=a[i];
            count++;
        }
        if(k<v.size())
            cout<<v[k];
        else
            cout<<rotate[(k-v.size())%(rotate.size())];
    }
  
    return 0;
}

Measured memory_bytes: 17676
#include <stdio.h>


int solve(int, int, int, int *);


int main(){

  int j, n, A[20], q, m;


  scanf("%d", &n);

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


  scanf("%d", &q);

  for(j=0 ; j<q ; j++){

    scanf("%d", &m);

    if(solve(0, m, n, A)==1){
      printf("yes\n");
    }else{ 
      printf("no\n");
    }
  }

  return 0;

}




int solve(int i, int m , int n, int *A){

  int res;

  if(m == 0) return 1;

  if(i >= n) return 0;

  res = solve(i+1, m, n, A) || solve(i+1, m-A[i], n, A);
  return res;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main()
{
  int n, m, c;
  cin >> n >> m >> c;
  vi b(m);
  re(i, m) cin >> b[i];

  vi a(m);
  int count = 0;
  re(i, n) {
    int s = 0;
    re(j, m) {
      cin >> a[j];
      s += a[j] * b[j];
    }
    if (s + c > 0) count++;
  }

  cout << count << endl;

  return 0;
}


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

struct dice{
	vector<int>d,init;
	bool operator==(const dice&oth){
		vector<string>v={"-"s,"N"s,"W"s,"WW"s,"E"s,"N"s};
		vector<int>tmp=d; d=init; 
		string rotate="SEN"s;
		for(auto&&i:v){
			for(auto&&j:i){
				roll(j);
			}
			for(int j=0;j<4;++j){
				if(d==oth.d){
					d=tmp;
					return true;
				}
				for(auto&&k:rotate){
					roll(k);
				}
			}
		}
		return false;
	}
	bool operator<(const dice&oth)const{
		return d<oth.d;
	}
	void insert(){
		for(int i=0;i<6;++i){
			int n; cin>>n;
			d.emplace_back(n);
			init.emplace_back(n);
		}
	}
	void roll(char c){
		int&top=d.at(0),&dow=d.at(1),&rig=d.at(2)
		,&lef=d.at(3),&upp=d.at(4),&btm=d.at(5);
		if(c=='N')swap(top,upp),swap(top,btm),swap(top,dow);
		else if(c=='E')swap(top,rig),swap(top,btm),swap(top,lef);
		else if(c=='S')swap(top,dow),swap(top,btm),swap(top,upp);
		else if(c=='W')swap(top,lef),swap(top,btm),swap(top,rig);
	}
	void prtop(){
		cout<<d.at(0)<<"\n"s;
	}
	void prrig(int top,int dow){
		vector<string>v={"-"s,"N"s,"W"s,"WW"s,"E"s,"N"s};
		vector<int>tmp=d; d=init;
		const int&nwtop=d.at(0),&nwdow=d.at(1),&nwrig=d.at(2);
		string rotate="SEN"s;
		for(auto&&i:v){
			for(auto&&j:i){
				roll(j);
			}
			for(int j=0;j<4;++j){
				if(top==nwtop&&dow==nwdow){
					cout<<nwrig<<"\n"s;
					d=tmp;
					return;
				}
				for(auto&&k:rotate){
					roll(k);
				}
			}
		}
	}
	dice sort(){
		vector<string>v={"-"s,"N"s,"W"s,"WW"s,"E"s,"N"s};
		dice mn=*this;
		string rotate="SEN"s;
		for(auto&&i:v){
			for(auto&&j:i){
				roll(j);
			}
			for(int j=0;j<4;++j){
				mn=min(mn,*this);
				for(auto&&k:rotate){
					roll(k);
				}
			}
		}
		return mn;
	}
};

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<dice>v(n); for(auto&&i:v)i.insert();
	for(auto&&i:v)i=i.sort();
	sort(v.begin(),v.end());
	bool yes=true;
	for(int i=1;i<v.size();++i){
		if(v.at(i-1)==v.at(i))yes=false;
	}
	cout<<(yes?"Yes"s:"No"s)<<"\n"s;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int H,W;
	cin >> H >> W;
	V<string> s(H);
	rep(i,H) cin >> s[i];
	VV<int> cnt(H,V<int>(W));
	rep(t,4){
		rep(i,H){
			int c = 0;
			rep(j,W){
				if(s[i][j] == '#') c = 0;
				else c++;
				cnt[i][j] += c;
			}
		}
		{
			V<string> ns(W,string(H,'.'));
			rep(i,H) rep(j,W) ns[j][i] = s[i][W-1-j];
			s = ns;

			VV<int> ncnt(W,V<int>(H));
			rep(i,H) rep(j,W) ncnt[j][i] = cnt[i][W-1-j];
			cnt = ncnt;

			swap(H,W);
		}
	}
	int ans = 0;
	rep(i,H) rep(j,W) chmax(ans,cnt[i][j]-3);
	cout << ans << endl;
}


Measured memory_bytes: 52352
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define REP(i,a,b) for(int i=int(a);i<=int(b);i++)
#define MOD 1000000007
#define INF 2000000000
#define DESPACITO 1000000000000000000
#define PI acos(-1);
#define E 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define double long double

using namespace std;

double x[100001],y[100001];
char dir[100001];
int n;

double check(double t)
{
	double maxx = -INF, maxy = -INF, minx = INF, miny = INF;
	REP(i,1,n)
	{
		double valx = x[i];
		double valy = y[i];
		if(dir[i] == 'U')
			valy+=t;
		else if(dir[i]=='D')
			valy-=t;
		else if(dir[i]=='R')
			valx+=t;
		else
			valx-=t;
		minx=min(minx,valx);
		maxx=max(maxx,valx);
		miny=min(miny,valy);
		maxy=max(maxy,valy);
	}
	double ans=(maxx-minx)*(maxy-miny);
	return ans;
}

int main()
{
	IOS;
	cin >> n;
	REP(i,1,n)
		cin >> x[i] >>  y[i] >> dir[i];
	double l=0,r=INF;
	REP(i,1,500)
	{
		double mid1=(2*l+r)/3, mid2 = (l+2*r)/3;
		if(check(mid1)<=check(mid2))
			r=mid2;
		else
			l=mid1;
	}
	double mid1=(2*l+r)/3, mid2 = (l+2*r)/3;
	cout << std::fixed;
	cout << setprecision(9) << min(check(mid1),check(mid2));
}	


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int n,m;
	cin>>n>>m;
	if(n==1&&m==1)cout<<1<<endl;
	else if(min(n,m)==1)cout<<max(n,m)-2<<endl;
	else cout<<(n-2)*(m-2)<<endl;
	return 0;
}

Measured memory_bytes: 256
//This disgusting code is wriiten by Juruo D0zingbear
//Please don't hack me! 0v0 <3
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#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 <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}

// cf IO: I64d
// atcoder IO: ｌｌｄ
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
string s;
int main(){
	cin>>s;
	if (s.size()<4){
		printf("No\n");
		return 0;
	}
	if (s.substr(0,4)=="YAKI"){
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int x[5],i;
    scanf("%d%d%d%d%d",&x[0],&x[1],&x[2],&x[3],&x[4]);
    for(i=0;i<5;i++){
        if(x[i]==0){
            break;
        }
    }
    printf("%d",i+1);
    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  set<int> x;
  bool f = false;
  int cnt = 0;

  rep(i, 0, n) {
    int a;
    cin >> a;
    if (a >= 3200)
      ++cnt;
    else
      x.insert(a / 400);
  }

  cout << max((int)(x.size()), (int)1) << ' ' << x.size() + cnt << '\n';
  return 0;
}

Measured memory_bytes: 3636
def resolve():
    N, K = map(int, input().split())
    if N <= K/2:
        print(N)
    elif N <= K:
        print(abs(N-K))
    else:
        N = N%K
        if N <= K/2:
            print(N)
        elif N <= K:
            print(abs(N-K))
resolve()

Measured memory_bytes: 9176
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;

import static java.util.stream.Collectors.toList;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            final List<Integer> NK = Arrays.stream(args.get(0).split(" ")).map(Integer::valueOf).collect(toList());
            final Integer K = NK.get(1);
            final char[] numList = args.get(1).toCharArray();

            Integer max = 0;
            Integer cnt = 0;
            Integer cntLeft1 = 0;
            Integer remainingK = K;
            List<Integer> stack = new ArrayList<>();
            int index = 0;
            while (index < numList.length) {
                if (numList[index] == '1') {
                    cnt++;
                    cntLeft1++;
                    index++;
                } else {
                    Integer cnt0 = 0;
                    while (index < numList.length && numList[index] == '0') {
                        cnt0++;
                        cnt++;
                        index++;
                    }
                    stack.add(cntLeft1 + cnt0);
                    cntLeft1 = 0;
                    if (remainingK > 0) {
                        remainingK--;
                    } else {
                        cnt -= stack.remove(0);
                    }
                }
                max = Math.max(max, cnt);
            }

            System.out.println(max);
        };
    }

}


Measured memory_bytes: 33372
N, M = map(int,input().split())
graph = [[False for i in range(N)] for j in range(N)]
for i in range(M):
    a, b = map(int,input().split())
    graph[a-1][b-1] = graph[b-1][a-1] = True

def dfs(v,n,visited):
    if not False in visited:
        return 1
    ret = 0
    for i in range(n):
        if not graph[v][i]:
            continue
        if visited[i]:
            continue
        visited[i] = True
        ret += dfs(i,n,visited)
        visited[i] = False
    return ret

visited = [False]*N
visited[0] = True
print(dfs(0,N,visited))



Measured memory_bytes: 3064
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
ans = 'U'*dy + 'R'*dx + 'D'*dy + 'L'*dx \
    + 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D' \
    + 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'

print (ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define MAX 100001
#define VMAX 100000

int main(){
  unsigned short *A;
  int i, j, x, r, n, m, q, p= 1;

  scanf("%d", &m);

  A = malloc(sizeof(short)*m+1);

  for(i = p; i <= m; i++){
    scanf("%hu", &A[i]);
  }
  x = A[m];
  i = p-1;
  for(j = p; j <= m-1; j++){
    if(A[j] <= x){
      i = i+1;
      n = A[i];
      A[i] = A[j];
      A[j] = n;
    }
  }
  n = A[i+1];
  A[i+1] = A[m];
  A[m] = n;
  q = i+1;
  
  for(j = p; j <= q-1; j++){
    printf("%u ", A[j]);
  }
  printf("[%u]", A[q]);
  for(j = q+1; j <= m; j++){
    printf(" %u", A[j]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2144
import itertools

n = int(input())
XY = [list(map(int, input().split())) for _ in range(n)]

cand = list(itertools.permutations(list(range(n)), n))

ans = 0
for cand_i in cand:
  for i in range(n-1):
    ans += ((XY[cand_i[i]][0]-XY[cand_i[i+1]][0])**2+(XY[cand_i[i]][1]-XY[cand_i[i+1]][1])**2)**(1/2)

print(ans/len(cand))

Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

constexpr int mod = 1e9+7;

int main(){
  int n, k; cin >> n >> k;
  int a[n+1];
  FOR(i, 1, n+1) cin >> a[i];

  vector<vector<ll>> dp(n+1, vector<ll>(k+1, 0));
  vector<vector<ll>> sum(n+1, vector<ll>(k+2, 0));
 
  dp[0][0] = 1; sum[0][0] = 1;
  FOR(i, 1, n+1){
    sum[i-1][0] = 0;
    REP(j, k+1) sum[i-1][j+1] = (dp[i-1][j] + sum[i-1][j]) % mod;

    REP(j, k+1){
      int l = max(0, j-a[i]), r = j+1;
      dp[i][j] = (sum[i-1][r] - sum[i-1][l] + mod) % mod;
    }
  }

  cout << dp[n][k] << endl;

  return 0;
}


Measured memory_bytes: 159088
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long 
struct capacity
{
    ll wt,val;
};
ll MaximUMpROFIT(ll N,ll Totalweight,vector<capacity> arr)
{
    ll dp[N+1][Totalweight+1];
    for(ll w=0;w<=Totalweight;w++)
    {
        dp[1][w]=0;
    }
    dp[1][arr[1].wt]=arr[1].val;
    for(ll i=2;i<=N;i++)
    {   
        for(ll j=0;j<=Totalweight;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(arr[i].wt>j)
            {
                continue;
            }
            dp[i][j]=max(dp[i][j],arr[i].val+dp[i-1][j-arr[i].wt]);
        }
    }

    return *max_element(dp[N],dp[N]+Totalweight+1);
}
int main() {
    ll N,Totalweight;
    cin>>N>>Totalweight;
    vector<capacity> arr(N+1);
    for(ll i=1;i<=N;i++)
    {
        cin>>arr[i].wt>>arr[i].val;
    }
    cout<<MaximUMpROFIT(N,Totalweight,arr);
}


Measured memory_bytes: 81584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >> N;
  int N1 = N / 1000 * 1000;
  int N3 = N / 10 * 10;
  if(N3 % 1110 == 0){
    cout << "Yes" << endl;
  }
  else if((N - N1) % 111 == 0){
    cout << "Yes" << endl;
  }
          else{
            cout << "No" << endl;
          }
}

Measured memory_bytes: 256