akhauriyash/Code-Regression huggingface dataset:
/*  
    And solitare's the only game in town
    And every road that takes him
    Takes him down
    And by himself it's easy to pretend
    He'll never love again
    _________________________
    _________________________
    984 Hours of Solitude
    Quarantine_Day : 41
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 200005

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

    ll d, n;
    cin>>d>>n;
    if(n == 100) n++;
    
    if(d == 0) cout<<n<<"\n";
    else if(d == 1) cout<<n * 100ll<<"\n";
    else if(d == 2) cout<<n * 10000ll<<"\n";

    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
k = 0

if X % 50:
    print(k)
else:
    maxA = min(X // 500, A)
    for i in range(maxA + 1):
        d = X - 500 * i
        maxB = min(d // 100, B)
        for j in range(maxB + 1):
            dd = d - 100 * j
            if dd // 50 <= C:
                k += 1
    print(k)

Measured memory_bytes: 3064
#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 UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != 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 main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a = 0, b = 0;
	REP(i, n) {
		int x;
		cin >> x;
		if (x % 4 == 0)a++;
		else if (x % 2 == 0)b++;
	}
	b = max(0, b - 1);
	if (a >= (n - b) / 2)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define in inline
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9') {
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int n,m,rt[200002],head[200002],a[200002],ls[20000002],rs[20000002],ans[200002],u,v,cnt,tot,s[20000002],la,r[200002],val[20000002];
struct edge{
	int to,next;
}e[400002];
inline void bu(re int x,re int y){
	e[++tot].to=y;
	e[tot].next=head[x];
	head[x]=tot;
}
inline int insert(re int v,re int l,re int r,re int x,re int vv) {
	int y=++cnt;
	s[y]=s[x]+1;val[y]=max(val[x],vv);
	if(l==r){
	val[y]=max(val[y],vv);
	return y;}
	ls[y]=ls[x];
	rs[y]=rs[x];
	int mid=(l+r)>>1;
	if(v<=mid)ls[y]=insert(v,l,mid,ls[x],vv);
	else rs[y]=insert(v,mid+1,r,rs[x],vv);
	return y;
}
inline int find(re int p,re int l,re int r,re int x){
	if(!p)return 0;
	if(r<=x)return val[p];
	re int mid=l+r>>1;
	if(x>mid)return max(find(ls[p],l,mid,x),find(rs[p],mid+1,r,x));
	else return find(ls[p],l,mid,x);
}
inline void dfs(re int x,re int y){
	ans[x]=find(rt[y],1,1e9+1,a[x]);
	rt[x]=insert(a[x]+1,1,1e9+1,rt[y],ans[x]+1);
	ans[x]=max(ans[x],ans[y]);
	for(re int i=head[x];i;i=e[i].next)
		if(e[i].to!=y)dfs(e[i].to,x);
}
int main(){
	n=read();
	for(re int i=1;i<=n;++i)a[i]=read();
	for(re int i=1;i<n;++i){
		u=read();
		v=read();
		bu(u,v);
		bu(v,u);
	}
	dfs(1,1);
	for(re int i=1;i<=n;++i)printf("%d\n",ans[i]+1);
}


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

#define DEBUG

#ifndef LOCAL
#undef DEBUG
#endif

#ifdef DEBUG
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define maxn 111111
int a[maxn];
int n;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if (a[i]==i)
		{
			ans++;
			swap(a[i],a[i+1]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
    long long N, N_copy;
    cin >> N;
    N_copy = N;
    long long digit_sum = 0;
    while (N > 0) {
        digit_sum += N % 10;
        N /= 10;
    }
    if (N_copy % digit_sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n):
    if x>=a[i]:
        x-=a[i]
        ans+=1
    else:
        break
else:
    if x>0:
        ans-=1
print(ans)

Measured memory_bytes: 9072
kind = int(input())
A = input().split()
B = input().split()
C = input().split()
stf = 0
temp = 0

for n in map(int, A):
    stf += int(B[n - 1])
    if n - temp == 1 and temp != 0:
        stf += int(C[n - 2])
    else:
        pass
    temp = n

print(stf)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll; 
 
using namespace std;
using P = pair<int, int>;

int main() {
	int N;
	cin >> N;
	vector<ll> a(N);
	vector<int> indx(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		indx[a[i]] = i;
	}

	ll res = 0;
	set<int> st;
	st.insert(-1);
	st.insert(N);
	for (int i = 1; i <= N; ++i) {
		auto it = st.lower_bound(indx[i]);
		
		ll r = (*it) - indx[i];
		it--;
		ll l = indx[i] - (*it);
		ll tmp = i * l * r;
		res += tmp;

		st.insert(indx[i]);
	}

	cout << res << endl;

	return 0;
}


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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int n, v[105], soma=0;
    ll resp2=0, resp1=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> v[i];
        soma+=v[i];
    }
    int meio1=(soma/n);
    int meio2=(soma/n)+1;
    for(int i=0; i<n; i++){
        resp1+=(v[i]-meio1)*(v[i]-meio1);
    }
    for(int i=0; i<n; i++){
        resp2+=(v[i]-meio2)*(v[i]-meio2);
    }
    cout << min(resp1, resp2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        ll a, b, s, ans;
        cin >> a >> b;
        s = ll(sqrt(a*b));
        ans = max(s-4,0LL)*2;
        if(min(a,b)<=s-4) ans--;
        vector<ll> x, y;
        for(int j=-3;j<=4;j++){
            if(s+j >= 1 && s+j != a) x.push_back(s+j);
            if(s+j >= 1 && s+j != b) y.push_back(s+j);
        }
        ll n = min(x.size(), y.size()), ma = 0;
        while(1){
            ll cnt = 0;
            for(int j=0;j<n;j++){
                if(x[j]*y[j]<a*b) cnt++;
            }
            ma = max(ma, cnt);
            if(!next_permutation(y.begin(), y.end())) break;
        }
        cout << ans + ma << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
int qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e10;
const int MAX_N = 200001;

/////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////

int main() {
	int n; cin >> n;
	//vector<int> v(n); 
	vector<pii> even(1e5), odd(1e5);
	rep(1e5) { even[i].first = 0, even[i].second = i, odd[i].first = 0, odd[i].second = i; }
	rep(n) {
		int a; cin >> a;
		if (i % 2 == 0) { (even[--a].first)++;}
		else{ (odd[--a].first)++;}
	}
	sort(all(even)), sort(all(odd));
	reverse(all(even)), reverse(all(odd));
	int ans;
	if (even[0].second != odd[0].second)ans = n - (even[0].first + odd[0].first);
	else {
		ans = n - max(even[0].first + odd[1].first, even[1].first + odd[0].first);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3456
#include<stdio.h>

int main() {

	int W, H,i,j;

	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;

		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if (i % 2 == 0 && j % 2 == 0) printf("#");
				else if (i % 2 == 1 && j % 2 == 1) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}


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


public class HelloWorld
{
    static public void Main()
    {
        var TwoFive = new long[19, 19];
        var N = long.Parse(Console.ReadLine());
        //var inp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        for (int i = 0; i < N; i++)
        {
            var tmp = Console.ReadLine().Split('.').ToArray();
            long A;
            if (tmp.Count() == 1)
            {
                A = long.Parse(tmp[0]);
                A *= 1000000000;
            }
            else
            {
                var tmp2 = tmp[0] + tmp[1].Substring(0,Math.Min(9,tmp[1].Length));
                A = long.Parse(tmp2);
                A *= (long)Math.Pow(10, 9 - Math.Min(9, tmp[1].Length));
            }

            var Two = 0;
            var Five = 0;
            while (A%2 == 0)
            {
                A /= 2;
                Two++;
            }

            while (A % 5 == 0)
            {
                A /= 5;
                Five++;
            }
            TwoFive[Math.Min(Two,18), Math.Min(Five, 18)]++;
        }
        long ans = 0;
        for (int i = 0; i < 19; i++)
        {
            for (int j = 0; j < 19; j++)
            {
                for (int k = 18 - i; k < 19; k++)
                {
                    for (int l = 18 - j; l < 19; l++)
                    {
                        if (TwoFive[i, j] > 0 && TwoFive[k, l] > 0 && ((i + k) >= 18) && ((j + l) >= 18))
                        {
                            if((i == k) && (j == l))
                            {
                                ans += TwoFive[i, j] * (TwoFive[k, l] - 1);
                            }
                            else {
                                ans += TwoFive[i, j] * TwoFive[k, l];
                            }
                        }
                    }
                }
            }
        }
        Console.WriteLine(ans/2);
    }
}

Measured memory_bytes: 41352
package main

import (
	"fmt"
)

func main() {
	var s, t, u string
	var a, b int
	fmt.Scan(&s, &t)
	fmt.Scan(&a, &b)
	fmt.Scan(&u)

	if u == s {
		a--
	} else if u == t {
		b--
	}

	fmt.Println(a, b)
}


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

 
int main() {
   int n;
   cin>>n;
   //小さい順のqueue
   priority_queue<double,vector<double>,greater<double>> que;
   rep(i,n){
      double v;
      cin>>v;
      que.push(v);
   }
   rep(i,n-1){
      double x=que.top();
      que.pop();
      double y=que.top();
      que.pop();
      que.push((x+y)/2);
   }
   cout<<que.top()<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;


int main()
{
	string a;
	cin >> a;

	int counter = 0;
	if (a[0] == '1') counter++;
	if (a[1] == '1') counter++;
	if (a[2] == '1') counter++;

	cout << counter << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
def num2alpha(x):
    if x <= 26:
        return chr(x + 64).lower()
    elif x % 26 == 0:
        return num2alpha(x // 26 -1) + chr(90).lower()
    else:
        return num2alpha(x // 26) + chr(x % 26 + 64).lower()  

def main():
    n = int(input())
    print(num2alpha(n))
    
main()

Measured memory_bytes: 9096
#define DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define F first
#define S second 
#define pb push_back
#define endl "\n"

#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { // from [0, x-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 

#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

int getInt () {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}


ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;

int col[3];

i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;
    int n;
    cin>>n;
    
    col[0] = col[1] = col[2] = 0;

    int ans = 1;
    
    int x;
    int idx, coun;
    for(int i=0;i<n;i++)
    {   
        cin>>x;
        idx = 0;
        coun = 0;

        if(col[0]==x)
        {
            coun++;
            idx=0;
        }
        if(col[1]==x)
        {
            coun++;
            idx=1;
        }
        if(col[2]==x)
        {
            coun++;
            idx=2;
        }

        col[idx]++;
        ans *= coun;
        ans%=mod;
    }

    cout<<ans<<endl;
    
}





Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char s[5][20] = {};
  scanf("%s%s%s", s[0], s[1], s[2]);
  printf("%c%c%c\n", s[0][0] - 32, s[1][0] - 32, s[2][0] - 32);
  return 0;
}

/*
  'a' - 'A' = 97 - 65 = 32
*/


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    ll n,ans;
    cin >> n;
    vector<ll> a(n),l(n),r(n);
    rep0(i, n)cin >> a[i];
    l[0] = a[0];
    r[n - 1] = a[n - 1];
    rep1(i, n - 1){
        l[i] = gcd(l[i - 1], a[i]);
    }
    rrep0(i, n - 1){
        r[i] = gcd(r[i + 1], a[i]);
    }
    ans = max(l[n - 2], r[1]);
    rep1(i, n - 2)ans = max(ans, gcd(l[i - 1], r[i + 1]));
    pf(ans)
    return 0;
}


Measured memory_bytes: 2560
let n, b = read_int (), ref true
let cs = Array.make n 0
let rec f n a = if n <= 0 then a else f (n - 1) (2 * a mod 1000000007)
let _ = for i = 1 to n do Scanf.scanf " %d" @@ fun a -> if a mod 2 = n mod 2 then b := false; cs.(a / 2) <- cs.(a / 2) + 1 done; for i = 0 to n / 2 + n mod 2 - 1 do if not !b || i = 0 && cs.(i) <> 2 - n mod 2 || i > 0 && cs.(i) <> 2 then (print_endline "0"; exit 0) done; Printf.printf "%d\n" @@ f (n / 2) 1

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

int main()
{
    int N,M;
    int ans = 0;
    cin>>N>>M;
    if(M>=2)
    {
        ans += (M * (M - 1)) / 2;
    }

    if(N>=2)
    {
        ans += (N * (N - 1)) / 2;
    }

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

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

int n,m;
int x[100],y[100],c[100];
bool use[100];
int par[100],rank[100];


int find(int a){
  if(par[a] == a)return a;
  else return par[a] = find(par[a]);
}

bool union2(void){
  int i;
  int a,b,cnt;

  for(i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
  
  cnt = n;
  for(i=0;i<m;i++){
    if(!use[i]){
      a = find(x[i]);
      b = find(y[i]);
      if(a != b){
	cnt--;
	if(rank[a] < rank[b]){
	  par[a] = b;
	}else{
	  par[b] = a;
	  if(rank[a] == rank[b])rank[a]++;
	}
      }
    }
  }
  
  if(cnt >= 2)return true;
  return false;
}

int main(){
  int cost,ans;
  int i,j;

  while(1){
    cin >> n >> m;
    if(!n && !m)break;

    cost = 0;
    for(i=0;i<m;i++){
      cin >> x[i] >> y[i] >> c[i];
      use[i] = false;
      if(c[i] <= 0){
	use[i] = true;
	cost += c[i];
      }
    }

    if(union2())ans = 0;
    else ans = 2147483647;

    for(i=0;i<m;i++){
      if(!use[i]){
	use[i] = true;
	if(union2())ans = min(ans,c[i]);
	
	for(j=i+1;j<m;j++){
	  if(!use[j]){
	    use[j] = true;
	    if(union2())ans = min(ans,c[i]+c[j]);
	    use[j] = false;
	  }
	}
	use[i] = false;
      }
    }

    cout << ans + cost << endl;
  }
}

Measured memory_bytes: 880
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
ll N;
ll ans;

void solve(string s) {
  if (stol(s) > N) return;
  if (count(all(s), '7') && count(all(s), '5') && count(all(s), '3')) ans += 1;
  solve(s + "7");
  solve(s + "5");
  solve(s + "3");
}

int main() {
  cin >> N;
  solve("3");
  solve("5");
  solve("7");
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;

int main() {
    int n, m;
    cin>>n>>m;
    cout<<((n*(n-1))/2+(m*(m-1))/2);
}


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

using namespace std;

int main(int argc, char * argv[]) {
    int N, L;
    cin >> N >> L;

    int first = L;
    int last = L + N - 1;
    if (first > 0) {
        first += 1;
    } else if (last < 0) {
        last -= 1;
    }

    int sum = (first + last) * (last - first + 1) / 2;
    cout << sum << endl;

    return 0;
}


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

int main() {
    int p[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int k;
    cin >> k;
    
    cout << p[k-1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
using namespace std;
using pii = pair<int,int>;

int bubbleSort(int a[], int N)
{
    bool swaped=true;
    int cnt = 0;
    for (int i=0; swaped; ++i) {
        swaped = false;
        for (int j=N-1; j > i; --j) {
            if (a[j-1] > a[j]) {
                swap(a[j-1], a[j]);
                swaped = true;
                ++cnt;
            }
        }
    }
    return cnt;
}

signed main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   int N, a[102];
   cin >> N;

   rep(i, N) cin >> a[i];

   int swapCnt = bubbleSort(a, N);

   rep(i, N) {
       cout << a[i] << (i+1 < N ? ' ' : '\n');
   }
   outl(swapCnt);
}




Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int B, B100, B10, B1;
  cin >> B;
  B100 = B / 100;
  B10 = (B - B100 * 100) / 10;
  B1 = (B - B100 * 100 - B10 * 10) / 1;
  cout << B100 + B10 + B1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int n;
int r[110];
int c[110];
int dp[110][110];


signed main(){
    cin >> n;
    rep(i, 0, n) cin >> r[i] >> c[i];

    rep(i, 0, n) rep(j, 0, n) if(i != j) dp[i][j] = INF;
    rep(l, 1, n) rep(i, 0, n-l) rep(j, i, i+l) chmin(dp[i][i+l], dp[i][j]+dp[j+1][i+l]+r[i]*c[j]*c[i+l]);

    cout << dp[0][n-1] << endl;

    return 0;
}


Measured memory_bytes: 3184
# include <iostream>
# include <vector>


using namespace std;


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

    vector<vector<int>> cs(10, vector<int>(10, 0));

    string si;
    int start_num, last_num;

    for (int i=1; i<n+1; i++) {
        si = to_string(i);
        cs[si[0]-'0'][si[si.size()-1]-'0']++;
    }

    int ans = 0;
    for (int i=1; i<10; i++) {
        for (int j=1; j<10; j++) {
            ans += cs[i][j] * cs[j][i];
        }
    }

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



Measured memory_bytes: 256
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    while(n) {
        if(n % 10 == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl;
    return 0;

}



Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
	int mou[11];
	int i;
	int best[3];
	int x = 0;
	
	mou[0] = 0;
	for (i = 0; i < 3; i++){
		best[i] = 0;
	}
	
	for (i = 1; i <= 10; i++){
		scanf("%d", &mou[i]);
		if (best[0] < mou[i]){
			best[2] = best[1];
			best[1] = best[0];
			best[0] = mou[i];
		}
		else if (best[1] < mou[i]){
			best[2] = best[1];
			best[1] = mou[i];
		
		}
		else if (best[2] < mou[i]){
			best[2] = mou[i];
		}
	
	}
	printf("%d\n%d\n%d\n", best[0], best[1], best[2]);
	
	return (0);
}

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

string str;

int main(){
  cin >> str;
  int n=0,e=0,w=0,s=0;

  for(int i=0;i<str.length();i++){
    switch(str[i]){
    case 'N':
      n++;
      break;
    case 'E':
      e++;
      break;
    case 'W':
      w++;
      break;
    case 'S':
      s++;
      break;
    }
  }

  if(n==0 && s==0 || n>0 && s>0)
    if(e==0 && w==0 || e>0 && w>0)
      cout << "Yes" << endl;
    else cout << "No" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#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++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int a,b,c;
	cin >> a >> b >> c;
	int i  = a;
	rep(j,b){
		if(i%b==c){
			cout << "YES" << endl;
			return 0;
		}
		i += a;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<list>
#include<set>
#include<algorithm>
#include<map>
#include<string>
#include<unordered_map>
#include<math.h>
#include<random>
#include<unordered_set>
#include<set>
#include<stdlib.h>
#include<memory>

using namespace std;

int main(void) {
	vector<int> in;
	list<int> list;

	in.resize(3);

	cin >> in[0] >> in[1];

	int result = in[1] * pow(in[1] - 1, in[0] - 1);

	cout << result << endl;
	
	return 0;
}

Measured memory_bytes: 512
from collections import deque

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

if len(c[0]) == 0:
    print('No')
    exit()

l = [0]*n
l[0] = 1
q = deque()
for i in c[0]:
    q.append(i)
    l[i] = 1
while q:
    p = q.pop()
    for i in c[p]:
        if l[i] == 0:
            l[i] = p+1
            q.appendleft(i)

print('Yes')
for i in range(1, n):
    print(l[i])

Measured memory_bytes: 36888
# -*- coding: utf-8 -*-
# @Date    : 2019-06-15 20:23:26
# @Author  : raj lath (oorja.halt@gmail.com)
# @Link    : link
# @Version : 1.0.0

import sys
sys.setrecursionlimit(10**5+1)

inf     =  int(10 ** 20)
max_val =  inf
min_val = -inf

RW  = lambda : sys.stdin.readline().strip()
RI  = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]


nb_elem = RI()
elements = sorted(RMI())
mins = elements[0]
maxs = elements[-1]
ans = []
for e in elements[1:-1]:
    if e > 0:
        ans.append([mins, e])
        mins -= e
    else:
        ans.append([maxs, e])
        maxs -= e
ans.append([maxs, mins])
print(maxs - mins)
for i in ans:
    print(*i)

Measured memory_bytes: 23328
function G(y,m,d){
   var date = new Date(m+"/"+d+"/"+y);
   return date.getTime();
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");

Arr.forEach(function(v){
var arr=v.split(" ").map(Number);
var y=arr[0];
var m=arr[1];
var d=arr[2];
var time=G(y,m,d);
var str="";
if(time<G(1868,9,8))str="pre-meiji";
if(time>=G(1868,9,8))str="meiji "+(y-1868+1)+" "+m+" "+d;
if(time>=G(1912,7,30))str="taisho "+(y-1912+1)+" "+m+" "+d;
if(time>=G(1926,12,25))str="showa "+(y-1926+1)+" "+m+" "+d;
if(time>=G(1989,1,8))str="heisei "+(y-1989+1)+" "+m+" "+d;
console.log(str);
});

Measured memory_bytes: 8936
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main()
{
    ios::sync_with_stdio(false);
    string s;
    cin >> s;

    int a = 0;
    int b = 0;
    REP(i, s.size())
    {
        if ((i % 2 == 0 and s[i] == '0') or (i % 2 == 1 and s[i] == '1'))
        {
            a++;
        }
        else
        {
            b++;
        }
    }

    cout << min(a, b) << endl;

    return 0;
}


Measured memory_bytes: 512
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    D, X = li_input()
    A = [int(input()) for _ in range(N)]

    e = sum([math.ceil(D / a) for a in A])

    print(e + X)


main()


Measured memory_bytes: 4680
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return v.copy()
    return [nlist(n[1:], v) for _ in range(n[0])]

class mod:
    def __init__(self, v=0):
        self.v = v
        self.v %= MOD
    def __add__(self, v):
        self.v += int(v)
        self.v %= MOD
        return self
    def __sub__(self, v):
        self.v -= int(v)
        return self
    def __mul__(self, v):
        self.v *= int(v)
        self.v %= MOD
        return self
    def __int__(self):
        return int(self.v)
    def __str__(self):
        return str(self.v)

# エントリーポイント
def main():
    S = input(str)
    dp = [[mod(0) for _ in range(13)] for _ in range(len(S) + 1)]
    dp[0][0].v = 1
    for i, s in enumerate(S):
        i += 1
        loop = range(10) if s == "?" else [int(s)]
        for n in range(13):
            for m in loop:
                dp[i][(n * 10 + m) % 13] += dp[i - 1][n]
    print(dp[-1][5])

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 162312
import collections
N = int(input())
S = []
for _ in range(N):
  s = list(input())
  s.sort()
  s = ''.join(s)
  S.append(s)
c = collections.Counter(S)
v = list(c.values())
count = 0
for j in v:
  count += j*(j-3)/2+j
print(int(count))

Measured memory_bytes: 19824
#include <stdio.h>
#include<string.h>
#include<stdlib.h>

int main()
{
  int x,y,z;
  scanf("%d%d%d",&x,&y,&z);
  
  int tmp1,tmp2;
  
  tmp1=x;
  x=y;
  y=tmp1;
  
  tmp2=x;
  x=z;
  z=tmp2;
  
  printf("%d %d %d\n",x,y,z);
 
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int a,b,c;
int d;

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

  if(a==b&&b==c&&a%2==0){
    cout<<-1<<endl;
    return 0;
  }
  while(a%2==0&&b%2==0&&c%2==0){
    int ca=(b+c)/2;
    int cb=(a+c)/2;
    int cc=(a+b)/2;
    a=ca;b=cb;c=cc;
    d++;
  }

  cout<<d<<endl;

  return 0;
}


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

int main(){
  string S;
  cin >> S;
  int N=S.size();
  int a,z;
  for(int i=0;i<N;i++){
    if(S.at(i)=='A'){
      a=i;
      break;
    }
  }
  for(int i=N-1;i>=0;i--){
    if(S.at(i)=='Z'){
      z=i;
      break;
    }
  }
  cout << z-a+1 << endl;
}

Measured memory_bytes: 640
k = gets.to_i
$queens = []
$field = Array.new(8).map{Array.new(8, false)}
ans = Array.new(8).map{Array.new(8, '.')}
row = [*0..7]
column = [*0..7]
$dx = [1,1,0,-1,-1,-1,0,1]
$dy = [0,1,1,1,0,-1,-1,-1]


k.times do
  $queens << gets.split().map(&:to_i)
end

$queens.each do |r, c|
  ans[r][c] = 'Q'
  column.delete(c)
  row.delete(r)
end

def initializeField()
  8.times do |i|
    8.times do |j|
      $field[i][j] = false
    end
  end
  $queens.each do |r, c|
    updateField(c, r)
  end
end

def updateField(x, y)
  return false if $field[x][y]
  $field[x][y] = true
  7.times do |i|
    8.times do |j|
      nx = $dx[j] * (i+1) + x
      ny = $dy[j] * (i+1) + y
      next if (nx < 0 || nx > 7 || ny < 0 || ny > 7)
      return false if $field[nx][ny]
    end
  end
  return true
end

column.permutation.to_a.each do |arrayX|
  initializeField()
  flag = true
  arrayX.each_with_index do |i, index|
    next if updateField(i, row[index])
    flag = false
    break
  end
  if flag
    arrayX.each_with_index do |i, index|
      ans[row[index]][i] = 'Q'
    end

    ans.each do |array|
      puts array.join('')
    end
    exit
  end
end













Measured memory_bytes: 8932
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n;
    long long int d;
    cin>>n>>d;
    d *= d;
    long long int p,q;
    int count=0;
    for(int i=0; i<n; i++){
        cin>>p>>q;
        p *= p;
        q *= q;
        if(p + q <= d){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3564
#include<cstdio>

int main() {
	int a,b,c;
	scanf("%d%d%d", &a,&b,&c);
	if (a==5&&(b==5&&c==7||b==7&&c==5)||a==7&&b==5&&c==5) {
		printf("YES");
	}
	else {
		printf("NO");
	}
	return 0;
}

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

int main(){

int n;
cin>>n;
string s ;
cin>>s ;
n%=26;
for(int i = 0 ; i < s.size();i++){
    if(s[i] + n<='Z'){
        s[i]+=n;
    }
    else{
        int k = 'Z'-s[i];
        s[i] = 'A' + n-(k+1);
    }
}
cout<<s<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int l[200010], r[200010];

int main(){
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    int now = 0;
    rep(i, k) {
        while (s[now] == 'x') now++;
        l[i] = now;
        now += c+1;
    }
    now = n-1;
    rrep(i, k) {
        while (s[now] == 'x') now--;
        r[i] = now;
        now -= c+1;
    }



    // rep(i, n) cout << l[i] << " ";
    // cout << endl;
    
    // rep(i, n) cout << r[i] << " ";
    // cout << endl;

    rep(i, k) if (l[i] == r[i]) cout << l[i] + 1 << endl;

    return 0;
}


Measured memory_bytes: 5220
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() 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)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



def main():
    flag = True
    L = LIR(3)
    diff_list = [[0] * 3 for _ in range(3)]
    for x in range(3):
        for y in range(3):
            diff_list[y][x] = L[y][x] - L[y - 1][x]


    for i, j, k in diff_list:
        if not i == j == k:
            flag = False


    diff_list = [[0] * 3 for _ in range(3)]
    for y in range(3):
        for x in range(3):
            diff_list[x][y] = L[y][x] - L[y][x - 1]


    for i, j, k in diff_list:
        if not i == j == k:
            flag = False


    if flag:
        return 'Yes'
    else:
        return 'No'


print(main())









Measured memory_bytes: 39080
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,d;
	cin>>a>>b;
	if(a<b){
		swap(a,b);
	}
	d=a*b;
	c=b;
	while(a%b!=0){
		c=a%b;
		a=b;
		b=c;
	}
	cout<<d/c;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ADodecagon
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var radius = int.Parse(Console.ReadLine());

            var answer = 3 * radius * radius;

            // 解答の出力
            Console.WriteLine(answer);
        }
    }
}


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

int main()
{

        int W;
        int a;
        int b;
        int out;
        scanf("%d %d %d",&W,&a,&b);
        if(a<=b)
        {
                out = -1*(a+W-b);
        }else{
                out = -1*(b+W-a);
        }
        if(out<=0)
        {
                printf("0\n");
        }else{
                printf("%d\n",out);
        }
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll mod = 1e9 + 7;
const int N = int(3e5) + 999;
#define int long long int
#define inf 1e18

int n;
int dp[21][1 << 21];
int arr[21][21];

int solve(int node, int mask)
{
    if (node == n and mask == (1 << n) - 1)
        return 1;
    if (node == n)
        return 0;
    if (dp[node][mask] != -1)
        return dp[node][mask];

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (arr[node][i] == 1 and (mask & (1 << i)) == 0)
        {
            ans = ans + solve(node + 1, (mask | (1 << i)));
            ans %= mod;
        }
    }
    return (dp[node][mask] = ans);
}

int32_t main()
{
    IOS;
    cin >> n;
    memset(dp, -1, sizeof dp);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> arr[i][j];

    int ans = solve(0, 0);
    cout << ans;
    return 0;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); \
				cin.tie(0); \
				cout.tie(0)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(_v)             _v.begin(), _v.end()
#define sz(_v)              (int) _v.size()
#define first(_obj)         (*_obj.begin())
#define last(_obj)          (*prev(_obj.end()))
#define FIND(_obj, _val)    (_obj.find(_val) != _obj.end())
#define RESET(_a, _v)       fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
#define REP(_i, _n)         for (int _i = 0; _i < (int) _n; _i++)
#define FOR(_i, _a, _b)     for (int _i = (int) _a; _i <= (int) _b; _i++)
#define FORD(_i, _a, _b)    for (int _i = (int) _a; _i >= (int) _b; _i--)
#define FORIT(_it, _obj)    for (auto _it = _obj.begin(); _it != _obj.end(); _it++)

// DEBUG UTIL
template<typename TF>
void debug(ostream &out, TF const &f) {
    out << f << std::endl;
}
 
template<typename TF, typename ... TR>
void debug(ostream &out, TF const &f, TR const& ... rest) {
    out << f << " ";
    debug( out, rest... );
}
 
#define DEBUG(...) debug(cerr, "[", #__VA_ARGS__, "]:", __VA_ARGS__)

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vi = vector<int>;
using vii = vector<pii>;
using vll = vector<ll>;
using vs = vector<string>;

const int DR[] = {-1, 0, 1, 0, -1, 1, 1, -1}; // ccw
const int DC[] = {0, -1, 0, 1, -1, -1, 1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = 1073741823;
const ll INFLL = 4e18;
const int MAX = 3e3;

int N;
double c[MAX+5], dp[MAX+5][MAX+5]; // pos, heads

void read() {
	cin >> N;
	FOR(i, 1, N) cin >> c[i];
}

void solve() {
	dp[0][0] = 1.0;

	FOR(i, 1, N) {
		dp[i][0] = (1 - c[i]) * dp[i - 1][0]; // tail

		FOR(j, 1, i) {
			dp[i][j] = (1 - c[i]) * dp[i - 1][j]; // tail
			dp[i][j] += c[i] * dp[i - 1][j - 1]; // head
		}
	}

	double ans = 0;
	FOR(j, ceil(N/2.0), N) ans += dp[N][j];
	cout << fixed << setprecision(12) << ans << "\n";
}

int main() {
	FAST_IO;
	int TC = 1;
	FOR(tc, 1, TC) {
		read();
		solve();
	}
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
    int k,n,sum=0,max=0;
    cin>>k>>n;
    int a[n+1],b[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
	}
	a[n]=k+a[0];
	for(int i=0;i<n;i++){
		b[i]=a[i+1]-a[i];
		sum+=b[i];
		if(b[i]>max){
			max=b[i];
		}
	}
	cout<<sum-max;
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
//system("pause");
return 0;

}


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

int main(void){
  string s;
  cin >> s;
  for(int i=0;i<s.length()-1;i++){
  	if(s.substr(i,2)=="AC") {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) (a>0?a:(-(a)))
using namespace std;
int a[1000],c[1000];
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	ll ans=0;
	for (int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		ans+=x;
	}
	for (int i=1;i<n;i++)
	scanf("%d",&c[i]);
	for (int i=2;i<=n;i++)
	if (a[i]==a[i-1]+1) ans+=c[a[i-1]];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
def main():
    N = input()
    ds = list(map(int, input().split()))
    ans = solve(ds)
    print(ans)


def solve(ds):
    ds = sorted(ds)
    imid = len(ds)//2
    abc_max = ds[imid-1]
    arc_min = ds[imid]

    return arc_min - abc_max


if __name__ == '__main__':
    main()

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	
	if(a <= c and c <= b) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
N=gets.to_i

paths=(N+1).times.map{[]}
(N-1).times do
    a,b,c = gets.split.map(&:to_i)
    paths[a] << [a,b,c]
    paths[b] << [b,a,c]
end

Q,K = gets.split.map(&:to_i)

arr = Array.new(N+1,-1)
arr[K] = 0
q = paths[K]

until q.empty?
    parent,child,d = q.shift
    next if arr[child] != -1

    arr[child] = arr[parent] + d

    q.concat paths[child]
end

Q.times do
    x,y = gets.split.map(&:to_i)
    puts arr[x]+arr[y]
end

Measured memory_bytes: 34344