akhauriyash/Code-Regression huggingface dataset:
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		n--;
		cout << (n * (n + 1)) / 2;
	}
	return 0;
}

Measured memory_bytes: 3636
#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[i];
  
    sort(A.begin(), A.end());
    int MIN1 = A[0];
    int MIN2 = A[1];
    //cout << MIN1 << " " << MIN2 << endl;
    int ans = 0;
    vector<int> yaku = {};
    for (int i = 1; i * i <= MIN1; i++) {
        if (MIN1 % i == 0) {
            yaku.push_back(i);
            yaku.push_back(MIN1 / i);
        }
    }

    //for (int i = 0; i < yaku.size(); i++) cout << yaku[i] << endl;
    sort(yaku.begin(), yaku.end());
    reverse(yaku.begin(), yaku.end());
    for (int i = 0; i < yaku.size(); i++) {
        int cnt = 0;
        for (int j = 0; j < N; j++) {
            if (A[j] % yaku[i] == 0) cnt++;
        }
        if (cnt >= N - 1) {
            ans = yaku[i];
            break;
        }
    }
  
    yaku = {};
    for (int i = 1; i * i <= MIN2; i++) {
        if (MIN2 % i == 0) {
            yaku.push_back(i);
            yaku.push_back(MIN2 / i);
        }
    }

    //for (int i = 0; i < yaku.size(); i++) cout << yaku[i] << endl;
    sort(yaku.begin(), yaku.end());
    reverse(yaku.begin(), yaku.end());
    for (int i = 0; i < yaku.size(); i++) {
        int cnt = 0;
        for (int j = 0; j < N; j++) {
            if (A[j] % yaku[i] == 0) cnt++;
        }
        if (cnt >= N - 1) {
            ans = max(ans, yaku[i]);
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
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();
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		String U = sc.next();
		sc.close();
		
		if(U.equals(S)) {
			A--;
			System.out.println(A + " " + B);
		}else if(U.equals(T)) {
			B--;
			System.out.println(A + " " + B);
		}

	}

}

Measured memory_bytes: 22612
class BallDistribution:
    def __init__(self):
        self.N, self.K = map(int, input().split())

    def max_number(self):
        if self.K == 1:
            print(0)
        else:
            print(self.N - self.K)


ballDistribution = BallDistribution()
ballDistribution.max_number()


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

vector< int > z_algorithm(const string &s, const string &t) {
  vector< int > prefix(s.size()+1, 0);
  prefix[s.size()] = 1;
//  for(int i = 1, j = 0; i < s.size(); i++) {
//    if(i + prefix[i - j] < j + prefix[j]) {
//      prefix[i] = prefix[i - j];
//    } else {
//      int k = max(0, j + prefix[j] - i);
//      while(i + k < s.size() && (s[k] == s[i + k] || s[k] == '?' || s[i + k] == '?')) ++k;
//      prefix[i] = k;
//      j = i;
//    }
//  }
//  prefix[0] = (int) s.size();
  REP(i, s.size()) {
    prefix[i] = 1;
    REP(k, min(t.size(), s.size()-i)) {
      if (s[i+k] != t[k] && s[i+k] != '?' && t[k] != '?') {
        prefix[i] = 0;
        break;
      }
    }
  }
  return prefix;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> s(3);
  REP(i ,3) cin >> s[i];
  vector<int> zal[3][3];
  REP(i, 3) {
    REP(j, 3) {
      zal[i][j] = z_algorithm(s[i], s[j]);
//      cout << i << " " << j << ": ";
//      REP(k, zal[i][j].size()) {
//        cout << zal[i][j][k] << " ";
//      }
//      cout << s[i] << " " << s[j] << " ";
//      cout << endl;
    }
  }
  vector<int> ord(3);
  iota(all(ord), 0);
  int64 res = s[0].size()+s[1].size()+s[2].size();
  do {
    int64 sum = 0;
    int64 a = ord[0], b = ord[1], c = ord[2];
    REP(i, s[a].size()+1) {
      b = ord[1];
      if (!zal[a][b][i]) continue;
      FOR(j, i, max(s[a].size()+1, i+s[b].size()+1)) {
        if (j - i < s[b].size() && !zal[b][c][j-i]) continue;
        if (j < s[a].size() && !zal[a][c][j]) continue;
//        cout << i << " " << j << endl;
        chmin(res, max({j+s[c].size(), s[a].size(), i+s[b].size()}));
      }
    }
  } while(next_permutation(all(ord)));
  cout << res << endl;
}


Measured memory_bytes: 384
import sys
S = input()
x,y = map(int,input().split())

f_first = S[0] == 'F'
x_moves = []
y_moves = []
x_dir = False
sp = S.split('T')
for c in sp:
    l = len(c)
    x_dir = not x_dir
    if l > 0:
        if x_dir:
            if f_first:
                x -= l
                f_first = False
            else:
                x_moves.append(l)
        else:
            y_moves.append(l)

x,y = abs(x),abs(y)
sum_x, sum_y = sum(x_moves),sum(y_moves)
if x > sum_x or y > sum_y:
    print('No')
    sys.exit()

def ok(moves, summ, to):
    if len(moves) == 0: return to == 0
    ss = set([0])
    rem = summ
    for m1 in moves:
        rem -= m1
        _ss = set()
        for m2 in ss:
            if m2 + m1 <= to + rem:
                _ss.add(m2 + m1)
            if m2 - m1 >= to - rem:
                _ss.add(m2 - m1)
        ss = _ss
    return to in ss

print('Yes' if ok(x_moves,sum_x,x) and ok(y_moves,sum_y,y) else 'No')


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int N, M; cin >> N >> M;
	vector<int> switches(M);
	vector<int> p(M);
	for (int i = 0; i < M; i++) {
		int k; cin >> k; while (k--) {
			int v; cin >> v; v--;
			switches[i] |= (1<<v);
		}
	}
	for (int i = 0; i < M; i++) cin >> p[i];
	int ans = 0;
	for (int m = 0; m < (1<<N); m++) {
		bool good = true;
		for (int i = 0; i < M; i++) {
			good = good && __builtin_popcount(switches[i] & m) % 2 == p[i];
		}
		if (good) ans++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int main(){
	int n[6];
	for(int i=0;i<6;i++){
		n[i]=0;
	}
	scanf("%d %d\n",&n[0],&n[1]);
	scanf("%d %d\n",&n[2],&n[3]);
	scanf("%d %d\n",&n[4],&n[5]);
	int q=0;
	int w=0;
	int e=0;
	int r=0;
	for(int i=0;i<6;i++){
		if(n[i]==1){
			q++;
		}
		if(n[i]==2){
			w++;
		}
		if(n[i]==3){
			e++;
		}
		if(n[i]==4){
			r++;
		}
	}
	if((q-3)*(w-3)*(e-3)*(r-3)==0){
		printf("NO\n");
	}else{
		printf("YES\n");
	}
}

Measured memory_bytes: 128
N = int(input())

ans = []
for i in range(N):
  char = list(input())
  dct = {chr(i):0 for i in range(97, 97+26)}
  for c in char:
    dct[c] += 1
  ans.append(dct)

dd = {chr(i):50 for i in range(97, 97+26)}
for i in range(len(ans)):
  for j in range(97, 97+26):
    dd[chr(j)] = min(ans[i][chr(j)], dd[chr(j)])

res = ''
for k,v in dd.items():
  res += k * v
res = sorted(res)
print("".join(res))

Measured memory_bytes: 40432
import sys
write = sys.stdout.write

def valid(x, y):
    H = info[nzpoint][2] + abs(info[nzpoint][0]-x) + abs(info[nzpoint][1]-y)
    for i in range(N):
        if i == nzpoint:
            continue
        if max(0, H - abs(x-info[i][0]) - abs(y-info[i][1])) != info[i][2]:
            return False
    return True
        

def printheight(i, j):
    write(str(info[nzpoint][2] + abs(i-info[nzpoint][0]) + abs(j-info[nzpoint][1])) + "\n")

N = int(input())
info = []
nzpoint = 0
for i in range(N):
    info.append(list(map(int,input().split())))
    if info[i][2] > 0:
        nzpoint = i
#0-100で全探索してみよか
for i in range(101):
    for j in range(101):
        if valid(i, j):
            write(str(i) + " " + str(j) + " ")
            printheight(i, j)
            sys.exit()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int i, a, b, c, x;
    cin >> a >> b >> c;
    x = 0;
    for(i=a; i<=b; i++)
    {
        if(c%i == 0)    
         x = x + 1;
    }
    cout << x << endl;
}


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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = int.Parse(Console.ReadLine());
            if (n  == 19 || n  == 29||n==39||n==49||n==59||n==69||n==79||n==89||n==90||n==91||n==92||n==93||n==94||n==95||n==96||n==97||n==98||n==99)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            Console.ReadKey();

        }
    }
}


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

typedef long long ll;
#define MAXN 200010
#define X first
#define Y second

int top, cnt;
int sta[MAXN], SG[MAXN], q[MAXN];
bool instack[MAXN], circle[MAXN];
int vis[MAXN];
vector<int> E[MAXN];


void DFS(int x)
{
	sta[++top] = x;
	vis[x] = instack[x] = true;
	for (int i = 0; i < E[x].size(); ++i)
	{
		int y = E[x][i];
		if (!vis[y]) DFS(y);
		else if (instack[y])
		{
			for (int j = 1; j <= top; ++j)
				circle[q[j] = sta[j]] = true;
			cnt = top;
		}
	}
	instack[x] = false; --top;
}

void Calc_SG(int x, bool f)
{
	
	if (SG[x] != -1) return;
	for (int i = 0; i < E[x].size(); ++i)
	{
		int y = E[x][i];
		if (f && circle[y]) continue;
		Calc_SG(y, f);
	}
	for (int i = 0; i < E[x].size(); ++i)
	{
		int y = E[x][i];
		if (f && circle[y]) continue;
		vis[SG[y]] = x;
	}
	SG[x] = 0;
	while (vis[SG[x]] == x) ++SG[x];
}

bool Check(int N)
{
	for (int i = 1; i <= cnt; ++i)
		SG[q[i]] = -1;
	Calc_SG(q[1], 1);

	for (int i = cnt; i > 1; --i)
	 	Calc_SG(q[i], 0);
	

	memset(vis, 0, sizeof(vis));
	for (int i = 0; i < E[q[1]].size(); ++i)
	{
		int y = E[q[1]][i];
		vis[SG[y]] = true;
	}
	int t = 0;
	while (vis[t]) ++t;
	if (t == SG[q[1]]) return true;
	
	
	memset(vis, 0, sizeof(vis));
	for (int i = 1; i <= cnt; ++i)
		SG[q[i]] = -1;
	for (int i = 0; i < E[q[1]].size(); ++i)
	{
		int y = E[q[1]][i];
		if (circle[y]) continue;
		vis[SG[y]] = true;
	}
	
	SG[q[1]] = 0;
	while (vis[SG[q[1]]]) ++SG[q[1]];
	++SG[q[1]];
	while (vis[SG[q[1]]]) ++SG[q[1]];
	memset(vis, 0, sizeof(vis));
	for (int i = cnt; i > 1; --i)
		Calc_SG(q[i], 0);
	memset(vis, 0, sizeof(vis));
//	for (int i = 1; i <= N; ++i)
//		cout << i << " " << SG[i] << endl;
	for (int i = 0; i < E[q[1]].size(); ++i)
	{
		int y = E[q[1]][i];
		vis[SG[y]] = true;
	}
	t = 0;
	while (vis[t]) ++t;
	return t == SG[q[1]];
}


int main()
{
//	freopen("in.in", "r", stdin);
//	freopen("out.out", "w", stdout);
	
	int N, x;
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i)
	{
		scanf("%d", &x);
		E[x].push_back(i);
	}
	for (int i = 1; i <= N; ++i) 
		if (!vis[i]) top = 0, DFS(i);

	memset(vis, 0, sizeof(vis));
	memset(SG, -1, sizeof(SG));
	for (int i = 1; i <= N; ++i)
		Calc_SG(i, 1);
	
	puts(Check(N)? "POSSIBLE":"IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 21504
class UnionFind:
    def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def root(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.root(self.parent[x])

    def size(self, x):
        return -parent[root(x)]


N, M = map(int, input().split())

uf_tree = UnionFind(N)
for _ in range(M):
    X, Y, Z = map(int, input().split())
    X -= 1; Y -= 1;
    uf_tree.unite(X, Y)

print(uf_tree._size)


Measured memory_bytes: 5464
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();

        int[] pos = new int[n];
        for (int i = 0; i < n - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                pos[i] = 1;
            }
//            System.out.println("pos:" + pos[i]);
        }

        int[] num = new int[n];
        num[0] = pos[0];
        for (int i = 1; i < n - 1; i++) {
            num[i] = num[i - 1] + pos[i];
//            System.out.println(num[i]);
        }
//        System.out.println();

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int max;
            if (r - 1 - 1 < 0) {
                max = 0;
            } else {
                max = num[r - 1 - 1];
            }
            int min;
            if (l - 1 - 1 < 0) {
                min = 0;
            } else {
                min = num[l - 1 - 1];
            }
            int ans = max - min;
            System.out.println(ans);
        }

        sc.close();
    }

}


Measured memory_bytes: 81600
#include <bits/stdc++.h>
using namespace std;
using Int = long long unsigned int;

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

    Int n,x,ans=0; cin>>n>>x; n-=x; if(x>n)swap(n,x);
    while(1){
        if(!(n%x)){ans+=n*3; break;}
        else {
            Int a=n; ans+=n/x*3*x; n=x; x=a%x;
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include<iostream> 
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath> 
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn=5010, inf=1e9+233;
struct edge{int too, pre;}e[maxn<<1];
int n, x, y, tot;
ll f[maxn][maxn][2], g[maxn][2];
int last[maxn], size[maxn], a[maxn];

template<typename T>
inline void read(T &k)
{
    int f=1; k=0; char c=getchar();
    while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
    while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
    k*=f;
}

inline void add(int x, int y) {e[++tot]=(edge){y, last[x]}; last[x]=tot;}

void dfs(int x, int fa)
{
    // printf("x:%d fa:%d\n", x, fa);
    size[x]=1;

    if(a[x]>0) f[x][0][0]=a[x];
    else f[x][0][1]=a[x];

    // if(x==5) printf("x:%d f[x][0][1]:%lld\n", x, f[x][0][1]);

    for(int i=last[x], too;i;i=e[i].pre)
        if((too=e[i].too)!=fa)
        {
            dfs(too, x);
            memset(g, 0x3f, sizeof(g));
            for(int j=0;j<size[x];j++)
            {
                for(int k=0;k<=size[too];k++)
                {
                    if(a[x]>0)
                    {
                        g[j+k][0]=min(g[j+k][0], f[x][j][0]+f[too][k][0]);
                        g[j+k][1]=min(g[j+k][1], f[x][j][1]+min(f[too][k][0], f[too][k][1]));
                        g[j+k][1]=min(g[j+k][1], min(f[x][j][0], f[x][j][1])+f[too][k][1]);
                        // if(x==2) printf("x:%d too:%d j:%d k:%d f[too][k][1]:%lld g:%lld\n", x, too, j, k, f[too][k][1], g[j+k][1]);
                    }
                    else g[j+k][1]=min(g[j+k][1], f[x][j][1]+min(f[too][k][1], f[too][k][0]));
                }
            }
            memcpy(f[x], g, sizeof(g));
            size[x]+=size[too];
            // printf("x:%d size[x]:%d size[too]:%d\n", x, size[x], size[too]);
            // if(x==5) printf("x:%d f[x][1][1]:%lld f[x][2][1]:%lld\n", x, f[x][1][1], f[x][2][1]);
        }

    for(int i=0;i<size[x];i++) if(f[x][i][1]<0) f[x][i+1][0]=min(f[x][i+1][0], 0ll);//, printf("x:%d qaq\n", x);
    for(int i=0;i<size[x];i++) if(f[x][i][0]<=(ll)(1e13)) f[x][i+1][0]=min(f[x][i+1][0], 0ll);//, printf("x:%d qwq\n", x);
        // printf("x:%d size[x]:%d f[x][size[x]][0]:%lld\n", x, size[x], f[x][size[x]][0]);
    // if(x==5) printf("x:%d f[x][2][1]:%lld f1:%lld f2:%lld\n", x, f[x][2][1], f[6][1][0], f[7][1][0]);
}

int main()
{
    read(n);
    for(int i=1;i<=n;i++) read(a[i]);
    for(int i=1;i<n;i++)
        read(x), read(y), add(x, y), add(y, x);

    memset(f, 0x3f, sizeof(f));
    dfs(1, 0);

    // printf("f[4][1][0]:%lld f[5][1][0]:%lld f[7][3][0]:%lld\n", f[4][1][0], f[5][1][0], f[7][3][0]);
    // printf("f:%lld\n", f[2][3][1]);

    for(int i=0;i<n;i++)
        if(f[1][i][0]<=(ll)(1e13) || f[1][i][1]<0) return printf("%d\n", i), 0;
}


Measured memory_bytes: 393216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int main(){
    int n; cin >> n;
    int v[n],c[n];
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    int ans=0;
    rep(i,n){
        if(v[i]>c[i]) ans+=v[i]-c[i];
    }
    cout << ans << endl;
    return 0;
}

//rate1379

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
vector<vector<int>> v(50);
int n,m;
int ans=0;
vector<bool> pass(10,false);
void dfs(int k){
    bool flag=true;
    pass[k]=true;
    rep(i,n){
        if(!pass[i]){
            flag=false;break;
        }
    }
    if(flag){
        ans++;pass[k]=false;return ;
    }
    else{
        rep(i,v[k].size()){
            if(!pass[v[k][i]]){
                dfs(v[k][i]);
            }
        }
    }
    pass[k]=false;
    //dfsから戻るときに通った記憶をリセットしてく
}

int main(){
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    
    dfs(0);
    cout<<ans<<endl;
    return 0;
}

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

vector<string> ansVec = {"YES", "NO"};

int main()
{
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    long long bFarthest, aFarthest;

    if (a < b)
    {
        bFarthest = b + w * t;
        aFarthest = a + v * t;

        cout << (bFarthest > aFarthest ? ansVec.at(1) : ansVec.at(0)) << endl;
    }
    else
    {
        bFarthest = b - w * t;
        aFarthest = a - v * t;

        cout << (bFarthest < aFarthest ? ansVec.at(1) : ansVec.at(0)) << endl;
    }
}

Measured memory_bytes: 3628
#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 n;
    cin >> n;

    int ans = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        if (i % 2 == 0 && a % 2 == 1)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	double a, b;
	cin >> a >> b;
	cout << ceil((a + b) / 2) << endl;
}

Measured memory_bytes: 256
<?php

class Operator
{
    private $operated_keys;
    private $operations_count;

    public function doOperations()
    {
        fscanf(STDIN, '%d', $this->operations_count);
        $this->operated_keys = new \SplDoublyLinkedList();
        for (;$this->operations_count > 0;$this->operations_count -= 1) {
            $operation = explode(' ', trim(fgets(STDIN)));
            if ($operation[0] === 'insert') {
                $this->operated_keys->unshift($operation[1]);
            } elseif ($operation[0] === 'deleteFirst') {
                $this->operated_keys->shift();
            } elseif ($operation[0] === 'deleteLast') {
                $this->operated_keys->pop();
            } elseif ($operation[0] === 'delete') {
                foreach ($this->operated_keys as $index => $element) {
                    if ($element === $operation[1]) {
                        $this->operated_keys->offsetUnset($index);
                        break;
                    }
                }
            }
        }
    }

    public function getAnswer()
    {
        $keys_operated = array();

        while (count($this->operated_keys) > 0) {
            $keys_operated[] = $this->operated_keys->shift();
        }
        echo implode(' ', $keys_operated), PHP_EOL;
    }
}

$operator = new Operator();
$operator->doOperations();
$operator->getAnswer();



Measured memory_bytes: 136152
#sys.stdin.readline()
import sys
input = sys.stdin.readline
N,K = map(int,input().split())
A = list(map(int,input().split()))

#まずAの左側を全部1にする
#(ex) (K=3)[1,1,1,8,4,6,2,5] -> 2個(k-1個)ずつ1にできることから
#あとは割り算で回数が求まる

min_index = A.index(1)
#左右反転でも回数変わらん,なるべく左側に1を
if(min_index > N//2):
  A.reverse()
  
count = 0
while(1):
  min_index = A.index(1)
  if(min_index == 0):
    break
  if((min_index-(K-1)) >= 0):
    del A[min_index-(K-1):min_index]
  elif((min_index-(K-1)) < 0):
    x = min_index - 1
    del A[0:x+1]
    y = K - min_index - 1
    del A[1:y+1]
  count += 1

if((len(A)-1)%(K-1) == 0):
 count += (len(A)-1)//(K-1)
else:
 count += (len(A)-1)//(K-1) + 1

print(count)    

Measured memory_bytes: 13304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  
///////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int a,b;
	cin>>a>>b;
	if(a<6)
	{
		cout<<"0";
		return 0;
	}
	if(a<13)
	{
		cout<<b/2;
		return 0;
	}
	cout<<b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a[100005],i,j,k;
    cin>>n>>m;
    int sum=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    int cnt=0;
    for(i=0;i<n;i++)
    {
        if(4*m*a[i]>=sum){cnt++;}
    }
    if(cnt>=m){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, K = MAP()

if K < A:
	print(K)
elif A <= K <= A+B:
	print(A)
elif K > A+B:
	print(A - (K-A-B))

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


namespace ACprac
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int n = int.Parse(str[0]);
            int t = int.Parse(str[1]);

            int cost = 1000;
            string rslt = "TLE";

            for(int i = 0; i < n; i++)
            {
                string[] tmp_s = Console.ReadLine().Split(' ');
                int tmp_t = int.Parse(tmp_s[1]);
                int tmp_c = int.Parse(tmp_s[0]);
                if (tmp_t <= t)
                {
                    rslt = cost.ToString();

                    if (cost > tmp_c)
                    {
                        cost = tmp_c;
                        rslt = cost.ToString();
                    }
                }
            }

            Console.WriteLine(rslt);

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
	ll x=0,f=1; char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-')f=-f;
	for(;ch>='0'&&ch<='9';ch=getchar())
		x=x*10+ch-'0';
	return x*f;
}
#define _ read()
#define N 100010

ll n = read(), K = read();
ll a[N], cnt[2];

bool cmp(int a, int b) {
	return a > b;
}

int main() {
	for(int i = 1; i <= n; ++i) a[i] = read();
	ll ans = 0;
	for(ll k = 42; k >= 0; --k) {
		cnt[0] = cnt[1] = 0; 
		for(int i = 1; i <= n; ++i) {
			cnt[(a[i]>>k)&1ll]++;
		}
		if(cnt[0] > cnt[1] && ans + (1ll << k) <= K) ans += (1ll << k);
	}
	ll sum = 0;
	for(int i = 1; i <= n; ++i) {
		sum += ans ^ a[i];
	}
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
long long int n,ans=0;
std::vector<long long int> v;

std::vector<long long int> enum_div(long long int n)
{
	std::vector<long long int> ret;
	for(long long int i=1 ; i*i<=n ; i++){
		if(n%i == 0){
			ret.push_back(i);
			if(i!=1 && i*i!=n)ret.push_back(n/i);
		}
	}
  ret.push_back(n);
  sort(ret.begin(),ret.end());
	return ret;
}

int main(){
  cin >> n;
  v = enum_div(n);
  for (long long int i = 0; i < v.size() ; i++) {
    if(v[i]-1 == 0)continue;
    if(floor(n/(v[i]-1)) == n%(v[i]-1)) ans += (v[i]-1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {

	int x, n;
	cin >> x >> n;

	vector<int> m;
	int tmp;

	for (int i = 0; i < n; i++) {
		cin >> tmp;
		m.push_back(tmp);
	}

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

	int d;
	int ans = 0;
	int mn = 2000;
	for (int i = -100; i < 102; i++) {
		d = abs(x - i);
		if (mn > d) {
			int s = 1;
			for (int j = 0; j < n; j++) {
				if (i == m[j]) {
					s = 0;
				}
			}
			if (s) {
				mn = d;
				ans = i;
			}

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

Measured memory_bytes: 3596
var cnt = 0;

function merge(A, left, mid, right) {
	var n1 = mid - left;
	var n2 = right - mid;
	var L = [];
	var R = [];
	for (var i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (var i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1] = Number.MAX_VALUE;
	R[n2] = Number.MAX_VALUE;
	var i = 0;
	var j = 0;
	for (var k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
}
function mergeSort(A, left, right) {
	if (left + 1 < right) {
		var mid = Math.floor((left + right) / 2);
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

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

var n = +lines.shift();
var A = lines.shift().trim().split(' ').map(function(i){return +i;});

mergeSort(A, 0, n);

console.log(A.join(' '));
console.log(cnt);

Measured memory_bytes: 103080
use std::io;
use std::str::FromStr;

fn main() {
    let (d, n) = {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.split_whitespace();
        (
            i32::from_str(it.next().unwrap()).unwrap(),
            i32::from_str(it.next().unwrap()).unwrap(),
        )
    };

    match (d, n) {
        (0, 100) => println!("{}", 101),
        (0, _) => println!("{}", n),
        (1, 100) => println!("{}", 10100),
        (1, _) => println!("{}", n * 100),
        (2, 100) => println!("{}", 1010000),
        (2, _) => println!("{}", n * 10000),
        (_, _) => {}
    }
}


Measured memory_bytes: 2140
using System;
namespace MSOLUTIONS.Problems
{
    class B
    {
        static void Main()
        {
            string[] inputs = Console.ReadLine().Split(" ");
            int red   = int.Parse(inputs[0]); // read
            int green = int.Parse(inputs[1]); // green
            int blue  = int.Parse(inputs[2]); // blue
            int k = int.Parse(Console.ReadLine());
            // green > red && blue > green
            for (var i = 0; i < k; i++)
            {
                if (green <= red)
                {
                    green *= 2;
                }
                else if (blue <= green)
                {
                    blue *= 2;
                }
            }
            if (green > red && blue > green)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27508
int main (void)
{
    int a, b, k, i;

    scanf("%d %d %d", &a, &b, &k);

    if((b - a) < (k * 2)) {
        for (i = a; i <= b; i++) {
            printf("%d\n", i);
        }
    } else {
        for (i = a; i < a + k; i++) {
            printf("%d\n", i);
        }
        for (i = b - k + 1; i <= b; i++) {
            printf("%d\n", i);
        }
    }
}

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

using namespace std;
typedef long long int lld;

lld n,a[3],d;
map<lld,lld> mm;
int k[3] = {2,3,5};
lld recur(lld n){
	if(mm.find(n)!=mm.end()) return mm[n];
	lld ans = 1e18;
	if((long double)d*(long double)n<ans) ans = min(ans,d*n);
	for(int p=0;p<3;p++){
		lld cc = recur(n/k[p]) + a[p] + (n%k[p])*d;
		ans = min(ans,cc);
		if(n%k[p]!=0){
			lld cc2 = recur((n/k[p])+1) + a[p] + (k[p]-(n%k[p]))*d;
			ans = min(ans,cc2);
		}
	}
	return mm[n] = ans;
}
int main(void){
	int t;
	scanf("%d",&t);
	while(t--){
		mm.clear();
		scanf("%lld%lld%lld%lld%lld",&n,&a[0],&a[1],&a[2],&d);
		mm[1] = d;
		mm[0] = 0;
		printf("%lld\n",recur(n));
	}
	return 0;
}


Measured memory_bytes: 4500
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    String s = sc.next();
    
    if (s.charAt(0) == s.charAt(2)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 21332
#include <stdio.h>
int main(void)
{
	char str[20];
	int W;
	int H;
	int x;
	int y;
	int r;
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d %d %d %d",&W, &H, &x, &y, &r);
	if(W >= x+r && 0 <= x-r && H >= y+r && 0 <= y-r){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int small, big;
  small = min(a,b);
  big = max(a,b);
  rep(i,big){
    cout << small;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n);

  int odd = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 2) odd++;
  }

  cout << odd / (double)n << endl;

  return 0;
}

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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A + B == C + D)
		cout << "Balanced";
	else if (A + B >= C + D)
		cout << "Left";
	else
		cout << "Right";

	return 0;
}

Measured memory_bytes: 256
import sys

NIL = -1

def set_depth(v, depth):
    tree[v][2] = depth
    
    for child in tree[v][1]:
        set_depth(child, depth + 1)

N = int(input())
tree = [[NIL, [], 0, 'leaf'] for _ in range(N)]

for _ in range(N):
    line = [int(i) for i in sys.stdin.readline().split()]
    t_id = line[0]
    children = line[2:]
    tree[t_id][1] = children
    
    if children:
        tree[t_id][3] = 'internal node'
    
    for child in children:
        tree[child][0] = t_id
        
for t_id in range(N):
    if tree[t_id][0] == NIL:
        tree[t_id][3] = 'root'
        r = t_id
        break

set_depth(r, 0)

for t_id in range(N):
    parent = tree[t_id][0]
    depth = tree[t_id][2]
    children = tree[t_id][1]
    type_t = tree[t_id][3]
    
    print('node {}: parent = {}, depth = {}, {}, {}'.format(t_id, parent, depth, type_t, children))

Measured memory_bytes: 37192
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  string s;
  while(cin >> s){
    int n = s.size();
    string r = s;
    reverse(all(r));

    vector< vector<int> > dp(n+1,vector<int>(n+1,0));
    rep(i,n){
      rep(j,n){
	if(s[i] == r[j])dp[i+1][j+1] = dp[i][j]+1;
	else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }

    int m = (dp[n][n]+1)/2;
    string pal;
    int a = n, b = n;
    while(a!=0 && b!=0 && (int)pal.size()<m){
      if(a>0 && b>0 && dp[a][b] == dp[a-1][b-1]+1 && s[a-1]==r[b-1]){
	pal += s[a-1]; a--; b--;
      }else if(a>0 && dp[a][b] == dp[a-1][b]){
	a--;
      }else if(b>0 && dp[a][b] == dp[a][b-1]){
	b--;
      }else{
	exit(1);
      }
    }
    
    for(int i=dp[n][n]/2-1;i>=0;i--)pal += pal[i];
    cout << pal << endl;
  }
}

Measured memory_bytes: 16912
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<sstream>
#include<set>
#include<map>
#include<algorithm>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
typedef long long ll;

int dy[]={-1,0,1,0},dx[]={0,-1,0,1};
int w,h,sy,sx; ll goal=0;

bool v[7][7];
void nul(int y,int x){
	v[y][x]=1;
	rep(d,4){
		int ny=y+dy[d],nx=x+dx[d];
		if(ny<0||nx<0||ny>=h||nx>=w||v[ny][nx])continue;
		nul(ny,nx);
	}
}
bool separate(ll c){
	rep(i,h)rep(j,w)v[i][j]=c&1ll<<i*w+j;
	int cnt=0;
	rep(i,h)rep(j,w)if(!v[i][j]){
		if(cnt++>0)return 1;
		nul(i,j);
	}
	return 0;
}
const int sz=1000003;
ll hash[sz];
bool ins(ll v){
	ll h=v%sz;
	for(;hash[h]!=~0ll;h=(h+1)%sz)if(hash[h]==v)return 1;
	hash[h]=v;
	return 0;
}

bool rec(int y,int x, ll c){
	if(ins(c<<6|y<<3|x))return 0;
	
	rep(d,4){
		int ny=y+dy[d],nx=x+dx[d];
		if(ny<0||nx<0||ny>=h||nx>=w||(c&1ll<<ny*w+nx))continue;
		ll nc=c|1ll<<ny*w+nx;
		
		if(nc==goal&&ny==sy&&nx==sx)return 1;
		if(!separate(nc)&&rec(ny,nx,nc))return 1;
	}
	return 0;
}
int main(){
	while(cin>>w>>h,w){
		sy=-1; sx=-1;
		ll c=0; int t;
		rep(i,h)rep(j,w){
			cin>>t;
			if(t)c^=1ll<<i*w+j;
		}
		goal=(1ll<<h*w)-1;
		
		if(h>4&&w>4&&c==0){
			if(h%2&&w%2)cout<<"No"<<endl;
			else cout<<"Yes"<<endl;
			continue;
		}
		rep(i,h)rep(j,w)if(!(c&1ll<<i*w+j)){
			int cnt=0;
			rep(d,4){
				int ny=i+dy[d],nx=j+dx[d];
				if(ny<0||nx<0||ny>=h||nx>=w||(c&1ll<<ny*w+nx))cnt++;
			}
			if(cnt>2)goto OUT;
		}
		
		rep(i,h)rep(j,w-1)if((c&1ll<<i*w+j)+(c&1ll<<i*w+j+1)==0){
			sy=i; sx=j; goto OUT;
		}
		OUT:if(sy<0){
			cout<<"No"<<endl; continue;
		}
		rep(i,sz)hash[i]=~0ll;
		cout<<(rec(sy,sx,c)?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 8676
n = int(input())
a = input().split(" ")
a = [int(i) for i in a]

tmp = 10**11
tmp2 = 0
count =0 

for i in range(len(a)):
    if (abs(a[i]) < tmp):
        tmp = abs(a[i])
        tmp2 = i
        
    if a[i] < 0:
        count += 1
    
if count % 2 == 0:
    a = [abs(i) for i in a]
    print(sum(a))
else:
    a = [abs(i) for i in a]
    a[tmp2] = a[tmp2]* -1
    print(sum(a))

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

int main() {
	std::string s;
	std::cin >> s;

	bool isOK = true;
	for (int i = 0; i < s.size(); ++i) {
		char c = s[i];

		if (c == 'U' || c == 'D')
			continue;
		if (i % 2 == 0 && c == 'R')
			continue;
		if (i % 2 == 1 && c == 'L')
			continue;

		isOK = false;
		break;
	}

	std::cout << (isOK ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,d,x;
  cin >> n >> d >> x;
  int ans=x,t;
  for (int i=0; i<n; i++) {
    cin >> t;
    ans += (d-1)/t+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main()
{
	int N, K, S = 1;
	int itl = 0;

	cin >> N >> K;

	while (S < K && itl < N) {
		S *= 2;
		itl++;
	}

	for (int i = itl; i < N; i++) {
		S += K;
	}

	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	string S,T;
	std::cin >> S >> T;
	S += T[T.size() - 1];
	if (S == T) {
		std::cout << "Yes" << endl;
	}
	else {
		std::cout << "No" << endl;
	}

	return 0;
}


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


int main()
{
    int s[3], sum = 0;
    for (int i = 0; i < 3; i++)
    {
        cin >> s[i];
        sum += s[i] * pow(10, 2 - i);
    }
    if (sum % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

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

#define int128 long long

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3e5 + 5;

struct Line {
	ll k, b;
	mutable const Line* nx;
	bool operator<(ll x) const {
		if (!nx) return 0;
		return b - nx->b < (nx->k - k) * x;
	}
	bool operator<(const Line& rhs) const {
		return k < rhs.k;
	}
};
// will maintain upper hull for maximum
struct HullDynamic : multiset<Line, less<>> {
	bool bad(iterator y) {
		auto z = next(y);
		if (y == begin()) {
			if (z == end()) return 0;
			return y->k == z->k && y->b <= z->b;
		}
		auto x = prev(y);
		if (z == end()) return y->k == x->k && y->b <= x->b;
		return (x->b - y->b) * (int128)(z->k - y->k) >= (y->b - z->b) * (int128)(y->k - x->k);
	}
	void insert_line(ll k, ll b) {
		auto y = insert({ k, b, 0 });
		if (bad(y)) { erase(y); return; }
		auto z = next(y);
		while (z != end() && bad(z)) z = erase(z);
		if (z != end()) y->nx = &*z;
		while (y != begin() && bad(z = prev(y))) erase(z);
		if (y != begin()) z->nx = &*y;
	}
	ll eval(ll x) {
		auto l = *lower_bound(x);
		return l.k * x + l.b;
	}
};

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	HullDynamic cht;

	ll n, C; cin >> n >> C;

	vector<ll>h(n);
	for (ll i = 0; i < n; i++) cin >> h[i];

	ll cur = 0;
	

	for (ll i = 0; i < n; i++) {
		if (i)cur = C + h[i] * h[i] - cht.eval(h[i]);
		else cur = 0;
		cht.insert_line(2 * h[i], -(h[i] * h[i] + cur));
	}

	cout << cur << endl;

	return 0;
}

/*
5
2 6 15 5 10

4
2 6 15 5

*/

Measured memory_bytes: 14336
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 3100
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
vector<double>v;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
///vector<pair<ll,ll> >adj[MAX+10];
double dp[MAX][MAX];
double calc(ll pos,ll nisi)
{
    if(pos>=n)
    {
        if(nisi>=req) return 1.0;
        else return 0.0;
    }
    else if(dp[pos][nisi]!=-1.0) return dp[pos][nisi];
    double r1=0.00,r2=0.0;
    double head=v[pos];
    double tail=1.00-v[pos];
    r1+=(calc(pos+1,nisi+1)*head);
    r2+=(calc(pos+1,nisi)*tail);
    ///visited[pos][nisi]=true;
    return dp[pos][nisi]=r1+r2;
}
int main()
{
    sf(n);
    req=(n+2)/2;
    FOR(i,n)
    {
         FOR(j,n) dp[i][j]=-1.0;
    }
    FOR(i,n)
    {
        double a;
        scanf("%lf",&a);
        v.p_b(a);
    }
    double ans=calc(0,0);
    printf("%.10lf",ans);
    return 0;
}


Measured memory_bytes: 74112