akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef vi poly;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int mod=998244353;
namespace Poly{
	const int N=(1<<20)+5,g=3;
	int power(int x,int p){
		int res=1;
		for(;p;p>>=1,x=(ll)x*x%mod)
			if(p&1)res=(ll)res*x%mod;
		return res;
	}
	int fix(const int x){
		return x>=mod?x-mod:x;
	}
	void dft(poly &A,int n){
		static ull W[N<<1],*H[30],*las=W,mx=0;
		for(;mx<n;mx++){
			H[mx]=las;ull w=1,wn=power(g,(mod-1)>>(mx+1));
			REP(i,1<<mx)*las++=w,w=w*wn%mod;
		}
		if(A.size()!=(1<<n))A.resize(1<<n);
		static ull a[N];
		for(int i=0,j=0;i<(1<<n);++i){
			a[i]=A[j];
			for(int k=1<<(n-1);(j^=k)<k;k>>=1);
		}
		for(int k=0,d=1;k<n;k++,d<<=1)
			for(int i=0;i<(1<<n);i+=(d<<1)){
				ull *l=a+i,*r=a+i+d,*w=H[k],t;
				for(int j=0;j<d;j++,l++,r++){
					t=(*r)*(*w++)%mod;
					*r=*l+mod-t,*l+=t;
				}
			}
		REP(i,1<<n)A[i]=a[i]%mod;
	}
	void idft(poly &a,int n){
		a.resize(1<<n),reverse(a.begin()+1,a.end());
		dft(a,n);int inv=power(1<<n,mod-2);
		REP(i,1<<n)a[i]=(ll)a[i]*inv%mod;
	}
	poly FIX(poly a){
		while(!a.empty()&&!a.back())a.pop_back();
		return a;
	}
	poly add(poly a,poly b,int op=0){
		a.resize(max(a.size(),b.size()));
		REP(i,b.size())a[i]=fix(op?a[i]+mod-b[i]:a[i]+b[i]);
		return FIX(a);
	}
	poly mul(poly a,poly b,int t=1){
		if(t==1&&min(a.size(),b.size())<=8){
			poly c(a.size()+b.size(),0);
			REP(i,a.size())REP(j,b.size())
				c[i+j]=(c[i+j]+(ll)a[i]*b[j])%mod;
			return FIX(c);
		}
		int n=1,aim=a.size()*t+b.size();
		while((1<<n)<=aim)n++;
		dft(a,n),dft(b,n);
		if(t==1)REP(i,1<<n)a[i]=(ll)a[i]*b[i]%mod;
		else REP(i,1<<n)a[i]=(ll)a[i]*a[i]%mod*b[i]%mod;
		idft(a,n),a.resize(aim);
		return FIX(a);
	}
}

const int N=205,M=8005;
int fac[M],rev[M],f[N][M],n,m;
void init(int n){
	fac[0]=1;
	rep(i,1,n)fac[i]=(ll)fac[i-1]*i%mod;
	rev[n]=Poly::power(fac[n],mod-2);
	per(i,n,1)rev[i-1]=(ll)rev[i]*i%mod;
}

poly A,B,C;

int main(){
	read(m),read(n),init(m+2);
	rep(i,0,m)f[n+1][i]=(ll)fac[m]*rev[i]%mod*rev[m-i]%mod;
	A.resize(m+1),B.resize(m+1);
	per(i,n,1){
		rep(j,1,m){
			A[j]=(ll)fac[j+2]*f[i+1][j]%mod;
			B[m-j]=rev[j+2];
		}
		C=Poly::mul(A,B);
		rep(j,0,m)
			f[i][j]=((ll)C[m+j]*rev[j]
				   +((ll)j*(j+1)/2+1)%mod*f[i+1][j])%mod;
	}
	printf("%d\n",f[1][0]);
	return 0;
}

Measured memory_bytes: 10760
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    ll n, k, a[100005] = {}, b[100005] = {};
    cin >> n >> k;
    for (ll i = 1; i <= n; i++) {
        cin >> a[i];
        ll t = max(0LL, a[i]);
        if (i == 1)b[1] = t;
        else b[i] = b[i - 1] + t;
    }
    for (ll i = 1; i <= n; i++) {
        a[i] += a[i - 1];
    }
    ll ans = -LLINF;
    for (ll i = 1; i <= n - k + 1; i++) {
        ll t = a[i + k - 1] - a[i - 1] + b[i - 1] - b[0] + b[n] - b[i + k - 1];
        ans = max(ans, t);
        t = b[i - 1] - b[0] + b[n] - b[i + k - 1];
        ans = max(ans, t);
    }
    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++)
using LL = long long;
using P = pair<int,int>;


int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int ans = min(B, D) - max(A, C);
	cout << max(0, ans) << endl;
}












Measured memory_bytes: 3572
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	A := sc.nextInt()
	B := sc.nextInt()
	C := sc.nextInt()
	K := sc.nextInt()

	sum := 0
	if A < K {
		sum += A
	} else {
		fmt.Println(K)
		return 0
	}
	K -= A

	if B < K {
		sum += 0
	} else {
		fmt.Println(sum)
		return 0
	}
	K -= B

	if C < K {
		sum -= C
		fmt.Println(sum)
	} else {
		fmt.Println(sum - K)
		return 0
	}

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 1756
#include <iostream>
#include <fstream>

int main(void){

        int a, b, c;

        std::cin >> a >> b;
        c = a * b;

        if( c%2 == 0){ 
                std::cout << "Even" << std::endl;
        }else{
                std::cout << "Odd" << std::endl;
        }   

        return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 300005
using namespace std;
ll domod(ll a, ll b){
    a = (a * b) % mod;
    while(a < 0)
        a += mod;
    return a;
}
int main()
{
    FLASH
    ll n,k,ans = 1;
    cin >> n >> k;
    vector<ll> po,ne;
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;
        if(x > 0){
            po.pb(x);
        }
        else{
            ne.pb(x);
        }
    }
    ll nn = po.size(),mm = ne.size(),pos,neg;
    neg = 0,pos = nn;
    sort(all(po));
    reverse(all(po));
    sort(all(ne));
    if(k == n){
        for(int i = 0; i < (int)po.size(); i++)ans = domod(ans,po[i]);
        for(int i = 0; i < (int)ne.size(); i++)ans = domod(ans,ne[i]);
        cout << ans << '\n';
        return 0;
    }
    if(nn == 0){
        if(k % 2 == 1)
        reverse(all(ne));
        for(int i = 0; i < k; i++)ans = domod(ans,ne[i]);
        cout << ans << '\n' ;
        return 0;
    }
    pos = min(nn,k);
    neg = k - pos;
    if(neg % 2 == 1 && neg + 1 <= mm){
        pos--;
        neg++;
    }
    while(neg + 1 <= mm - 1 && pos - 2 >= 0 && ne[neg] * ne[neg + 1]  > po[pos - 1] * po[pos - 2]){
        neg += 2;
        pos -= 2;
    }
    for(int i = 0; i < pos; i++)
        ans = domod(ans,po[i]);
    for(int i = 0; i < neg; i++)
        ans = domod(ans,ne[i]);
    cout << ans << '\n' ;
    return 0;
}


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

ll h,w,m;

int main(){
    cin >> h >> w >> m;
    unordered_set<ll> s;
    vector<ll> row(h,0),col(w,0);

    rep(i,m){
        ll y,x;
        cin >> y >> x;
        y--, x--;
        row.at(y)++, col.at(x)++;
        s.insert(1e6*y + x);
    }

    vector<ll> row_cand(0),col_cand(0);
    ll row_maxnum = 0, col_maxnum = 0;
    rep(i,h){
        row_maxnum = max(row_maxnum,row.at(i));
    }
    rep(i,w){
        col_maxnum = max(col_maxnum,col.at(i));
    }
    rep(i,h){
        if(row.at(i) == row_maxnum) row_cand.emplace_back(i);
    }
    rep(i,w){
        if(col.at(i) == col_maxnum) col_cand.emplace_back(i);
    }

    bool flag = 1;
    for(auto i:row_cand){
        for(auto j:col_cand){
            if(!s.count(1e6*i+j)){
                flag = 0;
                break;
            }
        }
        if(!flag) break;
    }
    cout << row_maxnum + col_maxnum - flag << "\n";
    return 0;
}

Measured memory_bytes: 29840
#ifdef APTEST
#include "debug_tools/program.h"
#endif
#include <iostream>
using namespace std;
const unsigned int maxn = 100000, maxm = 100000;

struct edge
{
    unsigned int to;
    const edge* pre;
} ed[maxm * 2 + 1];
const edge* head[maxn + 1];
unsigned long long siz[2][maxn + 1];
bool col[maxn + 1], vis[maxn + 1];

void addEdge(const unsigned int from, const unsigned int to)
{
    static edge* cur = ed;
    cur->to = to;
    cur->pre = head[from];
    head[from] = cur;
    ++cur;
}
bool dfs(const unsigned int x, const unsigned int sta)
{
    ++siz[col[x]][sta];
    vis[x] = true;
    bool ret = true;
    for (const edge* i = head[x]; i; i = i->pre)
    {
        const unsigned int to = i->to;
        if (vis[to])
        {
            if (col[to] == col[x])
                ret = false;
            continue;
        }
        col[to] = !col[x];
        ret &= dfs(to, sta);
    }
    return ret;
}
int main()
{
#ifndef APTEST
    ios_base::sync_with_stdio(false);
#endif
    unsigned int n, m;
    cin >> n >> m;
    for (unsigned int i = 0; i < m; ++i)
    {
        unsigned int u, v;
        cin >> u >> v;
        addEdge(u, v);
        addEdge(v, u);
    }
    unsigned long long ret = 0;
    for (unsigned int i = 1; i <= n; ++i)
        if (!vis[i])
        {
            const bool typ = dfs(i, i);
            const unsigned long long s = siz[0][i] + siz[1][i];
            ret += typ ? siz[0][i] * siz[1][i] : s * (s - 1) / 2;
        }
    cout << ret - m << endl;
    return 0;
}

Measured memory_bytes: 8156
count=0
answer=[]
while count<50:
    m,f,r=(int(x) for x in input().split())
    if m==-1 and f==-1 and r==-1:
        break
    if m==-1 or f==-1:
        answer.append('F')
    elif m+f>=80:
        answer.append('A')
    elif 65<=m+f<80:
        answer.append('B')
    elif 50<=m+f<65:
        answer.append('C')
    elif 30<=m+f<50:
        if r>=50:
            answer.append('C')
        else:
            answer.append('D')
    else:
        answer.append('F')
    count+=1
for i in answer:
    print(i)


Measured memory_bytes: 5600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  multiset<int> mst;
  mst.insert(A[0]);
  for(int i = 1; i < N; i++) {
    if(A[i] > *(mst.begin())) {
      auto f = mst.lower_bound(A[i]);
      auto l = f;
      f--;
      mst.erase(f, l);
    }
    mst.insert(A[i]);
  }
  cout << mst.size() << endl;
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define EPS 1e-10
using namespace std;
typedef long long ll;
struct Point{
	double x,y;
	Point(double x = 0.0,double y = 0.0): x(x),y(y) {}
	Point operator + (Point p){
		return Point(x + p.x,y + p.y);
	}
	Point operator - (Point p){
		return Point(x - p.x,y - p.y);
	}
	Point operator * (double lambda){
		return Point(x * lambda,y * lambda);
	}
	Point operator / (double lambda){
		return Point(x / lambda,y / lambda);
	}
	Point operator - (){
		return Point(-x,-y);
	}
	double norm(){
		return x * x + y * y;
	}
	double abs_(){
		return sqrt(norm());
	}
	bool operator == (const Point &p)const
	{
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
	bool operator < (const Point &p)const
	{
		if(abs(x - p.x) < EPS) return y < p.y;
		else return x < p.x;
	}
};
typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(Point p1 = Point(),Point p2 = Point()): p1(p1),p2(p2) {}
};
typedef Segment Line;
struct Circle{
	Point c;
	double r;
	Circle(Point c = Point(),double r = 0.0): c(c),r(r) {}
};
typedef vector<Point> Polygon;
double dot(Vector a,Vector b){
	return a.x * b.x + a.y * b.y;
}
double det(Vector a,Vector b){
	return a.x * b.y - b.x * a.y;
}
Vector rot(Vector a,double theta){//rotate.
	double x1 = cos(theta) * a.x - sin(theta) * a.y;
	double y1 = sin(theta) * a.x + cos(theta) * a.y;
	return Point(x1,y1);
}
vector <Point> commonTangents(Circle o1,Circle o2){
	double rdif = o1.r - o2.r,rsum = o1.r + o2.r;
	Vector a = o2.c - o1.c,b = a / a.abs_() * o1.r;
	vector <Point> res;
	res.clear();
	double alpha;
 	if(abs(abs(rdif) - a.abs_()) < EPS){
		if(rdif < 0) alpha = acos(-1);
		else alpha = acos(1);
		res.push_back(o1.c + rot(b,alpha));
	}else if(abs(rdif) < a.abs_() - EPS){
		alpha = acos(rdif / a.abs_());
		res.push_back(o1.c + rot(b,alpha));
		res.push_back(o1.c + rot(b,-alpha));
	}
	if(abs(rsum - a.abs_()) < EPS){
		alpha = acos(1);
		res.push_back(o1.c + rot(b,alpha));
	}else if(rsum < a.abs_() - EPS){
		alpha = acos(rsum / a.abs_());
		res.push_back(o1.c + rot(b,alpha));
		res.push_back(o1.c + rot(b,-alpha));
	}
	return res;
}
Circle a,b;
int main(){
	scanf("%lf%lf%lf%lf%lf%lf",&a.c.x,&a.c.y,&a.r,&b.c.x,&b.c.y,&b.r);
	vector <Point> ans = commonTangents(a,b);
	sort(ans.begin(),ans.end());
	for(int i=0;i<(int)ans.size();i++){
		printf("%.10f %.10f\n",ans[i].x,ans[i].y);
	}
	return 0;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;
int main(){
	int n;cin>>n;
	vector<int> A(n+2);
	A[0]=A[n+1]=0;
	rep(i,n){
		cin>>A[i+1];
	  }
	  int sum =0 ;
	  rep(i,n+1){
		 sum+=abs(A[i]-A[i+1]); 
		}
  rep(i,n){
	  int old, sin ;
	  old = abs(A[i+1]-A[i])+abs(A[i+2]-A[i+1]);
	  sin = abs(A[i+2]-A[i]);
	  int ans = sum - old + sin;
	  cout <<ans<<endl;
	}
}	



Measured memory_bytes: 1664
use std::io;
use std::io::BufRead;

fn main() {
  let stdin = io::stdin();
  for line in stdin.lock().lines() {
    let line = line.unwrap();
    let mut iter = line.trim()
      .split_whitespace()
      .map(|x| x.parse::<usize>().unwrap());
    let (h, w) = (iter.next().unwrap(), iter.next().unwrap());

    if h == 0 && w == 0 { break; }

    let out_line = "#".repeat(w);
    for _ in 0..h {
      println!("{}", out_line);
    }
    println!("");
  }
}


Measured memory_bytes: 5036
def cumsum(lis):
    n = len(lis)
    new_lis = [0] * n
    new_lis[0] = lis[0]
    for i in range(1,n):
        new_lis[i] = new_lis[i-1] + lis[i]
    return new_lis

n = int(input())
a1 = cumsum(list(map(int,input().split())))
a2 = cumsum(list(map(int,input().split()))[::-1])[::-1]

for i in range(n):
    a1[i] = a1[i] + a2[i]
print(str(max(a1)))

Measured memory_bytes: 3064
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import qualified Data.IntMap as IM
import Data.List

solve :: Int -> [Int] -> Int
solve n vs
  | ok1 /= ek1            = (m - on1) + (m - en1)
  | on1 + en2 < on2 + en1 = (m - on2) + (m - en1)
  | otherwise             = (m - on1) + (m - en2)

  where
    m = n `div` 2

    divide [] = ([], [])
    divide (o:e:vs) = let (os, es) = divide vs in (o:os, e:es)

    (os0, es0) = divide vs

    getTwo xs = case sortOn ((* (-1)) . snd) $ IM.toList $ count xs of
      [(k1, n1)] -> (k1, n1, 0, 0)
      (k1, n1) : (k2, n2) : _ -> (k1, n1, k2, n2)

    (ok1, on1, ok2, on2) = getTwo os0
    (ek1, en1, ek2, en2) = getTwo es0




count xs = foldr f IM.empty xs
  where f x im = case IM.lookup x im of
          Nothing -> IM.insert x 1 im
          Just t -> IM.adjust (+ 1) x im


bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

main = do
  conts <- B.getContents
  let n:vs = bsReadInts conts
  putStrLn $ show $ solve n vs


Measured memory_bytes: 23804
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF (1<<21)
#define N 100
int Q[N+1],d[N+1],color[N+1],M[N+1][N+1];
int head,tail,n;
void bfs(int s){
  int i,u,v;
  head=tail=1;
  Q[tail++]=s;
  for(i=0;i<n;i++){
    d[i]=INF;
  }
  d[s]=0;
  while(head!=tail){
    u=Q[head++];
    for(v=0;v<n;v++){
      if(M[u][v]==WHITE) continue;
      if(d[v]!=INF) continue;
    d[v]=d[u]+1;
    Q[tail++]=v;
    }
  }
  for(i=0;i<n;i++) printf("%d %d\n",i+1,((d[i]==INF)?(-1):d[i]));    
}
int main(){
  int i,j,u,k,v;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    for(j=0;j<n;j++) M[i][j]=0;
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);
  return 0;
}

Measured memory_bytes: 636
cnt = gets.chomp.to_i
count_ac = 0
count_wa = 0
count_tle = 0
count_re = 0
 
for i in 1..cnt
  result = gets.chomp
  case result
    when "AC" then
      count_ac += 1
    when "WA" then
      count_wa += 1
    when "TLE" then
      count_tle += 1
    when "RE" then
      count_re += 1
  end
    i += 1
end
  
puts "AC x #{count_ac}"
puts "WA x #{count_wa}"
puts "TLE x #{count_tle}"
puts "RE x #{count_re}"

Measured memory_bytes: 14240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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

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

int main() {
	int a, b;
	cin >> a >> b;
		
	int num = a + b;
	
	if (num % 2 != 0) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	int ans = num/2;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int num,arr[100],tmp,flag,cnt = 0,i;
  scanf("%d",&num);
  for(int i = 0; i < num; i++){
    scanf("%d",&arr[i]);
  }
  flag = 1;
  i = 0;
  while(flag ==1){
    flag = 0;
    for(int j = num - 1; j > 0; j--){
      if(arr[j] < arr[j-1]){
	tmp = arr[j];
	arr[j] = arr[j-1];
	arr[j-1] = tmp;
	cnt++;
	flag = 1;
      }
    }
    i++;
  }
  for(int i = 0; i < num -1; i++){
    printf("%d ",arr[i]);
  }
  printf("%d\n%d\n",arr[num - 1],cnt);
  return 0;
}


Measured memory_bytes: 2048
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<deque>
using namespace std;
int main(){
	int D,N;
	cin >> D >> N;
	int day[220];
	int clothes[212][212];
	memset(clothes,-1,sizeof(clothes));
	for(int i = 0; i < D; i++){
		scanf("%d",&day[i]);
	}
	for(int i = 0; i < N; i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		for(int j = 0; j < D; j++){
			if(a <= day[j] && day[j] <= b)clothes[j+1][i+1] = c;
		}
	}
	int dp[212][212];
	memset(dp,-1,sizeof(dp));
	N++;D++;
	for(int j = 1; j < N; j++){
		if(clothes[1][j]!=-1)dp[1][j] = 0;
	}
	for(int i = 2; i < D; i++){
		for(int j = 1; j < N; j++){
			if(clothes[i][j]!=-1){
				for(int k = 1; k < N; k++){
					if(dp[i-1][k]!=-1){
						dp[i][j] = max(dp[i][j],dp[i-1][k]+abs(clothes[i-1][k]-clothes[i][j]));
					}
				}
			}
		}
	}
	int ans = -1000;
	for(int i = 0; i < N; i++){
		ans = max(ans,dp[D-1][i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1588
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define LONGMAX 1e18
#define MOD 1000000007
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define fr(a,n) for(int i=a;i<n;i++)

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

	string s,t;
	cin>>s>>t;

	int n,m;
	n=s.length();
	m=t.length();

	int dp[n+1][m+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i-1]==t[j-1])
				// dp[i][j]=max((1+dp[i-1][j-1]),max(dp[i-1][j],dp[i][j-1]));
				 dp[i][j]=(1+dp[i-1][j-1]);
			else
				dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
		}
	}
	string ans="";

	int i=n,j=m;



	while(i and j)
	{
		if(dp[i][j-1]==dp[i][j])
			j--;
		else if(dp[i-1][j]==dp[i][j]){
			i--;}
		else
		{
			ans=s[i-1] + ans;
			i--,j--;
			// cout<<ans<<endl;
		}


	}
		cout<<ans;

}	



Measured memory_bytes: 35456
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


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

	if (N == M)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    vector<int> B(N);
    REP(i, N) cin >> B[i];
    vector<tuple<int, int>> pair(N);
    vector<int> A_copy(A);
    vector<int> B_copy(B);
    sort(A_copy.begin(), A_copy.end());
    sort(B_copy.begin(), B_copy.end());
    bool flg = false;
    REP(i, N ){
        if(A_copy[i] <= B_copy[i]) {
            if(i != N-1 && A_copy[i+1] <= B_copy[i]) {
                flg = true;
            }
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    if(flg) {
        cout << "Yes" << endl;
        return 0;
    }
    REP(i, N) {
        pair[i] = make_tuple(A[i], B[i]);
    }
    sort(pair.begin(), pair.end(),
       [](auto const &a, auto const &b) { return get<1>(a) < get<1>(b); });
    map<int, int> mp;
    REP(i, N) {
        mp[A_copy[i]] = i;
        A_copy[i] = i;
    }
    REP(i, N) {
        get<0>(pair[i]) = mp[get<0>(pair[i])];
    }
    int size = 0;
    int Aidx = 0;
    vector<bool> existed(N, false);
    while(true) {
        existed[Aidx] = true;
        Aidx = get<0>(pair[Aidx]);
        size++;
        if(existed[Aidx]) {
            break;
        }
    }
    if(size != N) {
        cout << "Yes" << endl;
    }else {
        cout << "No "<< endl;
    }
    return 0;

    flg = false;
    REP(i, N) {
        if(A_copy[i] != get<0>(pair[(i+1)%N])) {
            flg = true;
            break;
        }
    }
    if(!flg) {
        cout << "No" << endl;
        return 0;
    }
    flg = false;
    REP(i, N) {
        if(A_copy[i] != get<0>(pair[(i-1+N)%N])) {
            flg = true;
            break;
        }
    }
    if(!flg) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 7296
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include <cstdint>

using namespace std;

const long long MOD = 1000000007;

long long mod(long long a, long long m = MOD)
{
    long long q = a % m;
    if (q < 0)
        q += m;
    return q;
}

long long modadd(long long a, long long b, long long m = MOD)
{
    return (a + b) % m;
}

long long modsub(long long a, long long b, long long m = MOD)
{
    return mod((a % m) - (b % m));
}

long long modmul(long long a, long long b, long long m = MOD)
{
    return (a * b) % m;
}

long long modpow(long long a, long long b, long long m = MOD)
{
    long long c = 1;
    while (b > 0)
    {
        if (b & 1)
            c = modmul(c, a, m);
        a = modmul(a, a, m);
        b >>= 1;
    }
    return c;
}

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

long long moddiv(long long a, long long b, long long m = MOD)
{
    return modmul(a, modinv(b, m), m);
}

int dp[2001][2001];
int n, m;
int s[2000];
int t[2000];
int main()
{
    cin >> n >> m;
    REP(i, n) {cin >> s[i];}
    REP(i, m) {cin >> t[i];}
    REP(i, n + 1) {dp[i][0] = 0;}
    REP(i, m) {dp[0][i] = 0;}
    for (int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) {
        if (s[i - 1] == t[j - 1]) {
            dp[i][j] = modadd(modadd(dp[i - 1][j], dp[i][j - 1]), 1);
        } else {
            dp[i][j] = modsub(modadd(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]);
        }
    }
    // REP(i, n + 1) {
        // DA(dp[i], m + 1);
    // }
    cout << dp[n][m] + 1<< endl;
}


Measured memory_bytes: 15872
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,l,r) for(int i=(l);i<(r);i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    

template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}    
// g++ -std=c++11 prac.cpp 

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
    ll x=0,y=0,z=0,n,m=0,k,ans=0,h,w,sum=0,Max=-1e9-1,cnt=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n >> s;
    int l=0,r=0;
    rep(i,n){
        if(s[i]=='.')
            r++;
    }
    rep(i,n){
        chmin(Min,l+r);
        if(s[i]=='#'){ l++; }
        else{ r--; }
    }
    chmin(Min,l+r);
    cout << Min << endl;
    return 0;
}


Measured memory_bytes: 640
total_count, total_legs = map(int, input().split())
isYes = 'false'

for i in range(total_count+1):
  test = 2*i+4*(total_count-i)
  if total_legs == test:
    isYes = 'true'
    print("Yes")

if isYes=='false':
  print("No")

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

int h, w;
char field[60][60];
int minDis[60][60];
int INF = 1000000;
int x4[4] = {1, -1, 0, 0}, y4[4] = {0, 0, 1, -1};

int bfs() {
  queue<P> que;
  rep(i, h) rep(j, w) minDis[i][j] = INF;
  que.push(P(0, 0));
  minDis[0][0] = 0;

  while (que.size()) {
    P p = que.front(); que.pop();
    if (p.first == h-1 && p.second == w-1) break;

    rep(i, 4) {
      int ny = p.first + y4[i], nx = p.second + x4[i];

      if (0 <= nx && nx < w && 0 <= ny && ny < h && field[ny][nx] != '#' && minDis[ny][nx] == INF) {
        que.push(P(ny, nx));
        minDis[ny][nx] = minDis[p.first][p.second] + 1;
      }
    }
  }

  return minDis[h-1][w-1];
}

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

  cin >> h >> w;
  int cnt = 0;
  rep(i, h) rep(j, w) {
    char c;
    cin >> c;
    if (c == '.') cnt++;
    field[i][j] = c;
  }

  int res = bfs();
  if (res == INF) cout << -1 << endl;
  else cout << cnt-bfs()-1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const int INF=1e7;
const LL LINF=1e18;

priority_queue<LL> pq;

int main(){
    int N;
    LL T;
    cin >> N >> T;
    LL a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    LL maxi=0;
    LL dist[N];
    for(int i=N-1;i>=0;i--){
        maxi=max(maxi,a[i]);
        dist[i]=maxi;
    }
    priority_queue<LL> pq;
    for(int i=0;i<N;i++){
        pq.push(dist[i]-a[i]);
    }
    LL ch=pq.top(),ans=0;
    while(1){
        if(ch==pq.top()){
            ans++;
            pq.pop();
        }
        else break;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2936
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            var dic = new Dictionary<string,int>();
            int max = 0;
            for (int i = 0; i < n;i++)
            {
                var s = ReadLine();
                if(dic.ContainsKey(s))
                {
                    dic[s]++;
                }
                else
                {
                    dic[s] = 1;
                }
                if(max < dic[s])
                    max = dic[s];
            }
            var ans = dic.Where(x => x.Value == max).Select(x=>x.Key).ToList();
            ans.Sort(StringComparer.Ordinal);
            WriteLine(string.Join("\n",ans));
        }

    }


    static class Util
    {
        public static void ChMin(ref long a, long b)
        {

            if (a > b)
            {
                a = b;
            }
        }

        public static void ChMax(ref long a, long b)
        {
            if (a < b)
            {
                a = b;
            }
        }




    }
}


Measured memory_bytes: 50576
def solve():
    D, G = map(int, input().split())
    p = [0 for _ in range(D)]
    c = [0 for _ in range(D)]

    for i in range(D):
        p[i], c[i] = map(int, input().split())

    ans = 1000
    for i in range(2 ** D):
        comp = [0 for _ in range(D)]
        num = 0
        score = 0
        for j in range(D):
            if i >> j & 1:
                comp[j] = 1
                # print('j',j)
                score += 100 * (j + 1) * p[j] + c[j]

        for j in range(D):
            if comp[j] == 1:
                num += p[j]
        if score < G:
            index = 0
            for j in range(D - 1, 0, -1):
                if comp[j] == 0:
                    index = j
                    break
            for _ in range(p[index]):
                score += 100 * (index + 1)
                num += 1
                if score >= G:
                    break
            if score < G:
                continue
        # print('i', i)
        # print('num',num)
        # print('score',score)
        ans = min(ans, num)
    print(ans)


if __name__ == "__main__":
    solve()


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

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

	int a[4];

	for(int i=0;i<4;i++){
		a[i] = s[i]-'0';
	}

	for(int i=0;i<8;i++){
		int j=i,t=a[0];

		for(int k=1;k<4;k++){
			if(j&1) t-=a[k];
			else t+=a[k];

			j>>=1;
		}

		if(t==7){
			j=i;
			cout << a[0];
			for(int k=1;k<4;k++){
				if(j&1) cout << '-' << a[k];
				else cout << '+' << a[k];
				j>>=1;
			}
			cout << "=7" << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n,k;cin >> n >> k;
	int need = n*(n-1)/2 - k - (n-1);
	if(need < 0){
		cout << -1 << endl;
		return 0;
	}
	cout << need + n-1 << endl;
	rep(i,n-1){
		cout << 1 << " " << i+2 << endl;
	}
	rep(j,n)rep(i,j){
		if(i ==0)continue;
		if(need > 0){
			cout << i+1 << " " << j+1 << endl;
			need--;
		}
	}

	return 0;
}

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

using namespace std;

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

  int n, q;
  cin >> n;
  int A[n];
  for(int i =0; i<n; ++i) cin >> A[i];

  cin >> q;
  int P[q];
  for(int j=0; j<q;++j) cin >> P[j];

  int count = 0;
  for(int j=0; j<q; ++j)
    count += binary_search(&A[0], &A[n], P[j]);

  cout << count << endl;
}


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

int main() {
  int N, F;
  cin >> N >> F;

  map<string, map<string, int>> count;

  for(int i = 0; i < N; ++i) {
    int M;
    cin >> M;

    vector<string> item(M);
    for(auto& i: item) cin >> i;

    sort(begin(item), end(item));
    for(int f = 0; f < M; ++f) for(int l = f + 1; l < M; ++l) ++count[item[f]][item[l]];
  }

  set<string> answer;
  for(auto i: count) for(auto j: i.second) if(F <= j.second) answer.insert(i.first + " " + j.first);
  cout << answer.size() << endl;
  for(auto i: answer) cout << i << endl;
}

Measured memory_bytes: 4060
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    String S = scan.next();
    String[] splitS = S.split("");
    String T = scan.next();
    String[] splitT = T.split("");
    StringBuilder sb = new StringBuilder();
    for (int i = 0;i < N;i++) {
      sb.append(splitS[i]);
      sb.append(splitT[i]);
    }
    System.out.println(sb);
  }
}


Measured memory_bytes: 35596
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

bool m[N];
vi primes(1,2);
ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

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

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


int main(){_
	char s; cin>>s;
	if(s>='A' and s<='Z')cout<<"A"<<ENDL;
	else cout<<"a"<<ENDL;
}


Measured memory_bytes: 3664
//In the Name of God
//Let Our Voices Echo
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define X real()
#define Y imag()
typedef long long ll;
typedef double ld; 
typedef complex<ld> point;
const ld eps=1e-9;
const int MAX=1e5+9,MOD=1e9+7,lg=20;
int n,ans;
vector<int> g[MAX];
int dfs(int v,int p=-1)
{
	int res=0,mi=0;
	for (auto u:g[v])	
		if (u!=p)
		{
			int mask=dfs(u,v);
			for (int i=0;i<lg;i++) 
				if ((mask>>i&1) && (res>>i&1)) 
					mi=max(mi,i+1);
			res|=mask;
		}
	for (int i=mi;;i++)
		if (!(res>>i&1))
		{
			ans=max(ans,i);
			res|=(1<<i);
			for (int j=i-1;j>=0;j--)
				if (res>>j&1)
					res^=(1<<j);
			return res;
		}
	
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for (int i=1,v,u;i<n;i++) cin>>v>>u,v--,u--,g[v].push_back(u),g[u].push_back(v);
	dfs(0);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 10240
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(void){
  int n,m,k;
  cin >> n >> m >> k;

  UnionFind tree(n+1);
  vector<int> fnum(n+1,1);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    tree.unite(a,b);
    fnum[a]++;
    fnum[b]++;
  }
  
  rep(i,k){
    int c,d;
    cin >> c >> d;
    if(tree.same(c,d)){
      fnum[c]++;
      fnum[d]++;
    }
  }

  rep(i,n){
    cout << tree.get_num(i+1)-fnum[i+1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 2432
package main

import (
	"fmt"
	"reflect"
	"sort"
)

func main() {
	s := make([]string, 4)
	t := []string{"1", "4", "7", "9"}

	fmt.Scan(&s[0], &s[1], &s[2], &s[3])

	sort.Strings(s)

	if reflect.DeepEqual(s, t) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include <stdio.h>

int n, a[100];

int main(void) {
    int i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    
    for (i = n - 1; i >= 0; --i) {
        if (i != n - 1) printf(" ");
        printf("%d", a[i]);
    }
    
    printf("\n");
    return 0;
}

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

int main(){
    int H;
    cin >> H;
    int tree[H+1];
    for (int i = 1; i <= H; i++) {
        int key;
        cin >> key;
        tree[i] = key;
    }
    for (int i = 1; i <= H; i++) {
        cout << "node " << i << ": key = " << tree[i] << ", ";
        if (i / 2 > 0) cout << "parent key = " << tree[i/2] << ", ";
        if (i * 2 <= H) cout << "left key = " << tree[i*2] << ", ";
        if (i * 2 + 1 <= H) cout << "right key = " << tree[i*2+1] << ", ";
        cout << endl;
    }

    return 0;
}

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

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    if (b - 1 <= n) {
        ll x = b - 1;
        cout << a * x / b - a * (x / b) << endl;
    } else {
        ll x = n;
        cout << a * x / b - a * (x / b) << endl;
    }
}


Measured memory_bytes: 3636
n=int(input())
a=sorted(list(map(int,input().split())))
flag=True
if n%2==1:
    if a.count(0)!=1:
        flag=False
    for i in range(2,n,2):
        if not (a[i-1]==a[i] and a[i]==i):
            flag=False
            break
else:
    for i in range(1,n,2):
        if not (a[i-1]==a[i] and a[i]==i):
            flag=False
            break
print(2**(n//2)%(10**9+7) if flag else 0)

Measured memory_bytes: 13880
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int v[105];

int main(void) {
  int i,j;
  int n,x;
  cin>>n>>x;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  rep(i,n)x-=a[i];
  cout<<n+x/a[0]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
using namespace std;

typedef pair<int,int> P1;
typedef pair<P1,P1> P2;

int main(){
  int i,k;
  bool mint[20][20][4][101];
  int sig[20][20],cost[20][20][20][20];
  int m,n,d,ns,nc,nj,sw,sh,gw,gh;
  char c,t;

  for(;;){
    cin >> m >> n;
    if(!m && !n)break;

    cin >> d;
    fill(&cost[0][0][0][0],&cost[m-1][n-1][m-1][n-1]+1,d);

    cin >> ns;
    fill(&sig[0][0],&sig[m-1][n-1]+1,0);
    for(i=0;i<ns;i++){
      cin >> c >> t >> sw >> k;
      sh = c-'a';
      sig[sh][sw-1] = k;
    }

    cin >> nc;
    for(i=0;i<nc;i++){
      cin >> c >> t >> sw;
      sh = c-'a';
      cin >> c >> t >> gw;
      gh = c-'a';
      cost[sh][sw-1][gh][gw-1] = -1;
      cost[gh][gw-1][sh][sw-1] = -1;
    }

    cin >> nj;
    for(i=0;i<nj;i++){
      cin >> c >> t >> sw;
      sh = c-'a';
      cin >> c >> t >> gw;
      gh = c-'a';
      cin >> k;
      cost[sh][sw-1][gh][gw-1] += k;
      cost[gh][gw-1][sh][sw-1] += k;
    }

    cin >> c >> t >> sw;
    sh = c-'a';
    sw--;
    cin >> c >> t >> gw;
    gh = c-'a';
    gw--;

    fill(&mint[0][0][0][0],&mint[m-1][n-1][4][101]+1,false);
    mint[sh][sw][0][0] = true;;
    queue<P2> q;
    q.push(P2(P1(0,0),P1(sh,sw)));
    int ans = 1<<30;

    while(q.size()){
      P2 p=q.front();q.pop();
      int t = p.first.first;
      int d = p.first.second;
      int y = p.second.first;
      int x = p.second.second;

      for(int dd=0;dd<4;dd++){
	if(dd==(d+2)%4)continue;
	int dy=y,dx=x,dt=t;
	if(dd==0)dx++;
	if(dd==1)dy++;
	if(dd==2)dx--;
	if(dd==3)dy--;
	if(dy<0 || dx<0 || m<=dy || n<=dx)continue;
	if(cost[y][x][dy][dx]<0)continue;
	dt += cost[y][x][dy][dx];
	k = sig[dy][dx];
	if(k && ( ((dt/k)&1) == (dd&1) ) )continue;
	if(!mint[dy][dx][dd][dt]){
	  if(dy==gh && dx==gw)ans = min(ans,dt);
	  mint[dy][dx][dd][dt] = true;;
	  q.push(P2(P1(dt,dd),P1(dy,dx)));
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

template <typename T>
class CompressCoordinate{
public:
	vector<T> a, c; // 圧縮した数列、ソートした数列
	CompressCoordinate(const vector<T>& arg){
		a = vector<T>(arg.size());
		c = arg;
		compress(c);
		rep(i,arg.size()){
			a[i] = lb(c, arg[i]);
		}
	}
	void compress(vector<T> &v) {
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(),v.end()),v.end());
	}
	int lb(const vector<T>& v, T num){
		return lower_bound(all(v), num) - v.begin();
	}
	int map(T a){
		return lb(c, a);
	}
};

int main(){
	int h, w;
	cin >> h >> w;

	vector<pair<int, int>> p;
	vector<int> x, y;
	rep(i,h){
		rep(j,w){
			char c;
			cin >> c;
			if(c == '#'){
				p.emplace_back(i,j);
				x.emplace_back(j);
				y.emplace_back(i);
			}
		}
	}

	CompressCoordinate<int> cx(x), cy(y);

	vector<vector<char>> m(cy.c.size(), vector<char>(cx.c.size(), '.'));
	rep(i,p.size()){
		m[cy.map(p[i].first)][cx.map(p[i].second)] = '#';
	}

	rep(i,m.size()){
		rep(j,m[0].size()){
			cout << m[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long n,m,t;
	unsigned long long s;
	scanf("%lld %lld",&n,&m);
	if(n>m)
	{
		t=m;
		m=n;
		n=t;
	}
	if(n==1&&m==1)
	{
		s=1;
	}
	else if(n==1)
	{
		s=m-2;
	}
	else
	{
		s=(n-2)*(m-2);
	}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main(void) {
	double r;
	scanf("%lf", &r);
	double pi = acos(-1);
	printf("%lf %lf\n", pi*r*r, 2 * pi*r);
	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#define EPS (1e-7)
using namespace std;


long long lcm(long long n, long long m) {
	long long r,x,tmp;
	x = m * n;
	/* 自然数 a > b を確認・入替 */
	if (n < m) {
		tmp = n;
		n = m;
		m = tmp;
	}

	/* ユークリッドの互除法 */
	r = n % m;
	while (r != 0) {
		n = m;
		m = r;
		r = n % m;
	}
	return x / m;

}



int main() {

	int N;
	cin >> N;
	vector<int> d(N);
	int ans = 0;
	for (auto i = 0; i < N; i++)
	{
		cin >> d[i];
	}

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


	ans = d[N / 2 ] - d[N / 2 -1];



	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640