akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll N = 1e5 + 3;

ll n, q, res[N];
char s[N];

int main() {
	cin >> n >> q;
	for (ll i = 1; i <= n; ++i) cin >> s[i];
	for (ll i = 2; i <= n; ++i) {
		res[i] = res[i-1];
		if (s[i-1] == 'A' && s[i] == 'C') ++res[i];
	}
	
	while (q--) {
		ll l, r; cin >> l >> r;
		cout << res[r] - res[l] << "\n";
	}

	return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var K = int.Parse(Console.ReadLine());
            var results = new List<long>();
            foreach (var i in Enumerable.Range(0, 11 * 11 * 11))
            {
                var pows = new int[] { i / 11 / 11, (i / 11) % 11, i % 11 };
                if (pows.Sum() != K) continue;
                var result = (long)0;
                foreach(var j in Enumerable.Range(0, 3))
                {
                    result += vals[j] * (long)Math.Pow(2, pows[j]);
                }
                results.Add(result);
            }
            Console.WriteLine(results.Max());
        }
    }
}


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

int main() {
  int X, K;
  cin >> X;
  K = 0;
  
  for (int i = 1; ; i++) {
    if  ((i * X) % 360 == 0) {
      K++;
      break;
    }
    K++;
  }
  cout << K << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int n; cin >> n;
	int a; VI p(100001,0);
	ll sum=0;
	REP(i,n){
		cin >> a;
		p[a]++;
		sum+=a;
	}
	int q; cin >> q;
	ll b, c;
	while(q--){
		cin >> b >> c;
		sum-=p[b]*(b-c);
		cout << sum << endl;
		p[c]+=p[b];
		p[b]=0;
	}
	return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

using namespace std;

int main() {

    int a, b;
    
    cin >> a >> b;

    string ans = "Odd";
    if (a*b % 2 == 0) ans = "Even";

    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let mut vec = vec![];
    for _ in 0..n {
        let a: u64 = read();
        let b: u64 = read();
        vec.push((a, b));
    }
    vec.sort_by_key(|k| k.1);
    let mut now = 0;
    for i in vec {
        let time = i.0;
        let shime = i.1;
        now += time;
        if (now > shime) {
            println!("No");
            return;
        }
    }
            println!("Yes");
}



Measured memory_bytes: 9284
array = gets.split.map(&:to_i)
f = 0
s = 0
for t in 0..2
 if array[t] == 5
  f = f+1
 elsif array[t] == 7
  s = s+1
 end
end
if f == 2 && s == 1
 print("YES")
else
 print("NO")
end 
  


Measured memory_bytes: 1788
class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.componentCount = size

    def root(self, index):
        if self.parent[index] == index:  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2):  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2:  # 連結されている場合
            return

        self.componentCount -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2]:
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else:
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2]:
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2):
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index):
        return self.size[self.root(index)]

N, M = map(int, input().split())
tree = UnionFind(N)

for _ in range(M):
    a, b = map(lambda a: int(a) - 1, input().split())
    tree.union(a, b)

print(tree.componentCount - 1)


Measured memory_bytes: 14416
N, K = map(int,input().split())
ans = 0
if K == 0:
  print(N ** 2)
  exit()
ans = 0
for b in range(K+1,N+1):
  ans += N // b * (b - K)
  if N % b - (K - 1) > 0:
    ans += N % b - (K - 1) 
print(ans)

Measured memory_bytes: 3060
n=int(input())
monsters=list(map(int, input().split()))
battle=list(map(int, input().split()))
remain=0
win=0
for i in range(n):
    if monsters[i] < battle[i]:
        win += monsters[i]
        if monsters[i+1] >= battle[i] - monsters[i]:
            win += battle[i] - monsters[i]
            monsters[i+1] -= battle[i] - monsters[i]
        else:
            win += monsters[i+1]
            monsters[i+1] = 0
    else:
        win += battle[i]
print(win)

Measured memory_bytes: 19156
import math

D, G = map(int, input().split())
prob = [list(map(int, input().split())) for i in range(D)]
tmp = 100*10

for i in range(1<<D):
    grade = 0
    cnt = 0
    judge = list(range(1, D+1))

    for j in range(D):
        if (i>>j & 1):
            grade += (100*(j+1)*prob[j][0] + prob[j][1])
            cnt += prob[j][0]
            judge[j] = 0

    if grade >= G and tmp > cnt:
        tmp = cnt
        
    num = prob[(max(judge))-1][0]

    if G > grade and num > math.ceil((G - grade)/(max(judge)*100)):
        cnt += math.ceil((G - grade)/(max(judge)*100)) 
        if tmp > cnt:
            tmp = cnt

print(tmp)


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int X;
    std::cin >> X;
    std::cout << ((X == 3 || X == 5 || X == 7) ? "YES" : "NO") << std::endl;

    return 0;
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

bool isPrime(int a) {
  if(a == 2) return true;
  if(a < 2 || !(a % 2)) return false;

  double sq = sqrt(a);
  for(int i = 3; i <= sq; i += 2) {
    if(a % i == 0) return false;
  }
  return true;
}


int main() {
  int h, r;
  cin >> h >> r;
  if(h + r > 0) cout << 1 << endl;
  else if(h + r == 0) cout << 0 << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3220
n, m = gets.split.map(&:to_i)
nums = []
n.times { nums << gets.split.map(&:to_i) }
ans = []
2.times do |first|
  2.times do |second|
    2.times do |third|
      nums_dup = Marshal.load(Marshal.dump(nums))
      n.times do |i|
        nums_dup[i][0] *= - 1 if first == 0
        nums_dup[i][1] *= - 1 if second == 0
        nums_dup[i][2] *= - 1 if third == 0
      end
      sums = nums_dup.map { |array| array.inject(:+) }.sort.reverse
      ans << sums.select.with_index { |sum, index| index < m }.inject(0) { |res, num| res + num }
    end
  end
end
puts ans.max


Measured memory_bytes: 2552
#include <stdio.h>
#include <math.h>
int main(void){
	int i,cnt;
	double sum,n;
	char str[100];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
	cnt=1; sum=0.0;
	sscanf(str,"%lf",&n);
	for(i=0;i<10;i++){
		sum+=n;
		cnt++;
		if(cnt%2==0)
			n=n*2.0;
		else
			n=n/3.0;
	}
	printf("%f\n",sum);
	}
	return 0;
}

Measured memory_bytes: 656
import sys

N=input()
AB=[ tuple( map(int, sys.stdin.readline().split()) ) for _ in range(N) ] 

AB.sort(key=lambda x: x[1])

t=0	#Time
for a,b in AB:
	t+=a
	if b<t:
		print "No"
		quit()
else:
	print "Yes"

Measured memory_bytes: 58268
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long int64;

const int kInf = 1e9+10;
const int kMod = 1e9+7;

int64 calc(vector<int64>& x, int n) {
	int64 ans = 0;

	int64 sum = 0;

	for (int i = 1; i <= n; ++i) {
		ans = (ans + ((i-1) * x[i] % kMod - sum) + kMod) % kMod;
		sum = (sum + x[i])%kMod;
	}
	return ans;
}

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int64> x(n+1), y(m+1);

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

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

	sort(x.begin() + 1, x.end());
	sort(y.begin() + 1, y.end());

	int64 ans1 = calc(x, n);
	int64 ans2 = calc(y, m);

	cout << ans1 * ans2 % kMod << "\n";
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		solve();
	}
}

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

#define ll long long

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

    int n;
    cin >> n;
    int a[n+1];

    for (int i = 1; i <= n; i++) cin >> a[i];

    int min = a[1];

    while(1){
        int flag = 0;
        for (int i = 1; i <= n; i++){
            if (a[i] % min < min && a[i] % min != 0){
                flag = 1;
                min = a[i] % min;
            }
        }
        if (!flag) break;
    }

    cout << min << endl;

    return 0;
}



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

int main() {
    string a;
    cin >> a;
    vector<int> X(4);
    for (int i = 0; i < 4; ++i) {
        X[i] = a[i]-'0';
    }
    
    for (int i = 0; i < (1 << 3); ++i) {
        bitset<3> bit(i);
        int sum = X[0];
        vector<string> ans(7);
        ans.push_back(to_string(X[0]));
        for (int j = 0; j < 3; ++j) {
            if (bit.test(j)) {
                sum += X[j+1];
                ans.push_back("+");
            }
            else
            {
                sum -= X[j+1];
                ans.push_back("-");
            }
            ans.push_back(to_string(X[j+1]));
        }
        if (sum == 7) {
            string answer = "";
            for (auto s : ans) {
                answer += s;
            }
            cout << answer << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3688
N = int(input())
T = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
normal = True
def judge(a, b):
  m = b[0]-a[0]-abs(b[1]-a[1])-abs(b[2]-a[2])
  if m>=0 and m%2==0:
    return True
  else:
    return False
for i in range(N):
  if judge(T[i], T[i+1]):
    pass
  else:
    normal = False
    break
print("Yes" if normal else "No")

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

int main(){
  int n,ans=0;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n-2;i++){
    if(a[i]<a[i+1]&&a[i+1]<a[i+2]){
      ans++;
    }
    else if(a[i+2]<a[i+1]&&a[i+1]<a[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
}
  
    
    


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#define all(v) v.begin(),v.end()
#define pb push_back
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	int sp[26],tp[26];
	fill(sp,sp+26,-1);
	fill(tp,tp+26,-1);
	bool check=true;
	rep(i,s.size()){
		int to=(int)(t[i]-'a'),from=(int)(s[i]-'a');
		if(sp[from]!=-1||tp[to]!=-1){
			if(sp[from]!=to||tp[to]!=from){
				check=false;
				break;
			}
		}
		sp[from]=to;
		tp[to]=from;
	}
	cout<<(check?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef tuple <int, int, int> PP;
typedef long double ld;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

template< typename T >
T kruskal(Edges< T > &edges, int V) {
  sort(begin(edges), end(edges), [](const edge< T > &a, const edge< T > &b) {
    return (a.cost < b.cost);
  });
  UnionFind tree(V);
  T ret = 0;
  for(auto &e : edges) {
    if(tree.unite(e.src, e.to)) ret += e.cost;
  }
  return (ret);
}

int main(void)
{
	int n;
	cin >> n;
	vector<PP> r;
	rep (i, n) {
		int x, y;
		cin >> x >> y;
		r.emplace_back(x, y, i);
	}
	Edges<int> edges;
	sort(all(r));
	rep (i, n - 1) {
		edges.emplace_back(get<2>(r[i + 1]), get<2>(r[i]), abs(get<0>(r[i + 1]) - get<0>(r[i])));
		edges.emplace_back(get<2>(r[i]), get<2>(r[i + 1]), abs(get<0>(r[i + 1]) - get<0>(r[i])));
	}
	sort(all(r), [](PP a, PP b) {return get<1>(a) < get<1>(b);});
	rep (i, n - 1) {
		edges.emplace_back(get<2>(r[i + 1]), get<2>(r[i]), abs(get<1>(r[i + 1]) - get<1>(r[i])));
		edges.emplace_back(get<2>(r[i]), get<2>(r[i + 1]), abs(get<1>(r[i + 1]) - get<1>(r[i])));
	}
	cout << kruskal(edges, n) << endl;
	return 0;
}

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

const int N = 51;

typedef long long LL;

LL dp[N][N * N * N], sum[N];

int p[N], w[N], id[N]; LL pre[N], pre1[N];

int main() {
    int n, m, d; cin >> n >> m >> d;
    for (int i = 1; i <= n; i++) {
        cin >> sum[i], w[i] = 1, id[i] = i;
        if (i != 1) cin >> p[i];
    }
    for (int i = n; i >= 1; i--) 
        sum[p[i]] += sum[i], w[p[i]] += w[i];
    int lim = min(d, n);
    memset(dp, 0x3f, sizeof(dp)), dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= (i - 1) * lim * n; j++) if (dp[i - 1][j] <= m) {
            for (int k = 0; k <= lim; k++) {
                dp[i][j + k * w[i]] = min(dp[i][j + k * w[i]], dp[i - 1][j] + k * sum[i]);
                if (dp[i][j + k * w[i]] > m) break;
            }
        }
    }
    sort(id + 1, id + n + 1, [](int a, int b) {
        return w[a] * sum[b] > w[b] * sum[a];
    });
    for (int i = 1; i <= n; i++) {
        if (pre[i - 1] >= m) {
            pre[i] = pre[i - 1] + 1; continue;
        }
        int at = id[i], tmp = at == 1 ? 1e9 : d - lim;
        if (sum[at] >= m && tmp) pre[i] = m;
        else pre[i] = pre[i - 1] + tmp * sum[at], pre1[i] = pre1[i - 1] + (LL)tmp * w[at];
    }   
    LL res = 0;
    for (int i = 0; i <= n * n * lim; i++) if (dp[n][i] <= m) {
        LL remain = m - dp[n][i];
        int pos = upper_bound(pre + 1, pre + n + 1, remain) - pre - 1;
        res = max(res, i + pre1[pos] + w[id[pos + 1]] * ((remain - pre[pos]) / sum[id[pos + 1]]));
    }
    cout << res << endl;
    return 0;
}

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

int main() {
    vector<int> v(3);
    rep(i,3) cin >> v[i];
    sort(v.begin(),v.end(),greater<int>());
    cout << v[0]*10+v[1]+v[2] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int h, w, k;
vector<int> tobit(int m) {
    vector<int> res(h - 1, 0);
    int bit = m;
    for(int i = 0; i < h - 1; i++) {
        res[i] = (bit & 1);
        bit /= 2;
    }
    return res;
}
int solve(vector<vector<int>> &v) {
    for(int i = 0; i < v.size(); i++) {
        for(int j = 0; j < w; j++) {
            if(v[i][j + 1] - v[i][j] > k) {
                return INT_MAX;
            }
        }
    }
    int count = 0;
    int ind = 0;
    for(int i = 0; i < w; i++) {
        bool flag = false;
        for(int j = 0; j < v.size(); j++) {
            if(v[j][i + 1] - v[j][ind] > k) {
                flag = true;
            }
        }
        if(flag) {
            count++;
            ind = i;
        }
    }
    /*
        if(count + v.size() - 1 == 3) {
            for(int i = 0; i < v.size(); i++) {
                for(auto e : v[i]) {
                    cout << e << " ";
                }
                cout << endl;
            }
        }
        */
    return count + v.size() - 1;
}
int main() {
    cin >> h >> w >> k;
    vector<string> s(h);
    for(int i = 0; i < h; i++) {
        cin >> s[i];
    }
    vector<vector<int>> rui(h, vector<int>(w + 1, 0));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            rui[i][j + 1] = rui[i][j] + (s[i][j] == '1');
        }
    }
    int ans = INT_MAX;
    for(int i = 0; i < (2 << (h - 2)); i++) {
        vector<int> tob = tobit(i);
        vector<int> gru(h, 0);
        for(int i = 1; i < h; i++) {
            gru[i] = gru[i - 1] + tob[i - 1];
        }
        vector<vector<int>> v(gru.back() + 1, vector<int>(w + 1, 0));
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w + 1; j++) {
                v[gru[i]][j] += rui[i][j];
            }
        }
        ans = min(ans, solve(v));
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
ab=array(N)
N.times do|i|
    ab[i]=get_i
end
ab.sort!{|x,y| y[0]+y[1]<=>x[0]+x[1]}
ans=0
N.times do|i|
  if i.even?
      ans+=ab[i][0]
  else
      ans-=ab[i][1]
  end
end
puts ans

Measured memory_bytes: 21880
#include<stdio.h>
int main(void){

  int N,x,i,j,B=0,C=1,flag=0;

  scanf("%d",&N);

  for(i=0;i<N;i++){
      flag=0;
      B=0;
      C=1;
      for(j=0;j<10;j++){
	  scanf("%d",&x);
	  if(B>C && x>B)B=x;
	  else if(B>C && x<B && x>C)C=x;
	  else if(B<C && x>C)C=x;
	  else if(B<C && x<C && x>B)B=x;
	  else {flag=1; break;}
	}
      if(flag)printf("NO\n");
      else printf("YES\n");
}

  return 0;
}

Measured memory_bytes: 0
import sys
n = int(sys.stdin.readline().rstrip("\n"))
h = 10 ** 9 + 7
n_10 = pow(10,n,h)
n_9 = pow(9,n,h)
n_8 = pow(8,n,h)
ans = (n_10 - 2*n_9 + n_8) % h
print(ans)

Measured memory_bytes: 61700
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
	using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N, M; cin >> N >> M;
	cout << C(N) + C(M) << endl;
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll x[100000];
int perm[100000];
bool used[100000];
ll d[100000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> x[i];
	for (int i = 0; i + 1 < N; i++) perm[i] = i;
	int M;
	ll K;
	cin >> M >> K;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		a--;
		swap(perm[a], perm[a - 1]);
	}
	for (int i = 0; i + 1 < N; i++) {
		if (used[i]) continue;
		vector<int> v;
		while (!used[i]) {
			v.push_back(i);
			used[i] = 1;
			i = perm[i];
		}
		for (int j = 0; j < v.size(); j++) {
			int k = v[(j + K) % v.size()];
			d[v[j]] = x[k + 1] - x[k];
		}
	}
	cout << x[0] << endl;
	ll now = x[0];
	for (int i = 0; i + 1 < N; i++) {
		now += d[i];
		cout << now << endl;
	}
}


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

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

    ll L, R; cin >> L >> R;

    if (R - L >= 2019) {
        L %= 2019;
        R = 2019;
    } else {
        L %= 2019;
        R %= 2019;
    }

    ll sum = 1000000000000000;
    for (int i = L; i < R; i++) {
        for (int j = i + 1; j <= R; j++) {
            if ((i * j) % 2019 < sum) sum = (i * j) % 2019;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String [] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		double X[] = new double[N];
		double Y[] = new double[N];
		
		int a = 0;
		
		for (int i = 0; i < N; i++) {
			X[i] = sc.nextDouble();
			Y[i] = sc.nextDouble();
			
			double A =  Math.sqrt((X[i] * X[i]) + (Y[i] * Y[i]));
			
			if(A <= D)				a++;
		}
		
		System.out.println(a);
	}
}


Measured memory_bytes: 66968
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,m;cin >> n >> m;
  int res = 0;
  if(n != 0) res += n * (n - 1) / 2;
  if(m != 0) res += m * (m - 1) / 2;
  cout << res << "\n";
  return 0;
}


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

using namespace std;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

ll a[100001];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	
	for (int i = n - 1; i > 0; i--) {
		if (a[i] < a[i - 1]) {
			a[i - 1] -= 1; 
			if (a[i] < a[i - 1]) {
				cout << "No" << '\n'; return 0;
			}
		}
	}
	cout << "Yes" << '\n';





}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

const int MAX = 501;
const int INF = (1<<25);

struct Edge{
  int to,t;
  Edge(){}
  Edge(int to, int t):to(to),t(t){}
};
struct State{
  int pos,t;
  State(){}
  State(int pos, int t):pos(pos),t(t){}
  bool operator < (const State& s) const {return t > s.t;}
};
int n,m;
string s,p,g;
vector<Edge> V[MAX];
map<string,int> M;
int T[MAX];

void init(){
  for(int i = 0; i < MAX; i++) V[i].clear();
  M.clear();
}

void input(){
  cin >> s >> p >> g;
  int cnt = 1;
  for(int i = 0; i < m; i++){
    string a,b;
    int d,t;
    cin >> a >> b >> d >> t;
    if(M[a] == 0) M[a] = cnt++;
    if(M[b] == 0) M[b] = cnt++;
    V[M[a]].push_back(Edge(M[b],d/40+t));
    V[M[b]].push_back(Edge(M[a],d/40+t));
  }
}

int solve(int from, int to){
  fill(T,T+MAX,INF);

  priority_queue<State> Q;
  Q.push(State(from,0));
  T[from] = 0;

  while(!Q.empty()){
    State now = Q.top();
    Q.pop();
    
    if(T[now.pos] < now.t) continue;

    for(int i = 0; i < (int)V[now.pos].size(); i++){
      Edge e = V[now.pos][i];
      State nex;
      nex.pos = e.to;
      nex.t = now.t+e.t;
      if(T[nex.pos] > nex.t){
	T[nex.pos] = nex.t;
	Q.push(nex);
      }
    }
  }
  return T[to];
}

int main(){
  while(cin >> n >> m && n+m){
    init();
    input();
    cout << solve(M[s],M[p])+solve(M[p],M[g]) << endl;
  }
  return 0;
}

Measured memory_bytes: 1516
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main()
{
  int k;
  vector<int> K{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> k;
  cout << K[k-1];
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

S = input()

left = int(S[:2])
right = int(S[2:])

left_flag = False
if left <= 12 and left > 0:
    left_flag = True

right_flag = False
if right <= 12 and right > 0:
    right_flag = True

if left_flag is True and right_flag is True:
    print('AMBIGUOUS')
elif left_flag is True and right_flag is False:
    print('MMYY')
elif left_flag is False and right_flag is True:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Println(a...)
}

func vacantExists(left, right int, sl, sr string) bool {
	if (right-left)%2 == 0 && sl != sr {
		return true
	} else if (right-left)%2 == 1 && sl == sr {
		return true
	}
	return false
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)

	n := nextInt()

	left, right := 0, n-1
	var sl, sr, sm string
	puts(left)
	if sl = next(); sl == "Vacant" {
		return
	}
	puts(right)
	if sr = next(); sr == "Vacant" {
		return
	}

	for cnt := 2; cnt <= 20; {
		mid := (left + right) / 2
		puts(mid)
		cnt++
		if sm = next(); sm == "Vacant" {
			return
		}
		if vacantExists(left, mid, sl, sm) {
			right = mid
			sr = sm
		} else if vacantExists(mid, right, sm, sr) {
			left = mid
			sl = sm
		}
	}
}


Measured memory_bytes: 1108
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = N * (N - 1) / 2;

    println!("{}", ans);

}


Measured memory_bytes: 4352
s = input()

a = ["0", "1"]
b = ["1", "0"]

acount = 0
bcount = 0
for i in range(len(s)):
  if s[i] != a[i%2]:
    acount += 1
  if s[i] != b[i%2]:
    bcount += 1

print(min(acount, bcount))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  VEC<int> a(n);
  REP(i, 0, n) cin >> a[i];
  VEC<int> c=a;
  LL sum = 0;
  LL score = 0;
  REP(i, 0, n) {
    c[i] = a[i] - i - 1;
  }
  sort(ALL(c));
  int mid = c[n/2];
  double ave = (double)sum / n;
  LL answer = LLONG_MAX;
    LL b = mid;
    LL ans = 0;
    REP(i, 0, n) { ans += abs(a[i] - (b + i + 1)); }
    answer = min(answer, ans);
    // DUMP(c, sum, ave, score, b, ans);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
/* LittleFall : Hello! */
#include <bits/stdc++.h>
using namespace std; typedef long long ll;
inline int read(); inline void write(int x);
const int M = 500016, MOD = 1000000007;

int save[M];
int main(void)
{
	#ifdef _LITTLEFALL_
	freopen("in.txt","r",stdin);
    #endif

	int n = read(),x = read();
	for(int i=0;i<n;i++)
		save[i]=read();
	sort(save,save+n);
	int t = n;
	for(int i=0;i<n;i++)
	{
		x -= save[i];
		if(x<0)
		{
			t = i;
			break;
		}
	}
	if(x>0)
		t--;
	printf("%d\n",t );

    return 0;
}


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;
}
inline void write(int x)
{
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
 
        Scanner sc = null;
        sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        String before = "";
        int ans = 0;

        for (int i = 0; i < 3; i++) {
            if (i == 0) {
                if(s.substring(0,1).equals("R")){
                    ans = 1;
                }
                before = s.substring(0,1);
            } else {
                if (s.substring(i, i + 1).equals("R") && before.equals("R")) {
                    ans += 1;
                }else if(s.substring(i, i + 1).equals("R") && before.equals("S")){
                    ans = 1;
                }
                before = s.substring(i, i + 1);
            }
        }

        System.out.println(ans);   
      }
}

Measured memory_bytes: 35820
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    if n <= 999 {
        return "ABC".to_string();
    }

    return "ABD".to_string();
}


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

int main(){
  int N,K;
  cin >> N >> K;
  
  int counter = 0;
  rep(i,N){
    int A;
    cin >> A;
    if(K <= A) counter++;
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto hw = readln.split.to!(int[]);
    auto H = hw[0];
    auto W = hw[1];

    char[][] MAP;
    MAP.length = H;
    int s;
    foreach (i; 0..H) {
        MAP[i] = readln.chomp.to!(char[]);
        foreach (c; MAP[i]) if (c == '#') ++s;
    }

    int x, y, t;
    for (;;) {
        ++t;
        if (x < W-1 && MAP[y][x+1] == '#') {
            ++x;
        } else if (y < H-1 && MAP[y+1][x] == '#') {
            ++y;
        } else {
            break;
        }
    }
    writeln(s == t ? "Possible" : "Impossible");
}

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.typecons;

  int n, k; rd(n, k);
  auto a=new int[](n), b=new int[](n), c=new int[](n);
  foreach(i; 0..n) rd(a[i], b[i], c[i]);

  alias T=Tuple!(int, "s", int, "t");
  auto seq=new T[][](k, 0);
  foreach(i; 0..n){
    seq[c[i]-1]~=T(a[i], b[i]);
  }

  auto seq2=new T[][](k, 0);
  foreach(i; 0..k)if(seq[i].length>0){
    sort(seq[i]);
    T[] tmp; tmp~=seq[i][0];
    for(int j=1; j<seq[i].length; j++){
      if(tmp[$-1].t==seq[i][j].s) tmp[$-1].t=seq[i][j].t;
      else tmp~=seq[i][j];
    }
    seq2[i]~=tmp;
  }

  auto sum=new int[](2*100005);
  foreach(i; 0..k)foreach(e; seq2[i]){
    sum[e.s*2-1]++; sum[e.t*2]--;
  }
  foreach(i; 1..(sum.length)) sum[i]+=sum[i-1];

  writeln(reduce!(max)(sum));

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) stderr.write(e, " ");
  stderr.writeln;
}

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

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxn = 1005;
int main(){
    int m1,m2,d1,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 == m2) puts("0");
    else puts("1");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
    int n,k;
    cin>>n>>k;
    int ar[n+1];
    for(int i=1;i<=n;++i)
    cin>>ar[i];
    
    int dp[100010];
    memset(dp,126,sizeof dp);
    dp[1]=0;
    
    for(int i=2;i<=n;++i)
    {
        for(int j=1;(i-j)&&j<=k;++j)
            dp[i]=min(dp[i],abs(ar[i]-ar[i-j])+dp[i-j]);
    }
    
    
    
    cout<<dp[n];
    
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;

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

	int c = b + a;

	//cout << c % 2;

	if (c % 2 == 1) {
		cout << "IMPOSSIBLE";
	}
	else {
		cout << (a + b) / 2;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

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

    if(M - N >= 2) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for(int i = 2; i <= M; ++i) {
        ans *= i;
        ans %= MOD;
        if(i == N) {
            ans *= ans;
            ans %= MOD;
        }
    }
    cout << (M - N == 0 ? (ans * 2) % MOD : ans) << endl;
    return 0;
}


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

int main(){
int A,B,C;
  cin>>A>>B>>C;
  
  bool ans=false;
  for(int i=0; i<=B*A; i++){
   if(i*A%B==C){ans=true;}
  }
  
  if(ans){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn a() {
    let n = read!(usize);
    println!("{}", n.pow(3));
}

fn b() {
    unimplemented!();
}

fn c() {
    unimplemented!();
}

fn d() {
    unimplemented!();
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    a();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace std;
using namespace __gnu_pbds; 
#define     mod            (int)1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif






 
int main()
 
{  
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    IOS;

    int l, r, d;
    cin>>l>>r>>d;
    int ans =0;
    for(int i=l; i<=r; i++)
    {
        if(i%d == 0)ans++;
    }
   

   cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

const int inf = 1e9;
const int N = 601;
bool adj[N][N];
int deg[N];
double E[N][2];

signed main() {
	int n, m; cin >> n >> m;

	while(m--) {
		int s, t; cin >> s >> t; --s, --t;
		adj[s][t] = 1;
		++deg[s];
	}

	auto solve = [&](bool b) {
		E[n - 1][b] = 0;
		REP(i, 0, n) E[i][b] = 0;
		for (int i = n - 2; i >= 0; --i) {
			E[i][b] = 0;
			for (int j = i + 1; j < n - 1; ++j)
				if (adj[i][j])
					E[i][b] += E[j][b];
			E[i][b] /= deg[i];
			E[i][b] += 1;
		}
	};

	solve(0);
	double ans = E[0][0];

	REP(i, 0, n - 1) {
		if (deg[i] == 1) continue;

		int mxpos; double mx = -1;

		REP(j, i + 1, n)
			if (adj[i][j])
				if (mx < E[j][0]) {
					mxpos = j;
					mx = E[j][0];
				}

		--deg[i]; adj[i][mxpos] = 0;
		solve(1);
		++deg[i]; adj[i][mxpos] = 1;

		ans = min(ans, E[0][1]);
	}

	cout << fixed << setprecision(10) << ans;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define INIT(a) memset(a,0,sizeof(a))

#define fs first
#define sc second
#define pb push_back
#define sz size()

using namespace std;

const int MAX_V = 1000;
const int INF = 1e8;

int level[MAX_V];
int iter[MAX_V];

struct edge{ int from,to,cost,cap,rev; };

vector<edge> G[MAX_V];

void AddEdge(int s,int g,int c,int p){
  G[s].pb((edge){s,g,c,p,(int)G[g].sz});
  G[g].pb((edge){g,s,-c,0,(int)G[s].sz-1});
}

void bfs(int s){
  memset(level,-1,sizeof(level));
  level[s] = 0;
  queue<int> q; q.push(s);
  while(q.sz){
    int u = q.front(); q.pop();
    rep(i,G[u].sz){
      edge &e = G[u][i];
      if(e.cap > 0 && level[e.to] < 0){
	level[e.to] = level[u] + 1;
	q.push(e.to);
      }
    }
  }
}

int dfs(int u, int t, int f){
  if(u==t)return f;
  for(int &i = iter[u];i<(int)G[u].sz;i++){
    edge &e = G[u][i];
    if(e.cap > 0 && level[u] < level[e.to]){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

int dinic(int s, int t){
  int res = 0;
  for(;;){
    bfs(s);
    if(level[t]<0)return res;
    INIT(iter);
    int f;
    while((f=dfs(s,t,INF))>0)res += f;
  }
}

void visible(int v, const vector< vector<int> > &graph,
	     vector<int> &vis){
  if(vis[v])return;
  vis[v] = true;

  for(int u : graph[v]){
    visible(u,graph,vis);
  }
}

int main(){
  int n,m,a,b,s,t;
  while(cin >> n >> m){
    if(n==0 && m==0)break;
    cin >> s >> t; s--; t--;

    rep(i,n)G[i].clear();
    rep(i,m){
      cin >> a >> b; a--; b--;
      AddEdge(a,b,1,1);
    }

    int f = dinic(s,t);

    vector< vector<int> > fg(n), rg(n);
    rep(i,n){
      for(edge e : G[i]){
	if(e.cap>0){
	  fg[i].pb(e.to);
	  rg[e.to].pb(i);
	}
      }
    }

    vector<int> visS(n), visT(n);
    visible(s,fg,visS);
    visible(t,rg,visT);

    int ans = 0;
    rep(i,n){
      for(edge e : G[i]){
	if(e.cost>0 && visS[e.to] && visT[e.from])ans++;
      }
    }

    cout << f + (ans>0?1:0) << " " << ans << endl;
  }
}

Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int a, b;
	cin >> a >> b;
	if(in(a, 0, 10) and in(b, 0, 10)) cout << a * b << endl;
	else cout << -1 << endl;	
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

int main() {
	// your code goes here
		int n,k ; cin >> n>>k;
		vector<int> v(n,0);
		for(int i=0;i<n;i++) cin >> v[i];
		vector<bool> ans(k+1,false);
		for(int i=0;i<=k;i++){
		    for(int j: v){
		        if(i-j>=0&&!ans[i-j])ans[i]=true;
		    }
		}
	if(ans[k]) cout <<"First" << endl;
	else cout << "Second" << endl;
	return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, k;
  cin >> n >> k;
  int ans = LLONG_MAX;
  for(int i = 0; i <= n; i++) {
    int tmp = 1;
    for(int j = 0; j < i; j++) tmp *= 2;
    chmin(ans, tmp+k*(n-i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
F = [tuple(map(int, input().split())) for _ in range(n)]
P = [tuple(map(int, input().split())) for _ in range(n)]

ans = -10**12
from itertools import product
for i in range(1, 2**10):
    pattern = [(i>>j)&1 for j in range(10)]
    rieki = 0
    for ff, pp in zip(F, P):
        count = sum([f and p for f, p in zip(ff, pattern)])
        rieki += pp[count]

    ans = max(ans, rieki)
print(ans)


Measured memory_bytes: 69464
#include <iostream>
using namespace std;
int main(void){
    int k, m = 0;
    string s;
    cin >> s;
    k = s.length();
    for(int i=0;i<k;i++){
        if(s[i]=='o')m++;
    }
    if(m + 15 - k >= 8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
int S[101000];
int main() {
	int i, n, a;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		S[a+1]++;
		S[a]++;
		S[a + 2]++;
	}
	int r = 0;
	for (i = 0; i < 101000; i++)if (r < S[i])r = S[i];
	printf("%d\n", r);
}

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

int main(){
  
  int n,k; 
  string s;
  cin>>n>>k>>s;
  int c=0,ans=0,dif=0;
  for(int i=0;i<n-1;i++){
    c++;
  	if(s[i]!=s[i+1]){
      dif++;
      ans+=(c-1);
      c=0;
    }
  }
  ans+=c;
  dif++;
  dif/=2;
  if(dif<=k) ans=n-1;
  else ans+=k*2;
  cout<<ans<<endl;
}

Measured memory_bytes: 512