akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    long n = sc.nextLong();
    long a = sc.nextLong();

    long b = sc.nextLong();
    
    // make a < b
    if (a > b) {
      long tmp = a;
      a = b;
      b = tmp;
    }
    
    long distance = b - a;
    
    if (distance % 2 == 0) {
      os.println(distance / 2);
      return;
    }
    // a is nearer to the edge than b
    if (a - 1 < n - b) {
      os.println(((a - 1) + (b - 1) + 1) / 2);
    } else {
      os.println(((n - a) + (n - b) + 1) / 2);
    }
  }
}

Measured memory_bytes: 21844
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#include <algorithm>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>

using namespace std;
class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 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 a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() {return x * x + y * y; }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

};

typedef Point Vector;

double dot(Vector a, Vector b) {
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
  return a.x * b.y - a.y * b.x;
}

struct Segment {
  Point p1, p2;
};

typedef Segment Line;

typedef vector<Point> Polygon;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(Point p0, Point p1, Point p2) {
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
  if (cross(a, b) < -EPS) return CLOCKWISE;
  if (dot(a, b) < -EPS) return ONLINE_BACK;
  if (a.norm() < b.norm()) return ONLINE_FRONT;
  return ON_SEGMENT;
}

Polygon andrewScan(Polygon& s) {
  Polygon u, l;

  if (s.size() < 3) return s;
  sort(s.begin(), s.end());
  u.push_back(s[0]);
  u.push_back(s[1]);
  l.push_back(s[s.size() - 1]);
  l.push_back(s[s.size() - 2]);

  // upper
  for (int i = 2; i < s.size(); i++) {
    for (int n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--) { // if "!= CLOCKWISE", then points on edges are not included
      u.pop_back();
    }
    u.push_back(s[i]);
  }

  // lower
  for (int i = s.size() - 3; i >= 0; i--) {
    for (int n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--) { // if "!= CLOCKWISE", then points on edges are not included
      l.pop_back();
    }
    l.push_back(s[i]);
  }

  reverse(l.begin(), l.end());
  for (int i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

  return l;
}

int main() {
  int n;
  cin >> n;
  Polygon p;
  p.resize(n);
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> p[i].x >> p[i].y;
  }
  Polygon res_points = andrewScan(p);
  cout << res_points.size() << endl;
  auto sp = min_element(res_points.begin(),
                        res_points.end(),
                        [&](Point& a, Point& b) {return a.y != b.y ? a.y < b.y : a.x < b.x;});
  for (int i = 0; i < res_points.size(); i++, sp++) {
    if (sp == res_points.end()) sp = res_points.begin();
    cout << sp->x << " " << sp->y << endl;
  }
  return 0;
}



Measured memory_bytes: 6844
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  long long  h, w;
  long long  ans = 0;

  cin >> h >> w;

  if(h == 1 || w == 1){
    cout << 1 << endl;
    return 0;
  }

  // cout << "h = " << h<< endl;
  // cout << "w = " << w<< endl;
  long long hh = 0;
  long long hw = 0;
  long long wh = 0;
  long long ww = 0;
  if(w%2 == 1){
    ww = (w-1)/2+1;
    hw = (w-1)/2;
    // cout << "w %2 = 1" << endl;
  }else{
    ww = w/2;
    hw = w/2;
  }

  if(h%2 == 1){
    wh = (h-1)/2+1;
    hh = (h-1)/2;
    // cout << "h %2 = 1" << endl;
  }else{
    wh = h/2;
    hh = h/2;
  }
  long long wwnum = ww*wh;
  long long hhnum = hh*hw;
  ans = wwnum + hhnum;

  // cout << "hh = " << hh << endl;
  // cout << "hw = " << hw << endl;
  // cout << "wh = " << wh << endl;
  // cout << "ww = " << ww << endl;
  // cout << "hhnum = " << hhnum << endl;
  // cout << "wwnum = " << wwnum << endl;  
  cout << ans << endl;
}


Measured memory_bytes: 256
NML = input().split()
n = int(NML[0])
m = int(NML[1])
l = int(NML[2])

A = []
B = []
for i in range(n):
    A.append([])
    A_r = input().split()
    for j in range(m):
        A[i].append(int(A_r[j]))
for i in range(m):
    B.append([])
    B_r= input().split()
    for j in range(l):
        B[i].append(int(B_r[j]))
for i in range(n):
    for j in range(l):
        out=0
        for k in range(m):
            out +=A[i][k]*B[k][j]
        print(str(out),end="")
        if j != l-1:
            print(" ",end="")
    print("")

Measured memory_bytes: 8744
#include<iostream>
#include<string>
#define rep(i, n) for ( int i = 0; i < n; i++ )
using namespace std;
#define MAX 100
class Cube{
    public:
    string f[6];
    Cube(){}
    void roll_z(){ roll(1, 2, 4, 3);}
    void roll_y(){ roll(0, 2, 5, 3);}
    void roll_x(){ roll(0, 1, 5, 4);}
    void roll(int i, int j, int k, int l){
	string t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }
};

Cube C[MAX];
int n;

bool eq( Cube c1, Cube c2 ){
    rep(i, 6) if ( c1.f[i] != c2.f[i] ) return false;
    return true;
}

bool equal( Cube c1, Cube c2 ){
    rep(i, 6){
	rep(j, 4){
	    if ( eq(c1, c2) ) return true;
	    c1.roll_z();
	}
	if ( i % 2 == 0 ) c1.roll_y();
	else c1.roll_x();
    }
    return false;
}

main(){
    while( cin >> n && n ){
	rep(i, n) rep(j, 6) cin >> C[i].f[j];
	int cnt = 0;
	rep(i,n) {
	    bool hasSame = false;
	    for(int j=i+1; j<=n-1;j++) if (equal(C[i],C[j])) hasSame = true;
	    if ( !hasSame ) cnt++;
	}
	cout << n - cnt << endl;
    }
}

Measured memory_bytes: 936
h,w=map(int,input().split())
S = [list(map(str, input().split())) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j]=="snuke":
            a=i+1
            b=j+1
            break
b=chr(65+b-1)
ans=b+str(a)
print(ans)

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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        int a;
        cin>>a;
        if(a>=30) cout<<"Yes";
        else cout<<"No";

    }
    return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int V, E;
int cost[16][16];
int dp[1<<15][16];
int INF = 1000000;

int main() {
   cin >> V >> E;

   int s, t, d;
   fill(cost[0], cost[V], -1);
   for (int i = 0; i < E; i++) {
      cin >> s >> t >> d;
      cost[s][t] = d;
   }

   fill(dp[0], dp[1<<V], INF);

   dp[(1<<V) - 1][0] = 0;

   for (int S = (1<<V) - 2; S >= 0; S--) {
      for (int v = 0; v < V; v++) {
         for (int u = 0; u < V; u++) {
            if (cost[v][u] == -1) continue;
            if (S & (1<<u)) continue;
            // if (!(S>>u & 1)) {
               dp[S][v] = min(dp[S][v], dp[S + (1<<u)][u] + cost[v][u]);
            // }
         }
      }
   }
   int ans = dp[0][0];
   if (ans == INF) cout << "-1" << endl;
   else cout << ans << endl;
   return 0;
}



Measured memory_bytes: 5148
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

struct skillup{
    lli cost=N;
    vector<vector<lli>> skill;
    
    skillup(lli n,lli m){
        lli c,a,i,j;
        rep(i,0,n){
            vector<lli> vec;
            cin>>c;
            vec.push_back(c);
            rep(j,0,m){
                cin>>a;
                vec.push_back(a);
            }
            skill.push_back(vec);
        }
    }
    
    lli check(lli x,vector<lli> vec){
        lli i,b=0;
        rep(i,2,vec.size()){
            if(vec[i]<x){
                b=1;
                break;
            }
        }
        return b;
    }
    
    void calculate(lli x,lli n,lli m){
        lli i=1;
        vector<lli> vec;
        rep(i,0,m+2){
            vec.push_back(0);
        }
        queue<vector<lli>> cal;
        cal.push(vec);
        while(cal.size()!=0){
            vec=cal.front();
//            rep(i,0,vec.size()){
//                cout<<vec[i]<<" ";
//            }
//            cout<<endl;
            if(vec[0]<n){
                vec[0]++;
                cal.push(vec);
                rep(i,1,vec.size()){
                    vec[i]+=skill[vec[0]-1][i-1];
                }
                if(check(x,vec)==0){
//                    cout<<"値段は"<<vec[1]<<"円です"<<endl;
                    cost=min(cost,vec[1]);
                }
                else{
                    cal.push(vec);
                }
            }
            cal.pop();
        }
    }
    
    void ans(){
        if(cost==N){
            cost=-1;
        }
        cout<<cost<<endl;
    }
    
};

int main(){
    lli n,m,x;
    cin>>n>>m>>x;
    skillup up(n,m);
    up.calculate(x,n,m);
    up.ans();
}


Measured memory_bytes: 4196
// abc135c: City Savers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;

#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define in(x) cin>>(x)
#define oute(x) cout<<(x)<<endl

int main(){
  int n;in(n);
  vi a(n+1), b(n);
  upto(i,0,n+1,1) in(a[i]);
  upto(i,0,n,1) in(b[i]);

  ll c = 0;
  upto(i,0,n,1){
    int m = min(a[i],b[i]);
    a[i]-=m;
    b[i]-=m;
    c+=m;
    if(a[i]<=0 && b[i]>0){
      m = min(a[i+1],b[i]);
      a[i+1]-=m;
      c+=m;
    }
  }
  oute(c);
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
H = list(map(int, input().split()))

good = [1 for i in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] < H[B-1]:
        good[A-1] = 0
    elif H[A-1] > H[B-1]:
        good[B-1] = 0
    else:
        good[A-1] = good[B-1] = 0

count = 0
for g in good:
    if g == 1:
        count += 1

print(count)


Measured memory_bytes: 84980
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    
    for(int i=1; i<n; i++){
      int j = n - i;
      if(n == i + j && !(i == j)){
        count++;
      }
    }
    System.out.println(count/2);
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

template<typename T, T INIT, size_t WIDTH, size_t HEIGHT>
class Field
{
	T m_data[WIDTH*HEIGHT];
	T dummy;

public:
	Field()
	{
		for(auto& i : m_data)
			i = INIT;
		dummy = INIT;
	}

	T& $(size_t x, size_t y)
	{
		if(x < 0 || WIDTH <= x || y < 0 || HEIGHT <= y)
			return dummy;

		return m_data[y * WIDTH + x];
	}
};

int main()
{
	Field<int, 0, 10, 10> field;

	string line;
	while(cin >> line)
	{
		int x, y, s;
		sscanf(line.c_str(), "%d,%d,%d", &x, &y, &s);

		switch(s)
		{
		case 3:
			field.$(x+2, y  )++;
			field.$(x-2, y  )++;
			field.$(x  , y+2)++;
			field.$(x  , y-2)++;

		case 2:
			field.$(x+1, y+1)++;
			field.$(x+1, y-1)++;
			field.$(x-1, y+1)++;
			field.$(x-1, y-1)++;

		case 1:
			field.$(x  , y  )++;
			field.$(x  , y+1)++;
			field.$(x  , y-1)++;
			field.$(x+1, y  )++;
			field.$(x-1, y  )++;
		}
	}

	int clean = 0;
	int max = 0;
	for(int y = 0; y < 10; y++)
		for(int x = 0; x < 10; x++)
		{
			int& cell = field.$(x, y);

			if(cell == 0)
				clean++;
			else if(max < cell)
				max = cell;
		}

	cout << clean << endl;
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long a[n + 1];
    for(int i = 0 ; i < n ; i++)
    	cin >> a[i];
   	bool flag = true;
   	for(int i = n - 2 ; i >= 0 ; i--){
   		if(a[i] > a[i + 1])
   			a[i]--;
   	}
   	for(int i = 1 ; i < n ; i++)
   		if(a[ i ] < a[ i - 1])
   			flag = false;
   	flag == true ? cout << "Yes" : cout << "No" <<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>

using namespace std;

static const int MAX_N = 200000;

int N;
int A[MAX_N + 1];

int n[MAX_N + 1];

int main() {

    cin >> N;
    for (int i = 2; i <= N; i++) cin >> A[i];

    for (int i = 1; i <= N; i++) n[i] = 0;

    for (int i = 2; i <= N; i++) {
        n[A[i]] += 1;
    }

    for (int i = 1; i <= N; i++)
        cout << n[i] << endl;

    return 0;
}




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

namespace ABC066A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c, s;

			string[] word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);

			//アルゴリズム１
			//int x = a + b;
			//int y = b + c;
			//int z = c + a;

			// x, y, zの最小値
			//s = x;
			//if (y < s) s = y;
			//if (z < s) s = z;
			
			
			
			
			//アルゴリズム２
		   // a, b, cの最大値を求める
			int m = a;
			if (b > m) m = b;
			if (c > m) m = c;

			//最大値を除く金額の和
			s = a + b + c - m;

			Console.WriteLine(s);

			//Console.ReadLine();
				
				
		}
	}
}

Measured memory_bytes: 27508
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
using namespace std;
const int N = 1e5+5;
void fast(){std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
int main()
{
	fast();
	int a,b;
	cin>>a>>b;
	cout<<6-a-b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
#define PI 3.14159265359
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

ll sum(ll l, ll r){
    return (l+r)*(r-l+1)/2;
}

int main(){
    int n,k;
    cin >> n >> k;
    mint ans = 0;
    for(int i=k; i<=n+1; i++){
        ll l = sum(0,i-1), r = sum(n-i+1, n);
        ans = (ans + (r-l+1));
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3672
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string.h>
#include<set>
#define inf 0x3f3f3f3f
using namespace std;
int pre[110];
int main()
{
    int n;
    cin>>n;
    double sum1=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&pre[i]);
        sum1+=pre[i];
    }
    sum1/=n;
    int ans=0;
    int sum=sum1;
    if(fabs(sum1-sum)>0.5-0.0000001)sum++;
    for(int i=0;i<n;i++)
    {
        ans+=(pre[i]-sum)*(pre[i]-sum);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_C&lang=jp

#include<iostream>
 using namespace std;

int main(){
	int x[3000];
    int y[3000]; 
    int exchange; //xとyを交換するときに一時的に使う変数

 	for (int i=1; i<=3000; i=i+1 )
 	{
 	cin >> x[i] >>y[i] ;

		if( x[i] == 0 )
        {
            if( y[i] == 0 )
            {
            break; //x[i]とy[i]の両方が0なら、forループから抜ける。
            }else{
            //x[i]のみ0の場合。forループから抜けない。
            }

        }else{
        // x[i]が0でない場合。forループから抜けない。
        }

        if(x[i] > y[i]) //x[i]がy[i]より大きい場合は、x[i]とy[i]を入れ替える。
         {
        exchange=x[i];
          x[i]=y[i];
          y[i]=exchange;
         }else{
        // そうでなければ、何もしない。
        }

    cout<< x[i] <<" "<< y[i] << endl;
    }
    
 return 0;
 }


Measured memory_bytes: 3104
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

ll pow(ll a, ll b) {
	vector<ll> d = vector<ll>((ll)(log(b)) + 2);
	d[0] = a;
	rep(i, 1, d.size()) d[i] = d[i - 1] * d[i - 1];
	ll ret = 1;
	rep(i, 0, log(b) + 1) {
		if (b & 1 << i) ret *= d[i];
	}
	return ret;
}

vector<ll> a , b;

//145 B
int main(void) {
	ll n;
	string s;
	cin >> n >> s;
	if (n % 2 == 0) {
		if (s.substr(0, n / 2) == s.substr(n / 2, n/2)) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else cout << "No" << endl;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }

    map<ll ,ll> backet;
    for(ll i = 0; i < n; i++){
        backet[a[i]]++;
    }

    vector<ll> l;

    for(auto i : backet){
        if(i.second > 3){
            l.push_back(i.first);
            l.push_back(i.first);
        } else if(i.second > 1){
            l.push_back(i.first);
        }
    }

    sort(l.begin(), l.end(), greater<ll>());
    if(l.size() < 2){
        cout << 0 << endl;
        return 0;
    }

    ll ans = l[0] * l[1];

    cout << ans << endl;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3+5;
typedef long long ll;
const int inf = 1e9;
int h,a,sum,now,n;
int main(){
  // freopen("input.txt","r",stdin);
  cin>>h>>n;
  for(int i = 1;i <= n;i++) {cin>>now;sum+=now;}
  if(sum >= h) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (b - a <= 0) {
		cout << "delicious" << endl;
	} else if (b - a <= x) {
		cout << "safe" << endl;
	} else {
		cout << "dangerous" << endl;
	}
}


Measured memory_bytes: 3592
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int H, W;
    scan(H, W);
    auto ng = iota(H).map!(i => readln.chomp.map!(ch => ch == '#').array).array;
    auto dp = new long[][](H, W);
    dp[0][0] = 1;
    foreach (i ; 0 .. H) {
        foreach (j ; 0 .. W) {
            if (ng[i][j]) continue;
            if (i > 0) {
                dp[i][j] += dp[i - 1][j];
                dp[i][j] %= mod;
            }
            if (j > 0) {
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= mod;
            }
        }
    }
    auto ans = dp[H - 1][W - 1];
    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 13948
N, W = [int(i) for i in input().split()]
dp = [[0 for j in range(W + 1)] for i in range(N + 1)]
v = w = 0
for i in range(N - 1, -1, -1):
    v, w = [int(i) for i in input().split()]
    for j in range(0, W + 1):
        dp[i][j] = dp[i + 1][j] if j < w  else max(dp[i + 1][j], dp[i + 1][j - w] + v)
print(dp[0][W])

Measured memory_bytes: 27976
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main()
{
  string s,t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < t.size(); i++){
    if(s == t){
      ans = 1;
      break;
    }
    s = s.substr(1) + s[0];
  }
  if(ans == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;
  cin>>n;
  vector<int>v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  double ans=v[0];
  for(int i=1;i<n;i++)
    ans=(ans+v[i])/2;
  cout<<fixed<<setprecision(10)<<ans<<endl;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N, K;
    cin >> N >> K;
    int x[N] = {0};
    REP(i, N)
    {
        cin >> x[i];
    }
    int ans = INT32_MAX;
    for (int i = 0; i <= N - K; ++i)
    {
        int distance = INT32_MAX;
        if (x[i] < 0 && x[i + K - 1] <= 0) distance = -x[i];
        else if (x[i] <= 0 && x[i + K - 1] > 0 ) distance = min(-2 * x[i] + x[i + K - 1], -x[i] + 2 * x[i + K - 1]);
        else distance = x[i + K - 1];
        ans = min(ans, distance);
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;

void solve(){	
	int n, m;
	cin>>n>>m;
	vector<int> A;
	rep(i, 0, n) {
		int tem;
		cin>>tem;
		A.pb(tem);
	}
	sort(all(A));
	vector<pii> v;
	rep(i, 0, m) {
		int a, b;
		cin>>a>>b;
		v.pb(mp(b, a));
	}
	sort(all(v));
	reverse(all(v));
	int index = 0, ind = 0;
	ll ans = 0;
	while(index < m) {
		if(ind < n) {
			if(A[ind] < v[index].first) {
				A[ind] = v[index].first;
				ans += A[ind];
			}
			else {
				break;
			}
		}
		else {
			break;
		}
		v[index].second--;
		if(v[index].second == 0)
			index++;
		ind++;
	}
	while(ind < n) {
		ans += A[ind];
		ind++;
	}
	cout<<ans<<endl;

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


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int ans=0;
  for (int i=0;i<s.size();i++){
    if (s[i]=='1'){
      ans=ans+1;
    }
  }
  cout << ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> s(N);
  rep(i, N) cin >> s[i];
  sort(all(s));
  string res = "";
  rep(i, N) res += s[i];
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long X=sc.nextLong();
		long year=0;
		long yoki=100;
		while(yoki<X) {
			year++;
			yoki*=1.01;
		}
		System.out.println(year);
		}
}


Measured memory_bytes: 35772
#include<iostream>
#include<string>
#define MOD (1000000007)
using namespace std;
int main(){
  long long n,i=0,ans=1,t,si;
  int c_cnt[30]={};
  string s;
  cin >> n >> s;
  for(int i=0;i<s.size();i++){
    c_cnt[s[i]-'a']++;
  }
  for(int i=0;i<='z'-'a';i++){
    ans = (ans*(c_cnt[i]+1))%MOD;
  }
  ans = (ans-1)%MOD;
  cout << ans <<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> vect(n);
  // storing in vector
  for (int i = 0; i < n; i++)
    cin >> vect[i];
   vector<int> l(n+1,0),r(n+1,0);
  // base initialization
  l[1] = vect[0];
  r[n-1] = vect[n-1];
  // finding gcd (from right and left side)
  for(int i = 1; i < n; i++){
   	l[i+1] = __gcd(l[i],vect[i]);
    r[n-i-1] = __gcd(r[n-i],vect[n-i-1]);
  }

  int maxi = 0;
  int temp;
  for (int i = 1; i < n+1; i++){
  	temp = __gcd(l[i-1], r[i]);
    (temp > maxi)? maxi = temp : maxi = maxi;
    // cout << maxi <<'\n'
  }
  cout << maxi << '\n';

	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(void){
	int n,m;
	scanf("%d",&n);
	m=n%10;
	if(m==2||m==4||m==5||m==7||m==9){
		printf("hon");
		return 0;
	}else if(m==0||m==1||m==6||m==8){
		printf("pon");
		return 0;
	}else{
		printf("bon");
		return 0;
	}
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int n,m;
vii edges[100005];

int main()
{
    cin >> n >> m;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].pb(b);
        edges[b].pb(a);
    }
    bool used[n] = {};
    int now = 0;
    vii left = {0};
    used[0] = true;
    bool flag = true;
    while (flag){
        flag = false;
        for (auto nex:edges[now]){
            if (used[nex])
                continue;
            now = nex;
            used[now] = true;
            left.pb(now);
            flag = true;
            break;
        }
    }
    vii right = {0};
    now = 0;
    flag = true;
    while(flag){
        flag = false;
        for (auto nex:edges[now]){
            if (used[nex])
                continue;
            now = nex;
            used[now] = true;
            right.pb(now);
            flag = true;
            break;
        }
    }
    cout << right.size() + left.size() - 1 << endl;
    repr(i, right.size() - 1, -1) cout << 1+right[i] << " ";
    repf(i, 1, left.size()) cout << 1+left[i] << " ";
    cout << endl;
}


Measured memory_bytes: 6904
#include<stdio.h>
int H;
int A[500002];
void maxHeapify(int n){
  int l = n*2;
  int r = l+1;
  int large;
  int tmp;
  if(l<=H && A[l]>A[n]){
    large = l;
  }
  else large = n;
  if(r<=H && A[r]>A[large]){
    large = r;
  }

  if(large !=n){
    tmp = A[n];
    A[n] = A[large];
    A[large] = tmp;
    maxHeapify(large);
  }
}
void buildMaxHeap(void){
  int i;
  for(i=H/2;i>0;i--) maxHeapify(i);
}
int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}




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

int main(){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool flag = true;
    for(int i=0;i<s.size();++i){
        if(i == a && s[i] != '-' || i != a && (s[i] < '0' || s[i] > '9'))flag = false;
    }
    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
integer N
integer(16) i,j,k
integer(16) check
read*,N
do i=1,3500
  do j=1,3500
  check=4*i*j-N*i- N*j
  if(check<=0)cycle
  if(mod(N*i*j,check)==0)then
    k=(N*i*j)/check
    print"(i0,A,i0,A,i0)",i," ",j," ",k
    stop
  endif
  
  end do
end do
end

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
    ma=max(l[i-1],l[i],l[i+1])
    mi=min(l[i-1],l[i],l[i+1])
    if ma!=l[i] and mi!=l[i]:
        ans+=1
print(ans)



Measured memory_bytes: 3060
A,B = map(int,input().split())


#互いに素の性質
#a, b の最大公約数 gcd(a, b) が 1 に等しい。
#aとb1、aとb2がそれぞれ互いに素ならばaとb1b2も互いに素である。
#整数 ab (a, b > 1) を選ぶよりも、a を選んだほうが良いです (注意: ab が公約数ならば a も公約数です)。
#すなわち、P を最適解とすると、P で選んだ公約数の中に ab (a, b > 1) と表せる整数が存在したとすると、代わりにa を選ぶことができます。
#よって、1 または素数のみを選んだ最適解が存在します。 
#考察も実装も簡単な方法としては、A, B をそれぞれ素因数分解し 
#(時間計算量はそれぞれ O(√A), O(√B))、共通の素因数を探す方法があります。
#1 と共通の素因数を選ぶのが最適なので、共通の素因数の個数に 1 を加えた値が答えになります。

#nの素因数分解を行いリストを返す
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A_so = prime_factorize(A)
B_so = prime_factorize(B)

#与えられた素因数のリストを集合に変換(このあと共通項を見つけ出すため)
A_so = set(A_so)
B_so = set(B_so)

#集合でandを取る
A_B = A_so & B_so

#答えの出力(andの結果に 1　を加えた数が答え(1と共通の素因数を選ぶことが最適)
ans = len(A_B) + 1
print(ans)


Measured memory_bytes: 40560
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include<functional>

using namespace std;

int main(){
  int n,suma=0,sumb=0;
  cin >> n;
  vector<int> vi(n);
  for(int i=0;i<n;++i){
    scanf("%d",&vi[i]);
  }
  sort(vi.begin(),vi.end(),greater<int>());
  for(int i=0;i<n;++i){
    if(i%2) sumb += vi[i];
    else suma += vi[i];
  }
  suma = suma - sumb;
  cout << suma << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a > b)
      System.out.println("a > b");
    else if(a < b)
      System.out.println("a < b");
    else
      System.out.println("a == b");
  }
}


Measured memory_bytes: 26352
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
using P=pair<int,int>;
using ll=long long;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    if(k<=a)cout<<k<<endl;
    else if(k<=a+b)cout<<a<<endl;
    else cout<<a-(k-a-b)<<endl;
}

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

#define MAX_X (1000005)

void calcPrime(bitset < MAX_X > &prime)
{
    for ( int i = 2; i < MAX_X; i++ ) {
        prime[i] = true;
    }

    for ( int i = 2; i * i < MAX_X; i++ ) {
        if ( prime[i] ) {
            for ( int j = i * i; j < MAX_X; j += i ) {
                prime[j] = false;
            }
        }
    }
}

int main()
{
    int N, X;
    bitset < MAX_X > prime;

    calcPrime(prime);

    while ( cin >> N >> X, N || X ) {
        bitset < MAX_X > dp;

        dp[0] = true;
        for ( int i = 0; i < N; i++ ) {
            int v;
            cin >> v;
            for ( int j = 0; j <= X; j++ ) {
                if ( dp[j] && j + v <= X ) {
                    dp[j + v] = true;
                }
            }
        }
        int k = X;
        while ( k > 0 && (!prime[k] || !dp[k]) ) {
            k--;
        }
        if ( k > 0 ) {
            cout << k << endl;
        } else {
            cout << "NA" << endl;
        }
    }

    return (0);
}


Measured memory_bytes: 3280
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int a, b, c;
signed main() {
	cin >> a >> b >> b >> b >> b >> c;
	if (b - a > c) {
		cout << ":(\n";
	}
	else {
		cout << "Yay!\n";
	}
}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
S = input()

cum = [0]
last = S[0]
cnt = 0
for s in S:
    if s == last:
        cnt += 1
    else:
        cum.append(cum[-1] + cnt)
        cnt = 1
        last = s
cum.append(cum[-1] + cnt)

ans = 0
start = 0 if S[0] == '1' else 1
for i in range(start, len(cum), 2):
    ans = max(ans, cum[min(i + 2 * k + 1, len(cum) - 1)] - cum[i])

if S[0] == '0':
    ans = max(ans, cum[min(2 * k, len(cum) - 1)])

print(ans)

Measured memory_bytes: 7160
N = int(input())
A = list(map(int, input().split()))
memo = {1:0,2:0,4:0}

for a in A:
    if a % 4 == 0:
        memo[4] += 1
    elif a % 2 == 0:
        memo[2] += 1
    else:
        memo[1] += 1

if memo[4] >= (N//2):
    print("Yes")
elif memo[4] >= memo[1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
#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 pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

int n;
vi solve(int nn,int l,int r,int bak){
	//printf("%d  %d %d %d\n",nn,l,r,bak);
	if(nn==1)return {l&bak,r&bak};
	vi L,R,res;
	REP(i,n)if((bak>>i&1)&&((l>>i&1)^(r>>i&1))){
		int vl=(l>>i&1),vr=(r>>i&1),fr=0;
		REP(j,n)if((bak>>j&1)&&(j!=i))fr=1<<j;
		L=solve(nn-1,l,l^fr,bak^(1<<i));
		R=solve(nn-1,l^fr,r,bak^(1<<i));
		res.resize(1<<nn);
		int semi=1<<(nn-1);
		REP(j,semi)
			res[j]=L[j]^(vl<<i);
		REP(j,semi)
			res[j+semi]=R[j]^(vr<<i);
		break;
	}
	return res;
}

int main(){
	int l,r;
	cin>>n>>l>>r;
	if(__builtin_popcount(l^r)%2==0)
		return puts("NO"),0;
	vi ans=solve(n,l,r,(1<<n)-1);
	puts("YES");
	for(auto x:ans)printf("%d ",x);
	return 0;
}

Measured memory_bytes: 1648
#include <iostream>

using namespace std;

int W, H;
int dx[4] = {0, 1, 0, -1},
    dy[4] = {-1, 0, 1, 0};
char field[22][22];     // 1-origin

int dfs(int y, int x)
{
  if (field[y][x] == '#') {
    return 0;
  }
  
  field[y][x] = '#';
  int res = 1;
  for (int k = 0; k < 4; k++) {
    res += dfs(y + dy[k], x + dx[k]);
  }

  return res;
}

int main()
{

  while (cin >> W >> H && (W && H)) {

    // pre exec
    for (int i = 0; i <= 22; i++)
      for (int j = 0; j < 22; j++) 
        field[i][j] = '#';

    // read
    int sx = 1, sy = 1;
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        cin >> field[i][j];
        if (field[i][j] == '@') {
          sx = j; sy = i;
          field[i][j] = '*';
        }
      }
    }

    // depth first search
    cout << dfs(sy, sx) << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pb push_back
#define log(x,b) (log(b)/log(x))
#define rep(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;

const int mod=1e9+7;

int32_t main()
{
    int n,m;
    cin>>n>>m;
    vector<string>a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
      for (int i = 0; i < n + 2; i++)
  {
    if (i == 0 || i == n + 1) {
      for (int j = 0; j < m + 2; j++)
      {
        cout << '#';
      }
      cout << endl;
    } else {
      cout << '#' << a.at(i - 1) << '#' << endl;
    }
  }
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>

int main(int argc, const char * argv[]) {
    using namespace std;
    
    vector <int> Num;
    int Card, v, j;
    
    cin >> Card;
    int dummy;
    for(int i = 0;i < Card;i++){
        cin >> dummy;
        Num.push_back(dummy);
    }
    
    for(int i = 1;i <= Card - 1;i++){
        for(int h = 0;h < Card - 1;h++){
            cout << Num[h] << ' ';
        }
        cout << Num[Card - 1] << endl;
        v = Num[i];
        j = i - 1;
        while(j >= 0 && Num[j] > v){
            Num[j + 1] = Num[j];
            j--;
        }
        Num[j + 1] = v;
    }
    for(int h = 0;h < Card - 1;h++){
        cout << Num[h] << ' ';
    }
    cout << Num[Card - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if ((i+1)%2==1)cout << s[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MAX(a, b)  a>b?a:b
#define MIN(a, b)  a<b?a:b

int main()
{
	int n;
	int p[200000];
	int *ptr = p;
	int min=200000;
	int ans=0;

	cin>>n;

	for(int i=0 ; i<n ; i++){
		cin>>p[i];
	}

	for(int i=0 ; i<n ; i++){
		if(*ptr<=min){
			ans++;
			min=*ptr;
		}
		ptr++;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

class Solver extends Main{
	Solver(){
		
	}
}//Solver_end

@SuppressWarnings("unchecked")
class Main{
	static int imax=Integer.MAX_VALUE;
	static long lmax=Long.MAX_VALUE;
	
	public static void main(String[] args) throws FileNotFoundException{
		
		Scanner sc=new Scanner(System.in);
		int[] num=readlnI(sc," ");
		int eat=num[0]-num[1]+num[2];
		int lmt=num[0]*2;

		if(eat<=num[0]){
			puts("delicious");
		}else if(num[0]<eat && eat<=lmt){
			puts("safe");
		}else if(lmt<eat){
			puts("dangerous");
		}
		
		new Solver();
	}//main_end
	
//---------------------------------------------------------------------------
	static int readI(Scanner sc){
		return Integer.parseInt(sc.nextLine().trim());
	}
	static long readL(Scanner sc){
		return Long.parseLong(sc.nextLine().trim());
	}
	static String readS(Scanner sc){
		return sc.nextLine().trim();
	}
	static int[] readlnI(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToInt(Integer::parseInt).toArray();
	}
	static long[] readlnL(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToLong(Long::parseLong).toArray();
	}
	static String[] readlnS(Scanner sc, String dl){
		return sc.nextLine().trim().split(dl);
	}
	@SuppressWarnings("unchecked")
	static <T> void puts(T... args){
		for(int i=0; i<args.length-1; i++){
			System.out.printf("%s ",args[i]);
		}
		System.out.println(args[args.length-1]);
	}
	static void puts(int[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void puts(long[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void bs(){
		System.out.println("");
	}
	static int sum(int[] ary){
		int sum=0;
		for(int i=0; i<ary.length; i++) sum+=ary[i];
		return sum;
	}
	static long sum(long[] ary){
		long sum=0;
		for(int i=0; i<ary.length; i++) sum+=ary[i];
		return sum;
	}
	static void tblSort(int[][] tbl){
		Arrays.sort(tbl, new Comparator<int[]>(){
			@Override
			public int compare(int[] a, int[] b){
				if(a[0]==b[0]){
					return b[1]-a[1];
				}else{
					return b[0]-a[0];
				}
			}
		});
	}
}


Measured memory_bytes: 26708
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef struct {
    ll a, b;
} BUG;

BUG foo[300000];
int n;

int seg[1 << 19][2];
int seg_size;

ll _max(ll a, ll b)
{
    return (a > b ? a : b);
}

void init(int n)
{
    seg_size = 1;
    
    while (n > seg_size){
        seg_size *= 2;
    }
    memset(seg, -1, sizeof(seg));
}

void update(int k, int x)
{
    k += seg_size;
    
    seg[k][0] = x;
    seg[k][1] = k - seg_size;
    
    while (k != 0){
        k = (k - 1) / 2;
        if (seg[k * 2 + 1][0] > seg[k * 2 + 2][0]){
            seg[k][0] = seg[k * 2 + 1][0];
            seg[k][1] = seg[k * 2 + 1][1];
        }
        else {
            seg[k][0] = seg[k * 2 + 2][0];
            seg[k][1] = seg[k * 2 + 2][1];
        }
    }
}

int comp(const void *a, const void *b)
{
    BUG x, y;
    x = *(BUG *)a;
    y = *(BUG *)b;
    
    if (x.b != y.b){
        return (y.b - x.b);
    }
    else {
        return (x.a - y.a);
    }
}

int canPut(int piv)
{
    int i;
    ll lim;
    
    init(piv);
    
    lim = 0;
    for (i = 0; i < piv - 1; i++){
        lim += foo[i].a;
        update(i, foo[i].a);
    }
    
    while (i < n){
        if (i == piv - 1){
            lim += foo[i].a;
            update(i, foo[i].a);
        }
        else {
            lim -= seg[0][0];
            lim += foo[i].a;
            update(seg[0][1], foo[i].a);
        }
        
        if (lim <= foo[i].b * piv){
            return (1);
        }
        i++;
    }
    
    return (0);
}

int main(void)
{
    int i;
    int left, right, center;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        scanf("%lld %lld", &foo[i].a, &foo[i].b);
    }
    
    left = 0;
    right = n;
    
    qsort(foo, n, sizeof(BUG), comp);
    
    while (left != right){
        center = (left + right + 1) / 2;
        
        if (canPut(center)){
            left = center;
        }
        else {
            right = center - 1;
        }
    }
    
    printf("%d\n", left);
    
    return (0);
}

Measured memory_bytes: 9832
#include <stdio.h>

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

Measured memory_bytes: 128