akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector< pair<int64_t,int64_t> > v(N);
    for(int i=0; i<N; i++) {
        int64_t a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        v[i] = make_pair(a, b);
    }

    sort(v.begin(), v.end());
    v.emplace_back(v.front().second, v.back().first);

    vector<int64_t> lmax(N+1), lmin(N+1), r(N+1);
    for(int i=0; i<=N; i++) {
        lmax[i] = v[i].second;
        lmin[i] = v[i].second;
        r[i] = v[i].second;
    }
    for(int i=1; i<=N; i++) {
        lmax[i] = max(lmax[i-1], lmax[i]);
        lmin[i] = min(lmin[i-1], lmin[i]);
    }
    for(int i=N-1; i>=0; i--) {
        r[i] = max(r[i], r[i+1]);
    }

    int64_t ans = numeric_limits<int64_t>::max();
    for(int i=0; i<N; i++) {
        int64_t R_min = v.front().first;
        int64_t R_max = r[i+1];
        int64_t B_min = min(v[i+1].first, lmin[i]);
        int64_t B_max = max(lmax[i], v[N-1].first);
        ans = min(ans, (R_max - R_min) * (B_max - B_min));
    }

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


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

using namespace std;

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

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if (a==b) {
			System.out.println("Draw");
			return;
		}
		if (a==1) {
			System.out.println("Alice");
			return;
		}
		if (b==1) {
			System.out.println("Bob");
			return;
		}
		if (a>=2 && b>= 2 && a>b) {
			System.out.println("Alice");
			return;
		}
		if (a>=2 && b>= 2 && a<b) {
			System.out.println("Bob");
			return;
		}
	}
}


Measured memory_bytes: 23124
Q,*lrs=$<.read.split.map(&:to_i)
require 'prime'

ps = Array.new(10**5+1, false)
ps[3] = true
5.step(10**5,4) do |i|
    ps[i] = i.prime? && ((i+1)/2).prime?
end

sum = 0
ss = ps.map { |p| p ? sum+=1 : sum }

lrs.each_slice(2) do |l,r|
    puts ss[r] - ss[l-1]
end


Measured memory_bytes: 26620
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

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; }

/*
int N;
ll h[100010];

// DP テーブル
ll dp[100010];
*/

int main()
{
	int ans = 0;
	int max_ = 0;
	int N; cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
		max_ = max(max_, H[i]);

		if (H[i] >= max_) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
s = list(map(int, input().split()))

ans, t = 0, 0
for i in range(n-1):
    if s[i] >= s[i+1]:
        t +=1
    else:
        ans = max(ans, t)
        t = 0
ans = max(ans, t)

print(ans)

Measured memory_bytes: 63984
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DBinomialCoefficients solver = new DBinomialCoefficients();
        solver.solve(1, in, out);
        out.close();
    }

    static class DBinomialCoefficients {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a);
            int col = a[n - 1];
            int min = col / 2;
            int max = min + (col % 2 == 0 ? 0 : 1);
            out.print(col);
            out.print(' ');
            int d = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                int cd = Math.min(Math.abs(max - a[i]), Math.abs(min - a[i]));
                if (cd < d) {
                    d = cd;
                } else {
                    out.println(a[i - 1]);
                    return;
                }
            }
            out.println(a[n - 1]);
        }

    }
}



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

int main(){
  int a, b; cin >> a >> b;
  int ta, tb;
  int i;
  for(i = 0; i < 10000; i++){
    ta = (int)(i * 0.08);
    tb = (int)(i * 0.1);
    if(a == ta && b == tb) break;
  }
  if(i == 10000) i = -1;
  cout << i << endl;
  return 0;
}


Measured memory_bytes: 384
# B - Multiplication 2
def main():
    _, *A = open(0).read().split()
    if "0" in A:
        print(0)
        return
    prod = 1
    LIM = 10 ** 18
    for i in A:
        prod *= int(i)
        if prod > LIM:
            print(-1)
            return
    print(prod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19280
from collections import defaultdict
dic = defaultdict(int)
N = int(input())

for i in range(N):
  temp = str(input())
  dic[temp] += 1

MAX = max(dic.values())
ans = []
for x in dic.keys():
  if dic[x] == MAX:
    ans.append(x)
ans.sort()
print(*ans,sep="\n")

Measured memory_bytes: 157568
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  int tmp = n;
  while (n != 0)
  {
    tmp = n % 10;
    n /= 10;
    if (tmp == 7)
    {
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>

using namespace std;


const int N = 1e5+10 ;

struct Node{
    int l , r ;
    bool operator<(const Node& x) const
    {
        return r < x.r ;
    }
}range[N];

int n ;

int main()
{
    cin >> n ;
    for(int i = 0 ; i < n ; i++) {
        int x , L;
        cin >> x >> L ;
        range[i].l = x - L ;
        range[i].r = x + L ;
    }
    sort(range , range+n);
    int cnt = 0 , ed = -2e9;
    for(int i = 0 ; i < n ; i++ )
    {
        if(range[i].l >= ed){
            cnt++ ;
            ed = range[i].r;
        }
    }

    cout << cnt << endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

/*
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define ll long long
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz size()
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ld long double
#define sqr(x) (x)*(x)

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef pair < int, int > pii;
typedef vector < int >  vi;
typedef vector < vector < int> > vvi;
typedef pair < int, pair < int, int> > piii;
typedef vector < pair < int, int > > vpii;
typedef vector < ll >  vll;

bool valid(int x, int y, int n, int m){
    return x > 0 && x <= n && y > 0 && y <= m;
}

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

ll nok(ll a, ll b){
    return (a / gcd(a, b) * b);
}

ld dist(ll x, ll y, ll x2, ll y2){
    return sqrt(sqr(x - x2) + sqr(y - y2));
}


void solve() {
    char c;
    cin >> c;
    if(c >= 'A' && c <= 'Z'){
        cout << "A";
    }
    else{
        cout << "a";
    }
}

signed main() {
    fast_io;
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}





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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int cnt[13];
int c[24];

int dfs(int d) {
    int res = 0;
    if(d == 12){
        if(cnt[12] == 1) c[12] = 1;
        int a = 1;
        res = 100;
        inc(i, 1, 25){
            if(c[i%24] == 1){
                res = min(res, a);
                a = 1;
            }else{
                a++;
            }
        }
        return res;
    }
    if(cnt[d] == 0) return dfs(d+1);
    if(cnt[d] == 1){
        c[d] = 1;
        res = max(res, dfs(d+1));
        c[d] = 0;
        c[24-d] = 1;
        res = max(res, dfs(d+1));
        c[24-d] = 0;
    }
    if(cnt[d] == 2){
        c[d] = 1;
        c[24-d] = 1;
        return dfs(d+1);
        c[d] = 0;
        c[24-d] = 0;
    }
    if(cnt[d] > 2) return 0;
    return res;
}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> d(n);
    inc(i, 0, n){
        cin >> d[i];
        cnt[d[i]]++;
    }
    cnt[0]++;
    if(cnt[0] > 1 || cnt[12] > 1){
        cout << 0 << endl;
        return 0;
    }
    c[0] = 1;
    cout << dfs(1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
const ll maxn=1e5+10;
ll dis[maxn],head[maxn],sizes,k;
bool flag[maxn];
struct lzq
{
    ll to,val,next;
} a[maxn*2];
void init()
{
    memset(head,-1,sizeof(head));
    sizes=0;
}
void add_edge(ll from,ll to,ll val)
{
    a[++sizes].to=to,a[sizes].val=val;
    a[sizes].next=head[from];
    head[from]=sizes;
}
void dfs(ll from)
{
    flag[from]=1;
    ll i,j;
    for(i=head[from]; i+1; i=a[i].next)
    {
        ll to=a[i].to,val=a[i].val;
        if(flag[to]) continue;
        flag[to]=1;
        dis[to]=dis[from]+val;
        dfs(to);
    }
}
int main()
{
    init();
    ll n,from,to,val,i,m;
    scanf("%lld",&n);
    for(i=1; i<n; i++)
        scanf("%lld%lld%lld",&from,&to,&val),add_edge(from,to,val),add_edge(to,from,val);
    scanf("%lld%lld",&m,&k);
    dfs(k);
    for(i=1; i<=m; i++)
        scanf("%lld%lld",&from,&to),printf("%lld\n",dis[from]+dis[to]);
    return 0;
}


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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  int result = -1;
  if ((1 <= A) && (A <= 9) &&
      (1 <= B) && (B <= 9)) {
    result = A * B;
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;

int main(void) {
	int N;
	int x[101], y[101], h[101];
	
	cin >> N;
	for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> h[i];

	for (int cy = 0; cy < 101; cy++) {
		for (int cx = 0; cx < 101; cx++){
			int H = -1;
			for (int i = 0; i < N; i++) {
				if (h[i] > 0) {
					int tmp = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
					if (H == -1) {
						H = tmp;
					}
					else {
						if (tmp != H) {
							H = -2;
							break;
						}
					}
				}
			}
			if (H == -2) continue;
			for (int i = 0; i < N; i++) {
				if (h[i] == 0) {
					int tmp = abs(cx - x[i]) + abs(cy - y[i]);
					if (H > tmp) {
						H = -2;
						break;
					}
				}
			}
			if (H == -2) continue;

			cout << cx << " " << cy << " " << H << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
	int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for( int i = 0; i< N ; i++){
	cin >> a.at(i);
	}
	int count = 0;
	for(int j = 0; j < N; j++){
	if((j%2==0)){
	if(!((a.at(j)%2)==0)){
	count++ ;
	}
	}
	
	
	}
      cout << count << endl;
    }

Measured memory_bytes: 3556
integer(16) N
integer(16),allocatable,dimension(:)::A,B,C,D
integer(16) ans,i,j,k
read*,N
allocate(A(N),B(N),C(N),D(N))
read*,A
read*,B
read*,C
call heapsort(n,a)
call heapsort(n,b)
call heapsort(n,c)

D=0
j=1
do i = 1, n
   do while (j <= n .and. a(j) < b(i))
      j = j + 1
   end do
   D(i) = j - 1
end do
ans=0
k=0
j=1
do i = 1, n
   do while (j <= n .and. b(j) < c(i))
      k = k + D(j)
      j = j + 1
   enddo
   ans = ans + K
enddo

print"(i0)",ans

contains

subroutine heapsort(n,array)
  implicit none
  integer(16),intent(in) :: n
  integer(16),intent(inout) :: array(1:n)
  integer(16)::i,k,j,l
  integer(16):: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort

end

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

int main() {
  int A, B, sum = 0;
  cin >> A >> B;
  if(A > B + 1) sum += 2*A - 1;
  else if(B > A + 1) sum += 2*B - 1;
  else sum += A + B;

  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int 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;}


signed main(){
  int n;

  int a[1000],sum=0;
  cin >> n;
  FOR(i,n){
    cin >> a[i];
    sum+=a[i];
  }
  sum/=n;
  int hoge=INF;
  iFOR(j,-100,101){
    int ans = 0;
    FOR(i,n){
      ans += (a[i]-j)*(a[i]-j);
    }
    chmin(hoge,ans);
  }
  cout << hoge fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

vector<int> c;
vector<vector<int> > g;  // to
vector<ll> ans;

int dfs(int par, int curr, map<int,int>& mp)
{
    int sum = 0;
    vector<map<int, int> > v;
    int i;
    for (i = 0; i < (int)g[curr].size(); i++) {
        int next = g[curr][i];
        if (par == next) continue;

        v.push_back(map<int, int>());
        map<int, int>& mp0 = v.back();
        int ret = dfs(curr, next, mp0);
        sum += ret;

        int num0 = 0;
        auto it0 = mp0.find(c[curr]);
        if (it0 != mp0.end()) {
            num0 = it0->second;
        }
        int tmp=ret - num0;
        ans[c[curr]]+=(ll)tmp*(tmp + 1) / 2;
    }

    if (!v.empty()) {
        int max = -1, maxi = 0;
        for (i = 0; i < (int)v.size(); i++) {
            int tmp = v[i].size();
            if (tmp > max) {
                max = tmp;
                maxi = i;
            }
        }
        mp.swap(v[maxi]);

        for (i = 0; i < (int)v.size(); i++) {
            if (i != maxi) {
                map<int, int>& mp0 = v[i];
                auto it = mp0.begin();
                for (; it != mp0.end(); ++it) {
                    mp[it->first] += it->second;
                }
            }
        }
    }

    mp[c[curr]] = sum + 1;
    return sum + 1;
}

void solve()
{
    int n;
    scanf("%d", &n);

    c.resize(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &c[i]); c[i]--;
    }
    g.resize(n);
    for (i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d%d", &a, &b); a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ans.resize(n);
    map<int, int> mp;
    int ret = dfs(-1, 0, mp);
    assert(ret == n);

    for (i = 0; i < n; i++) {
        int num0 = 0;
        auto it0 = mp.find(i);
        if (it0 != mp.end()) {
            num0 = it0->second;
        }
        int tmp=ret - num0;
        ans[i]+=(ll)tmp*(tmp + 1) / 2;
    }

    for (i = 0; i < n; i++) {
        printf("%lld\n", (ll)n*(n+1)/2-ans[i]);
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 72160
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
string s; 
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>s;
	for(int i=0;i<s.length()-1;i++){
		if(s[i]=='A' && s[i+1]=='C'){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	//system("pause");
	return 0;
}

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

using namespace std;

const int N = 1e5+15;

#define ll long long


ll sz[N];

vector<int> adj[N];

int a[N],b[N],w[N],cc[N];

ll dp[N];

bool iscentroid[N];

multiset<int> mini[N];

int gid[N];

void dfs(int root,int p,int pid,int n){
    sz[root]= 1;
    int u,i,id;
    iscentroid[root] = 1;


    cc[root] =1;
    for(i=0;i<adj[root].size();++i){
        id = adj[root][i];

        u= a[id]^b[id]^root;

        if(u==p)continue;
        dfs(u,root,id,n);
        
        sz[root]+=sz[u];
        dp[root] += sz[u]*w[id]*2;
        dp[root]+=dp[u];
        
        mini[root].insert(w[id]);
        
        if(sz[u]*2>n)
            iscentroid[root]= 0;
        if(sz[u]*2==n)
            cc[root] = 2,gid[root] = id;
    }
    if( (n-sz[root])*2>n)
        iscentroid[root]= 0;
    if( sz[root]*2==n)
        cc[root] = 2,gid[root] = pid;
    
}

ll value = 0;
void dfs2(int root,int p,int pid,ll tsz,ll n,ll val){
    if(pid!=-1){
        mini[root].insert(w[pid]);
    }
    
    if(iscentroid[root]){    
        ll minus = 0;
        
        minus= *mini[root].begin(); 
        
        if(cc[root]==2)
            minus = w[gid[root]];
        
        value = max(value, val + dp[root]-minus);
    }
    int u,i,id;

    ll add;
    
    for(i=0;i<adj[root].size();++i){
        id = adj[root][i];

        u = a[id]^b[id]^root;
        if(u==p)continue;
        
        add = dp[root] -dp[u] - sz[u]*w[id]*2 + val;
        tsz = n- sz[u];
        add += tsz*2*w[id];

        dfs2(u,root,id,n-sz[u],n,add);
    }
}

int main(){
    int n,i;
    cin>>n;
    for(i=0;i<n-1;++i){
        scanf("%d%d%d",&a[i],&b[i],&w[i]);
        adj[a[i]].push_back(i);
        adj[b[i]].push_back(i);
    }
    dfs(1,0,-1,n);
    dfs2(1,0,-1,0,n,0);
    cout<<value<<endl;
}



Measured memory_bytes: 32384
import java.util.*;
import java.io.*;

public class Main {

    int[] a;

    void solve() {
	String S = sc.next();

	boolean n = false;
	boolean w = false;
	boolean s = false;
	boolean e = false;

	for (int i = 0; i < S.length(); i++) {
	    if (S.charAt(i) == 'N') {
		n = true;
	    }
	    if (S.charAt(i) == 'W') {
		w = true;
	    }

	    if (S.charAt(i) == 'S') {
		s = true;
	    }

	    if (S.charAt(i) == 'E') {
		e = true;
	    }
	}

	if (n ^ s) {
	    System.out.println("No");
	} else if (e ^ w) {
	    System.out.println("No");
	} else {
	    System.out.println("Yes");
	}
    }

    void print(int[] a) {
	out.print(a[0]);
	for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
	out.println();
    }

    public static void main(String[] args) throws Exception {
	new Main().run();
    }

    MyScanner sc = null;
    PrintWriter out = null;
    public void run() throws Exception {
	sc = new MyScanner(System.in);
	out = new PrintWriter(System.out);
	for (;sc.hasNext();) {
	    solve();
	    out.flush();
	}
	out.close();
    }

    class MyScanner {
	String line;
	BufferedReader reader;
	StringTokenizer tokenizer;

	public MyScanner(InputStream stream) {
	    reader = new BufferedReader(new InputStreamReader(stream));
	    tokenizer = null;
	}
	public void eat() {
	    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
		try {
		    line = reader.readLine();
		    if (line == null) {
			tokenizer = null;
			return;
		    }
		    tokenizer = new StringTokenizer(line);
		} catch (IOException e) {
		    throw new RuntimeException(e);
		}
	    }
	}
	public String next() {
	    eat();
	    return tokenizer.nextToken();
	}
	public String nextLine() {
	    try {
		return reader.readLine();
	    } catch (IOException e) {
		throw new RuntimeException(e);
	    }
	}
	public boolean hasNext() {
	    eat();
	    return (tokenizer != null && tokenizer.hasMoreElements());
	}
	public int nextInt() {
	    return Integer.parseInt(next());
	}
	public long nextLong() {
	    return Long.parseLong(next());
	}
	public double nextDouble() {
	    return Double.parseDouble(next());
	}
	public int[] nextIntArray(int n) {
	    int[] a = new int[n];
	    for (int i = 0; i < n; i++) a[i] = nextInt();
	    return a;
	}
    }
}


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

int main()
{
    int S;
    int hour, minute, second;

    cin >> S;

    second = S % 60;
    S = (S - second) / 60;
    minute = S % 60;
    hour = (S - minute) / 60;

    cout << hour << ":" << minute << ":" << second << endl;

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF const ll INF = 1001001001;
#define PI const ld PI = 3.14159265358979323846;



int main() {
   int N;
   cin>>N;
   int b[N+1];
   rep3(i,N){
       cin>>b[i];
   }
   bool flag[N+1];
   int way[N+1];
   rep3(i,N){
       way[i]=-1;
   }
   rep3(i,N){
       flag[i]=false;
   }
   int flag_count;
   rep3(i,N){
       flag_count=0;
       rep3(j,N){
           if(flag[j]){
               flag_count++;
           }
           


       }
       repr3(j,N){
           if(flag[j]){
               flag_count--;
           }
           else if(flag_count+1==b[j]){
               way[i]=b[j];
               flag[j]=true;
               break;
           }
       }
       if(way[i]==-1){
           cout<<-1<<endl;
           return 0;
       }
   }
   rep3(i,N){
       cout<<way[i]<<endl;
   }

}

Measured memory_bytes: 256
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]

memo = [[] for i in range(h*w)]
for i in range(h):
    for j in range(w):
        memo[a[i][j]-1].append((i, j))

cost = [0 for i in range(h*w)]
for t in range(d, h*w):
    i, j = memo[t-d][0]
    x, y = memo[t][0]
    cost[t] = abs(x-i) + abs(y-j)
for s in range(d):
    for i in range(s, h*w-d, d):
        cost[i+d] += cost[i]

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(cost[r-1]-cost[l-1])

Measured memory_bytes: 28008
def main():
    n,m=map(int,input().split())
    sscc=[]
    for _ in range(m): 
        s,c=map(int,input().split())
        sscc.append((s,c))
    nn=[]
    for _ in range(n):
        nn.append(None)
    for s,c in sscc:
        if nn[s-1] is None:
            nn[s-1] = c
        elif nn[s-1] != c:
            print(-1)
            return
    if nn[0] is None:
        if n!=1:
            X=10**(n-1)
        else:
            X=0
    else:
        if n!=1 and nn[0]==0:
            print(-1)
            return
        X=nn[0]*(10**(n-1))
    for i in range(1,n):
        if nn[i] is not None:
            X+=nn[i]*(10**(n-1-i))
    print(X)

main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int A[] = new int[n];
        for(int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }

        int sum[] = new int[20*2000];
        for(int i = 0; i < 20*2000; i++) {
            sum[i] = 0;
        }
        sum[0] = 1;

        for(int i = 0; i < n; i++) {
            for(int j = 20*2000-1; j >= 0 ; j--) {
                if(sum[j] == 1) {
                    sum[j + A[i]] = 1;
                }
            }
        }

        int q = sc.nextInt();
        for(int i = 0; i < q; i++) {
            int m = sc.nextInt();
            if(sum[m] == 1) {
                System.out.println("yes");
            }
            else {
                System.out.println("no");
            }
        }
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n+10,0);
  for(int i = 0;i < n;i++){
    cin >> p[i];
  }
  
  int res = 0;
  for(int i = 1;i < n-1;i++) {
    if ((p[i-1] > p[i] && p[i] > p[i+1]) || (p[i-1] < p[i]  && p[i] < p[i+1])){
      res++;
    }
  }
  cout << res << endl;
}

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

using namespace std;

int main(){

    int n, m;
    cin >> n >> m;

    priority_queue<int> pq;

    for(int i=0; i<n; i++){
        int k;
        cin >> k;

        pq.push(k);
    }

    while(m-- && !pq.empty()){
        int cur = pq.top();
        pq.pop();

        cur /= 2;
        if(cur != 0) pq.push(cur);
    }

    long long int sum = 0;
    while(!pq.empty()){
        int cur = pq.top();
        pq.pop();

        sum += cur;
    }

    cout << sum << endl;
}

Measured memory_bytes: 892
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
const int INF=2e9;
const db eps=1e-8;
inline void read(int &x)
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
inline void read(ll &x)
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//==========================head template==========================
int a[3];
bool cmp(int a,int b) {
	return a>b;
}
int main()
{
	for(int i=0;i<3;i++) read(a[i]);
	sort(a,a+3,cmp);
	int ans=0;
//	for(int i=0;i<3;i++) printf("%d ",a[i]); puts("");
	int t1=(a[0]-a[1])/2; a[1]+=2*t1;
	int t2=(a[0]-a[2])/2; a[2]+=2*t2;
	ans=t1+t2;
	sort(a,a+3,cmp);
	if(a[1]!=a[2]) ans+=2;
	else if(a[0]!=a[1]) ans+=1;
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
    int r;
    cin >> r;
    double ans = 0;
    ans = 2.0 * r * 3.14159265358979323846;
    printf("%5.20f",ans);

    return 0;
}


Measured memory_bytes: 3748
using System;
namespace Sample{
class Sample
  {
    static void Main(string[] args)
    {
      int N=int.Parse(Console.ReadLine());
   double ans=0;
      if((N%2)==0){
      ans=0.5;
      }else{
        ans=(double)((N/2)+1)/N;
  
      }
      
    Console.WriteLine(ans);
  }
 
}
}


Measured memory_bytes: 13140
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
    map<string,int> m;                  //通常のmapはkeyに対して1つの値を持つ。multimapになると、keyにいくつもの値を持たせることが出来る。
    int n, q, x;
    string k, s;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> q >> k;

        if( q == 0 )
        {
            cin >> x;
            m[k] = x;
        }
        else if( q == 1 )
            cout << m[k] << endl;
        else if( q == 2 )
            m[k] = 0;
        else
        {   
            cin >> s;
            map<string,int>::iterator l = m.lower_bound(k), r = m.upper_bound(s);
            for( ; l != r; l++ )
                if( l -> second != 0 )                                                  //keyに対応する値が0の場合は、削除済みを表すため出力しない
                    cout << l -> first << " " << l -> second << endl;                   //mapのkeyと対応する値にアクセスする場合、アロー演算子を用いる
        }

    }
    return 0;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;

int n;
int cc;

void init ();
void input ();
void work ();



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d", &n );
	int x;
	lpi ( i, 1, n ){
		scanf ( "%d", &x );
		cc ^= x & 1;
	}
}

void work ()
{
	// main work
	
	cout << ( cc ? "NO" : "YES" ) << endl;
}

Measured memory_bytes: 256
def main():
    n, W = list(map(int, input().split()))
    V = 100000
    INF = float('inf')
    dp = [[INF] * (V + 1) for _ in range(n + 1)]
    dp[0][0] = 0
    for i in range(1, n + 1):
        w, v = list(map(int, input().split()))
        for j in range(V + 1):
            if v > j:
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j])
    ans = V
    while dp[n][ans] > W:
        ans -= 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 305144
import math
X = int(input())
max = 0
bRange = math.floor(math.sqrt(X))
pRange = math.floor(math.log(X,2))
for b in range(bRange + 1):
    for p in range(pRange + 1):
        # print(b**p)
        if(max < b**p <= X):
            max = b**p
print(max)


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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<pair<int, int>> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i].first >> vec[i].second;
  }
  sort(vec.begin(), vec.end());
  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += vec[i].second;
    if (cnt >= k) {
      cout << vec[i].first << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1024
#include <math.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N, count = 0;
    cin >> N;
    for (int i = 1; i < N; i++) {
        count +=floor( (N-1) / i);
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
n, m, c = map(int, input().split())
bn = list(map(int, input().split()))
cnt = 0
for _ in range(n):
  an = list(map(int, input().split()))
  val = sum([a * b for (a, b) in zip(an, bn)]) + c
  if val > 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		System.out.println(Math.max(A * B, C * D));
	}
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=305;
int f[N][N],sf[N][N],n,k,mod,c[N][N];
signed main(){
	n=read(),k=read(),mod=read();
	for(int i=0;i<=n;i++)c[i][0]=1;
	for(int i=1;i<=n;i++)for(int j=1;j<=i;j++)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	for(int i=0;i<=k;i++)f[1][i]=1,sf[1][i]=k-i+1;
	for(int i=2;i<=n+1;i++){
		for(int j=0;j<=k;j++)for(int s=1;s<i;s++)f[i][j]=(f[i][j]+1ll*f[i-s][j]*sf[s][j+1]%mod*c[i-2][s-1]%mod)%mod;
		for(int j=k;j>=1;j--)sf[i][j]=(sf[i][j+1]+f[i][j])%mod;
	}return cout<<f[n+1][0],signed();
}

Measured memory_bytes: 4660
#include <iostream>
using namespace std;
int main()
{
    int i, j, k, h, w;
   
    cin >> h >> w;
    while(h>0 || w>0)
    {
        for(i=1; i<=h; i++)
        {
            for(j=1; j<=w; j++)
            {
                if (i>1 && i<h && j>1 && j<w)
                    cout << ".";
                else
                    cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


Measured memory_bytes: 3120
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int n,k;
	cin>>n>>k;
	if(1+2*(k-1)<=n)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int i,j,k,n,m,x,y,t=0;
    string s;
    cin>>s>>k;
    for(i=0;i<s.length();i++)
    {
        if(s[i]!='1')
        {
            cout<<s[i]<<endl;
            return 0;
        }
        else if(i+1==k)
        {
            break;
        }
    }
    cout<<1<<endl;

    return 0;
}


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

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if(k%2==0)
        cout << a - b;
    else
        cout << b - a;
    cout << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int64_t> L(87);
  for(int i=0; i<87; i++){
    if (i==0){
      L.at(i)=2;
    } else if (i==1){
      L.at(i)=1;
    } else {
      L.at(i)=L.at(i-1)+L.at(i-2);
    }
  }
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256
from collections import Counter
s = input()
n = len(s)
count = [0 for i in range(3)]
for i in range(n):
    count[ord(s[i]) - ord('a')] += 1
count.sort()
if count[2] - count[0] > 1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3444
# -*- coding: utf-8 -*-
N, M = map(int, input().split())

ab = []
for _ in range(M):
    ab.append(list(map(int, input().split())))

map_org = [[0 for _ in range(N)] for _ in range(N)]

for a, b in ab:
    map_org[a-1][b-1] = 1
    map_org[b-1][a-1] = 1

def dfs(v):
    visited[v] = 1
    if sum(visited) == N:
        return 1

    ret = 0    
    for i in range(N):
        if map_org[v][i] == 1:
            if visited[i] == 0:
                ret += dfs(i)
                visited[i] = 0
    return ret


visited = [0 for _ in range(N)]
print(dfs(0))

Measured memory_bytes: 3064
function main(input) {
  var a = input[0].split(" ")[0]-0;
  var b = input[0].split(" ")[1]-0;
  var k = input[0].split(" ")[2]-0;

  var x = Math.min(a,k);
  a -= x;
  k -= x;
  x = Math.min(b,k);
  b -= x;
  console.log(a + " " + b);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


Measured memory_bytes: 7372
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
class Cube{
    public:
    int f[6];
    Cube(){}
    void roll_y(){ roll(0, 2, 5, 3);}
    void roll_x(){ roll(0, 1, 5, 4);}
    void roll(int i, int j, int k, int l){
	int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }
  
  bool valid(){
    bool v[6];
    rep(i, 6) v[i] = false;
    rep(i, 6) if ( 1 <= f[i]  && f[i] <= 6 ) v[f[i]-1] = true;
    rep(i, 6) if ( !v[i] ) return false;
    return f[0]+f[5]==7 && f[1]+f[4]==7 && f[2]+f[3]==7;
  }
};

class State{
  public:
  int pi, pj;
  Cube cube;
  State(){}
  State(int pi, int pj):pi(pi),pj(pj){
    rep(i, 6) cube.f[i] = -1;
  }
  bool operator < ( const State &s) const{
    if ( pi != s.pi ) return pi < s.pi;
    if ( pj != s.pj ) return pj < s.pj;
    rep(i, 6){
      if ( cube.f[i] == s.cube.f[i] ) continue;
      return cube.f[i] < s.cube.f[i];
    }
    return false;
  }
};

int G[7][7];
set<State> V;

bool dfs(State u){
  u.cube.f[5] = G[u.pi][u.pj];
  if ( u.cube.valid() ) return true;
  V.insert(u);

  State v;
  int di[4] = {1, -1, 0, 0};
  int dj[4] = {0, 0, -1, 1};
  int dp[4] = {1, 4, 3, 2};
  rep(r, 4){
    if ( u.cube.f[dp[r]] == -1 && G[u.pi+di[r]][u.pj+dj[r]] ||
	 u.cube.f[dp[r]] == G[u.pi+di[r]][u.pj+dj[r]] ){
      v = u;
      v.pi += di[r]; v.pj += dj[r];
      if ( dp[r] == 1 ) rep(i, 3) v.cube.roll_x();
      if ( dp[r] == 4 ) v.cube.roll_x();
      if ( dp[r] == 3 ) v.cube.roll_y();
      if ( dp[r] == 2 ) rep(i, 3) v.cube.roll_y();
      if ( V.find(v) == V.end() && dfs(v) ) return true;
    }
  }
  return false;
}

bool valid(vector<int> d){
  if ( d.size() != 6 ) return false;
  sort(d.begin(), d.end());
  rep(i, 6)
    if ( i+1 != d[i] ) return false;
  return true;
}

main(){
  int tcase; cin >> tcase;
  rep(t, tcase){
    rep(i, 7) rep(j, 7) G[i][j] = 0;
    int si, sj;
    vector<int> d;
    for ( int i = 1; i <= 5; i++ ){
      for ( int j = 1; j <= 5; j++ ){
	cin >> G[i][j];
	if ( G[i][j] ) { 
	  si = i; sj = j; 
	  d.push_back(G[i][j]);
	}
      }
    }
    State s = State(si, sj);
    V.clear();
    if ( valid(d) && dfs(s) ) cout << "true" << endl;
    else cout << "false" << endl;
  }
}

Measured memory_bytes: 0
import sys

readline = sys.stdin.readline

def main():
    S = list(readline()[:-1])
    lenS = len(S)
    cntR = 0; cntL = 0
    status0 = [0]*lenS
    status1 = [0]*lenS
    for i, s in enumerate(S):
        if (s == 'R' and cntL > 0) or i == lenS-1:
            if i == lenS-1:
                cntL += 1
            cnt = max(cntR, cntL)
            sumRL = cntR + cntL
            tmp = sumRL//2
            place = i - cntL - (i!=lenS-1)*1
            if sumRL%2 == 0:
                status0[place] = tmp
                status0[place+1] = tmp
                status1[place] = tmp
                status1[place+1] = tmp
            else:
                if (cnt-1)%2 == 0:
                    if cntR > cntL:
                        status0[place] = tmp+1
                        status0[place+1] = tmp
                        status1[place] = tmp
                        status1[place+1] = tmp+1
                    else:
                        status0[place] = tmp
                        status0[place+1] = tmp+1
                        status1[place] = tmp+1
                        status1[place+1] = tmp
                else:
                    if cntR > cntL:
                        status0[place] = tmp
                        status0[place+1] = tmp+1
                        status1[place] = tmp+1
                        status1[place+1] = tmp
                    else:
                        status0[place] = tmp+1
                        status0[place+1] = tmp
                        status1[place] = tmp
                        status1[place+1] = tmp+1
            cntR = 1; cntL = 0
        elif s == 'R':
            cntR += 1
        elif s == 'L':
            cntL += 1
        else:
            return
    print(*status0)

if __name__ == "__main__":
    main()


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  ll n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<ll> zero;
  vector<ll> one;
  if(s[0]=='0'){
    one.push_back(0);
  }
  char b = 'n';
  ll num = 0;
  rep(i,n){
    if(s[i]==b){
      num++;
    }else if(b=='1'){
      one.push_back(num);
      num=1;
    }else if(b=='0'){
      zero.push_back(num);
      num=1;
    }else{
      num = 1;
    }
    b = s[i];
  }
  if(s[n-1]=='0'){
    one.push_back(0);
    zero.push_back(num);
  }else{
    one.push_back(num);
  }

  // cout << one.size() << endl;
  // cout << zero.size() << endl;
  ll ans = 0;
  if(k >= zero.size()){
    rep(i,zero.size()){
      ans += one[i];
      ans += zero[i];
    }
    ans += one[one.size()-1];
    cout << ans << endl;
  }else{
    ll res;
    rep(i,k){
      ans += one[i];
      ans += zero[i];
    }
    ans += one[k];
    res = ans;
    rep(i,zero.size()-k){
      res -= one[i];
      res -= zero[i];
      res += one[k+i+1];
      res += zero[k+i];
      ans = max(res,ans);
    }
    cout << ans << endl;
  }


  return 0;
}

Measured memory_bytes: 1404