akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
  input = input.split("\n");
  var N = input[0].split("").map(i=>parseInt(i));
  var ans =0;
  for(var i=N.length-1;i>=0;i--){
    if(N[i]<=4){
      ans+=N[i];
    }else if(N[i]==5){
      if(N[i-1]<=4){
        ans+=N[i];
      }else{
        ans+=N[i];
        N[i-1]++;
      }
    }else{
      ans+=(10-N[i])
      if(i!=0){
        if(N[i-1]!=9){
          N[i-1]++;
        }else{
          var j=i-1;
          while(true){
            if(N[j]==9){
              N[j]=0;
              if(j==0){
                ans++;
              }
            }else{
              N[j]++;
              break;
            }
            j--;
          }
        }
      }else{
        ans++;
      }
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30448
#include <iostream>
#define ARRAY_SIZE 10000

using namespace std;

int main(){
    int n, num, ma = 0, mi = ARRAY_SIZE + 1, A[ARRAY_SIZE] = {};
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> num;
        A[num]++;
        ma = max(ma, num);
        mi = min(mi, num);
    }

    for(int i = mi; i <= ma; i++){
        for(int j = 0; j < A[i]; j++){
            if(i > mi || j > 0){ cout << " "; }
            cout << i;
        }
    }
    cout << endl;
    return 0;
}


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

void prians(bool answer) {
  if(answer)
    cout << "Brown" << endl;
  else
    cout << "Alice" << endl;
}
long long x, y, cnt = 0;

int main() {
  cin >> x >> y;
  prians(x == y || (max(x, y) - min(x, y) == 1));
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

total = s.count("R") * s.count("G") * s.count("B")
for i in range(n-2):
    for j in range(i+1, n-1):
        if j * 2 - i >= n:
            continue
        k = j * 2 - i
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            total -= 1

print(total)

Measured memory_bytes: 68172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    int next = 1;
    int c = 0;
    while (c < N){
        if (vec[c] != next){
            c++;
        }
        else{
            next++;
            c++;
        }
    }
    if (next == 1){
        cout << -1 << endl;
    }
    else{
        cout << N - next + 1 << endl;
    }
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
using namespace std;
 
int main(){
    int A = 0;
    int B = 0;
    int buf;
    for(int a = 0; a < 4; a++){
        scanf("%d", &buf);
        A += buf;
    }
    for(int a = 0; a < 4; a++){
        scanf("%d", &buf);
        B += buf;
    }
    printf("%d\n", max(A, B));
    return 0;
}

Measured memory_bytes: 2700
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<int>> u(h, vector<int>(w, 0)), d(h, vector<int>(w));
  vector<vector<int>> l(h, vector<int>(w, 0)), r(h, vector<int>(w, 0));
  vector<vector<char>> g(h, vector<char>(w));
  for(int i = 0; i < h; i++){
    string s;
    cin >> s;
    for(int j = 0; j < w; j++) {
      g[i][j] = s[j];
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(g[i][j] == '#'){
        u[i][j] = 0;
        d[i][j] = 0;
        l[i][j] = 0;
        r[i][j] = 0;
      }else{
        if(i > 0){
          d[i][j] += d[i - 1][j] + 1;
        }else{
          d[i][j] = 1;
        }
        if(j > 0){
          r[i][j] += r[i][j - 1] + 1;
        }else{
          r[i][j] = 1;
        }
      }
    }
  }
  for(int i = h - 1; i >= 0; i--){
    for(int j = w - 1; j >= 0; j--){
      if(g[i][j] == '#'){
        u[i][j] = 0;
        d[i][j] = 0;
        l[i][j] = 0;
        r[i][j] = 0;
      }else{
        if(i < h - 1){
          u[i][j] += u[i + 1][j] + 1;
        }else{
          u[i][j] = 1;
        }
        if(j < w - 1){
          l[i][j] += l[i][j + 1] + 1;
        }else{
          l[i][j] = 1;
        }
      }
    }
  }
  int maxi = 0;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++){
      maxi = max(maxi, u[i][j] + d[i][j] + r[i][j] + l[i][j]);
    }
  }
  cout << maxi - 3 << endl;
  return 0;
}

Measured memory_bytes: 67072
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, P;
	cin >> N >> P;

	int t = P;
	vector<pair<int,int>> prime;
	for (int i = 2; i <= (int)sqrt(P); i += (i == 2 ? 1 : 2))
	{
		if (t%i == 0)
		{
			prime.push_back(mp(i, 0));
		}
		while (t%i == 0)
		{

			prime.back().second++;
			t /= i;
		}
	}
	if (t != 1)
	{
		prime.push_back(mp(t, 1));
	}

	int ans = 1;
	rrep(i, 0, SZ(prime))
	{
		ans *= pow(prime[i].first, prime[i].second / N);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
c = list(map(int, input().split()))
mod = 10 ** 9 + 7

c.sort(reverse=True)
ans = 0
for i, e in enumerate(c):
    ans += e * (2 + i)
    ans %= mod

ans *= pow(2, 2 * n - 2, mod)
ans %= mod

print(ans)


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

int nijou(int n){
    ll ans=1;
    for(int i = 0; i < n; i++) {
        ans *= 2;
    }
    return ans;
}

int main() {
    int n,k;
    cin >> n >> k;
    double ans=0;
    int b;
    for(int i = 1; i <= n; i++) {
        int a;
        if(i>=k){
            a=0;
            if(i==1) b=a;
        }
        else{
            int j=0;
            int l=i;
            while(l<k){
                l *= 2;
                j++;
                if(l>=k){
                    a=j;
                }
            }
            if(i==1) b=a;
        }

        ans += nijou(b-a);
    }
    ans /= nijou(b);
    ans /= n;
    cout << fixed << setprecision(12);
    cout << ans << endl;

    return 0;
}

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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var N = input[0];
            var A = input[1];
            var B = input[2];
            var dif = B - A;
            var ans = 0L;
            if (dif % 2 == 0) ans = dif / 2;
            else
            {
                if (A - 1 < N - B) ans += A;
                else ans += N - B + 1;
                ans += (dif - 1) / 2;
            }

            Console.WriteLine(ans);
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <stack>

#define pb push_back
#define ins insert
#define pob pop_back
#define er erase
#define emp empty
#define f first
#define s second
#define ff f.f
#define fs f.s
#define sf s.f
#define ss s.s
#define var auto

using namespace std;
template<typename  T>
using s = set<T>;
template<typename T>
using  v = vector<T>;
template<typename T1, typename  T2>
using p = pair < T1, T2>;
typedef long long ll;
typedef p<int, int> pii;
typedef v<int> vi;
typedef v<pii> vpii;
typedef s<int> si;
typedef s<pii> spii;


const int Max = 3e3 + 100;
const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n, k;
ll dp[Max][Max];
ll A[Max];
ll ps[Max];

ll CALC(int i, int j)
{
	if (dp[i][j] == -1)
	{
		ll opVal1 = CALC(i + 1, j);
		ll opVal2 = CALC(i, j - 1);

		dp[i][j] = max(ps[j] - ps[i + 1] + A[i + 1] - opVal1 + A[i], ps[j - 1] - ps[i] + A[i] - opVal2 + A[j]);
	}
	return dp[i][j];
}

int main()
{
	cin >> n;


	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
		if (i > 0)
			ps[i] = ps[i - 1] + A[i];
		else
			ps[0] = A[0];
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			dp[i][j] = -1;
		}
		dp[i][i] = A[i];
	}

	cout << CALC(0, n - 1) - (ps[n - 1] - CALC(0, n - 1));
}

Measured memory_bytes: 74240
import sys

def extractMax(A):
    x = A[0]
    A[0] = A[-1]
    A.pop()
    H = len(A)
    i = 0
    while i < H: # ???????????????
        v = A[i]
        rv = 0
        lv = 0
        r = (i+1) * 2
        l = r - 1
        if l < H:
            lv = A[l]
            if r < H:
                rv = A[r]

        if v < lv and lv > rv:
            A[l] = v
            A[i] = lv
            i = l
        elif v < rv:
            A[r] = v
            A[i] = rv
            i = r
        else:
            break
    return x

def insert(A, n):
    i = len(A)
    A.append(n)
    while i > 0: # ???????????????
        p = int((i + 1) / 2) - 1
        v = A[i]
        pv = A[p]
        if pv < v: # ???????????§??????
            A[p] = v
            A[i] = pv
            i = p
        else:
            break

def main():
    """ ????????? """
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())

    end = False
    S = []
    for cmd in cmds: # input()
#        print("cmd:{} S:{}".format(cmd,S))
        if cmd[0] == "i":
            insert(S,int(cmd[7:]))

        elif cmd == "extract":
            a = extractMax(S)
            print(a)

        elif cmd == "end":
            end = True
            break


if __name__ == '__main__':
    main()

Measured memory_bytes: 218264
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<(#a)<<':'<<(a)<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key < value;
}

int binary_search(vector<ll> a,ll key){
  ll ok = a.size();
  ll ng = -1;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int a,b,c;cin>>a>>b>>c;
  if(a + b + c < 22){
    print("win");
  }else{
    print("bust");
  }

  return 0;
}


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

void bfs(int x, vector<long long> &ans,vector<vector<int>> &da,vector<long long> &sc,long long no) {
	int y = da[x].size();
	no += sc[x];
	ans[x] = no;
	for (int i = 0;i < y;i ++) {
		if (ans[da[x][i]] <0) {
			bfs(da[x][i], ans, da,sc,no);
		}
	}
	no -= sc[x];
}

int main() {
	int n,q;
	cin >> n >> q;
	vector<vector<int>> da(n, vector<int>(0));
	for (int i = 0;i < n-1;i++) {
		int a, b;
		cin >> a >> b;
		da[a - 1].push_back(b - 1);
		da[b - 1].push_back(a - 1);
	}
	vector<long long> sc(n, 0);
	for (int i = 0;i < q;i++) {
		int q;
		long long x;
		cin >> q >> x;
		sc[q - 1] += x;
	}
	vector<long long> ans(n,-1);
	bfs(0, ans, da, sc, 0);
	ans[0] = sc[0];
	for (int i = 0;i < n;i++) {
		if (i == n - 1) {
			cout << ans[i] << endl;
		}
		else {
			cout << ans[i] << ' ';
		}
	}
}


Measured memory_bytes: 32128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll fpow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1LL)
			res = (res * x) % mod;
		y = y >> 1LL;
		x = (x * x) % mod;
	}
	return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second < b.second);}
bool fd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.first > b.first);}
bool sd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second > b.second);}
ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};
bool valid(ll x, ll y, ll n, ll m) {
	if (x < 0 || y < 0) {
		return false;
	}
	else if (x >= n || y >= m) {
		return false;
	}
	else
		return true;
}
#define MAXN 1000001
ll spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (ll i = 2; i < MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (ll i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (ll i = 3; i * i < MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (ll j = i * i; j < MAXN; j += i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}

int main() {

	// int t;
	// cin >> t;
	// while (t--) {
	ll h1, m1, h2, m2, st;
	cin >> h1 >> m1 >> h2 >> m2 >> st;
	ll total_time = h2 * 60 + m2 - (h1 * 60 + m1);
	cout << total_time - st  << endl;
	// }

	return 0;
}


Measured memory_bytes: 3632
a,b,c,d = map(int,input().split())
ab = [i for i in range(a,b+1)]
cd = [i for i in range(c,d+1)]

inter = set(ab).intersection(set(cd))

if len(inter) != 0:
  print(len(inter) - 1)
else:
  print(0)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
int main(void){
  char maze[9][9];
  while(true){
    rep(i,8)rep(j,8)cin>>maze[i][j];
    if(cin.eof())break;
    bool used = false;
    rep(y,8){
      rep(x,8){
	if (maze[y][x] == '1') {
	  if (maze[y][x+1] == '1' && maze[y+1][x] == '1' && maze[y+1][x+1] == '1')
	    cout << "A" << endl;
	  else if (maze[y+1][x] == '1' && maze[y+2][x] == '1' && maze[y+3][x] == '1')
	    cout << "B" << endl;
	  else if (maze[y][x+1] == '1' && maze[y][x+2] == '1' && maze[y][x+3] == '1')
	    cout << "C" << endl;
	  else if (maze[y+1][x] == '1' && maze[y+1][x-1] == '1' && maze[y+2][x-1] == '1')
	    cout << "D" << endl;
	  else if (maze[y][x+1] == '1' && maze[y+1][x+1] == '1' && maze[y+1][x+2] == '1')
	    cout << "E" << endl;
	  else if (maze[y+1][x] == '1' && maze[y+1][x+1] == '1' && maze[y+2][x+1] == '1')
	    cout << "F" << endl;
	  else
	    cout << "G" << endl;
	  used = true;
	}
        if(used)break;
      }
      if(used)break;
    }
  }

  return 0;
}

Measured memory_bytes: 1136
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;
const int BG = 1000000007;

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

    if (x < 1200)
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ARC" << endl;
    }
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=0

cnt=[0]*(10**5+1)

for i in a:
  if i>10**5:
    ans+=1
   
  else:
    cnt[i]+=1
    
for i in range(10**5+1):
  if i>cnt[i]:
    ans+=cnt[i]
  elif i<cnt[i]:
    ans+=cnt[i]-i

print(ans)

Measured memory_bytes: 85928
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var uf = new UnionFind(N);
		var di = new Dictionary<int,int>();
		for(int i=0;i<N;i++){
			if(!di.ContainsKey(X[i])) di.Add(X[i],i);
			uf.Unite(i, di[X[i]]);
		}
		di.Clear();
		for(int i=0;i<N;i++){
			if(!di.ContainsKey(Y[i])) di.Add(Y[i],i);
			uf.Unite(i, di[Y[i]]);	
		}
		var hx = new HashSet<int>[N];
		var hy = new HashSet<int>[N];
		for(int i=0;i<N;i++){
			hx[i] = new HashSet<int>();
			hy[i] = new HashSet<int>();
		}
		for(int i=0;i<N;i++){
			hx[uf.Parent(i)].Add(X[i]);
			hy[uf.Parent(i)].Add(Y[i]);
		}
		long tot = 0;
		for(int i=0;i<N;i++){
			tot += (long)hx[i].Count * (long)hy[i].Count;
		}
		Console.WriteLine(tot - N);
	}
	int N;
	int[] X,Y;
	public Sol(){
		N = ri();
		X = new int[N];
		Y = new int[N];
		for(int i=0;i<N;i++){
			var d = ria();
			X[i] = d[0]; Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

class UnionFind{
	
	int[] parent;
	int[] mem;
	int compo;
	int N;
	public UnionFind(int n_){
		Initialize(n_);
	}
	
	public void Initialize(int n_){
		N=n_;
		parent=new int[N];
		mem=new int[N];
		for(int i=0;i<N;i++){
			parent[i]=i;
			mem[i]=1;
		}
		compo=N;
	}
	
	public int Parent(int a){
		if(parent[a]==a) return a;
		return parent[a] = Parent(parent[a]);
	}
	
	public bool IsUnited(int a,int b){
		return Parent(a) == Parent(b);
	}
	
	public void Unite(int a,int b){
		a = Parent(a); b = Parent(b);
		if(a == b) return;
		if(mem[a] > mem[b]){var t = a; a = b; b = t;}
		parent[a] = b;
		mem[b] += mem[a];
		compo -= 1;
	}
	
	public bool IsRoot(int x){
		return x == parent[x];
	}
	public int MemCnt(int x){
		return mem[Parent(x)];
	}
	
	public void Dump(){
		for(int i=0;i<parent.Length;i++){
			Console.Write(i==0?"{0}":" {0}",parent[i]);
		}
		Console.WriteLine("");
	}
	
	public int Compo{
		get{
			return compo;
		}
	}
	
}



Measured memory_bytes: 41052
import itertools


N, M = map(int, input().split())
path = [ list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
for p in path:
    graph[p[0]-1].append(p[1]-1)
    graph[p[1]-1].append(p[0]-1)
# print(graph)

arr = [i for i in range(1,N)]
perms = [v for v in  itertools.permutations(arr, len(arr))]
# print(perms)

solved = 0
for perm in perms:
    now = 0
    res = True

    for v in perm:
        if v in graph[now]:
            now = v
        else:
            res = False
            break
    if res:
        solved += 1

print(solved)
    
    

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

int main() {
    int N, count=1;
    cin >> N;
    vector<int> v(N);

    for(int i=0; i<N; i++) cin >> v[i];
    sort(v.begin(), v.end());

    for(int i=0; i < N-1; i++) {
        if(v[i] != v[i+1]) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3636
def permutation(lst):
    # If lst is empty then there are no permutations
  if len(lst) == 0:
    return []

        # If there is only one element in lst then, only
    # one permuatation is possible
  if len(lst) == 1:
    return [lst]

        # Find the permutations for lst if there are
    # more than 1 characters

  l = []  # empty list that will store current permutation

    # Iterate the input(lst) and calculate the permutation
  for i in range(len(lst)):
    m = lst[i]

        # Extract lst[i] or m from the list.  remLst is
        # remaining list
    remLst = lst[:i] + lst[i + 1:]

        # Generating all permutations where m is first
        # element
    for p in permutation(remLst):
      l.append([m] + p)
  return l


N = input()
x = [int(x) for x in input().split()]
y = [int(x) for x in input().split()]

NN = list(range(1, int(N) + 1))
P = permutation(NN)

xx = P.index(x)
yy = P.index(y)
print(abs(xx - yy))

Measured memory_bytes: 9716
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

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

using namespace std;

void solution()
{
    string s,t;
    cin >> s >> t;
    int count = 0;
    rep(i,s.size()){
        if(s[i] != t[i]) count++;
    }
    cout << count << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;
typedef pair<long,long> pr;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef vector<pr> VP;

int main(void){
	short H,W;
	long D,Q,L,R;
	long val;
	cin >> H >> W >> D;
	VP A(H*W+1);
	VI acc(H*W+1,0);
	REP(i,H){
		REP(j,W){
			cin >> val;
			A[val] = pr (i+1,j+1); 
		}
	}

	FOR(i,1+D,D+D+1){
		for(long j = i;j <= H*W;j += D){
			acc[j] += (abs(A[j].first - A[j - D].first) + abs(A[j].second - A[j - D].second) + acc[j-D]); 
		}
	}

	cin >> Q;
	REP(i,Q){
		long ans = 0;
		cin >> L >> R;
		ans = acc[R] - acc[L];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: &Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let a = read::<String>();
    let b = read::<String>();

    let S = a + &*b;
    let num: i32 = S.parse().unwrap();
    let r = (num as f64).sqrt() as i32;
    if r * r == num {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
participants, fields = gets.split.map(&:to_i)

if participants % 2 == 0
  fields.times do |i|
    if (fields * 2 - i - i) <= participants / 2
      puts "#{ i + 1 } #{ (fields * 2) - i }"
    else
      puts "#{ i + 1 } #{ (fields * 2) - i + 1 }"
    end
  end
else
  fields.times do |i|
    puts "#{ i + 1 } #{ (fields * 2) - i }"
  end
end

Measured memory_bytes: 14408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	int n, m;
	cin >> n >> m;
	vi h(n + 1);
	for (int i = 1;i <= n;i++)
		cin >> h[i];
	vi adj[n + 1];
	for (int i = 0;i < m;i++) {
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int ans = 0;
	for (int i = 1;i <= n;i++) {
		int mx = 0;
		for (auto next : adj[i])
			mx = max(mx, h[next]);
		if (mx < h[i])
			ans++;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 8784
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!([isize]; n);

    let mut dp = vec![0; 1<<n];
    let mut vals = vec![0; 1<<n];
    for msk in 0..(1<<n) {
        for i in 0..n {
            for j in (i+1)..n {
                if msk&(1<<i) > 0 && msk&(1<<j) > 0 {
                    vals[msk] += a[i][j];
                }
            }
        }
    }

    for msk in 0..(1<<n) {
        let mut msk2 = msk;
        while msk2 > 0 {
            dp[msk] = max!(dp[msk],dp[msk-msk2] + vals[msk2]);
            msk2 = (msk2-1)&msk;
        }
    }
    println!("{}", dp[(1<<n)-1]);
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;



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

    ll h,n; cin >> h >> n;
    vll dp(10000 + 2, 1e8);
    dp[0] = 0;
    ll ans = 1e8;

    REP(i,n){
        ll a, b; cin >> a >> b;
        if (h<=a){
            ans = min(ans, b);
            continue;
        }
        for(int i=a; i<h; i++) dp[i] = min(dp[i-a]+b, dp[i]);
        for(int j=h-a; j<h; j++) ans = min(ans, dp[j]+b);
    }   
    cout << ans;
    return 0;
}



Measured memory_bytes: 384
module Main where
import Data.Char
int = read :: String -> Int
inte = read :: String -> Integer
getWord :: IO String
getWord = do
  c <- getChar
  if isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map inte . words
printer = unlines . (:[]) . show 

solver (n:m:xs)
  | n == 1 && m == 1 = 1
  | n == 2 || m == 2 = 0
  | n == 1 = m - 2
  | m == 1 = n - 2
  | otherwise = (n-2)*(m-2)




Measured memory_bytes: 508
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
int a[123];

int main() {
    int N;
    while (~scanf("%d", &N)) {
          int sum = 0;
          for (int i = 0; i < N; i++) {
              scanf("%d", &a[i]);
              sum += a[i];
          }
          int ans = sum, idx = 0;
          for (int i = 0; i < N; i++) {
              int tmp = abs(a[i] * N - sum);
              if (tmp < ans) {
                 ans = tmp;
                 idx = i;
              }
          }
          printf("%d\n", idx);
    }
    return 0;
}


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

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    typedef pair<ll, ll> P;
    vector<P> ab(n);
    rep(i,n) cin >> ab[i].second >> ab[i].first;
    sort(ab.begin(), ab.end());
    ll now = 0;
    rep(i,n) {
        now += ab[i].second;
        if (now > ab[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3328
import numpy as np

N = int(input())
A = list(map(int, input().split()))

A = np.array(A, dtype = np.int64)
INF = 10 ** 12

dp1 = np.array([-INF] * (N + 1), dtype = np.int64)
dp2 = np.array([+INF] * (N + 1), dtype = np.int64)

if N % 2 == 0:
    dp2[1:] = -A[:]
    # print (dp2)
    for k in range(2, N + 1):
        if k % 2 == 1:
            dp2[k:] = np.minimum(dp1[k - 1:N] - A[k - 1:], dp1[k:] - A[:N - k + 1])
            # print (dp2)
        else:
            # print (dp2[k - 1:N], A[k - 1:], dp2[k:], A[: N - k])
            dp1[k:] = np.maximum(dp2[k - 1:N] + A[k - 1:], dp2[k:] + A[:N - k + 1])
            # print (dp1)
    print (dp1[N])

else:
    dp1[1:] = A[:]
    # print (dp1)
    for k in range(2, N + 1):
        if k % 2 == 0:
            dp2[k:] = np.minimum(dp1[k - 1:N] - A[k - 1:], dp1[k:] - A[:N - k + 1])
            # print (dp2)
        else:
            # print (dp2[k - 1:N], A[k - 1:], dp2[k:], A[: N - k])
            dp1[k:] = np.maximum(dp2[k - 1:N] + A[k - 1:], dp2[k:] + A[:N - k + 1])
            # print (dp1)
    print (dp1[N])


Measured memory_bytes: 12516
import fractions
A,B,C=map(int,input().split())

if fractions.gcd(A,B)==1:
  print("YES")
else:
  gcd_AB=fractions.gcd(A,B)
  #print(gcd_AB)
  if C%gcd_AB==0:
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 5048
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long 
#define int ll
//#define slld(t) scanf("%lld",&t)
// #define sd(t) scanf("%d",&t)
// #define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define pdd pair<double , double>
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N    200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
#define s3   1.73205080757          // square root 3
const  int inf = (int)1e18+10 ;
const int MAX= 100;

 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set S;

int powmod(int x , int y){
	int res = 1;
	while(y > 0){
		if(y%2==1)
			res = (res*x)%mod;
		x = (x*x)%mod;
		y/=2;
	}
	return res;
}
int mul(int x , int y){
	return (x*y)%mod;
}
int a[N + 10] = {0};
void pre(){
	a[1] = 1;
	for(int i = 2 ; i*i <= N ; i++){
		   if(a[i] == 0){
		   	   for(int j = i*i ; j <= N ; j+=i)
		   	   	  a[j] = 1;
		   }
	}
}

signed main(){
  fast;
 
 
  pre();
  int x;
  cin >> x;
  for(int i = x ; i <= N ; i++){
  	   if(a[i] == 0){
  	   	   cout << i << endl;
  	   	   break;
  	   }
  }

 }

Measured memory_bytes: 1792
/* Kadai2_3
   nabe9393 */
 
#include <stdio.h>
 
int main(void) {
    int Neutral, White, Black;
 
    //入力受け取り
    scanf("%d", &Neutral);
    scanf("%d", &White);
    //Blackの値が黒く塗ることになるマスの数
    //Neutralの二乗からWhiteを引いた数
    Black = Neutral*Neutral - White;
    printf("%d\n", Black);
    return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input!{
        n: usize,
        a: [f64; n],
    }

    let b = a.iter().map(|x| 1.0/x);
    let sum: f64 = b.fold(0.0, |sum, x| sum+x);

    println!("{}", 1.0/sum)
}


Measured memory_bytes: 4352
use std::io;
use std::cmp;
use std::collections::VecDeque;

fn main() {
    let n = read_one::<usize>();
    let mut g = vec![Vec::new(); n];
    for i in 0..n - 1 {
        let (a, b) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1)
        };
        g[a].push((i, b));
        g[b].push((i, a));
    }

    let mut colors = vec![0; n - 1];
    let mut q = VecDeque::new();
    let mut siz = 0;
    q.push_back((0, 0, 0, n + 1));
    while let Some((_, u, c, p)) = q.pop_front() {
        let mut color = 1;
        for &v in &g[u] {
            if p == v.1 { continue; }
            if c == color { color += 1; }
            colors[v.0] = color;
            siz = cmp::max(siz, color);
            q.push_back((v.0, v.1, color, u));
            color += 1;
        }
    }
    println!("{}", siz);
    for c in colors {
        println!("{}", c);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int K;

ll points(vector<ll> A, int banme){
	ll ans=1;
	for(int i=banme - K+1;i<banme+1;i++){
		ans*=A.at(i);
	}
	return ans;
}

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

	vector<ll> A(N), Ans(N);
	rep(i, N){
		cin >> A.at(i);
	}

//	for(int i=K-1;i<N;i++){
//		Ans.at(i) = points(A, i);
//	}

	for(int i=0;i<N-K;i++){
		if(A.at(i+K) <= A.at(i)){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}
}


Measured memory_bytes: 6424
N = int(input())
T = list(map(int, input().split()))
M = int(input())
D = []
for i in range(M):
    a, b = input().split()
    D.append((int(a), int(b)))

time = sum(T)

for k in range(M):
    print(time - T[D[k][0]-1] + D[k][1])



Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int a;

void init() {

}

void input() {

}

void solve() {
  cin >> a;
  if (a ==  25) {
    cout << "Christmas" << endl;
  }
  if (a ==  24) {
    cout << "Christmas Eve" << endl;
  }
  if (a ==  23) {
    cout << "Christmas Eve Eve" << endl;
  }
  if (a ==  22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

ll modpow(ll a, ll n, ll p){
  if(n == 0){
    return 1;
  }
  if(n%2 == 0){
    ll root = modpow(a,n/2,p);
    return root * root %p;
  }
  else{
    return a*modpow(a,n-1,p)%p;
  }
}


int main(void){
  int n,k;
  cin >> n >> k;

  ll work[n+2];
  rep(i,n+1)work[i] = i;
  rep(i,n+1)work[i+1] += work[i];

  ll ans = 0;
  for(int i=k;i<=n;i++){
    ans += work[n]-work[n-i]-work[i-1]+1;
    ans %= MAX;
  }

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


Measured memory_bytes: 5128
import sys
a,b=map(str,input().split())
ans=[]
for i in range(len(a)):
  ans.append(a[i])
for i in range(len(b)):
  ans.append(b[i])
n=int(''.join(ans))
i=0
while i*i<=n:
  if i*i==n:
    print('Yes')
    sys.exit()
  i+=1
print('No')

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

class UnionFind {
 private:
  int _size;
  vector<int> _parent; // 親の番号（親自身はー（マイナス）集合要素の個数）

 public:
  // n要素で生成
  explicit UnionFind(int n) : _size{n}, _parent{vector<int>(n, -1)} {}

  // 木の根を求める
  int find(int x) {
    if (x < 0 || x >= _size) {
      return x;
    }

    if (_parent[x] < 0) {
      return x;
    }

    return _parent[x] = find(_parent[x]);
  }

  // xとyの属する集合を併合する
  bool unite(int x, int y) {
    if (x < 0 || x >= _size || y < 0 || y >= _size) {
      return false;
    }

    x = find(x);
    y = find(y);
    if (x == y) {
      return false;
    }

    if (size(x) > size(y)) {
      _parent[x] += _parent[y];
      _parent[y] = x;
    } else {
      _parent[y] += _parent[x];
      _parent[x] = y;
    }

    return true;
  }

  // xとyが同じ集合に属するか
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // xの属する集合の個数を求める
  int size(int x) {
    if (x < 0 || x >= _size) {
      return 1;
    }

    return -_parent[find(x)];
  }

  // 全体の個数を求める
  int size() {
    return _size;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (int i{}; i < M; ++i) {
    cin >> A[i] >> B[i];
    --A[i];
    --B[i];
  }

  UnionFind uni(N);

  vector<long long> ans(M);
  ans[M - 1] = (long long) N * (N - 1) / 2;

  for (int i{M - 1}; i >= 1; --i) {
    ans[i - 1] = ans[i];
    if (uni.find(A[i]) != uni.find(B[i])) {
      ans[i - 1] -= (long long) uni.size(A[i]) * uni.size(B[i]);
      uni.unite(A[i], B[i]);
    }
  }

  for (int i{}; i < M; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}


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

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

using namespace std;

int main(){
  int x;
  cin>>x;
  if(x==3 || x==5 || x==7){
    cout<<"YES";
  }else{
    cout<<"NO";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vecint v(n);
  REP(i,n) cin>>v[i];
  sort(ALL(v));
  int mx = v.back();
  int mid = v.front();
  REP(i,n-1) {
    if (abs(2*v[i] - mx) < abs(2*mid - mx)) {
      mid = v[i];
    }
  }
  cout << mx << ' ' << mid << endl;
  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>


using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

ll gcd(ll a,ll b)
{
//   ll x = a*b;
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  ll r;
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}



int main()
{
   ll n,k;
   cin >> n >> k;
   ll a = n/k;
   ll b = n-a*k;
   a++;
   ll c = abs(n-a*k);
   if(b > c)
   {
     b = c;
   }
   cout << b << endl;
}


Measured memory_bytes: 256