akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#define input std::cin

using vector = std::vector<int>;
using lint = long long int;
using string = std::string;

struct range {
  int l, r;
};

int modulo = 998244353;

int main() {
  int n, k; input >> n >> k;
  std::vector<range> ranges; ranges.reserve(k);
  for (int i=0; i<k; i++) {
	int l, r; input >> l >> r;
	ranges.push_back({l,r});
  }
  vector cells (n+1); cells[n] = 0; cells[n-1] = 1;
  for (int i=n-2; i>=0; i--) {
	cells[i] = 0;
	for (int j=0; j<k; j++) {
	  range &rng = ranges[j];
	  int sum = (cells[std::min(i+rng.l, n)] -
				 (lint)cells[std::min(i+rng.r+1, n)] +
				 modulo)%modulo;
	  cells[i] = (cells[i] + (lint)sum) % modulo;
	}
	if (i == 0)
	  std::cout << cells[i] << std::endl;
	cells[i] = (cells[i] + (lint)cells[i+1]) % modulo;
  }
}



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

namespace abc160_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string s1 = a.Substring(2, 1);
            string s2 = a.Substring(3, 1);
            string s3 = a.Substring(4, 1);
            string s4 = a.Substring(5, 1);

            if (s1 == s2 && s3 == s4)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>

void swap(int *,int *);

int main(void){
  int N,work,cnt=0;
  int *data;
  int i,j;

  scanf("%d",&N);

  data=(int *)malloc(sizeof(int)*N);

  for(i=0;i<N;i++){
    scanf("%d",&data[i]);
  }

  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(data[j-1]>data[j]){
	cnt++;
	swap(&data[j-1],&data[j]);
      }
    }
  }

  printf("%d",data[0]);
  for(i=1;i<N;i++) printf(" %d",data[i]);
  printf("\n%d\n",cnt);

  free(data);

  return 0;
}

void swap(int *a,int *b){
  int work;

  work=*a;
  *a=*b;
  *b=work;
}

Measured memory_bytes: 600
#include <stdio.h>

int main()
{
    int N,sum = 0,h,a;
    int p[10];
    scanf("%d",&N);
    for(int i = 0;i < N;i++)
    {
        scanf("%d",&p[i]);
    }
    a = p[0];
    for(int j = 0;j < N;j++)
    {
        if(a < p[j])a = p[j];
        sum += p[j];
    }
    sum -= (a / 2);
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int t[101];
	int sum=0;
	for(int i=1;i<=n;i++){
		cin >> t[i];
		sum+=t[i];
	}
	int m;
	cin >> m;
	for(int i=1;i<=m;i++){
		int p,x;
		cin >> p >> x;
		cout << sum-t[p]+x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
s=input()
ans=0
a=[0]
for i in s:
  if i=='<':
    if a[-1]>=0:a[-1]+=1
    else:a+=[1]
  else:
    if a[-1]<0:a[-1]-=1
    else:a+=[-1]
n=len(a)
for i in range(n//2):
  i*=2
  j=i+1
  if a[i]<abs(a[j]):
    x=abs(a[j])
    y=a[i]-1
  else:
    x=abs(a[j])-1
    y=a[i]
  ans+=x*(x+1)//2+y*(y+1)//2
ans+=n%2*a[-1]*(a[-1]+1)//2
print(ans)

Measured memory_bytes: 83984
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int ara[n],h[n];
    for(i=0;i<n;i++) scanf("%d",&ara[i]);
    h[0]=0;
    h[1]=abs(ara[1]-ara[0]);
    for(i=2;i<n;i++){
        h[i]=min(h[i-1]+abs(ara[i]-ara[i-1]),h[i-2]+abs(ara[i]-ara[i-2])); //cout<<h[i]<<endl;
    }
    cout<<h[n-1];
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <list>
#include <set>

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

using namespace std;

int N, M, K, W,X;
int dp[3][101];

int main() {
	int k,res=0,Ma, Mb;

	cin >> N;
	
	vector <int> a(N),b(N);
	vector <vector<int>> aa;
	
	rep(i, N) {
		cin >> a[i];
		
	}
	rep(i, N) {
		cin >> b[i];
	}
	aa.push_back(a);
	aa.push_back(b);

	rep(i, 3) {
		rep(j, N+1) {
			dp[i][j] = 0;
		}
	}

	rep(i, 2) {
		for (int j = 0; j < N; j++) {
			
			dp[i+1][j] = max(dp[i][j] + aa[i][j], dp[i + 1][j - 1] + aa[i][j]);
			//上からくるか横からくるか大きい方

			}
		}
	cout << dp[2][N-1];

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    long a;
    unordered_map<long, long> m;
    for (int i = 0; i < n; i++) {
        cin >> a;
        m[a]++;
    }
    int cnt = 0;
    for (auto i = m.begin(); i != m.end(); i++) {
        if (i->second - i->first < 0) {
            cnt += i->second;
        } else {
            cnt += (i->second - i->first);
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4260
/**
 *    Creator :  bizarre
 *    Date : 4/2020
 *    Problem Number : 415
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre     ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
/*
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}

void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}



int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }

        }
    }

}
const int inf = 2e9, mod = 1e9 + 7,N=1e5+5;
long long fact[N], inv[N];
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
long long ncrtane(long long n, long long r)
{
    long long ans=1,cntr=1;
    for(int i=n;i>n-r;i--)
    {
        ans*=i;
        ans/=cntr;
        cntr++;
    }
    return ans;
}
*/
int main()
{
    bizarre
  long long n,cnt=0;
  cin>>n;
  vector<int>vec,vec2;
  for(int i=0;i<=n;i++)
  {
      int x;
      cin>>x;
      vec.push_back(x);
  }
  for(int i=0;i<n;i++)
  {
      int x;
      cin>>x;
      vec2.push_back(x);
  }
  for(int i=0;i<n;i++)
  {
       int x=vec2[i];
        int y=vec[i];
        if(x>=y)
        {
            vec[i]=0;
            x-=y;
            cnt+=y;
        }
        else
        {
            vec[i]-=x;
            cnt+=x;
            x=0;
        }
        if(x)
        {
            y=vec[i+1];
            if(x>=y)
            {
                vec[i+1]=0;
                x-=y;
                cnt+=y;
            }
            else
            {
                vec[i+1]-=x;
                cnt+=x;
                x=0;
            }
        }
  }
  cout << cnt;
    return 0;
}


Measured memory_bytes: 1400
#coding:utf-8

x = int(input())
P = 40000
p = []
b = 0
flag = 0

for i in range(1,P+1):
    if x % i == 0:
        p.append(i)

for i in p:
    a = 0
    while a <= 40000:
        b = a - i
        y = (a ** 5) - (b ** 5)
        if y == x:
            print("{} {}".format(a,b))
            flag = 1
            break
        a += 1
    if flag == 1:
        break

Measured memory_bytes: 9200
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int n;
	long  long a[N];
	long long b[N];
	long long s, ans;
	bool v = true;
	s = 0;
	ans = 10000000000;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d %d", &a[i],&b[i]);
		if (a[i] != b[i])v = false;
		s += a[i];
		if ((a[i] > b[i]) && (ans>b[i]))ans = b[i];
	}
	if (!v){
		ans = s - ans;
	}
	else ans = 0;

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 2432
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)

ll n, m, h, k;
vector<ll> f;
vector<ll> b;
vector<ll> srcx, srcy;
vector<ll> s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    while (cin >> n >> m >> h >> k && n) {
        s.resize(n);
        for (size_t i = 0; i < n; i++) {
            cin >> s[i];
        }
        b.resize(m);
        vector<pair<int, int>> p(m);
        for (size_t i = 0; i < m; i++) {
            int x, y;
            cin >> x >> y;
            p[i] = make_pair(y, x);
        }
        sort(p.begin(), p.end());
        for (size_t i = 0; i < m; i++) {
            b[i] = p[i].second - 1;
        }
        vector<int> cur(n);
        for (size_t i = 0; i < n; i++) {
            cur[i] = i;
        }
        srcx.resize(m); srcy.resize(m);
        for (size_t i = 0; i < m; i++) {
            srcx[i] = cur[b[i]];
            srcy[i] = cur[b[i] + 1];
            swap(cur[b[i]], cur[b[i] + 1]);
        }
        vector<int> dst(n);
        for (size_t i = 0; i < n; i++) {
            dst[cur[i]] = i;
        }
        ll org = 0;
        for (size_t i = 0; i < k; i++) {
            org += s[dst[i]];
        }
        ll ans = org;
        for (size_t i = 0; i < m; i++) {
            int a = srcx[i];
            int b = srcy[i];
            if (a > b) swap(a, b);
            if (a < k && b >= k) {
                ans = min(ans, org - s[dst[a]] + s[dst[b]]);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 6260
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n, m; cin >> n >> m;
    bool ans = false;
    set<int> fromIsland1, toIslandN;
    REP(i, m){
        int a, b; cin >> a >> b;
        if(a == 1 and b == n) ans = true;
        else if(a == 1) fromIsland1.emplace(b);
        else if(b == n) toIslandN.emplace(a);
    }
    if(!ans){
        REP(i, n){
            if(fromIsland1.find(i) != fromIsland1.end() and toIslandN.find(i) != toIslandN.end()){
                ans = true;
                break;
            }
        }
    }
    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;

}

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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=2E5+10;

int n,Ans[MAXN],Mx[MAXN];
vector<int> T[MAXN];
map<int,int> M[MAXN];

int f(int x,int fa,int w)
{
	if(M[x].count(w))
		return M[x][w];
	int ret=0;
	for(int v:T[x])
		if(v!=fa&&v<=w)
			ret+=f(v,x,w)+1;
	return M[x][w]=ret;
}

void dfs(int x,int fa)
{
	Mx[x]=max(Mx[fa],fa);
	if(x>Mx[fa])
		Ans[x]=Ans[fa]+f(x,fa,Mx[x])+1;
	else
		Ans[x]=Ans[fa]-f(x,fa,Mx[fa])+f(x,fa,Mx[x]);
	if(x==1)
		Ans[x]=0;
	for(int v:T[x])
		if(v!=fa)
			dfs(v,x);
}

int main()
{
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++)
		scanf("%d%d",&u,&v),
		T[u].push_back(v),
		T[v].push_back(u);
	dfs(1,0);
	for(int i=2;i<=n;i++)
		printf("%d%c",Ans[i],"\n "[i!=n]);
}


Measured memory_bytes: 54784
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

//#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_N (5000)
#define MAX_K (5000)

int N, K;
int A[MAX_N];
bitset<MAX_K> DP(1);

void solve() {
  sort(A, A + N);
  ll sum = 0;
  for (int i = 0; i < N; i++) sum += A[i];

  int ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    bool no_need = true;
    for (int j = 0; j < K; j++) {
      if (DP[j] && j + sum >= K) {
        no_need = false;
        break;
      }
    }
    if (no_need) ans++;

    debug_printf("sum = %lld, a = %d\n", sum, A[i]);
    for (int j = 0; j < K; j++) debug_printf("%s ", DP[j]? "o": "x");
    debug_printf("\n");

    DP |= DP << A[i];

    sum -= A[i];
  }
  printf("%d\n", ans);
}

int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);

  solve();

  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
pp = gets.chomp.split().map(&:to_i)
q  = gets.chomp.split().map(&:to_i)
nums = [1,2,3,4,5,6,7,8]
num_array = nums.slice(0,n)
pattern = 1
j = 0
while true
    pattern = pattern * num_array[j]
    j += 1
    if j == num_array.size
        break
    end
end
num_order = num_array.permutation.to_a
i = 0
a = 0
b = 0
for i in 0..pattern
    if num_order[i] == pp
        a = i
    end
    if num_order[i] == q
        b = i
    end
end
print (a-b).abs



Measured memory_bytes: 20372
n = gets.to_i
w = gets.split(" ").map(&:to_i)

i = 0
j = w.length - 1
s1 = w[i]
s2 = w[j]

while (j - i) != 1 do
    case s1 <=> s2
    when 1 then
        j = j - 1
        s2 = s2 + w[j]
    when 0 then 
        j = j - 1
        s2 = s2 + w[j]
    when -1 then
        i = i + 1
        s1 = s1 + w[i]
    end
end
puts (s1-s2).abs


    

Measured memory_bytes: 1788
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int i;
string s;
int num() {
	int ret = 0;
	while (isdigit(s[i])) {
		ret *= 10;
		ret += s[i] - '0';
		++i;
	}
	return (ret + 1) / 2;
}
int f() {
	
	if (isdigit(s[i])) {
		int a = num();
		++i;
		return a;

	}
	vi v;

	while (i<s.size()&&s[i] != ']') {
		++i;
		v.push_back(f());
	}
	int ret = 0;
	sort(ALL(v));
	REP(j, (v.size() + 1) / 2) {
		ret += v[j];
	}
	++i;
	return ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(a, n) {
		cin >> s;
		i = 0;
		cout << f() << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N; cin >> N;
    int A[N]; A[0] = 1e5+5;
    FOR(i,0,N-2) {
        int B; cin >> B;
        A[i] = min(A[i], B);
        A[i+1] = B;
    }

    int sum = 0;
    FOR(i,0,N-1){ sum += A[i]; }
    cout << sum << '\n';
}



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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  ll n, a, b; cin >> n >> a >> b;
  if((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl;

  } else {
    cout << min(a + (b-a-1)/2, n-b+1+(b-a-1)/2) << endl;
    
  }

}


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

using namespace std;

vector<pair<double, double>> crosspoint(double x1, double y1, double r1, double x2, double y2, double r2) {
	x1 -= x2;
	y1 -= y2;
	double S = x1 * x1 + y1 * y1;
	double a = (S + r2 * r2 - r1 * r1) / 2.0;
	double D = S * r2 * r2 - a * a;
	if (D < 0) { return {}; }

	double A1 = a * x1;
	double B1 = y1 * sqrt(D);
	double A2 = a * y1;
	double B2 = x1 * sqrt(D);
	return {
		{ (A1 + B1) / S + x2, (A2 - B2) / S + y2 },
		{ (A1 - B1) / S + x2, (A2 + B2) / S + y2 }
	};
}

int main() {
	const double EPS = 1e-9;
	int N, K;
	cin >> N >> K;
	vector<double> x(N), y(N), c(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i] >> c[i];
	}

	auto check = [&](double mid) {
		vector<double> r(N);
		for (int i = 0; i < N; ++i) { r[i] = mid / c[i]; }
		vector<pair<double, double>> ps;
		for (int i = 0; i < N; ++i) {
			ps.emplace_back(x[i], y[i]);
			for (int j = i + 1; j < N; ++j) {
				auto vec = crosspoint(x[i], y[i], r[i], x[j], y[j], r[j]);
				for (auto& p : vec) { ps.push_back(p); }
			}
		}
		for (auto& p : ps) {
			int cnt = 0;
			double X = p.first, Y = p.second;
			for (int i = 0; i < N; ++i) {
				if (r[i] + EPS >= hypot(X - x[i], Y - y[i])) { ++cnt; }
			}
			if (cnt >= K) { return true; }
		}
		return false;
	};

	double ok = 1e9, ng = 0;
	int loop = 0;
	while (loop++ < 100) {
		double mid = (ok + ng) / 2;
		(check(mid) ? ok : ng) = mid;
	}
	cout.precision(15);
	cout << fixed << ok << endl;

	return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<ctime>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<memory.h>
#include<map>
#include<ctime>
#include<algorithm>
#include<ctime>
#include<set>
#define ll long long
#define For(i,j,k)  for(ll i=j;i<=k;++i)
#define FOr(i,j,k)  for(ll i=j;i>=k;--i)
#define rep(i,j,k)	for(ll i=j;i<k;++i)
#define ld double
using namespace std;
inline ll read(){   ll 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 wrote(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) wrote(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){ wrote(x);   puts("");   }
const ll N=20;
ll a[N],b[N],n,ans;
void dfs(ll x){
	if (x>n){
		ll answ=0;
		For(i,1,n)	answ|=b[i]%2==0;
		ans+=answ;
		return;
	}
	For(i,a[x]-1,a[x]+1){
		b[x]=i;
		dfs(x+1);
	}
}
int main(){
	n=read();
	For(i,1,n)	a[i]=read();
	dfs(1);
	writeln(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000

int main(void) {
	ll n; cin >> n;
	vint a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(),a.end() ,greater<ll>());
	queue<ll> q;
	ll ans = 0;
	q.push(a[0]);
	for (int i = 1; i < n;i++) {
		ll x = q.front(); q.pop();
		ans += x;
		if (x != a[i]) {
			q.push(a[i]);
			q.push(a[i]);
		}
		else {
			q.push(a[i]);
			q.push(a[i]);
		}
		continue;
	}
	cout << ans << endl;

	return  0;
}


Measured memory_bytes: 6372
#include <iostream>
#include <string>
#include <numeric>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(int, char**) {
  int x, y, z, K;
  cin >> x >> y >> z >> K;
  std::vector<unsigned long long> a(x), b(y), c(z);
  for (int i = 0; i < x; ++i) cin >> a[i];
  for (int i = 0; i < y; ++i) cin >> b[i];
  for (int i = 0; i < z; ++i) cin >> c[i];
  std::sort(a.begin(), a.end(), std::greater<unsigned long long>());
  std::sort(b.begin(), b.end(), std::greater<unsigned long long>());
  std::sort(c.begin(), c.end(), std::greater<unsigned long long>());

  std::vector<unsigned long long> ans;
  for (int i = 0; i < x; ++i) {
      for (int j = 0; j < y; ++j) {
          for (int k = 0; k < z; ++k) {
                if ((i + 1) * (j + 1) * (k + 1) <= K) {
                    unsigned long long ret = a[i] + b[j] + c[k];
                    ans.push_back(ret);
                } else break;
          }
      }
  }
  std::sort(ans.begin(), ans.end(), std::greater<unsigned long long>());
  for(int i = 0; i < K; ++i) cout << ans[i] << endl;
}


Measured memory_bytes: 1404
#include <iostream>

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
	ll N;
	cin >> N;
	string ans;
	switch(N % 10) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			ans = "hon";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			ans = "pon";
			break;
		case 3:
			ans = "bon";
			break;
	}

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


Measured memory_bytes: 3100
#include<iostream>
	#include<cmath>
	using namespace std;
     
    main(){
      int A,B,K;
      cin >> A >> B;
     
      for (K=min(A,B); K<=max(A,B); K++){
        if (abs(A - K) - abs (B - K) == 0){
          cout << K;
          break;
        }
        if (K==max(A,B)){
          cout << "IMPOSSIBLE";
          break;
        }
      }
    }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
#define ll long long

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++) {
        if(i%3 == 0 && i%5 == 0) {}
        else if(i%3 == 0) {}
        else if(i%5 == 0) {}
        else sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <typeinfo>
using namespace std;


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin2(n,m);
    intv way(n+1);
    int x;
    rap(2*m,i){
        cin >> x;
        way[x]++;
    }
    for(int i=1;i<=n;i++){
        cout<<way[i]<<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 a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        for(int i = a ; i <= b; i++){
            if(c % i == 0)  count++;
        }
        System.out.println(count);
    }
}


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

using namespace std;

int main() {

    int n;
    scanf("%d", &n);

    vector<long long> sticks;

    for (int i = 0; i < n; i++) {
        long long d;
        scanf("%lld", &d);
        sticks.push_back(d);
    }

    sort(sticks.begin(), sticks.end());
    vector<long long> match;

    int last = 0, i = sticks.size() - 1;
    while (i >= 0) {
        if (last == sticks[i]) {
            match.push_back(sticks[i]);
            last = 0;
        } else last = sticks[i];

        i--;
    }

    if (match.size() >= 2) printf("%lld", match[0] * match[1]);
    else printf("0");

    return 0;
}


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

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

  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i*j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i, *T;
  int n;
  
  scanf("%d", &n);

  T= (int *) malloc ( sizeof(int) * (n+1) );
  
  for(i=1; i<=n; i++) scanf("%d", &T[i]);
  
  //出力 (output)
  for(i=1; i<=n; i++){
    printf("node %d: key = %d,",i,T[i]);
    if(i != 1) printf(" parent key = %d,",T[i/2]);
    if(i*2 <= n) printf(" left key = %d,",T[i*2]);
    if(i*2+1 <= n) printf(" right key = %d,",T[i*2+1]);
    printf(" \n");
  }
  
    return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

int main() {
    // 前処理
    COMinit();

    int H, W, n;
    cin >> H >> W >> n;
    vector<vector<int>> v(n+2, vector<int>(2));
    v[0][0] = 1; v[0][1] = 1;
    srep(i,1,n+1)cin >> v[i][0] >> v[i][1];
    v[n+1][0] = H; v[n+1][1] = W;

    sort(v.begin(), v.end());

    ll dp[n+2][2];
    rep(i,n+2)rep(j,2)dp[i][j] = 0;
    dp[n+1][0] = 1;

    drep(j,n+2){
        drep(i,j){
            int dh = v[j][0] - v[i][0];
            int dw = v[j][1] - v[i][1];
            rep(k,2){
                if(i == 0 || i == n + 1) dp[i][k] = (dp[i][k] + COM(dh+dw, dh) * dp[j][k]) % MOD;
                else dp[i][k] = (dp[i][k] + COM(dh+dw, dh) * dp[j][(k+1)%2]) % MOD;
            }
        }
    }

    ll ans = (dp[0][0] + MOD - dp[0][1]) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12416
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,Q; cin >> N >> Q;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<pii> X(Q);
    rep(i,Q) {
        cin >> X[i].first;
        X[i].second = i;
    }

    int L = N/2;
    vector<ll> S(N+1),B(L+1);
    rep(i,N) S[i+1] = S[i]+A[i];
    reverse(all(A));
    A.emplace_back(0);
    reverse(all(A));
    for (int i = 1; i <= L; i++) {
        B[i] = A[N-2*i];
    }
    for (int i = L; i > 1; i--) {
        B[i-1] += B[i];
    }

    sort(all(X)); reverse(all(X));
    int cur = 0;
    vector<ll> ans(Q);
    for (int i = 1; i <= L; i++) {
        while (cur < Q && abs(A[N-i] - X[cur].first) < abs(X[cur].first - A[N-2*i])) {
            ans[X[cur].second] += S[N] - S[N-i] + B[i];
            cur++;
        };
    }
    while (cur < Q) {
        ans[X[cur].second] += S[N] - S[L];
        cur++;
    }

    rep(i,Q) cout << ans[i] << endl;
}

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

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

using namespace std;

#define encode(state,lock) (state|(lock<<10))
#define getState(v) (v&((1<<10)-1))
#define getLock(v) (v>>10)
#define isLock(state, lock) (state&(1<<lock))

void init(int n,string s,set<int> &S) {
  int state = 0;
  rep(i,n) {
    if( s[i] == 'u' ) {
      state = 0;
    } else {
      int lock = s[i] - '0';
      S.insert(encode(state,lock));
      state = state | (1<<lock);
    }
  }
}

bool hasDeadlock(int n,string s) {
  rep(i,n-1) if( s[i] != 'u' && s[i] == s[i+1] ) return true;

  set<int> S;
  init(n,s,S);
  bool update = true;
  while(update) {
    update = false;
    vector<int> buffer;
    /*
    for(auto v : S) {
      bitset<10> BIT(v&((1<<10)-1));
      cout << BIT << " : " << (v>>10) << endl;
    }
    puts("");
    */
    for(auto v1 : S) {
      int state1 = getState(v1);
      int lock1  = getLock(v1);
      for(auto v2 : S) {
        int state2 = getState(v2);
        int lock2  = getLock(v2);
        if( state1 & state2 ) continue;
        if( state2 & (1<<lock1) ) buffer.push_back(encode((state1|state2),lock2));
        if( isLock(state1,lock2) && isLock(state2,lock1) ) {
          return true;
        }
      }
    }
    rep(i,(int)buffer.size()) {
      if( S.count(buffer[i]) ) continue;
      S.insert(buffer[i]);
      update = true;
    }
  }
  return false;
}

int main() {
  int n;
  string s;
  while( cin >> n, n ) {
    cin >> s;
    puts(hasDeadlock(n,s)?"UNSAFE":"SAFE");
  }
  return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,i,l,r,ans=0;
  string c;
  cin>>n>>c;
  l=0;
  r=n-1;
  while(l<r){
    while(l<n&&c.at(l)=='R') l++;
    while(0<=r&&c.at(r)=='W') r--;
    if(l<r){
      c.at(l)='R';
      l++;
      c.at(r)='W';
      r--;
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

int cnt = 0;

void insertionsort(vector<int> &A, int g){
    for(int i=g; i<A.size(); ++i){
        int x = A[i];
        int j = i-g;
        while( j>=0 and A[j]> x ){
            A[j+g]=A[j];
            j = j-g;
            cnt++;
        }
        A[j+g] = x;

    }
}

void shellsort(vector<int> &A){
    vector<int> G;

    for(int h=1; ; ){
        if( h>A.size() ){
            break;
        }
        G.push_back(h);
        h = 3*h + 1;
    }
    int m = G.size();

    cout << m << endl;
    for(int i=G.size()-1; i>=0; --i){
        if ( i<G.size() -1 )
            cout << ' ';
        cout << G[i];
    }
    cout << endl;

    for(int i=m; i>=0; --i){
        insertionsort(A,G[i]);
    }
    cout << cnt << endl;
}


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

    vector<int> A(n,0);
    for(int i=0; i<n; ++i){
        cin >> A[i];
    }


    shellsort(A);
    for(int i=0; i<n; ++i){
        cout << A[i] << endl;
    }

}


Measured memory_bytes: 6796
#include<stdio.h>
  #include<string.h>
  #include<stdlib.h>
  int top,N[1000];
  void push(int p){
    N[++top]=p;
  }
  int pop(){
    top--;
    return N[top+1];
  }
  int main(){
    int x,y;
    top=0;
    char n[100];

    while(1){
      if(scanf("%s",n)==EOF) break;
      if(n[0]=='+'){
        x=pop();
        y=pop();
        push(x+y);
      }else if(n[0]=='-'){
        x=pop();
        y=pop();
        push(y-x);
      }else if(n[0]=='*'){
        x=pop();
        y=pop();
        push(x*y);
      }else {
        push(atoi(n));
      }
    }
    printf("%d\n",pop());
    return 0;
  }



Measured memory_bytes: 2096
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-05-31
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.rbegin(), v.rend())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm ( ll a, ll b ) {
    return ( a / __gcd ( a, b ) ) * b;
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10) << fixed;
    int n, nn;
    cin >> n >> nn;
    cout << n*nn << "\n";    
    return 0;
}


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

int main()
{
    int A, B, C, D;

    cin >> A >> B >> C >> D;

    if (A + B == C + D)
    {
        cout << "Balanced" << endl;
    }
    else if (A + B < C + D)
    {
        cout << "Right" << endl;
    }
    else if (A + B > C + D)
    {
        cout << "Left" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define MOD 1000000007 //10^9+7
#define INF 1000000000 //10^9

int main ()
{
    string str;
    while (getline(cin,str)) {
        bool f=0;
        int a=0,b=0;
        for (int i=0; i<(int)str.length(); i++) {
            if (str[i]==' ') f=1;
            else if (!f) a=a*10+(str[i]-'0');
            else b=b*10+(str[i]-'0');
        }
        cout<<(int)log10(a+b)+1<<endl;
    }
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const int N=100000+10;
struct edge
{
	int to,val;
}e;
vector<edge>g[N];
int x,y,w,n,color[N];
ll sum;
void dfs(int u,int p)
{
	color[u]=(sum&1?0:1);
	for(edge e:g[u]){
		if(e.to==p)continue;
		sum+=1ll*e.val;
		//cout<<sum<<"\n";
		dfs(e.to,u);
		sum-=e.val;
	}
	return;
}
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<n;i++){
    	cin>>x>>y>>w;
    	e.to=y;e.val=w;
    	g[x].push_back(e);
    	e.to=x;
    	g[y].push_back(e);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)cout<<color[i]<<"\n";
    return 0;
}

Measured memory_bytes: 8448
#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
int a,b,i;
string s,sr,ss;
cin>>s>>sr;
cin>>a>>b;
cin>>ss;
if(ss==s)
cout<<a-1<<" "<<b;
if(ss==sr)
cout<<a<<" "<<b-1;
 
 
	return 0;
}

Measured memory_bytes: 3628
A,B = map(int,input().split())

if A  == 1:
  if A < B:
    print('Alice')
  else:
    print('Draw')
elif B == 1:
  if B < A:
    print('Bob')
else:
  if A > B:
    print('Alice')
  elif A == B:
    print('Draw')
  else:
    print('Bob')

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int min = N * 2;

		for(int i = N; i<=min; i=i*2){
			if(i % N == 0 && i % 2 == 0){
				System.out.println(i);
				break;
			}
		}

		sc.close();
	}

}


Measured memory_bytes: 23380
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    g = LIR(n)
    dp = [[float("inf")]*(n+1) for i in range(n)]
    for i in range(n):
        dp[i][i+1] = 0
    for k in range(1,n+1):
        for l in range(n):
            hl,wl = g[l]
            r = l+k
            if r > n:
                break
            hr,wr = g[r-1]
            nd = dp[l][r]
            for j in range(l+1,r):
                hj,wj = g[j-1]
                cost = hl*wj*wr
                nd = min(nd,dp[l][j]+dp[j][r]+cost)
            if nd < dp[l][r]:
                dp[l][r] = nd
    print(dp[0][n])
    return

#Solve
if __name__ == "__main__":
    solve()



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

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
    int n;
    cin >> n;
    V a(n);
    for(auto & i : a)   cin >> i;
    int cnt = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            for(int k = 0; k < n; k++)
                if(((a[i] + a[j]) > a[k]) && (a[i] + a[k] > a[j]) && (a[k] + a[j] > a[i]) && (a[i] != a[j] && a[j] != a[k] && a[k] != a[i]) && (i < j && j < k))  cnt++;
    cout << cnt << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 3844
using System;

namespace ABC168
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());

            if (N % 10 == 3)
            {
                Console.WriteLine("bon");
            }
            else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }
        }
    }
}


Measured memory_bytes: 27528
s=str(input())
S=[]
S[0:0]=s
for i in range(len(S)):
    S[i]=int(s[i])
t=0
for i in range(len(S)):
    p=len(S)-i-1
    for j in range(p):
        t+=S[i]*10**j*2**(len(S)-j-2)
    t+=S[i]*10**p*2**i
print(t)

Measured memory_bytes: 3060
import java.util.Scanner;
 class Main{
 	
	
	public void solve(){
		Scanner sc =new Scanner(System.in);
	    int ban,hito,uriage,i;
		for(int b=0;b<4;b++){
			ban=sc.nextInt();
			if(ban==1){
				i=6000;
			}else if(ban==2){
				i=4000;
			}else if(ban==3){
				i=3000;
			}else{
				i=2000;
			}
			hito=sc.nextInt();
			uriage=i*hito;
			System.out.println(uriage);
		}
	}
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
 }
	

Measured memory_bytes: 17236
def main():
    N=int(input())
    A=list(map(int, input().split()))
    even=[i for i in A if i % 2 == 0]
    for i in even:
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            print('DENIED')
            return
    print('APPROVED')
main()

Measured memory_bytes: 8924
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    long long int A,B,C,X,Y,Z;
    cin >> A >> B >> C >> X >> Y;
    Z = 0;
    long long int ans = 9876543210;
    for(int i = 0;i < 100001;i++){
      ans = min(ans,2*i*C+A*max(Z,X-i)+B*max(Z,Y-i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int N;
  cin>>N;
  if(1<=N && N<10){
    cout<<N;
  }
  if(10<=N && N<100){
    cout<<9;
  }
  if(100<=N && N<1000){
    cout<<9+N-99;
  }
  if(1000<=N && N<10000){
    cout<<9+900;
  }
  if(10000<=N && N<100000){
    cout<<9+900+N-9999;
  }
  if(N==100000){
    cout<<9+900+90000;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int k,L,l;
string S,s[100005];
int main()
{
	cin>>S>>k; 
	L=S.size();
	for(int i=1;i<=5;i++)
	  for(int j=0;j<=L-i;j++)
		s[l++]=S.substr(j,i);
	sort(s,s+l);
	l=unique(s,s+l)-s;
	cout<<s[k-1];
	return 0;
}

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

using P = pair<int,int>;

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


int main()
{
    int n,Q;
    cin >> n >> Q;
    vector<int> c(n);
    rep(i,n) {
        cin >> c[i];
        c[i]--;
    }
    vector<int> ql(Q),qr(Q);
    vector<vector<int>> table(n);
    rep(i,Q) {
        cin >> ql[i] >> qr[i];
        ql[i]--; qr[i]--;
        table[qr[i]].push_back(ql[i]);
    }

    vector<int> place(n,-1);
    BinaryIndexedTree<int> bit(n);

    map<P,int> mp;
    rep(i,n) {
        if(place[c[i]] != -1) bit.add(place[c[i]], -1);
        place[c[i]] = i;
        bit.add(i, 1);
        for(int l : table[i]) {
            if(l > 0) mp[P(l,i)] = bit.sum(i) - bit.sum(l-1);
            else mp[P(0,i)] = bit.sum(i);
        }
    }

    rep(i,Q) cout << mp[P(ql[i],qr[i])] << endl;
    return 0;
}

Measured memory_bytes: 65504
#from collections import deque
def hanbun(L):
    N = len(L)
    flag = N % 2
    N = N // 2
    ans = []
    for i in range(N):
        ans.append(L[2 * i] * L[2 * i + 1])
    if flag == 1:
        ans.append(L[-1])
    return(ans)

N = int(input())
A = list(map(int, input().split()))
while len(A) > 1:
    A = hanbun(A)
ans = A[0]
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21644
use proconio::input;
fn main (){
let mut _a: i128;
let mut _b: i128;
let mut _c: i128;


input! {
    _a: i128,
    b: i128,
    c: i128,

}
 

let x = (b*10) + c ;



if x % 4 == 0  {
    println!("YES");
}else {
    println!("NO");


}
 
}


Measured memory_bytes: 2104