akhauriyash/Code-Regression huggingface dataset:
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)7           __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

    int n;
    cin>>n;
    if(n==10000)
	{
		cout << "0";
	}
	else
	{
		 if(n%1000==0)
		 {
		 	cout << "0";
		 }
		 else if(n>=1 && n<1000)
		 {
		 	                    cout << 1000-n;
		 }
		 else if(n>1000 && n<2000)
		 {
		 	cout << 2000-n;
		 }
		 else if(n>2000 && n<3000)
		 {
		 	cout << 3000-n;
		 }
		 else if(n>3000 && n<4000)
		 {
		 	cout << 4000-n;
		 }
		 else if(n>4000 && n<5000)
		 {
		 	cout << 5000-n;
		 }
		 else if(n>5000 && n<6000)
		 {
		 	cout << 6000-n;
		 }
		 else if(n>6000 && n<7000)
		 {
		 	cout << 7000-n;
		 }
		 else if(n>7000 && n<8000)
		 {
		 	cout << 8000-n;
		 }
		 else if(n>8000 && n<9000)
		 {
		 	cout << 9000-n;
		 }
		 else if(n>9000 && n<10000)
		 {
		 	cout << 10000-n;
		 }
	}


}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
const lli N=1e6+5;
lli n,m,k;
set<lli> row[N],col[N];
vector<pair<lli,lli>> v;

bool inbounds(lli x, lli y)
{
    return (x>0 && x<=n && y>0 && y<=m);
}
void remove()
{
    for(auto j : v)
    {
        row[j.first].erase(j.second);
        col[j.second].erase(j.first);
    }
    v.clear();
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli x1,y1,x2,y2,val,x,y;
    cin>>n>>m>>k>>x1>>y1>>x2>>y2;
    lli i,j,num;
    char a[n+1][m+1];
    
    for(i=1;i<=n;i++) for(j=1;j<=m;j++) cin>>a[i][j];
    for(i=1;i<=n;i++) for(j=1;j<=m;j++) row[i].insert(j),col[j].insert(i);
    
    set<pair<lli, pair<lli,lli>>> s;
    s.insert({0, {x1,y1}});
    row[x1].erase(y1);
    col[y1].erase(x1);
    
    while(!s.empty())
    {
        pair<lli, pair<lli,lli>> p=*s.begin();
        s.erase(p);
        
        val=p.first;
        x=p.second.first;
        y=p.second.second;
        if(x==x2 && y==y2) return cout<<val, 0;
        
        auto it=row[x].lower_bound(y);
        while(it!=row[x].end())
        {
            num=*it;
            if(!inbounds(x, num) || num-y>k || a[x][num]=='@') break;
            
            s.insert({val+1, {x, num}});
            v.push_back({x, num});
            it++;
        }
        remove();
        
        it=row[x].lower_bound(y);
        while(it!=row[x].begin())
        {
            it--;
            num=*it;
            if(!inbounds(x, num) || y-num>k || a[x][num]=='@') break;
            
            s.insert({val+1, {x, num}});
            v.push_back({x, num});
        }
        remove();
        
        it=col[y].lower_bound(x);
        while(it!=col[y].end())
        {
            num=*it;
            if(!inbounds(num, y) || num-x>k || a[num][y]=='@') break;
            
            s.insert({val+1, {num, y}});
            v.push_back({num, y});
            it++;
        }
        remove();
        
        it=col[y].lower_bound(x);
        while(it!=col[y].begin())
        {
            it--;
            num=*it;
            if(!inbounds(num, y) || x-num>k || a[num][y]=='@') break;
            
            s.insert({val+1, {num, y}});
            v.push_back({num, y});
        }
        remove();
    }
    cout<<-1;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll A, B, C;
    cin >> A >> B >> C;

    ll res = 0;
    if(A%2 && B%2 && C%2){
    	res = A*B;
    	res = min(res, B*C);
    	res = min(res, C*A);
    }else{
    	res = 0;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

def A():
    n = stdin.readline().rstrip()
    flag = bool()

    for st in n:
        if st == '7':
            flag = True

    if flag:
        print("Yes")
    else:
        print("No")  


def B():
    n = stdin.readline().rstrip()
    sum = 0

    for i in range(1, int(n) + 1):
        if not(i % 3 == 0 or i % 5 == 0):
            sum = sum + i

    print(sum)


def main():
    B()

if __name__ == "__main__":
    main()

Measured memory_bytes: 9144
a = list(map(int,input().split()))
N = a[0]
K = a[1]

i = 2
x = (N-K+1)
y = 1
z = (x*y)%(10**9+7)
print(z)

while K >= i:
    if (N-K+1) >= i:
        x = (N-K+2-i)*x//i
        y = (K-i+1)*y//(i-1)
        z = (x*y)%(10**9+7)
        print(z)
    else:
        print(0)
    i = i + 1


Measured memory_bytes: 9048
n=int(input())
s=input()
num_s=[]
value=[]
left=0
for f_s in s:
    if(f_s=="E"):
        num_s.append(0)
    else:
        num_s.append(1)
right=sum(num_s[1:])
len_s=n-1
value.append(len_s-right)
for p in range(1,n):
    left+=num_s[p-1]
    right-=num_s[p]
    len_s-=1
    value.append(left+len_s-right)
print(min(value))

Measured memory_bytes: 21368
import sys

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

def solve():
    a = [int(i) for i in input().split()]
    a.sort()

    if a[0] + a[1] == a[2]:
        ans = 'Yes'
    else:
        ans = 'No'

    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
require 'set'

N, M, P = gets.split.map(&:to_i)
abc_list = M.times.map do
  a, b, c = gets.split.map(&:to_i)
  [a - 1, b - 1, -(c - P)]
end
graph = Array.new(N) { [] }
abc_list.each do |(a, b, c)|
  graph[a].push([b, c])
end
reverse_graph = Array.new(N) { [] }
abc_list.each do |(a, b, c)|
  reverse_graph[b].push([a, c])
end

INF = 1 << 60

def reachable(graph, s)
  visit = Set.new
  visit.add(s)
  queue = [s]
  while !queue.empty?
    u = queue.shift
    graph[u].each do |(v, _)|
      next if visit.include?(v)
      visit.add(v)
      queue.push(v)
    end
  end
  visit
end

def bellman_ford(edge_list, s, max_count)
  d = Array.new(N, INF)
  d[s] = 0
  c = 0
  loop do
    is_update = false
    edge_list.each do |(u, v, c)|
      if d[u] != INF && d[u] + c < d[v]
        d[v] = d[u] + c
        is_update = true
      end
    end
    return d if !is_update
    c += 1
    return nil if c == max_count
  end
end

reachable_from_0 = reachable(graph, 0)
reachable_to_n = reachable(reverse_graph, N - 1)
v_set = Set.new
N.times do |v|
  v_set.add(v) if reachable_from_0.include?(v) && reachable_to_n.include?(v)
end
edge_list = abc_list.select do |(a, b, _)|
  v_set.include?(a) && v_set.include?(b)
end
ans = bellman_ford(edge_list, 0, v_set.size)
puts(ans == nil ? '-1' : [-(ans[N - 1]), 0].max)


Measured memory_bytes: 5244
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)


int main(){
    int k,n;
    cin >> k >> n;
    if(k%2==0){
        rep(i,n){
            if(i==0){
                cout << k/2 << " ";
            }else{
                cout << k << " ";
            }
        }
        cout << endl;
    }else{
        vector<int>res(n);
        rep(i,n){
            res[i] = (k+1)/2;
        }
        int p = n/2;
        if(k==1){
            rep(zz,p){
                res[n-1-zz] = 0;
            }
        }else{
        rep(zz,p){
            // for(int i= 0;i<n;i++){
            //     cerr << res[i] << " ";
            // }
            // cerr << endl;
            for(int i = n-1;i>=0;i--){
                if(res[i]==0){
                    continue;
                }
                if(i==n-1){
                    res[i]--;
                    break;
                }else{
                    res[i]--;
                    if(res[i]==0){
                        for(int j=i+1;j<n;j++){
                            res[j] = 0;
                        }
                    }else{
                        for(int j=i+1;j<n;j++){
                            res[j] = k;
                        }
                    }
                    break;
                }
            }
        }
        }
        rep(i,n){
            if(res[i]==0)break;
            cout << res[i] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

const int MAX_N = 1e5 +10;
vector<int> es[MAX_N];
bool f = true;

bool check(int cur, int par) {
	int cnt = 0;
	if(par != -1 && es[cur].size() == 1) return false;
	for(auto& to : es[cur]) {
		if(to == par) continue;
		if(!check(to, cur)) cnt++;
	}
	if(cnt > 1) f = false;
	return cnt;
} 

int main(){
	int n;
	cin >> n;
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		es[a].pb(b);
		es[b].pb(a);
	}
	f &= check(0, -1);
	cout << (f?"Second":"First") << endl;
	return 0;
}

Measured memory_bytes: 5888
H, W = gets.split.map(&:to_i)
s = []
white = 0
H.times do |i|
    s[i] = gets.chomp.split('')
    white += s[i].count('.')
end
cost = Array.new(H){Array.new(W)}
cost[0][0] = 1
prev_points = [[0, 0]]
(2..(H*W)).each do |c|
    next_points = []
    prev_points.each do |pp|
        h, w = pp
        [[h - 1, w], [h + 1 , w], [h, w - 1], [h, w + 1]].each do |np|
            nh, nw = np
            next unless nh.between?(0, H - 1) && nw.between?(0, W - 1)
            if s[nh][nw] == '.' && !cost[nh][nw]
                cost[nh][nw] = c
                next_points.push([nh, nw])
            end
        end
    end
    break if next_points == []
    prev_points = next_points
end

if cost[H-1][W-1]
    print white - cost[H-1][W-1]
else
    print -1
end

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

#define db double
#define eps 1e-8
struct point{db x,y;};
point operator +(point a,point b){return (point){a.x+b.x,a.y+b.y};}
point operator -(point a,point b){return (point){a.x-b.x,a.y-b.y};}
db operator *(point a,point b){return a.x*b.y-b.x*a.y;}
point operator *(point a,db x){return (point){a.x*x,a.y*x};}
point operator /(point a,db x){return (point){a.x/x,a.y/x};}
bool a_onleft(point a,point b){return a*b<-eps;}

deque<point> q;
int n,L;
point o;
int main(){
	scanf("%d%d",&n,&L);
	o=(point){0,0};
	q.push_back((point){0,0});
	point add=(point){0,0};
	for(int i=1,t,v;i<=n;i++){
		scanf("%d%d",&t,&v);
		point p=(point){v,v*1LL*t};
		add=add+p;
		
		db end=L-add.x;
		while(q.size()>=2&&q[q.size()-2].x>end) q.pop_back();
		if(q[q.size()-1].x>end){
			int sz=q.size();
			point p=(q[sz-1]-q[sz-2])/(q[sz-1].x-q[sz-2].x)*(end-q[sz-2].x)+q[sz-2];
			q[sz-1]=p;
		}
		
		point ins=o;
		while(q.size()>=2&&a_onleft(q[1]+add-ins,q[0]+add-ins)) q.pop_front();
		q.push_front(ins-add);
		
		point ans=q[q.size()-1]+add;
		printf("%.10lf\n",ans.y/ans.x);
		
	}
	return 0;
}

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

namespace AGC033ATeacher2
{
    class Program
    {
            struct pos
        {
            public int x;
            public int y;
        }
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int H = int.Parse(str[0]);
            int W = int.Parse(str[1]);
            int[,] A = new int[H, W];
            int max_DP = H + W - 1;
            var list = new List<pos>();
            pos p = new pos();
            for (var i = 0; i < H; i++)
            {
                string str2 = Console.ReadLine();
                for (var j = 0; j < W; j++)
                {
                    if (str2.Substring(j, 1) == "#")
                    {
                        A[i, j] = 0;
                        p.x = i;
                        p.y = j;
                        list.Add(p);
                    }
                    else
                    {
                        A[i, j] = max_DP;
                    }
                }
            }
            int max = 0;
            while (list.Count > 0)
            {
                var list2 = new List<pos>(list);
                list.Clear();
                for (var i = 0; i < list2.Count; i++)
                {
                    int x = list2[i].x;
                    int y = list2[i].y;
                    if (x > 0)
                    {
                        if (A[x - 1, y] == max_DP)
                        {
                            A[x - 1, y] = A[x, y] + 1;
                            max = Math.Max(max, A[x-1, y]);
                            p.x = x - 1;
                            p.y = y;
                            list.Add(p);
                        }
                    }
                    if (x < H - 1&&A[x + 1, y] == max_DP)
                    {
                            A[x + 1, y] = A[x, y] + 1;
                            max = Math.Max(max, A[x+1, y]);
                            p.x = x + 1;
                            p.y = y;
                            list.Add(p);
                    }
                    if (y > 0&&A[x, y - 1] == max_DP)
                    {
                            A[x, y - 1] = A[x, y] + 1;
                            max = Math.Max(max, A[x, y-1]);
                            p.x = x;
                            p.y = y - 1;
                            list.Add(p);
                    }
                    if (y < W - 1&&A[x, y + 1] == max_DP)
                    {
                            A[x, y + 1] = A[x, y] + 1;
                            max = Math.Max(max, A[x, y+1]);
                            p.x = x;
                            p.y = y + 1;
                            list.Add(p);
                    }
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 33224
#include <iostream>

using namespace std;

int main() {
    int N;
    long long int x;
    cin >> N >> x;
    long long int pre=0;
    long long int ans=0;
    for(int n=0; n<N; n++) {
        long long int a;
        cin >> a;
        if(a+pre>x) {
            ans += a+pre-x;
            pre = a-(a+pre-x);
        } else {
            pre = a;
        }
    }
    cout << ans << endl;



    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<climits>
#include<algorithm>
#include<cmath>

using namespace std;

int main() {
    int n, k, h;
    cin >> n >> k;
    vector<int> dp(n, INT_MAX);
    vector<int> input(n);
    for (int i=0; i<n; ++i) {
        cin >> h;
        input[i] = h;
    }
    dp[0] = 0;
    for (int i=0; i<input.size()-1; ++i) {
        for (int j=1; j<=k; ++j) {
            if (i+j>=n) continue;
            dp[i+j] = min(dp[i+j], dp[i] + abs(input[i+j]-input[i]));
        }
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int A[100005];
ll dp[100005];

int main()
{
	//! 最長部分増加列
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}

	fill(dp, dp + N, INF);
	REP(i, N)
	{
		*lower_bound(dp, dp + N, A[i]) = A[i];
	}

	cout << lower_bound(dp, dp + N, INF) - dp << endl;
	return 0;
}


Measured memory_bytes: 4304
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string s; cin >> s;
    int n = sz(s),ans=0,a=0;
    for (int i=0;i<n-2;i++){
        string str = s.substr(i,3); 
        if (str=="ABC") {
            ans++; ans += a;
            s[i] = 'B'; s[i+1]='C';
            s[i+2] = 'A'; 
            i++;
        }
        else if (s[i]=='A') a++;
        else a=0;
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0; 
}
/*

ABC --> BCA... 
 
intput: ABCABC 
output: 3 
 
input: ABCACCBABCBCAABCB 
output: 6 
 
*/

Measured memory_bytes: 3752
N = int(input())
W = list(map(int,input().split()))
sumW = []
for i in range (N):
    sumW.append(sum(W[0:i+1]) - sum(W[i+1:N]))
    
W2 =[]
for k in range (N):
    W2.append(abs(sumW[k]))

print(min(W2))



Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
int main()
{
	int n, m, a, b[1000], k, ans=0;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d", &a, &b[i]);
	}
	for (int i = 0; i < m; i++)
	{
		for (int j = i + 1; j < m; j++)
		{
			if (b[i] > b[j])
			{
				k = b[i];
				b[i] = b[j];
				b[j] = k;
			}
		}
	}
	for (int i = 0; i < m - 1; i++)
	{
		if(b[i]>n)
		ans += b[i]-n;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll a[N],b[N];
int main(){
	ll n,k;
	cin>>n>>k;
	ll sum = 0;
	a[0] = n;
	for(int i = 1; i <= n; i++){
		a[i] = a[i-1] + n - i;
//		a[i] %= mod;
	}
	b[0] = 0;
	for(int i = 1; i <= n; i++){
		b[i] = b[i-1] + i;
//		b[i] %= mod;
	}
	for(int i = k-1; i <= n; i++){
		ll tmp = a[i] - b[i] + 1;
		tmp %= mod;
//		cout<<tmp<<endl;
		sum += tmp;
		sum %= mod;
		
	}
	cout<<sum<<endl;


	return 0;
}






Measured memory_bytes: 6720
#include<stdio.h>
int main()
{
	int m,f,b,r;
	scanf("%d%d%d",&m,&f,&b);
	r=b-m;
	if(r>0&&f>=r){
		printf("%d\n",r);
	}else if(r>0&&f<r){
		printf("NA\n");
	}else{
		printf("%d\n",0);
	}
	return 0;
}



Measured memory_bytes: 2140
// D problem

#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

using pii = pair<int, int>;
using ppii = pair<int, pii>;

pii x[100010], y[100010];

//頂点のキュー
vector<ppii> queue;

// 素集合データ構造
struct UnionFind
{
	// par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
	vector<int> par;
	// sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
	vector<int> sizes;

	UnionFind(int n) : par(n), sizes(n, 1) {
		// 最初は全てのデータiがグループiに存在するものとして初期化
		for (int i = 0; i < n; i++) par[i] = i;
	}

	// データxが属する木の根を得る
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		// sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};

int main() {

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x[i].first >> y[i].first;
		x[i].second = y[i].second = i;
	}

	sort(x,x+n);
	sort(y,y+n);

	for (int i = 0; i < n - 1; i++) {
		queue.push_back(ppii(abs(x[i].first - x[i+1].first),pii(x[i].second,x[i+1].second)));
	}

	for (int i = 0; i < n - 1; i++) {
		queue.push_back(ppii(abs(y[i].first - y[i + 1].first), pii(y[i].second, y[i + 1].second)));
	}

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

	long long int res = 0;

	UnionFind uf(n);

	for (int i = 0; i < queue.size(); i++) {

		ppii t = queue[i];

		if (!uf.same(t.second.first,t.second.second)) {
			uf.unite(t.second.first, t.second.second);
			res += t.first;
		}

	}

	cout << res << endl;

}

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

using namespace std;

using ll = long long;
using ld = long double;

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

    int n;
    cin >> n;

    vector<ll> s(n);
    for (auto &s_i : s) cin >> s_i;

    ll max_score = 0;
    for (int c = 1; c <= n - 1; ++c) {
        ll sum = 0;

        set<int> visited;
        for (int k = 0; (k + 1) * c < n - 1; ++k) {
            if (k * c == n - 1 - k * c) break;
            if (visited.count(k * c) or visited.count(n - 1 - k * c))
                break;
            visited.insert(k * c);
            visited.insert(n - 1 - k * c);

            sum += (s[k * c] + s[n - 1 - k * c]);
            max_score = max(max_score, sum);
        }
    }

    cout << max_score << endl;

    return 0;
}


Measured memory_bytes: 5760
import math
from functools import reduce
import collections
import itertools
s1 = list(map(int,input().split()))
n = s1[0]
s = list(map(int,input().split()))
t = s[0]
a = s[1]
li = list(map(int,input().split()))
li1 = []
diff = 1000000000000000
ans = 0
co = 0
li2 = []
for i in li:
    co += 1

    if co == 1:
        diff = abs((t-i*0.006)-a)
        ans = 1
    #li1.append((t-i*0.006))
    #li2.append(abs((t-i*0.006)-a))
    if abs((t-i*0.006)-a) < diff:
        diff = abs((t-i*0.006)-a)
        ans = co
        


print(ans)


Measured memory_bytes: 3700
w,h,n=map(int,input().split())
y=[0,w]
t=[0,h]
def ct(w0,h0,a0):
  if a0==1:
    v=max(w0,y[0])
    y[0]=v
  if a0==2:
    v=min(w0,y[1])
    y[1]=v
  if a0==3:
    v=max(h0,t[0])
    t[0]=v
  if a0==4:
    v=min(h0,t[1])
    t[1]=v
for i in range(n):
  w1,h1,a1=map(int,input().split())
  ct(w1,h1,a1)

print(max(0,y[1]-y[0])*max(0,t[1]-t[0]))
  

Measured memory_bytes: 3064
#include<iostream>
// #include<numeric>
using namespace std;

long long gcd(long long a, long long b) {//a<b
    long long r = b%a;
    while(r) {
        b=a;
        a=r;
        r=b%a;
    }
    return a;
}

long long lcm(long long a, long long b) {//a<b
    if(a==b) return a;
    if(a==1 || a==2 || a==3) return a*b;
    return ((unsigned long long)a*(unsigned long long)b)/(unsigned long long)gcd(a,b);
}

int main() {
  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  if(C>D) {
    swap(C,D);
  }//C<D

  if(B<C) {
    cout << B-A+1 << endl;
    return 0;
  }
  
  long long LCMofCandD = lcm(C,D);
  long long divisiblesA = (A-1)/C + (A-1)/D - (A-1)/LCMofCandD;
  long long divisiblesB = B/C + B/D - B/LCMofCandD;

  cout << (B - divisiblesB) - (A - divisiblesA) + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 2e5+5;


void solve()
{
   ll n;
   cin>>n;
   vll a(n);
   map<ll,ll>m;
   for(int i=0;i<n;i++)
   {
        //ll a;
        cin>>a[i];
        m[a[i]]++;
   }
   
   vll v(N,0),z(N,0);
   ll sum = 0;
   for(auto itr = m.begin();itr!=m.end();itr++)
   {
        ll k = (*itr).ff;
        ll p = m[k];
        if(p>=2)
        {
             v[k] = (p*(p-1))/2;
             sum+=v[k];
        }
        p--;
        if(p>=2)
        {
                z[k] = (p*(p-1))/2;
        }
   }
   
   for(int i=0;i<n;i++)
   {
           cout<<(sum-v[a[i]]+z[a[i]])<<endl;
   }
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

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

#define pr pair<int, int>

using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;

#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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

// int a[10010][10010], b[1000];
// int dp[10010][3];

int main() {
    ll a,b,c,d; cin >> a >> b >> c >> d;
    bool win;
    rep(i,100){
        c -= b;
        if (c <= 0){
            win = true;
            break;
        }
        a -= d;
        if (a <= 0){
            win = false;
            break;
        }
    }
    cout << ((win)?"Yes":"No") << endl; 

return 0;
}


Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class ATransfer {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int a,b,c;
        in>>a>>b>>c;
        out<<max(0,c-a+b)<<endl;
    }
};

int main() {
    ATransfer solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,x,s;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>a>>b;
	for(int i=1;i<=b;i++){
		cin>>x;
		s+=x;
	}
	if(s>=a){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    string s;
    cin >> s;
    bool frag = true;
    if(s[0] != 'A')frag = false;
    int countC = 0;
    for(int i = 2; i < s.length() - 1; i++){
        if(s[i] == 'C'){
            countC++;
            s[i] = 'c';
        }
    }
    if(countC != 1)frag = false;
    for(int i = 1; i < s.length(); i++){
        if((int)s[i] < (int)'a' | (int)'z' < (int)s[i])frag = false;
    }
    if(frag)cout << "AC" << endl;
    else cout << "WA" << endl;
}

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

int main(){
  int N, n, sum = 0;
  cin >> N;
  
  n = N;
  for(int i = 0; i < 8; i++){
    sum += (n % 10);
    n /= 10;
  }
  
  if((N % sum) == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}
  

Measured memory_bytes: 256
import java.util.*;

class Main{           
 
   public static void main(String[] args){
      
      Scanner sc = new Scanner(System.in);
            
      int R = sc.nextInt();
      int G = sc.nextInt();
      
      System.out.println(2*G-R);
      
      
      
      
                                                
   }   
 }
  

        

Measured memory_bytes: 22996
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a, b = map(int, readline().split())
a_st = str(a) * b 
b_st = str(b) * a
if a_st <= b_st:
    print(a_st)
else:
    print(b_st)


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int A[3][3];
  bool a[3][3];
  int N, b;
  rep(i, 3) {
    rep(j, 3) {
      cin >> A[i][j];
      a[i][j] = false;
    }
  }
  cin >> N;
  rep(i, N) {
    cin >> b;
    rep(j, N) {
      rep(l, N) {
        if (A[j][l] == b) {
          a[j][l] =true;
          break;
        }
      }
    }
  }
  if ((a[0][0] && a[0][1] && a[0][2]) ||
      (a[1][0] && a[1][1] && a[1][2]) ||
      (a[2][0] && a[2][1] && a[2][2]) ||
      (a[0][0] && a[1][0] && a[2][0]) ||
      (a[0][1] && a[1][1] && a[1][1]) ||
      (a[0][2] && a[1][2] && a[2][2]) ||
      (a[0][0] && a[1][1] && a[2][2]) ||
      (a[2][0] && a[1][1] && a[0][0]))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
}


Measured memory_bytes: 256
from bisect import bisect_left,bisect
 
n = int(input())
p = [-1*int(input())]
for i in range(n-1):
    now = -1*int(input())
    if now >= p[-1]:
        p.append(now)
    else:
        p[bisect(p,now)] = now
print(len(p))

Measured memory_bytes: 80396
#include<stdio.h>

int main(){

    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);

    int L,R;
    L=a+b;
    R=c+d;
    
    if(L>R){
        printf("Left\n");
    }else if(L==R){
        printf("Balanced\n");
    }else{
        printf("Right\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N, M;
vector<pair<ll, ll>> B;

class UnionFind
{
public:
	UnionFind(ll size) : parent(size), rank(size) {
		for (ll i = 0; i < size; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	};

	ll root(ll x) {
		if (parent[x] == x) {
			return x;
		}
		else {
			return parent[x] = root(parent[x]);
		}
	}

	bool same(ll x, ll y) {
		return root(x) == root(y);
	}

	void unite(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return;

		if (rank[x] < rank[y]) {
			parent[x] = y;
		}
		else {
			parent[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}

private:
	//parent[i]==j  : iの親がj
	vector<ll> parent;
	vector<ll> rank;

};

//解法
void solve() {

	UnionFind uf(N);

	vector<ll> con(N, 1);
	vector<ll> ans(M);

	ll tmp_ans = 0;
	for (ll i = 1; i < N; i++) { tmp_ans += i; }

	rep(i, M) {

		ans[i] = tmp_ans;
		if (i == M - 1) break;

		if (uf.same(B[M - 1 - i].first - 1, B[M - i - 1].second - 1)) {
			continue;
		}

		ll a = con[uf.root(B[M - 1 - i].first - 1)] + con[uf.root(B[M - 1 - i].second - 1)];
		ll m = con[uf.root(B[M - 1 - i].first - 1)] * con[uf.root(B[M - 1 - i].second - 1)];

		uf.unite(B[M - 1 - i].first - 1, B[M - i - 1].second - 1);

		tmp_ans -= m;
		con[uf.root(B[M - 1 - i].first - 1)] = a;

	}

	rep(i, M) {
		cout << ans[M - 1 - i] << endl;
	}

	return;
}

int main() {

	//入力
	cin >> N >> M;
	B.resize(M);
	rep(i, M) cin >> B[i].first >> B[i].second;

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 6016
include Math

a,b,c = gets.split.map(&:to_i)
θ = c * PI / 180
s = a * b / 2 * sin(θ)
x = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(θ))
h = b * sin(θ)

puts s
puts a + b + x
puts h


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

int gcd(int a, int b) {
    return (b ? gcd(b, a % b) : a);
}

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int a, b;  cin >> a >> b;
    cout << lcm(a, b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
typedef long long ll;

int n,m,h,a;
string s,t;

int main() {
  cin >> h >> n;
  ll sum=0;
  rep(i,n) cin >> a, sum+=a;
  cout << (h<=sum ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<string>
#include<cstdio>
#include<cctype>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<set>
#include<map>

using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	cout<<(a*b%2==0?"Even":"Odd");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int m; cin >> m;
	while(m--){
		int money, year, n; cin >> money >> year >> n;
		int res = 0;
		for(int i=0;i<n;i++){
			int type, t; double r; cin >> type >> r >> t;
			if(type == 0){
				int cur= 0;
				for(int j=0;j<year;j++)
					cur += (money-j*t)*r;
				res = max(res, (money-year*t)+cur);
			} else {
				int cur = money;
				for(int j=0;j<year;j++)
					cur = cur*(1+r)-t;
				res = max(res, cur);
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define sz 150010
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return a*(b/gcd(a,b));}
const int mod=1000000007;

int main(){
    BeatMeScanf;
    int a,b;
    cin>>a>>b;
    ll ans=lcm(a,b);
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb(c) push_back(c)

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

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

	ll x;
	cin >> x;
	int b = 0;
	ll k = 100;
	while(k < x) {
		k = floor(k*1.01);
		b++;
	}
	cout << b << "\n";
}


Measured memory_bytes: 3760
//Love and Freedom.
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 20021225
#define N 200010
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return f*s;
}
ll pre[N]; int a[N],b[N],v[N],n;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)	v[i]=a[i]=read(),v[n+i]=b[i]=read();
	sort(v+1,v+2*n+1);
	for(int i=1;i<=n;i++)	pre[i]=pre[i-1]+v[i];
	ll ans=(ll)1e18,ta=0,tb=0;
	for(int i=1;i<=n;i++)
	{
		ll tmp; ta+=a[i],tb+=b[i];
		if(max(a[i],b[i])<v[n])	tmp=pre[n];
		else if(min(a[i],b[i])<v[n])	tmp=pre[n-1]+max(a[i],b[i]);
		else	tmp=pre[n-2]+a[i]+b[i];
		ans=min(ans,tmp); 
	}
	ans=min(min(ta,tb),ans);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> cnt(30);
	rep(i, n)
	{
		int a; cin >> a;
		rep(j, 30)
		{
			cnt[j] += a % 2;
			a /= 2;
		}
	}
	if (n % 3 == 0)
	{
		rep(i, 30)
		{
			if (cnt[i] != 0 && cnt[i] != (n / 3) * 2)
			{
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	else
	{
		rep(i, 30)
		{
			if (cnt[i] != 0)
			{
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string O, E;
    cin >> O >> E;
    int N = O.size();
    if (N == E.size()) {
        for (int i = 0; i < N; i++) {
            cout << O[i] << E[i];
        }
        cout << endl;
    }
    else {
        for (int i = 0; i < N - 1; i++) {
            cout << O[i] << E[i];
        }
        cout << O[N - 1] << endl;
    }
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using ll = int_fast64_t;

int main(){
        int n, m;
        scanf("%d %d", &n, &m);
        std::vector<int> v(n);
        for(int i=0; i<n; i++) v[i] = i;

        int path[n][n];
        for(int i=0; i<n*n; i++) path[i/n][i%n] = 0;
        for(int i=0; i<m; i++){
                int a, b;
                scanf("%d %d", &a, &b);
                path[a-1][b-1] = path[b-1][a-1] = 1;
        }

        int ans = 0;
        do{
                if(v[0]!=0) continue;
                bool cant = false;
                for(int i=1; i<n; i++){
                        if(!path[v[i-1]][v[i]]) cant = true;
                }
                if(!cant) ans++;
        }while(std::next_permutation(v.begin(), v.end()));
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  cin >> N >> D;
  int x=N;
  int i=0;
  int ans;
  while(x>=2*D+1){
    x=x-2*D-1;
    i++;
  }
  if(x==0){
    ans=i;
  }
  else{
    ans=i+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int h,w,d,a,q,l,r;
    cin>>h>>w>>d;
    int px[h*w+1],py[h*w+1],cost[h*w+1];
    for(auto &x:cost)x=0;
    for(auto &x:px)x=0;
    for(auto &x:py)x=0;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){cin>>a;px[a]=i;py[a]=j;}
    for(int i=1;i<=d;i++){
        for(int j=i;j<h*w+1;j+=d){
            if(j<=d)continue;
            cost[j]=abs(px[j]-px[j-d])+abs(py[j]-py[j-d])+cost[j-d];
        }
    }
    cin>>q;
    for(int i=0;i<q;i++){cin>>l>>r;cout<<cost[r]-cost[l]<<endl;}
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll 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; } //power
ll qp(int a, ll b, ll Mod=M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod=M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nCr(ll n, ll r, ll Mod=M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod;} //combination

int main(void) {
  int X, Y; cin >> X >> Y;
  int a, b; double a_d, b_d;
  a_d = (double)(2 * Y - X) / 3.0;
  b_d = 2 * Y - a_d;
  if (floor(a_d) != a_d || a_d < 0 || b_d < 0) {
    cout << 0 << "\n";
    return 0;
  }
  a = (2 * Y - X) / 3;
  b = Y - 2 * a;
  int n = a + b;
  cout << nCr(n,a,M) << "\n";
  return 0;
}

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


double dis(ll xy1[], ll xy2[]){
    return sqrt(pow((xy2[0] - xy1[0]), 2) + pow((xy2[1] - xy1[1]), 2));
}

ll f(ll n){
    if(n == 1){
        return 1;
    }else{
        return n * f(n-1);
    }
}


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

    ll n;
    cin >> n;

    ll xy[n][2];
    for(ll i=0; i < n; i++){
        cin >> xy[i][0] >> xy[i][1];
    }
    double ans = 0.0;
    for(ll i=0; i < n; i++){
        for(ll j=0; j < n; j++){
            ans += dis(xy[i], xy[j]) / n;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}


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

int main()
{
	int S, hour, minute, second;
	std::cin >> S;
	hour = (S / 60) / 60;
	minute = (S / 60) % 60;
	second = S % 60;
	printf("%d:%d:%d\n", hour, minute, second);
}

Measured memory_bytes: 3184
#include <vector>
#include <iostream>
using namespace std;
vector<vector<int> > d;
void add(int v1, int v2, int cost) {
	for (int i = 0; i < d.size(); i++) {
		for (int j = 0; j < d[i].size(); j++) {
			int dist2 = d[i][v1] + cost + d[v2][j];
			if (d[i][j] > dist2) d[i][j] = dist2;
		}
	}
}
int N, Q, tp, a, b, c;
int main() {
	while (scanf("%d%d", &N, &Q), N) {
		d = vector<vector<int> >(N, vector<int>(N, 999999999));
		for (int i = 0; i < N; i++) d[i][i] = 0;
		while (Q--) {
			scanf("%d%d%d", &tp, &a, &b); a--, b--;
			if (tp == 1) {
				scanf("%d", &c);
				add(a, b, c);
				add(b, a, c);
			}
			else printf("%d\n", d[a][b] != 999999999 ? d[a][b] : -1);
		}
	}
	return 0;
}

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

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> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  priority_queue<ll, VL, greater<ll>> q;
  map<ll, ll> m;
  vector<pair<ll, ll>> v(n);
  rep(i, n) {
    cin >> v[i].second >> v[i].first;
  }
  sort(rall(v));
  ll type = 0;
  ll b = 0;
  ll ans = 0;
  rep(i, k) {
    b += v[i].first;
    if(m[v[i].second]) {
      q.push(v[i].first);
    }
    else{
      m[v[i].second]++;
      type++;
    }
  }
  ans = b + type * type;
  for(int i = k; i < n && !q.empty(); ++i) {
    if(m[v[i].second]) continue;
    else {
      ll d = q.top();
      q.pop();
      b = b - d + v[i].first;
      m[v[i].second]++;
      type++;
      ans = max(ans, b + type * type);
    }
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 6140
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

double to_deg(double r) {
	return r * 180.0 / (atan(1.0) * 4.0);
}


signed main(void) {
	double a, b,d;
	cin >> a >> b >> d;
	double ans = 0;
	if ((a*a*b)/2<d) {
		ans = atan(pow(a, 3) / (2*(a*a*b-d)));
	}
	else {
		ans = atan((2 * d)/(a*b*b));
	}
	std::cout << std::fixed;
	std::cout << std::setprecision(7) << (90-to_deg(ans));
}

Measured memory_bytes: 512