akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vi32> s(m);
  rep(i, m) {
    int k; cin >> k;
    s[i] = vi32(k);
    cin >> s[i];
  }
  vi32 p(m); cin >> p;
  int ans = 0;
  rep(i, bit(n)) {
    bool f = true;
    rep(j, m) {
      int cnt = 0;
      each(k, s[j]) {
        if (i & bit(k - 1)) cnt = 1 - cnt;
      }
      if (cnt != p[j]) { f = false; break; }
    }
    if (f) ans++;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,m,a,x,map[1000][3],i,h,o;
    for(scanf("%d %d %d",&n,&m,&a);a;scanf("%d %d %d",&n,&m,&a)){
        for(i=0;i<m;i++){
            for(o=0;o<3;o++){
                scanf("%d",&map[i][o]);
            }
        }
        for(h=1000,x=a;h != 0;h--){
            for(i=0;i<m;i++){
                if(h == map[i][0] && x == map[i][1]){
                    x=map[i][2];
                    break;
                }
                else if(h == map[i][0] && x == map[i][2]){
                    x=map[i][1];
                    break;
                }
            }
        }
        printf("%d\n",x);
    }
    return 0;
}

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

int func(int p, int q, double a, int n, int l)
{
    int i;
    int b=0;
    
    if(n>0&&p>0){
        for(i=l;i<=a;i++){
            if(p*i==q){
                b++;
            }
            b+=func(p*i-q, q*i, a/i, n-1, i);
        }
    }
    return b;
}

int main(void)
{
    int p, q, a, n;
    
    while(1)
    {
        scanf("%d %d %d %d ", &p, &q, &a, &n);
        if(p==0&&q==0&&a==0&&n==0)
            break;
        
        printf("%d\n", func(p, q, (double)a, n, 1));
    }
    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
const int MAXN=10;
int n,rka,rkb,fac[MAXN],a[MAXN],b[MAXN];
int main () {
	scanf("%d",&n);
	fac[0]=1;
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		fac[i]=fac[i-1]*i;
	}
	for (int i=1;i<=n;i++) {
		int tmp=0;
		for (int j=i+1;j<=n;j++) {
			if (a[j]<a[i]) {tmp++;}
		}
		rka+=tmp*fac[n-i];
	}
	for (int i=1;i<=n;i++) {
		scanf("%d",&b[i]);
	}
	for (int i=1;i<=n;i++) {
		int tmp=0;
		for (int j=i+1;j<=n;j++) {
			if (b[j]<b[i]) {tmp++;}
		}
		rkb+=tmp*fac[n-i];
	}
	printf("%d\n",abs(rka-rkb));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s; cin >> s;
    bool flag = sz(s) % 2 != 0;
    for(int i =  0; i < sz(s)-1; i+=2){
      if(s[i] != 'h' || s[i+1] != 'i') flag = 1;
    }
    if(!flag) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> p(n), q(n);
    for (int i = 0; i < n; i++) std::cin >> p[i];
    for (int i = 0; i < n; i++) std::cin >> q[i];
    std::vector<int> id(n);
    std::iota(id.begin(), id.end(), 1);
    int a, b;
    int cnt = 0;
    do {
        cnt++;
        if (p == id) a = cnt;
        if (q == id) b = cnt;
    } while (std::next_permutation(id.begin(), id.end()));
    std::cout << std::abs(a - b) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<set>
//headers packages!
//headers packages!
#include<stack>
#include<string>
#include<iterator>
#include<algorithm>

using namespace std;
int main()
{

   int n;
   cin>>n;
   if(n>=30)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
    
 }

Measured memory_bytes: 3612
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a,b) memset(a, b, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

        set<string>S;
        int n; cin >> n;
        rep(i,n){
            string s;cin >> s;
            S.insert(s);
        }
        cout<<sz(S)<<endl;

return 0;
}



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

namespace ABC179
{
    public class B
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var d = Enumerable.Range(0, n).Select(_ => Console.ReadLine().Split().Select(Convert.ToChar).ToArray()).ToArray();

            int duplicated = 0;
            for (int i = 0; i < n; i++)
            {
                if (d[i][0] == d[i][1])
                {
                    duplicated++;
                }
                else
                {
                    duplicated = 0;
                }

                if (duplicated == 3)
                {
                    break;
                }
            }

            if (duplicated == 3)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 28416
#import <Foundation/Foundation.h>
#include <stdio.h>

int buf;
NSInteger intinput(void){
    scanf("%d",&buf);
    NSInteger ret = buf;
    return ret;
}

void output(NSString *s,NSString *sep){
    NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
    [fileHandle writeData:[s dataUsingEncoding:NSUTF8StringEncoding]];
    [fileHandle writeData:[sep dataUsingEncoding:NSUTF8StringEncoding]];
    [fileHandle closeFile];
}

NSMutableArray* to_numarray(NSString *s){
    NSMutableArray *l = [NSMutableArray arrayWithArray:[s componentsSeparatedByString:@" "]];
    NSInteger buf = 0;
    for(int i=0;i<[l count];i++){
        buf = [[l objectAtIndex:i] integerValue];
        [l replaceObjectAtIndex:i withObject:[NSNumber numberWithInteger:buf]];
    }
    return l;
}

int main(int argc, const char * argv[]) {
    NSInteger N = intinput();
    NSInteger K = intinput();
    NSInteger X = intinput();
    NSInteger Y = intinput();
    NSInteger v = (N-K>=0)?(K*X+(N-K)*Y):N*X;

    NSString *result = [NSString stringWithFormat:@"%ld",v];
    output(result,@"\n");
    return 0;
}


Measured memory_bytes: 11108
n, m = map(int, input().split())
p = [int(x) for x in input().split()]

par = [-1 for _ in range(n)]

def find(x):
    if par[x] < 0:
        return x
    par[x] = find(par[x])
    return par[x]

def union(x, y):
    x, y = find(x), find(y)
    if x == y:
        return
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x

def same(x, y):
    return find(x) == find(y)

def size(x):
    return par[find(x)]

for i in range(m):
    x, y = map(int, input().split())
    union(x-1, y-1)

ans = 0
for i in range(n):
    if same(p[i]-1, i):
        ans += 1
print(ans)

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

class Program
{

    public void Slove()
    {   
        var input = Console.ReadLine();
        int n = int.Parse(input);
        int[] array =
            Enumerable.Range(0, n)
            .Select(x => Console.ReadLine())
            .Select(int.Parse)
            .ToArray();
        long[] dp = new long[5];
        foreach(int i in array)
        {
            int temp = i;
            dp[4] = dp.Take(5).Min() + temp;
            temp = i == 0 ? 2 : i & 1;
            dp[3] = dp.Take(4).Min() + temp;
            temp = (i + 1) & 1;
            dp[2] = dp.Take(3).Min() + temp;
            temp = i == 0 ? 2 : i & 1;
            dp[1] = dp.Take(2).Min() + temp;
            dp[0] += i;
            //Console.WriteLine(string.Join(",", dp));
        }
        Console.WriteLine(dp.Min());
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 20276
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll A[200000];
ll B[200000];
ll cum_A[200001];
ll cum_B[200001];

int main() {
	ll N, M, K;
	cin >> N >> M >> K;

	for (int i=0; i<N; i++) {
		cin >> A[i];
		cum_A[i+1] = cum_A[i] + A[i];
	}

	for (int i=0; i<M; i++) {
		cin >> B[i];
		cum_B[i+1] = cum_B[i] + B[i];
	}

	ll ans = 0;

	for (int i=0; i<=N; i++) {
		if (cum_A[i] > K) break;
		ll j = upper_bound(cum_B, cum_B+M+1, K - cum_A[i]) - cum_B - 1;
		ans = max(ans, i + j);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9868
import numpy as np


N = int(input())
A = np.array(input().split(), dtype=np.int32)

left_idx = np.arange(N)
# 自身が左以下ならば0に
left_idx[1:][A[:-1] >= A[1:]] = 0
np.maximum.accumulate(left_idx, out=left_idx)

answer = (np.arange(N) - left_idx).max()
print(answer)


Measured memory_bytes: 24256
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int64_t solve(const int64_t a, const int64_t b)
{
  int64_t out = numeric_limits<int64_t>::max();

  if(!(a % 3)) return 0;

  out = b;

  for(int64_t i = 0; i < b + 1 && out; ++ i)
  {
    const auto x1 = i * a;
    const auto w = b - i;
    const auto x2 = a / 2 * w;
    const auto x3 = (a + 1) / 2 * w;

    out = min(out,
              max({x1, x2, x3}) - min({x1, x2, x3}));
  }

  return out;
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int64_t a, b;
  cin >> a >> b;

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


  return EXIT_SUCCESS;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), cnt = 1, tmp;
		if(n < 105) {
			System.out.println(0);
			return;
		}
		for(int m = 107; m <= n; m+=2) {
			tmp = 1;
			for(int k = 3; k <= m; k+=2) {
				if(m % k == 0)tmp++;
			}
			if(tmp == 8)cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23760
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string S;
    cin >> S;
    int L = S.size();
    string ans = "AC";
    
    if(S[0] != 'A')ans = "WA";
    
    int cnt = 0;
    for(int i = 1; i < L; ++i){
        if(isupper(S[i])){
            if(i == 1 || i == L - 1 || S[i] != 'C')ans = "WA";
            ++cnt;
        }
    }
    if(cnt != 1)ans = "WA";
        cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd( T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint power(lint N, lint P, lint M){if(P==0) return 1;if(P%2==0){lint t = power(N, P/2, M);return t*t % M;}return N * power(N, P-1, M);}
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**/int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	int a,b;
	in(a,b);
	out(a*b,2*a+2*b);
	return 0;
}



Measured memory_bytes: 3132
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	s := wordScanner()
	scanInts(s, &n)
	a := scanIntSlice(s, n+1)
	b := scanIntSlice(s, n)

	ans := 0
	for i, bi := range b {
		if bi > a[i] {
			if bi-a[i] > a[i+1] {
				ans += a[i] + a[i+1]
				a[i+1] = 0
				continue
			} else {
				a[i+1] -= bi - a[i]
			}
		}
		ans += bi
	}
	fmt.Println(ans)
}

func wordScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}

func scanIntSlice(s *bufio.Scanner, n int) []int {
	vals := make([]int, n)
	for i := range vals {
		s.Scan()
		m, _ := strconv.Atoi(s.Text())
		vals[i] = m
	}
	return vals
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
inline string lts(ll a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}
inline ll stl(string a){
  char x[100]; ll res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN (int)1e4+5
#if !testing
#define cerr if(0)cout
#endif
int dp[MAXN];
pi A[MAXN];
int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	int h,n;cin>>h>>n;
	FOR(i,1,n)cin>>A[i].f>>A[i].s;
	memset(dp,127,sizeof dp);
	dp[0] = 0;
	FOR(i,1,n) {
		FOR(j,0,h) {
			if(A[i].f<=j)minself(dp[j],dp[j-A[i].f]+A[i].s);
			else minself(dp[j],A[i].s);
		}
	}
	cout << dp[h];
}


Measured memory_bytes: 384
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
}node;
node T[MAX];

int n;

int pre(int);
int in(int);
int post(int);

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i = 0; i < n; i++)
    T[i].p = NIL;
  
  for(i = 0; i < n; i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if( l != NIL) T[l].p = v;
    if( r != NIL) T[r].p = v;
  }

  for(i = 0; i < n; i++){
    if(T[i].p == NIL) root = i;
  }

  printf("Preorder\n");
  pre(root);
  printf("\nInorder\n");
  in(root);
  printf("\nPostorder\n");
  post(root);
  printf("\n");

  return 0;
}

int pre(int u){
  if(u == NIL) return 0;
  printf(" %d",u);
  pre(T[u].l);
  pre(T[u].r);
}

int in(int u){
  if(u == NIL) return 0;
  in(T[u].l);
  printf(" %d",u);
  in(T[u].r);
}

int post(int u){
  if(u == NIL) return 0;
  post(T[u].l);
  post(T[u].r);
  printf(" %d" ,u);
}


    

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s; cin >> s;
    rep(i, (1<<3)) {
        int sum = s[0] - '0';
        rep(j, 3) {
            if(i & (1<<j)) sum += s[j+1] - '0';
            else sum -= s[j+1] - '0';
        }
        if(sum == 7) {
            cout << s[0];
            rep(j, 3) cout << (i&(1<<j) ? '+' : '-') << s[j+1];
            cout << "=7" << endl;
            return 0;
        }
    }
}


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

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

int main(){
	int n;
	string s;
	cin >> n >> s;
	
	int e = 0;
	for(char c : s){
		if(c == 'E') e++;
	}
	
	int w = 0;
	int ans = INF;
	for(char c : s){
		
		if(c == 'E'){
			e--;
			ans = min(ans, e + w);
		}
		else{
			ans = min(ans, e + w);
			w++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 900
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n, m;
  cin >> n >> m;

  llong ans = -1;
  for(int i = 1; i * i <= m; ++i){
    if(m % i == 0){
      llong a = i, b = m / i;
      if(a >= n){
        ans = max(ans, b);
      }else if(b >= n){
        ans = max(ans, a);
      } 
    }
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;
using ll = long long;

int main() {
    int n,m;
    cin>>n>>m;
    atcoder::dsu d(n);
    for(int i = 0;i < m;++i) {
        int a,b;
        cin>>a>>b;
        --a;--b;
        d.merge(a,b);
    }
    cout<<d.groups().size()-1<<endl;
    return 0;
}


Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
    	int n,m;
	cin>>n>>m;
	vector<vector<int> > dp(n+2,vector<int>(n+2,0) );
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		dp[a][b] = max(dp[a][b],c+1) ;
	}
	int cnt = 0;
	for(int i=1;i<=n;i++){
		for(int j = 1;j<=i;j++){
			if(dp[i][j] != 0){
				dp[i+1][j] = max(dp[i+1][j],dp[i][j]-1);
				dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]-1);
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;


	return 0;
}



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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
        
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    h = h * 60 + m;
    cout << sqrt(a * a + b * b - 2 * a * b * cos(h * 11 * M_PI / 360.0)) << endl;;
    return 0;
}


Measured memory_bytes: 4240
import numpy as np
H, W, M = map(int, input().split())
col = np.zeros(H)
row = np.zeros(W)
memo = []
for i in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    col[h] += 1
    row[w] += 1
    memo.append((h,w))

col_max = col.max()
row_max = row.max()

col_max_indexes = np.where(col == col_max)[0]
row_max_indexes = np.where(row == row_max)[0]

ans = col_max + row_max - 1
memo = set(memo)
for c in col_max_indexes:
    for r in row_max_indexes:
        if (c,r) not in memo:
            ans = col_max + row_max
            print(int(ans))
            exit()

print(int(ans))

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

using namespace std;


int main(){

string a,b,c;
cin>>a>>b;
int a1,b1;
cin>>a1>>b1;
cin>>c;
int x=0,y=0;
if(a==c)
{
    x=-1;
}
else if(b==c)
{
    y=-1;
}
    cout<<a1+x<<" "<<b1+y;
    
}


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

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long n;
    long long num[1000000];
    long long min1;
    long long sum=0;
    cin>>n;
    cin>>num[0];
    min1=num[0];
    for(int i=1;i<n;i++)
    {
        cin>>num[i];
        if(num[i]<min1)
            {
                sum++;
                min1=num[i];
            }
    }
    cout<<sum+1<<endl;
    return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = (1 << 17) + 5;

int M[N][17],fa[N],invfa[N],A[17],n,nn;

int comb(int i, int j){
    if(j > i) return 0;
    return fa[i] * invfa[j] % mod * invfa[i-j] % mod;
}
int f(int m, int i){
    if(i == 0) return (__builtin_popcount(m)&1 ? mod-1 : 1) * fa[nn-m-1] % mod * nn % mod;
    int j, &r = M[m][i];
    if(r != -1) return r;
    r = f(m,i-1);
    for(j=0;j<n;j++)
        if(!(m & (1 << j)) && nn-A[i]+1 >= (m | (1 << j)))
            r = (r + comb(nn-A[i]-m,(1 << j)-1) * fa[1 << j] % mod * f(m | (1 << j),i-1)) % mod;

    return r;
}

int m,t,x,i,j;
signed main(){
    for(invfa[0]=fa[0]=i=1;i<N;i++){
        fa[i] = fa[i-1] * i % mod;
        x = fa[i];
        t = 1;
        for(j = mod-2; j ; j>>=1){
            if(j & 1) t = t*x % mod;
            x = x*x % mod;
        }
        invfa[i] = t;
    }
    

    cin >> n >> m; nn = 1 << n;
    for(i=1;i<=m;i++) cin >> A[i];
    memset(M , -1 , sizeof M);
    cout << f(0,m);
}

Measured memory_bytes: 19712
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,i,t=1;
	cin >> a >> b;
	for(i=0;i<50;i++){
		if(t>=b){
			cout << i;
			return 0;
		}
		t=t+a-1;
	}
	return 0;
}

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

struct Pox
{
  int state,cost;
  Pox(int state,int cost):state(state),cost(cost){}
};

int main()
{
  while(1)
    {
      int n,U,k,r;
      scanf("%d %d",&n,&U);
      if(n+U == 0)
	break;
      int mincost[1<<n];
      for(int i=0;i<(1<<n);i++)
	mincost[i] = (1<<n);
      deque<Pox> deq;
      int G[n];
      int c[n];
      for(int i = 0;i<n;i++)
	{
	  scanf("%d %d",&c[i],&k);
	    G[i] = 0;

	  for(int j=0;j<k;j++)
	    {
	      scanf("%d",&r);
	      G[i] |= (1<<r);
	    }
	}

      deq.push_back(Pox(0,0));
      mincost[0] = 0;     
      int ans = (1<<n);
      while(!deq.empty())
	{
	  Pox pox = deq.front(); deq.pop_front();
	  int num = __builtin_popcount(pox.state);
	  if(num >= ans)
	    continue;
   
	  if(pox.cost >= U)
	    {
	      ans = min(ans,num);
	      continue;
	    }	 

	  for(int i=0;i<n;i++)
	    {
	      if((pox.state >> i) & 1)
		continue;
	      int pre = G[i];
	      pre &= pox.state;
	      if(pre != G[i])
		continue;
	      if(mincost[pox.state|(1<<i)] <= num+1)
		continue;
	      mincost[pox.state|(1<<i)] = num+1;
	      if(pox.cost + c[i] < U)
		deq.push_back(Pox(pox.state|(1<<i),pox.cost+c[i]));
	      else 
		ans = min(ans,num+1);
	    }
	}
      cout << ans << endl;
    }
  return 0;
}

Measured memory_bytes: 6928
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		
		String ans = "No";
		
		if(s.length() == t.length()-1 && s.equals(t.substring(0, t.length()-1))) {
			ans = "Yes";
		}
		
		System.out.println(ans);
	 }

}


Measured memory_bytes: 26928
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	string c;
	cin >> c;
	if (c == "a" || c == "o" || c == "e" || c == "i" || c == "u") {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}


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

typedef long long int int64;
static const int64 mod = 1000000007LL;
int64 fac[53],inv[53],invfac[53];
int64 dp[53][53];
int n;
int main()
{
	scanf("%d",&n);
	fac[0] = fac[1] = inv[1] = invfac[0] = invfac[1] = 1;
	for(int i = 2;i <= 50;++i) {
		fac[i] = fac[i-1]*i%mod;
		inv[i] = (mod-mod/i)*inv[mod%i]%mod;
		invfac[i] = (invfac[i-1]*inv[i])%mod;
	}
	dp[1][0] = dp[1][1] = 1;
	for(int i = 1;i < n;++i) {
		for(int j = 0;j <= i;++j) {
			for(int k = 0;i + k <= n;++k) {
				for(int l = 0;i + k + l <= n;++l) {
					if((j+k-l)%2==0 && (k!=0 || l!=0) && k+l>=j) {
						(dp[i+k+l][abs(j+k-l)/2] += dp[i][j] * invfac[k] % mod * invfac[l] % mod) %= mod;
					}
				}
			}
		}
	}
	printf("%lld\n", dp[n][0] * fac[n] % mod);
}


Measured memory_bytes: 256
function main(lines) {
    const input = lines.split(' ').map(Number)
    const x1 = input[0]
    const y1 = input[1]
    const x2 = input[2]
    const y2 = input[3]

    console.log(Math.sqrt(Math.pow(abs(x1-x2),2) + Math.pow(abs(y1-y2),2)).toFixed(4))
    
    function abs(val){
        return val < 0 ? -val : val;
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

using namespace std;

int main()
{
    int x;
    bool used[31] = {};
    for (int i = 0; i < 28; i++) {
        cin >> x;
        used[x] = 1;
    }

    for (int i = 1; i <= 30; i++) {
        if (!used[i]) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 10;

signed main() {
	// ios::sync_with_stdio(false);
	ll a, c;
	double b;
	cin >> a >> b;
	c = b * 100 + 0.1;
	cout << (ll)(a * c / 100) << '\n';
	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  int ans =0;
  for(int i=0; i<N; i++){
    cin >> h.at(i);
    if(h.at(i)>=K) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int num2(int x) {
  int ans = 0;
  while (x % 2 == 0) {
    x/=2;
    ans++;
  }
  return ans;
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int n; cin >> n;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    ans += num2(a);
  }
  cout << ans << nl;
  return 0;
}



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

bool solve() {
    ll N, a;
    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        if ( a % 2 == 0 ) {
            if ( a % 3 != 0 && a % 5 != 0) return false;
        }
    }
    return true;
}

int main() {
    string ans = solve() ? "APPROVED" : "DENIED";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if i+1 == P[i]:
        P[i], P[i+1] = P[i+1], P[i]
        ans += 1
if N == P[N-1]:
    ans += 1

print(ans)


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

int main() {
    int t, n;
    cin >> t;
    while (t--) {
        cin >> n;
        vector<int> v(n);
        for (int i=0; i<n; ++i) {
            cin >> v[i];
        }
        int h1 = 0, h2 = 0;
        for (int i=0; i<n-1; ++i) {
            h1 = max(h1, v[i+1] - v[i]);
            h2 = max(h2, v[i] - v[i+1]);
        }
        cout << h1 << " " << h2 << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
N, K = map(int,input().split())
P = list(map(int,input().split()))
P = [p+1 for p in P]
sm = sum(P[:K])  # 先頭のK個の和を計算
ans = sm  #  最大値（答え）を保存する
for i in range(N-K):
    sm = sm - P[i] + P[K+i]  # 窓をずらす
    ans = max(ans, sm)  # 最大値（答え）を更新
print (ans/2)


Measured memory_bytes: 24804
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;
    int cnt1=0,cnt2=0;
    string start="01";
    for(int i=0;i<s.sz;i++){
        if(start[0]!=s[i]) cnt1++;

        swap(start[0],start[1]);
    }
    start="10";
    for(int i=0;i<s.sz;i++){
        if(start[0]!=s[i]) cnt2++;

        swap(start[0],start[1]);
    }

    cout<<min(cnt1,cnt2)<<endl;
    End;
}


Measured memory_bytes: 512
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, M;
	
	cin >> N >> M;

	int a[M];

	rep(i, M)
	{
		cin >> a[i];
	}

	sort(a, a+M);

	int d[M-1];

	for(int i = 1; i < M; i++)
	{
		d[i-1] = a[i] - a[i-1];
	}

	sort(d, d+M-1);

	ll total = 0;

	rep(i, M - N)
	{
		total += d[i];
	}

	cout << total << endl;



	
	return 0;
}


Measured memory_bytes: 1024
#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 all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	map<pair<char, char>, ll> mp;
	for (int i = 1; i <= n; ++i)
	{
		string x = to_string(i);
		mp[make_pair(x[0], x.back())]++;
	}
	ll res = 0;
	for (int i = 1; i <= n; ++i)
	{
		string x = to_string(i);
		res += mp[make_pair(x.back(), x[0])];
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pob pop_back
#define vl vector<ll>
#define mp make_pair
#define sz size()
#define INF 1000000009
#define fast ios::sync_with_stdio(0)
#define maxx 100005
#define edge pair<ll,ll>
using namespace std;

// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦


int main()
{
	ll n;
	cin>>n;
	ll i;
	ll h[n];
	for(i=0;i<n;i++)
	{
		cin>>h[i];
	}
	ll dp[n];
	for(i=0;i<n;i++)
	{
		dp[i]=INF;
	}
	dp[0]=0;
	for(i=0;i<n;i++)
	{
		if(i+1<n)
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		if(i+2<n)
		dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int A[100050];
int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    for(int i = 1; i <= Q; i++) {
        int a;
        cin >> a;
        A[a]++;
    }
    for(int i = 1; i <= N; i++) {
        if(A[i] > Q - K) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static int Int(int a) {
		int i=0;
		if(a==9) {
			i=1;
		}
		else {
			i=9;
		}
		return i;
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=Int(a%10);
		a/=10;
		int c=Int(a%10);
		a/=10;
		int d=Int(a%10);
		System.out.println(d+""+c+""+b);
	}
}

Measured memory_bytes: 21716
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

n = int(input())
arr = list(map(int, input().split()))
ans = []
temp = 0
for i in arr:
	temp^=i
for i in range(n):
	ans.append(temp^arr[i])
print(*ans)








Measured memory_bytes: 31644
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		long xor0 = 0;
		List<Long> list = new ArrayList<>();
		List<Pair> pairs = new ArrayList<>();

		if(k==0) {
			for(int i=0;i<n;i++) {
				list.add(sc.nextLong());
			}
			long sum = 0;
				for(long l:list) {
					sum = (sum + xor(0,l));
				}
			System.out.println(sum);
			sc.close();
			return;
		}

		int logk = log(k);
		boolean[] kbit = new boolean[(int)logk+2];
		for(int i=0;i<n;i++) {
			list.add(sc.nextLong());
		}

		for(long l:list) {
			xor0 = (xor0 + xor(0,l));
		}

		int count = 0;
		for(long i=1;i<=k;i=i*2) {
			long sum = 0;
			for(long l:list) {
				sum = (sum + xor(i,l));
			}
			pairs.add(new Pair(i, sum-xor0));
			kbit[count] = (k/i)%2==1?true:false;
			count++;
		}

		//X=kをまず試す
		long ans = xor0;
		for(int j=0;j<=logk;j++) {
			if(kbit[j]) {
				ans = ans+pairs.get(j).b;
			}
		}
		for(int i=0;i<=logk;i++) {
			long tmpans = xor0;
			//どこかが1
			if(kbit[i]) {
				//そこから上はkと同じにする(j=iは0)
				for(int j=i+1;j<=logk;j++) {
					if(kbit[j]) {
						tmpans = tmpans+pairs.get(j).b;
					}
				}
				//そこから下は貪欲方
				for(int j=0;j<i;j++) {
					if(pairs.get(j).b>0) {
						tmpans = tmpans + pairs.get(j).b;
					}
				}
				ans = ans>tmpans?ans:tmpans;
			}
			else {
				continue;
			}
		}
		sc.close();
		System.out.println(ans);
		//一つ目足した結果
	}


	static long xor(long j,long b) {
		long c = j>b?j:b;
		long sum = 0;
		for(long i=1;i<=c;i=i*2) {
			if(j%2!=b%2) {
				sum = sum + i;
			}
			j = j/2;
			b = b/2;
		}
		return sum;
	}

	static int log(long x, int base)
	{
	    return (int) (Math.log(x) / Math.log(base));
	}

	static int log(long x)
	{
		long exp = 2;
		int count = 0;
	    while(exp<=x) {
	    	exp = exp *2;
	    	count++;
	    }
	    return count;

	}

	static class Pair implements Comparable<Pair> {
	    long a,b;
	    public Pair(long a,long b) {
	        this.a = a;
	        this.b = b;
	    }

	    //(a,b)が一致
	    @Override
	    public boolean equals(Object o) {
	        if (o instanceof Pair) {
	            Pair p = (Pair) o;
	            return a == p.a && b == p.b;
	        }
	        return super.equals(o);
	    }

	    /*
	     * x.equals(y) ならば hashCode(x) == hashCode(y)でなければならない。
	     * この実装では同じハッシュ値をもつペアを容易に見つけられるため、ハッシュとしては弱い。
	     */
//	    @Override
//	    public int hashCode() {
//	        return a ^ b;
//	    }

	    //辞書順比較
	    @Override
	    public int compareTo(Pair o) {
	        if (a != o.a) {
	            return Long.compare(a, o.a);
	        }
	        //変えた
	        return Long.compare(b, o.b);
	    }
	}

}


Measured memory_bytes: 64472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;



int main(void){
    int n;
    scanf("%d",&n);
    string po;
    cin >> po;
    int count[26]={};
    for(int i=0;i<2*n;i++)count[po[i]%26]++;
    for(int i=0;i<26;i++){
        if(count[i]%2!=0){
            printf("0\n");
            return 0;
        }
    }
    long long ans=0;
    for(int i=0;i<(1<<n);i++){
        vector<char> red,blue;
        for(int j=0;j<n;j++){
            if((i>>j)%2==1)red.push_back(po[j]);
            else blue.push_back(po[j]);
        }
        long long dp[n+1][n+1];
        for(int j=0;j<=n;j++)for(int k=0;k<=n;k++){
            dp[j][k]=0;
        }
        reverse(red.begin(),red.end());
        reverse(blue.begin(),blue.end());
        dp[0][0]=1;
        for(int j=0;j<n;j++){
            for(int k=0;k<=j;k++){
                if(k<red.size()&&red[k]==po[n+j])dp[k+1][j-k]+=dp[k][j-k];
                if(j-k<blue.size()&&blue[j-k]==po[n+j])dp[k][j-k+1]+=dp[k][j-k];
            }
        }
        ans+=dp[red.size()][blue.size()];
     //   for(int i=0;i<red.size();i++)printf("%c",red[i]);
       // printf("\n");
       // printf("%lld\n",dp[red.size()][blue.size()]);
    }
    printf("%lld\n",ans);
    return 0;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int len = sz(s);
    rep(i,len) {
        s[i] = 'A'+(s[i]-'A'+n)%26;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long

using namespace std;

// input
int w,h,x,y,r;

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

    cin >> w >> h >> x >> y >> r;
    
    if(w-r >= x && h-r >= y && x >= r && y >= r){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
int n;
long long dp[1000010][2][2];
const int mod=1e9+7;
int main(){
	cin>>n;
	dp[1][0][1]=1;
	dp[1][1][0]=1;
	dp[1][0][0]=8;
	for(int i=2;i<=n;i++){
		dp[i][0][0]+=dp[i-1][0][0]*8;
		dp[i][0][0]%=mod;
		dp[i][1][1]+=dp[i-1][0][1];
		dp[i][1][1]+=dp[i-1][1][0];
		dp[i][1][1]+=dp[i-1][1][1]*10;
		dp[i][1][1]%=mod;
		dp[i][0][1]+=dp[i-1][0][1]*9;
		dp[i][0][1]+=dp[i-1][0][0];
		dp[i][0][1]%=mod;
		dp[i][1][0]+=dp[i-1][1][0]*9;
		dp[i][1][0]+=dp[i-1][0][0];
		dp[i][1][0]%=mod;
	}
	//cout<<dp[2][0][0]<<endl;
	cout<<dp[n][1][1]<<endl;	
} 

Measured memory_bytes: 34632