akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll m,d;
	cin>>m>>d;
	int ans=0;
	range(i,1,m+1)range(j,1,d+1){
		if(j/10>=2 and j%10>=2 and (j/10)*(j%10)==i)ans++;
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 256
#include "iostream"

using namespace std;

int main()
{
	bool f = true;
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < a + b + 1; i++) {
		char c;
		cin >> c;
		if (i == a) { if (c != '-') f = false; }
		else if (c<'0' || c>'9') f = false;
	}
	if (f) cout << "Yes";
	else cout << "No";
	return 0;
}

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


using namespace std;
int main(){
    long int N; cin >> N;
    for (long int i=100000;i>=1;i--){
        if (i*i<=N) {
            cout << i*i << endl;
            return 0;
        }
    }
    
} 

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

ans = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        flg = 0
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flg = 1
                    break
        if flg == 0:
            ans = 1
            break

print('Yes' if ans else 'No')


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

namespace AtCorder1
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.WriteLine(Test(Console.ReadLine().ToList()));
		}

		private static String Test(IEnumerable<char> s)
		{
			var ls = new List<int>();

			do
			{
				var r = s.TakeWhile(t => t == 'R').Count();
				var l = s.Skip(r).TakeWhile(t => t == 'L').Count();
				int h = (r + l) / 2;
				if ((r + l) % 2 == 0)
				{
					ls.AddRange(Enumerable.Repeat(0, r - 1)
						.Append(h)
						.Append(h)
						.Concat(Enumerable.Repeat(0, l - 1)));
				}
				else
				{
					ls.AddRange(Enumerable.Repeat(0, r - 1)
						.Append(h + (r % 2))
						.Append(h + (l % 2))
						.Concat(Enumerable.Repeat(0, l - 1)));
				}

				s = s.Skip(r + l);
			} while (s.Any());

			return String.Join(" ", ls);
		}
	}
}

Measured memory_bytes: 47072
//01
#include<iostream>
#include<algorithm>

using namespace std;

int n;
char g[100][100];

bool fr(int y,int x,int py,int px){
  bool f=true;
  for(int i=0;i<4;i++){
    int d[]={0,1,0,-1,0};
    int jy=y+d[i];
    int jx=x+d[i+1];
    f&=min(jx,jy)<0||n<=max(jx,jy)||(px==jx&&py==jy)||g[jy][jx]==' ';
  }
  return f;
}

int main(){
  int ds;
  cin>>ds;
  while(ds--){
    cin>>n;
    fill(g[0],g[100],' ');
    g[0][0]='#';
    int d=0,y=0,x=0;
    int p=0;
    for(;;){
      int dx[]={0,1,0,-1};
      int dy[]={1,0,-1,0};
      int ny=y+dy[d];
      int nx=x+dx[d];
      int jy=ny+dy[d];
      int jx=nx+dx[d];
      if(0<=min(nx,ny)&&max(nx,ny)<n&&fr(ny,nx,y,x)){
	y=ny;
	x=nx;
	g[ny][nx]='#';
	p=0;
      }else{
	p++;
	d=(d+1)%4;
	if(p>=2){
	  break;
	}
      }
    }
    for(int y=n-1;y>=0;y--){
      for(int x=0;x<n;x++){
	cout<<g[y][x];
      }
      cout<<endl;
    }
    if(ds){
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1168
#include<stdio.h>

int n, A[50];

bool solve(int i, int m) {
  if(m == 0) return true;
  else if(i >= n) return false;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for( i = 0; i < q; i++) {
    scanf("%d", &M);
    if(solve(0, M)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  ll left = 0, right = 0;
  rep(i, n + 1) {
    left = (left + i) % mod;
    right = (right + n - i) % mod;
    if (i >= k - 1) ans = (ans + right - left + 1 + mod) % mod;
  }
  cout << ans << '\n';




  
  return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

const int MOD = 1e9 + 7;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1), b(n + 1);
  for (int i = 1; i <= m; i++) {
    int t; cin >> t;
    b[t] = 1;
  }
  a[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (b[i]) continue;
    (a[i] += a[i - 1]) %= MOD;
    if (i >= 2) (a[i] += a[i - 2]) %= MOD;
  }
  cout << a[n] << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

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

template <typename T> inline string toString(const T &a){ostringstream oss; oss<<a; return oss.str();};

int main(){
    int n, k; cin>>n>>k;
    if(n%k==0) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char

readInt = read :: String -> Integer
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
gets = map read . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

fix x = round (x * 100000)

f [x1,y1,x2,y2,x3,y3,x4,y4] = dx1 * dy2 == dy1 * dx2
  where
    dx1 = x2 - x1
    dy1 = y2 - y1
    dx2 = x4 - x3
    dy2 = y4 - y3

main = getInt >>= flip replicateM gets >>= mapM_ (putStrLn . cond "YES" "NO" . f . map fix)

Measured memory_bytes: 4424
import numpy as np

N, W = map(int, input().split())
wv = np.array([list(map(int, input().split())) for _ in range(N)], dtype="int64")
dp = np.zeros(W + 1, dtype="int64")

for w, v in wv:
    dp[W:w-1:-1] = np.maximum(dp[W:w-1:-1], dp[W-w::-1] + v)
    
print(dp[-1])

Measured memory_bytes: 15504
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	pp := make([][]plane, 4)
	for i := 0; i < n; i++ {
		x := getNextInt(scanner)
		y := getNextInt(scanner)
		u := getNextString(scanner)
		switch u {
		case "U":
			pp[0] = append(pp[0], plane{x: x, y: y})
		case "R":
			pp[1] = append(pp[1], plane{x: x, y: y})
		case "D":
			pp[2] = append(pp[2], plane{x: x, y: y})
		case "L":
			pp[3] = append(pp[3], plane{x: x, y: y})
		}
	}
	var ans int
	ans = math.MaxInt32
	chmin(&ans, mincol(get(pp[0], getx, gety), get(pp[2], getx, gety), 5))
	chmin(&ans, mincol(get(pp[1], gety, getx), get(pp[3], gety, getx), 5))
	chmin(&ans, mincol(get(pp[0], getyx, getx), get(pp[3], getyx, getx), 10))
	chmin(&ans, mincol(get(pp[1], getyx, getx), get(pp[2], getyx, getx), 10))
	chmin(&ans, mincol(get(pp[1], getxy, getx), get(pp[0], getxy, getx), 10))
	chmin(&ans, mincol(get(pp[2], getxy, getx), get(pp[3], getxy, getx), 10))
	if ans == math.MaxInt32 {
		fmt.Fprintln(writer, "SAFE")
		return
	}
	fmt.Fprintln(writer, ans)
}

type plane struct {
	x, y int
}

func getx(p plane) int {
	return p.x
}
func gety(p plane) int {
	return p.y
}
func getyx(p plane) int {
	return p.y - p.x
}
func getxy(p plane) int {
	return p.x + p.y
}
func get(pp []plane, f func(plane) int, g func(plane) int) [][]int {
	n := 600005
	aa := make([][]int, n)
	for _, p := range pp {
		aa[f(p)+200000] = append(aa[f(p)+200000], g(p))
	}
	for i := 0; i < n; i++ {
		sort.Ints(aa[i])
	}
	return aa
}
func mincol(aa [][]int, bb [][]int, m int) int {
	ans := math.MaxInt32
	n := len(aa)
	for i := 0; i < n; i++ {
		if len(aa[i]) == 0 {
			continue
		}
		b := 0
		for j := 0; j < len(aa[i]); j++ {
			for b < len(bb[i]) && aa[i][j] >= bb[i][b] {
				b++
			}
			if b == len(bb[i]) {
				break
			}
			if ans > (bb[i][b]-aa[i][j])*m {
				ans = (bb[i][b] - aa[i][j]) * m
			}
		}
	}
	return ans
}

func chmin(a *int, b int) {
	if *a > b {
		*a = b
	}
}


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

int main()
{
    int a, b;
    vector<string> S;

    cin >> a >> b;

    rep(i, max(a, b))
    {
        cout << min(a, b);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    int  input[100001];
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>input[i];
    }
    vector<int> dp(n+1);
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=i-1;j>=1 && (i-j)<=k;j--)
            dp[i]=min(dp[i],abs(input[i]-input[j]) + dp[j]);
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<int> b(n);
    for(int i=0; i<=n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];
    ll answer=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<2; j++){
            int tmp=min(a[i+j],b[i]);
            answer+=tmp;
            b[i]-=tmp;
            a[i+j]-=tmp;
        }
    }
    cout<<answer;

    return 0;
}


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

#define rep(i,min,sup) for(int i=min;i<sup;i++)
#define per(i,min,sup) for(int i=(sup-1);i>=min;i--)
#define swap(a,b) {a+=b;b=a-b;a-=b;}
#define ll long long

using namespace std;

main(){
  int A[9];
  rep(i,0,9)scanf("%d",&A[i]);
  int N,b,c=0;
  scanf("%d",&N);
  rep(i,0,N){
    scanf("%d",&b);
    rep(j,0,9)if(b==A[j])c+=1<<j;
  }
  int bingo[8]={0b100100100,0b010010010,0b001001001,0b111000000,
                0b000111000,0b000000111,0b100010001,0b001010100};
  rep(i,0,8){
    if(bingo[i]==(bingo[i]&c)){
      printf("Yes");return 0;
    }
  }
  printf("No");
}

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    
    int n;
    cin >> n;
    vi a(n);
    set<int> st;
    rep (i, n) {
        cin >> a[i];
        st.insert(a[i]);
    }

    map<int, int> mp;
    int cnt = 0;
    for (auto itr = st.begin(); itr != st.end(); itr++) mp[*itr] = cnt++;

    rep (i, n) a[i] = mp[a[i]];

    cnt = 0;
    rep (i, n) {
        if (i % 2 != a[i] % 2) cnt++;
    }
    assert(cnt % 2 == 0);
    cout << cnt / 2 << endl;
}

Measured memory_bytes: 15036
// 復習
// cf) https://atcoder.jp/contests/abc077/submissions/7483866

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

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

    int n; cin >> n;
    vector<vector<int>> M(3, vector<int>(n));
    for (auto& r : M) {
        for (int& c : r) cin >> c;
        sort(r.begin(), r.end());
    }

    ll ans = 0;
    for (int c : M[1]) {
        auto itr1 = lower_bound(M[0].begin(), M[0].end(), c);
        auto itr2 = upper_bound(M[2].begin(), M[2].end(), c);
        ans += distance(M[0].begin(), itr1) * distance(itr2, M[2].end());
    }

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

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a < b) rep(i,b) cout << a;
  else rep(i,a) cout << b;
  cout << endl;
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7


N = int(input())
a = [0 for i in range(N)]
for i in range(N):
    a[i] = int(input())

cnt = 0
ans = -1
position = 1
for i in range(N):
    position = a[position-1]
    cnt += 1
    if position == 2:
        ans = cnt
        break

print(ans)


Measured memory_bytes: 9556
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
const int N = 1e5 + 10;

struct edge{ int to, pre; } e[N << 1]; int u[N], l = 0;
void ins(int a, int b) { e[++l] = (edge){b, u[a]}, u[a] = l; }
#define v e[i].to
#define reg(i,a) for(int i = u[a]; i; i = e[i].pre)

int T, n, m;
int pre[N], dfn = 0, dep[N], fa[N], cx, cy;
void dfs(int x, int f) {
	pre[x] = ++dfn, dep[x] = dep[f] + 1, fa[x] = f;
	reg(i,x) if (v != f) {
		if (!pre[v]) dfs(v, x);
		else if (pre[v] > pre[x]) cx = x, cy = v; 
	}
}

LL ans;

int cal(int x, int f, int f1, int f2) {
	int w = 0;
	if (dep[x] & 1) w = 1; else w = -1;
	reg(i,x) if (v != f1 && v != f2 && v != f) w += cal(v, x, f1, f2);
	ans += ab(w);
	return w;
}

void work() {
	memset(u, 0, sizeof(u)); l = 0;
	scanf("%d%d",&n,&m);
	rep(i,1,m) {
		int a, b; scanf("%d%d",&a,&b);
		ins(a, b), ins(b, a);
	}
	if (n & 1) { printf("-1\n"); return; }
	memset(pre, 0, sizeof(pre)); cx = cy = 0;
	dfs(1,0);
	if (!cx && !cy) cx = fa[n], cy = n;
	int ca = 0, cb = 0;
	rep(i,1,n) if (dep[i] & 1) ca++; else cb++;
	if ((dep[cx] ^ dep[cy]) & 1) { if (ca != cb) { printf("-1\n"); return; } }
	static int c[N], cl; cl = 0;
	while (cy != cx) c[++cl] = cy, cy = fa[cy];
	if (c[cl] != cx) c[++cl] = cx;
	static int a[N], s[N]; ans = 0;
	rep(i,1,cl) 
		a[i] = cal(c[i], 0, c[(i == 1 ? cl : i - 1)], c[i % cl + 1]),
		ans -= ab(a[i]);
	s[0] = 0; rep(i,1,cl) s[i] = s[i - 1] + a[i];
	int x;
	if (!(cl & 1)) {
		nth_element(s + 1, s + ((cl + 1) >> 1), s + cl + 1);
		x = s[(cl + 1) >> 1];
	} else x = (ca - cb) / 2;
	rep(i,1,cl) ans = ans + ab(s[i] - x);
	printf("%lld\n",ans);
}

int main() {
	work();
	return 0;
}


Measured memory_bytes: 9216
//////////////////////////////////////
////       ABHINASH GIRI          ////
/////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define pr 4294967296   // 2^32
#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define high 1000000001
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             -1e18
#define pinf              1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define e               1000000000
#define w(x)            int t; cin>>t; while(t--)
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define co(x) cout<<(x)<<"\n"
#define endl "\n"
typedef unsigned long int  ul;
//typedef unsigned long long int ull;
typedef unsigned long long  int  li;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<long int> vl;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long int,long int>> vpl;
typedef vector<pair<long long int,long long int>> vpll;
typedef long long ll;
int main() {
    std::chrono::time_point<std::chrono::high_resolution_clock> start_timer, end_timer;
    start_timer = std::chrono::high_resolution_clock::now();
    bool show_time = false;  //  change it to true when needed;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif

    /* Cook your Code  */
    fast;
    ll a,b,c,k,s=0;
    cin>>a>>b>>c>>k;
    if(a>=k)
    {
        s+=k;
    }
    else if(a>0)
    {
       s+=a;
       k-=a;
    }
    if(k>0)
    {
       if(b>=k)
       {
           k=0;

       }
       else if(b>0) { k-=b; }
       if(k>0 and c>=k)
       {
           s-=k;
       }
       else if(k>0 and c<k)
       {
           s-=c;
           k-=c;
       }
       cout<<s<<endl;
    }

    end_timer = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_timer-start_timer).count();
    if(show_time)
    {cout << "\\nElapsed Time: " << elapsed_time << "ms\\n";}

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n, ans=0;
unordered_map<string, ll>store;

int main(){
	IOS
	cin >> n;
	for(int i=0;i<n;i++){
		string x;
		cin >> x;
		sort(x.begin(), x.end());
		ans+=store[x];
		store[x]++;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 10424
#include <iostream>
// Solution for task: https://informatics.msk.ru/mod/statements/view3.php?id=207&chapterid=58#1
// If you find any mistakes, please write me in Telegram (@d1aas)
using namespace std;



int main() {
    int n;
    cin >> n;
    cout << n * n * n;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val L = IntArray(N) { sc.next().toInt() }.sorted().toIntArray()
        var ans = 0L
        for (i in 0 until N - 2) {
            for (j in i + 1 until N - 1) {
                if (L[i] == L[j]) continue
                for (k in j + 1 until N) {
                    if (L[j] == L[k]) continue
                    if (L[i] + L[j] > L[k]) {
                        ans++
                    }
                }
            }
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 41256
#include<stdio.h>
int main()
{
	int a, b, c, x;
	scanf("%d %d %d %d", &a, &b, &c, &x);
	int cnt = 0;
	for(int i = 0; i <= a; i++)
	{
		for(int j = 0; j <= b; j++)
		{
			for(int k = 0; k <= c; k++)
			{
				if(500 * i + 100 * j + 50 * k == x)
				{
					cnt++;
				}
			}
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
#include  <cmath>
#include  <fstream>
#include  <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
using namespace std;


int main(void)
{
    int Num_max;
    cin >> Num_max;
    long int Sum = 0;
    for(int i=1; i<=Num_max; i++)
    {
        if(i%3 !=0 && i%5 != 0)
        {
            Sum += i;
        }

    }
    cout << Sum << endl;



    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n, a, b; cin >> n >> a >> b;
    int ans = min(a * n, b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int r;
	scanf("%d", &r);

	if (r < 1200) {
		puts("ABC");
	}
	else if (r < 2800) {
		puts("ARC");
	}
	else {
		puts("AGC");
	}
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF = 10 ** 9
N = int(input())
h = list(map(int, input().split()))
def chmin(dp, idx, b):
    if dp[idx] > b:
        dp[idx] = b
        return True
    return False
def solve(dp, i):
    if i == 0:return 0
    if dp[i] < INF: return dp[i]
    chmin(dp, i, solve(dp, i-1) + abs(h[i]-h[i-1]))
    chmin(dp, i, solve(dp, i-2) + abs(h[i]-h[i-2]))
    return dp[i]
def main():
    dp = [INF] * N
    dp[0] = 0
    dp[1] = abs(h[0]-h[1])
    print(solve(dp, N-1))
if __name__ == "__main__":
    main()

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  string ans = "";

  REP(i, n) {
    ans += s[i];
    ans += t[i];
  }

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

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

typedef long long ll;

const int N = 1e9+7;

ll h, w, n, ans[10];
set<pair<ll,ll>> s;

int main () {
    cin >> h >> w >> n;
    ans[0] = (h-2)*(w-2);
    for (int i = 0; i < n; i++) {
        int a, b; cin >> a >> b;
        for (int ai = a-1; ai <= a+1; ai++) {
            if (ai <= 1 || ai >= h) continue;
            for (int bi = b-1; bi <= b+1; bi++) {
                if (bi <= 1 || bi >= w) continue;
                ll temp = 0;
                for (int j = ai-1; j <= ai+1; j++)
                    for (int k = bi-1; k <= bi+1; k++) 
                        if (s.count({j,k}))
                            temp++;
                ans[temp]--;
                ans[temp+1]++;
            }
        }
        s.insert({a,b});
    }
    for (int i = 0; i < 10; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 6528
N, K = map(int, input().split())
L = list(map(int, input().split()))
E = [(v+1)/2 for v in L]
tmp = sum(E[:K])
ans = tmp
for l, p in zip(E[K:], E):
    tmp = tmp+l-p
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 24812
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int inH = stdin.nextInt();
		int inW = stdin.nextInt();

		char[][] grid = new char[inH][];
		int white = 0;
		for (int h = 0; h < inH; h++) {
			grid[h] = stdin.next().toCharArray();
			for (int w = 0; w < inW; w++) {
				if (grid[h][w] == '.') {
					white++;
				}
			}
		}

		int[][] act = new int[inH][inW];
		act[inH - 1][inW - 1] = 1;
		int updateCount = 0;
		while ((act[0][0] == 0) && (updateCount < (inH * inW))) {
			int[][] next = new int[inH][inW];
			for (int h = 0; h < inH; h++) {
				for (int w = 0; w < inW; w++) {
					next[h][w] = getCount(act, grid, h, w);
				}
			}

			act = next;
			updateCount++;
		}

		if (updateCount == (inH * inW)) {
			System.out.println(-1);
			return;
		}

		int moveCount = 1;
		int h = 0;
		int w = 0;

		while ((h != (inH - 1)) || (w != (inW - 1))) {
			int nextH = h;
			int nextW = w;
			int max = act[h][w];

			if (((h - 1) >= 0) && (act[h - 1][w] > max)) {
				max = act[h - 1][w];
				nextH = h - 1;
				nextW = w;
			}
			if (((h + 1) < act.length) && (act[h + 1][w] > max)) {
				max = act[h + 1][w];
				nextH = h + 1;
				nextW = w;
			}
			if (((w - 1) >= 0) && (act[h][w - 1] > max)) {
				max = act[h][w - 1];
				nextH = h;
				nextW = w - 1;
			}
			if (((w + 1) < act[h].length) && (act[h][w + 1] > max)) {
				max = act[h][w + 1];
				nextH = h;
				nextW = w + 1;
			}

			h = nextH;
			w = nextW;
			moveCount++;
		}

		System.out.println(white - moveCount);
	}

	private static int getCount(int[][] act, char[][] grid, int h, int w) {
		if (grid[h][w] == '#') {
			return 0;
		}
		else if ((h == (act.length - 1)) && (w == (act[h].length - 1))) {
			return act[h][w] + 1;
		}

		int max = act[h][w];
		if ((h - 1) >= 0) {
			max = Math.max(max, act[h - 1][w]);
		}
		if ((h + 1) < act.length) {
			max = Math.max(max, act[h + 1][w]);
		}
		if ((w - 1) >= 0) {
			max = Math.max(max, act[h][w - 1]);
		}
		if ((w + 1) < act[h].length) {
			max = Math.max(max, act[h][w + 1]);
		}

		return max;
	}
}


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

long long func(long long x){
    if(x <= 0) return 0;
    long long res = 0;
    for(int i = 0; i < 40; i++){
        long long hoge, foo, bar, cnt;
        hoge = (1LL << (i+1));
        foo = x / hoge;
        bar = x % hoge;
        cnt = foo * hoge / 2;
        cnt += max(bar - hoge / 2 + 1, 0LL);
        if(cnt%2 == 1) res |= (1LL << i);
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a, b;
    cin >> a >> b;
    cout << (func(b) ^ func(a-1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	ll n, a, ans = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a;
		while (true) {
			if (a % 2 == 1 || a == 0)break;
			ans++;
			a /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
  char w,x,y,z;
  scanf("%c %c %c %c",&w,&x,&y,&z);
  if ((w==x&&x==y)||(x==y&&y==z)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include <string.h>
using namespace std;
typedef long long ll;
ll t=0,n,m;
ll y,z;
ll i,j,k;
char c[1000005];
int main()
{
    ll h,x=0,j,ans=0,ma=0;
        for(i=1; i<=3; i++)
        {
            scanf("%c",&c[i]);
           if(c[i]=='R')
           {
               ans++;
               if(ma<ans)
               {
                   ma=ans;
               }
           }
           else
           {
               ans=0;
           }
        }
        printf("%lld\n",ma);

    return 0;
}


Measured memory_bytes: 3812
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

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

int main(){

	int N;
	cin >> N;
	vector<ll> A(N), B(N);
	for(int i = 0; i < N; i ++){
		cin >> A[i] >> B[i];
	}
	ll addNum = 0;
	for(int i = N - 1; i >= 0; i --){
		if((A[i] + addNum)%B[i] != 0)addNum += B[i] - (A[i] + addNum)%B[i];
	}
	cout << addNum << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>;
int main(){
	long long a,b,x;
	scanf("%lld%lld%lld",&a,&b,&x);
	if(a>=1){
		printf("%lld\n",(b/x+1)-((a-1)/x+1));
	}
	
	else{
		printf("%lld\n",b/x+1);
	}
	return 0;
}

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

using namespace std;

int main(){
  long long w,h,x,y;
  cin >> w >> h >> x >> y;
  int s=0;
  if(w%2==0 && h%2==0 && x==w/2 && y==h/2){
    s=1;
  }
  cout << (long long)w*h/2.0 <<" "<< s << endl;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int get_exp2(ll n) {
	
	ll a = 1;
	ll b = 0;
	while (true) {
		if (a <= n && n < a * 2) break;
		a *= 2;
		b += 1;
	}

	return b;

}


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	ll h; cin >> h;
	int n = get_exp2(h);
	ll ans = 0;
	ll j = 1;
	rep(i, n + 1) {
		ans += j;
		j *= 2;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll H, W, K;
    char c;
    cin >> H >> W >> K;
    vector<vector<ll>> fs(H, vector<ll>(W, 0));

    rep(i, H){
        rep(j, W){
            cin >> c;
            fs[i][j] = (c=='.');
        }
    }
    // cout << "ok" <<endl;
    ll ans = 0;
    for(ll bit=0;bit<(1<<H); ++bit){
        set<ll> use_row;
        for(ll w=0;w<H;++w){
            if(bit & (1<<w)){
                use_row.insert(w);
            }
        }
        for(ll bit2=0;bit2<(1<<W); ++bit2){
            set<ll> use_col;
            for(ll w=0;w<W;++w){
                if(bit2 & (1<<w)){
                    use_col.insert(w);
                }
            }
            vector<vector<ll>> fs2(H, vector<ll>(W, 0));
            rep(h, H){
                bool is_h_ok = use_row.find(h) != use_row.end();
                rep(w, W){
                    bool is_w_ok = use_col.find(w)!= use_col.end();
                    fs2[h][w] = (is_h_ok || is_w_ok);
                }
            }
            ll this_k = 0;
            rep(h, H){
                rep(w, W){
                    this_k += (fs2[h][w] == 0 && fs[h][w] == 0);
                }
            }
            if(this_k == K){
                ans += 1;
            }
        }
    }
    cout << ans <<endl;
}

int main(){
    Main();
}

Measured memory_bytes: 3160
import sys
input = sys.stdin.readline

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

LOW=[B[i]-A[i] for i in range(n) if B[i]>A[i]]
HIGH=[A[i]-B[i] for i in range(n) if A[i]>B[i]]

HIGH.sort(reverse=True)

ANS=len(LOW)
rest=sum(LOW)

i=0
while rest>0:
    if i==len(HIGH):
        print(-1)
        sys.exit()
    rest-=HIGH[i]
    i+=1
    ANS+=1

print(ANS)

Measured memory_bytes: 18992
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

unsigned long long int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = -1, mini = 9999, counter = 0, startp = 0, endp = 0, checker = 0;
std::vector <char> vec{}, vecsec{}, vecth{};
int iremono[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input, one, two;
char rev[100001];
unsigned long long int kakunou2[101][101] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{

	cin >> a>>b>>c;
	if (b > a*c) {
		cout << c << endl;
	}
	else {
		cout << b / a << endl;
	}
	
}


Measured memory_bytes: 256
abcd = input()

n = 2 ** 3
result = ''

for i in range(n):
  bin_n = bin(i)[2:]
  bin_n = '0' * (3 - len(bin_n)) + bin_n

  num = int(abcd[0])
  for j in range(3):
    if bin_n[j] == '0':
      num += int(abcd[j+1])

    else:
      num -= int(abcd[j+1])

  if num == 7:
    result = bin_n

print(abcd[0], end='')
print('+' if result[0] == '0' else '-', end='')
print(abcd[1], end='')
print('+' if result[1] == '0' else '-', end='')
print(abcd[2], end='')
print('+' if result[2] == '0' else '-', end='')
print(abcd[3], end='')
print('=7')

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

using namespace std;

typedef vector<int> vec;

int cnt=0;

void Merge_Sort(vec& A)
{
	int n=A.size();
	if(n==1) return;
	cnt+=A.size();
	vec A1,A2;
	for(int i=0;i<n;i++)
		if(i<(n>>1))
			A1.push_back(A[i]);
		else
			A2.push_back(A[i]);
	Merge_Sort(A1);Merge_Sort(A2);
	int t=0,t1=0,t2=0,n1=A1.size(),n2=A2.size();
	while(t1<n1&&t2<n2)
	{
		if(A1[t1]<A2[t2])
			A[t++]=A1[t1++];
		else
			A[t++]=A2[t2++];
	}
	while(t1<n1) A[t++]=A1[t1++];
	while(t2<n2) A[t++]=A2[t2++];
}

int main()
{
	int n;
	vec A;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int t;
		scanf("%d",&t);
		A.push_back(t);
	}
	Merge_Sort(A);
	for(int i=0;i<n;i++)
		printf("%d%c",A[i],i+1==n?'\n':' ');
	printf("%d\n",cnt);
}

Measured memory_bytes: 8764
/* 
	今日も一日がんばるぞい
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];//ソートするやつ
    vector<int> v;
    REP(i,n){
        scanf("%d",&a[i]);
        v.push_back(a[i]);
    }
    sort(v.begin(),v.end());
    int num1 = v[(n-1)/2];
    int num2 = v[n/2];
    for(int i:a){
        if(i<=num1)COUT(num2);
        else if(num2<=i)COUT(num1);
    }
    return 0;
}


Measured memory_bytes: 3828
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

index = None
mindiff = 1000000000
for i in range(1, n + 1):
  diff = abs(t - a - 0.006 * h[i - 1])
  if mindiff > diff:
    mindiff = diff
    index = i

print(index)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int X, ans=1;

  cin >> X;

  for(int i = 2; i <= X; i++){
    int t = i;
    if(X < t*t) break;
    while(t <= X) t *= i;
    t /= i;
    if(ans < t) ans = t;
  }

  cout << ans << endl;

	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

static const char d[] = "23456789TJQKA";

int main() {
	char trump;
	while(cin >> trump && trump != '#') {
		int rank[13][4];
		char suit[13][4];
		REP(j,4)REP(i,13) {
			char r;
			cin >> r >> suit[i][j];
			rank[i][j] = find(&d[0], &d[13], r) - &d[0];
		}
		int pt[] = {-6, -6};
		int leader = 0;
		REP(i,13) {
			char led = suit[i][leader];
			REP(j,4)if(suit[i][j] == trump)
				led = trump;
			int w = 0, g = -1;
			REP(j,4)if(suit[i][j] == led && g < rank[i][j])
				g = rank[i][w = j];
			pt[w%2]++;
			leader = w;
		}
		int w = pt[0] < pt[1];
		cout << (w ? "EW " : "NS ") << pt[w] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int A = NM[0];
		int B = NM[1];
		
		if(A<=5) {print(0);}
		else if(A<=12) {print(B/2);}
		else {print(B);}
		
		//String[] s = readLine();
		//print(num);
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 22996
#include<cstdio>
#include<cstring>

struct Node{
    int data;
    Node *prev;
    Node *next;
};

class LNode{
private:
    Node *head;
    Node *last;
public:
    LNode(){
        head = new Node;
        head->next = NULL;
        head->prev = NULL;
        last = head;
    }
    ~LNode(){
        Node *p = head, *q;
        while(p){
            q = p;
            p = p->next;
            delete q;
        }
    }
    void insert(int x){
        Node *q = new Node;
        if(!(head->next)) last = q;
        q->data = x;
        q->prev = head;
        q->next = head->next;
        head->next = q;
        if(q->next)
            q->next->prev = q;
    }
    void Delete(int x){
        Node *q = head;
        while(q->next){
            q = q->next;
            if(q->data == x){
                if(last == q) last = last->prev;
                Node *p = q->prev;
                p->next = q->next;
                if(p->next)
                    p->next->prev = p;
                delete q;
                break;
            }
        }
    }
    void DeleteFirst(){
        Node* p = head->next;
        head->next = p->next;
        if(p->next)
            p->next->prev = head;
        delete p;
    }
    void DeleteLast(){
        Node *q = last->prev;
        delete last;
        last = q;
        q->next = NULL;
    }
    void print(){
        Node *p = head;
        int first = 1;
        while(p->next){
            p = p->next;
            if(first) first = 0;
            else printf(" ");
            printf("%d", p->data);
        }
        puts("");
    }
};

int main(){
    LNode a;
    char opt[20];
    int n;
    scanf("%d", &n);
    while(n--){
        scanf("%s", opt);
        if(!strcmp(opt, "insert")){
            int x;
            scanf("%d", &x);
            a.insert(x);
        }
        else if(!strcmp(opt, "delete")){
            int x;
            scanf("%d", &x);
            a.Delete(x);
        }
        else if(!strcmp(opt, "deleteFirst")){
            a.DeleteFirst();
        }
        else if(!strcmp(opt, "deleteLast")){
            a.DeleteLast();
        }
    }
    a.print();
    return 0;
}



Measured memory_bytes: 33812
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int Max = 10 + 1e8;
int main()
{
	int n; cin >> n;
	vector<int> p(n);
	vector<int> q(n);
	vector<int> a(n);
	rep(i, n) cin >> p[i];
	rep(i, n) cin >> q[i];
	int drn, frx;
	bool ok = false;
	bool okk = false;
	a = p;
	int cnt = 0;
	sort(a.begin(), a.end());
	do {
		if (a == p) {
			frx = cnt;
			ok = true;
		}
		if (a == q) {
			drn = cnt;
			okk = true;
		}
		if (ok and okk)
			break;

		cnt++;
		
	} while (next_permutation(a.begin(), a.end()));
	cout << abs(drn - frx);

}

Measured memory_bytes: 3588
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    auto nt = aryread;
    long r = long.max;
    foreach (i; 0 .. nt[0])
    {
        auto tmp = aryread;
        if (tmp[1] <= nt[1])
        {
            r = min(r,tmp[0]);
        }
    }
    if (r == long.max)
    {
        writeln("TLE");
        return;
    }
    writeln(r);
}


Measured memory_bytes: 256