akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
	class Program
	{
		static void Main(string[] args)
		{
			//var n = Console.ReadLine();
			var nmr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int[,] d = new int[nmr[0], nmr[0]];
			int c = int.MaxValue / 4;
			for (int i = 0; i < nmr[0]; i++)
			{
				for (int j = 0; j < nmr[0]; j++)
				{
					d[i, j] = c;
				}
			}
			var r = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			for (int i = 0; i < nmr[1]; i++)
			{
				var abc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				d[abc[0]-1, abc[1]-1] = abc[2];
				d[abc[1]-1, abc[0]-1] = abc[2];
			}
			for (int i = 0; i < nmr[0]; i++)
			{
				for (int j = 0; j < nmr[0]; j++)
				{
					for (int k = 0; k < nmr[0]; k++)
					{
						if (d[i, j] > d[i, k] + d[k, j])
						{
							d[i, j] = d[i, k] + d[k, j];
						}
						if (d[j, i] > d[k, i] + d[j, k])
						{
							d[j, i] = d[k, i] + d[j, k];
						}
					}
				}
			}
			for (int i = 0; i < nmr[0]; i++)
			{
				for (int j = 0; j < nmr[0]; j++)
				{
					for (int k = 0; k < nmr[0]; k++)
					{
						if (d[i, j] > d[i, k] + d[k, j])
						{
							d[i, j] = d[i, k] + d[k, j];
						}
						if (d[j, i] > d[k, i] + d[j, k])
						{
							d[j, i] = d[k, i] + d[j, k];
						}
					}
				}
			}
			int min = int.MaxValue;
			var perm = new Permutation();
			foreach (var n in perm.Enumerate(r))
			{
				int pos = -1;
				int sum = 0;
				foreach (var x in n)
				{
					if(pos == -1)
					{
						pos = x;
						continue;
					}
					if (d[x - 1, pos - 1] == c) goto NEXT;
					sum += d[x - 1, pos - 1];
					pos = x;
				}
				min = Math.Min(min, sum);
			NEXT:;
			}
			Console.WriteLine(min);
			//Console.ReadLine();
		}
	}

	public class Permutation
	{
		public IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items)
		{
			return _GetPermutations<T>(new List<T>(), items.ToList());
		}

		private IEnumerable<T[]> _GetPermutations<T>(IEnumerable<T> perm, IEnumerable<T> items)
		{
			if (items.Count() == 0)
			{
				yield return perm.ToArray();
			}
			else
			{
				foreach (var item in items)
				{
					var result = _GetPermutations<T>(perm.Concat(new T[] { item }),
														items.Where(x => x.Equals(item) == false)
									);
					foreach (var xs in result)
						yield return xs.ToArray();
				}
			}
		}
	}
}

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

using namespace std;
typedef long long ll;




int main()
{
    int N;cin >> N;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if(i*j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
    
    return 0;
}



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

bool cards[2][201];
int N, field, rest[2];
int main()
{
  while(true)
  {
    cin >> N;
    if(!N)
      break;
    for(int i = 0; i <= N * 2; i++)
      cards[0][i] = 0;
    for(int i = 0; i < N; i++)
    {
      int tmp;
      cin >> tmp;
      cards[0][tmp] = 1;
    }
    for(int i = 0; i <= N * 2; i++)
    {
      if(!cards[0][i])
        cards[1][i] = 1;
      else
        cards[1][i] = 0;
    }
    rest[0] = rest[1] = N;

    field = 0;
    int turn = 0;
    while(rest[0] > 0 && rest[1] > 0)
    {
      bool b = true;
      for(int i = 1; i <= 2 * N; i++)
      {
        if(cards[turn][i] && i > field)
        {
          cards[turn][i] = 0;
          rest[turn]--;
          field = i;
          b = false;
          break;
        }
      }
      if(b)
        field = 0;
      turn = (turn + 1) % 2;
    }
    cout << rest[1] << endl << rest[0] << endl;
  }
}

Measured memory_bytes: 1160
fun main (args:Array<String>){
    var (monsterHp , raccoonBlowNum) = readLine()!!.split(" ").map(String::toInt)
    val attackPoint = readLine()!!.split(" ").map(String::toInt)
    for (i in 0..raccoonBlowNum-1){
        monsterHp -= attackPoint[i]
    }
    if(monsterHp <= 0) print("Yes")
    else print("No")
}

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


int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int counter = 0;
  
  rep(counter,d){
  	if(b<=a){
      b *= 2;
      continue;
  	}
    if(c<=b){
      c *=2;
      continue;
    }
  }
  if(a < b && b < c){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}

Measured memory_bytes: 3632
/*  
    Talkin' to myself and feelin' old
    Sometimes I'd like to quit, nothin' ever seems to fit
    Hangin' around, nothin' to do but frown
    Rainy days and Mondays always get me down
    _________________________
    _________________________
    912 Hours of Solitude
    Quarantine_Day : 38
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005


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

	ll n, k; cin>>n>>k;
	vl v(n);
	REP(i, n) cin>>v[i];
	GSORT(v);
	ll sum = 0;
	REP(i, k) sum += v[i];
	cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    n=int(input())
    D=defaultdict(int)
    for _ in range(n):
        tup=tuple(sorted(input()))
        D[tup]+=1

    ans=0
    for x in D.values():
        ans+=x*(x-1)//2

    print(ans)
resolve()

Measured memory_bytes: 128348
n, k=gets.split.map(&:to_i)

ret=0
1.upto n do |b|
  m=(n+1)/b
  ret+=[b-k, 0].max*m
  l=n+1-m*b
  ret+=[l-k, 0].max
end

ret-=n if k==0
puts ret

Measured memory_bytes: 1788
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

bob = []
alice = []

for i in range(n):
    if(i%2 == 0):
        alice.append(a[i])
    else:
        bob.append(a[i])

print(sum(alice) - sum(bob))


Measured memory_bytes: 3060
//#pragma optimization_level 3

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <chrono>
#include <ctime>
#include <queue>
#include <math.h>
#include <deque>
#include <stack>
#include <iomanip>
#include <assert.h>
#include <stdio.h>
#include <cstring>
#include <random>

using namespace std;

#define int long long
#define ld long double
#define ull unsigned long long
//#define endl '\n'
#define try tr
#define pii pair<int, int>
#define ti tuple <int, int, int>
#define vi vector <int>
#define vpi vector <pii>
#define umap unordered_map
#define uset unordered_set
#define left left11
#define right right11
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define X first
#define Y second

ld TL = 1.0;
bool is_tl = 0;
int CALLS = 0;

inline bool IS() {
    if (++CALLS == 1000) {
        CALLS = 0;
        is_tl |= clock() > (TL - 0.1) * CLOCKS_PER_SEC;
    }
    return is_tl;
}

template<typename T1, typename T2>
inline void amin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void amax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p) {
    os << p.first << ' ' << p.second << endl;
    return os;
}

template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
    is >> p.first >> p.second;
    return is;
}

template<typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
    for (auto &u : v) os << u << ' ';
    os << endl;
    return os;
}

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 7, NS = 2e3 + 7, lg = 19, sq = 550, inf = 1e18 + 7, SM = 1e2 + 7;
const ld eps = 1e-9;
int hash_mod[4] = {1000000007, 998244353, 1000000009, 999999937}, mod = hash_mod[rnd() % 4];
int hash_pows[4] = {179, 239, 1007, 2003}, P = hash_pows[rnd() % 4];

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = min({a * b * ((c + 1) / 2 - c / 2), b * c * ((a + 1) / 2 - a / 2), a * c * ((b + 1) / 2 - b / 2)});
    cout << ans;
}

signed main() {
    fast
    solve();

}

Measured memory_bytes: 3608
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    VV gragh(n);
    rep(i, n - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        gragh[a].push_back(b);
        gragh[b].push_back(a);
    }
    ll m;
    cin >> m;
    queue<ll> q;
    q.push(0);
    V reg(n, -1);
    reg[0] = 0;
    while (!q.empty())
    {
        ll k = q.front();
        q.pop();
        rep(i, gragh[k].size())
        {
            if (reg[gragh[k][i]] == -1)
            {
                reg[gragh[k][i]] = (1LL << gragh[k][i] | reg[k]);
                q.push(gragh[k][i]);
            }
        }
    }
    V reg2(m);
    rep(i, m)
    {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        reg2[i] = reg[u] ^ reg[v];
      //    cout<<bitset<8>(reg2[i])<<endl;
    }
    ll res = 0;
    rep3(bit, 0, (1LL << m))
    {
        ll temp = 0;
        rep(j, m)
        {
            if (bit&(1LL<<j))
            {
                temp |= reg2[j];
            }
        }
       // cout<<temp<<endl;
        ll k = n - 1 - __builtin_popcountll(temp);
        ll f = __builtin_popcountll(bit);
     //   cout<<k<<" "<<f<<endl;
        if (f % 2 == 0)
        {
            res += (1LL<<k);
        }
        else
        {
            res -= (1LL<<k);
        }
      //  cout<<(1LL<<k)<<endl;
    }
    cout << res << endl;
}


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

typedef long long ll;

/// precalculate factorials
ll fact[200010];
void gen(ll m) {
    fact[0] = 1;
    for(int i = 1; i <= 200000; i++) {
        fact[i] = i * fact[i - 1];
        fact[i] %= m;
    }
}

/// binary exponentiation
ll binpow(ll a, ll b, ll m) {
    if(b == 0) return 1;

    ll res = binpow(a, b / 2, m);
    res *= res;
    res %= m;

    if(b & 1) return (res * a) % m;
    else return res;
}

/// moduldar inverse when m is prime O(log m)
ll modinv(ll a, ll m) {
    return binpow(a, m - 2, m);
}

ll ncr(ll n, ll k, ll m) {
    ll num = 1, den = 1;

    for(ll i = n; i > (n - k); i--) {
        num *= i;
        num %= m;
    }

    for(ll i = 1; i <= k; i++) {
        den *= i;
        den %= m;
    }

    return (num * modinv(den, m)) % m;
}

const ll mod = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);

    gen(mod);

    int n, a, b;
    cin >> n >> a >> b;

    ll x = binpow(2, n, mod);

    ll y = (1 + ncr(n, a, mod) + ncr(n, b, mod)) % mod;

    ll ans = (x - y + mod) % mod;

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

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

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

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


void Main() {
  int N; cin >> N;
  vector<int> d(N);
  rep(i, 0, N) cin >> d[i];
  ll res = 0;
  rep(i, 0, N - 1){
    rep(j, i + 1, N){
      res += d[i] * d[j];
    }
  }
  cout << res << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 8064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    ll res = INF;
    for(int i=1; i<h; i++){
        ll s[3]; s[0] = i*w;
        s[1] = (h-i)*(w/2); s[2] = h*w - (s[0]+s[1]);
        sort(s, s+3);
        chmin(res, s[2]-s[0]);

        s[0] = i*w;
        s[1] = w*((h-i)/2); if(s[1] == 0) continue;
        s[2] = h*w - (s[0]+s[1]);
        sort(s, s+3);
        chmin(res, s[2]-s[0]);
    }
    
    swap(h,w);

    for(int i=1; i<h; i++){
        ll s[3]; s[0] = i*w;
        s[1] = (h-i)*(w/2); s[2] = h*w - (s[0]+s[1]);
        sort(s, s+3);
        chmin(res, s[2]-s[0]);

        s[0] = i*w;
        s[1] = w*((h-i)/2); if(s[1] == 0) continue;
        s[2] = h*w - (s[0]+s[1]);
        sort(s, s+3);
        chmin(res, s[2]-s[0]);
    }
    cout << res << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 // #include <ext/pb_ds/tree_policy.hpp>
 // #include <ext/pb_ds/assoc_container.hpp>
 // #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 // using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define mod        1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        2e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}

vector<string>ch;

void recur(int ps,string s,int fl)
{
  if(ps==0)
  {
    for(int j=0;j<=9;j++)
    {
      if(j>0) fl=0;
      s[ps] = j+'0';
      recur(ps+1,s,fl);
    }
    return ;
  }
  else if(ps==10)
  {

    ch.pb(s);
    return ;
  }
  
  for(int j=0;j<=9;j++)
    if(abs(s[ps-1] - (j+'0'))<=1 || fl==1)
    {
      s[ps] = j+'0';
     if(j>0) recur(ps+1,s,0);
     else recur(ps+1,s,fl);
    }
}

void solve()
{
 
 int k;
 cin >> k ;

 string s;
 s.assign(10,'0');
 
 recur(0,s,1);


 string an = ch[k];
 while(an[0]=='0')an.erase(an.begin());
 cout<<an<<endl;
}

int32_t main()
{
  //pr_init();
  fastio;
  solve();

 }


Measured memory_bytes: 11588
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int[] W = new int[N];
		Arrays.setAll(W, $ -> Integer.parseInt(sc.get()));

		int[] cum = new int[N];
		cum[0] = W[0];
		for (int i = 1; i < W.length; i++) {
			cum[i] = cum[i - 1] + W[i];
		}

		int min = Integer.MAX_VALUE;
		for (int i = 0; i < W.length; i++) {
			int lower = cum[i];
			int upper = cum[N - 1] - cum[i];
			min = Math.min(min, Math.abs(upper - lower));
		}
		System.out.println(min);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 27092
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <array>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iostream>
using namespace std;

typedef unsigned long long Uint64;
const Uint64 answer=1147797409030816545ULL;
const int bw=20000;//1<<13;
int ROW[]={3,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3};
int COL[]={3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2};

vector<int> neighbor[16] = {
    {4, 1, }, {0, 5, 2, }, {1, 6, 3, }, {2, 7, },
    {0, 8, 5, }, {1, 4, 9, 6, }, {2, 5, 10, 7, }, {3, 6, 11, },
    {4, 12, 9, }, {5, 8, 13, 10, }, {6, 9, 14, 11, }, {7, 10, 15, },
    {8, 13, }, {9, 12, 14, }, {10, 13, 15, }, {11, 14, },
};

Uint64 encode(const array<char, 16>& a)
{
    Uint64 res=0;
    for(int i=0;i<16;++i) res|=(Uint64)a[i]<<(4*i);
    return res;
}

void decode(array<char, 16>& a, Uint64 val)
{
    for(int i=0;i<16;++i) a[i]=(val>>(4*i))&15;
}

#define get(x, i) (int((x)>>4*(15-(i)))&15)
#define slide(x, v, i, j) { x|=(Uint64)(v)<<4*(15-(i)); x&=~(15ULL<<4*(15-(j))); }

int calcscore(const Uint64& x)
{
    int sumd=0, hoge=0;
    for(int i=0;i<16;++i) {
        int t=get(x, 15-i);
        if (t==0) continue;
        int d=abs(ROW[t]-i/4)+abs(COL[t]-i%4);
        for(int j: neighbor[15-i]) if (0<d and d<3 and abs(t-(int)get(x, j))==1) ++hoge;
        sumd+=d;
    }
    return -1024*sumd+hoge;
}

void input(array<char, 16>& a, int& k){
    int c;
    
    for(int i = 0; i < 16; i++){
        cin >> c;
        a[i] = c;
        if(a[i] == 0)
            k = i;
    }
}

int main(){
    array<char, 16> a;
    int f0;
    input(a, f0);
    
    if(encode(a) == answer){
        cout << 0 << endl;
        return 0;
    }
    
    unordered_map<Uint64, int> scores;
    unordered_map<Uint64, pair<int, Uint64>> seq;
    vector<pair<Uint64, int>> q(bw);
    f0=15-f0;
    q.emplace_back(encode(a), f0);
    seq[encode(a)]={-1, -1};
    while (true) {
        priority_queue<tuple<int, Uint64, int>> nq;
        for(auto& p: q) {
            auto b=p.first;
            int i=p.second;
            for(int j: neighbor[i]) {
                int t=get(b, j);
                slide(b, t, i, j);
                if (seq.count(b)==0) {
                    int score=calcscore(b);
                    nq.emplace(score, b, j);
                    seq[b]={t, p.first};
                }
                b=p.first;
            }
        }
        int N=min<int>(nq.size(), bw);
        for(int i=0;i<N;++i) {
            Uint64 b;
            int j;
            tie(ignore, b, j)=nq.top();
            q[i]=make_pair(b, j);
            nq.pop();
        }
        if (q[0].first==answer) break;
    }
    
    vector<int> res;
    Uint64 asr=answer;
    while (seq.count(asr)) {
        auto b=seq[asr].second;
        int x=seq[asr].first;
        if (x==-1) break;
        res.push_back(x);
        asr=b;
    }
    
    reverse(begin(res), end(res));
    cout << res.size() << endl;
}



Measured memory_bytes: 79256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main() {
    int N;
    cin >> N;
    map<int, int> A;
    rep(i, N) {
        int input;
        cin >> input;
        if(A.count(input)) {
            cout << "NO" << endl;
            return 0;
        } else {
            A[input] = 1;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

ll cn[511][511],sum[511][511];

int main(){
    ll n,m,q;cin>>n>>m>>q;
    rep(i,0,m){
        ll l,r;
        cin>>l>>r;
        cn[l][r]++;
    }
    rep(i,1,502){
        rep(j,1,502){
            sum[i][j]=sum[i][j-1]+cn[i][j];
        }
    }
    rep(i,0,q){
        ll l,r,an=0;
        cin>>l>>r;
        rep(j,l,r+1){
            an+=sum[j][r]-sum[j][l-1];
        }
        cout<<an<<endl;
    }
    
}
    









Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    if(fabs(a-x)>fabs(x-b))
        printf("B\n");
    else
        printf("A\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N, M, K, A;
int cnt = 0;  
cin >> N >> M;
  
int a[30] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  for(int i = 0;i < N;i++){
    cin >> K;
  for(int j = 0;j < K;j++){
  cin >> A;
    a[A-1]++;
  }
  }
  
  for(int i = 0;i < 30;i++){
  if(a[i] == N){
  cnt++;
  } 
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

int main(){
	ll n;
	scanf("%lld",&n);
	printf("%lld",n/3);
}

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

int main(){
    int N, input, alice = 0, bob = 0;
    cin >> N;
    vector<int> a;
    for(int i = 0; i < N; i++){
        cin >> input;
        a.push_back(input);
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < N; i++){
        if(i % 2 == 0) alice += a[N - i - 1];
        else bob += a[N - i - 1];
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, M;
    while(cin>>N>>M, N|M){
        vector<int> code_book(M);
        vector<int> data(N);
        for(auto &c: code_book)
            cin >> c;
        for(auto &d: data)
            cin >> d;
        
        vector<vector<int>> dp(N+1, vector<int>(256, INF));
        dp[0][128] = 0;
        for(int i=0; i<N; i++){
            for(int j=0; j<256; j++){
                for(auto c: code_book){
                    int ni = min(255, max(0, j+c));
                    auto &next = dp[i+1][ni];
                    int error = (ni-data[i])*(ni-data[i]);
                    next = min(next, dp[i][j]+error);
                }
            }
        }
        
        int ans = INF;
        for(auto &t: dp[N])
            ans = min(ans, t);
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 22008
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int edge[111][1111];
int main(void){
  while(1){

    int n,m,a;
    cin >> n >> m >> a;
    if(!n && !m && !a) break;
    a--;

    for(int i = 0; i < n; i++){
      fill(edge[i],edge[i] + 1111,i);
    }

    for(int i = 0; i < m; i++){
      int h,p,q;
      cin >> h >> p >> q;
      p--;
      q--;
      edge[p][h] = q;
      edge[q][h] = p;
    }

    for(int i = 1000; i > 0; i--){
      a = edge[a][i];
    }
    cout << a + 1 << endl;
  }
}

Measured memory_bytes: 1592
import java.util.*;
import java.util.stream.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),k=s.nextInt();
		int[]a=new int[n];
		Arrays.setAll(a,i->s.nextInt());
		System.out.println(IntStream.range(0,n-k+1)
				.map(i->Math.min(Math.abs(a[i]),Math.abs(a[i+k-1]))+a[i+k-1]-a[i])
				.min().getAsInt());
	}
}


Measured memory_bytes: 63136
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAX 256

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};


int X, Y, E;

struct edge {
    int to;
    int cap;
    int rev;
};

vector<edge> G[MAX];
bool used[MAX];

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    while (1) {
        for (int i = 0; i < MAX; i++) used[i] = false;
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int main(void) {
    cin >> X >> Y >> E;
    while (E--) {
        int x, y;
        cin >> x >> y;
        add_edge(x, X+y, 1);
    }
    int s = X+Y, t = s+1;
    for (int i = 0; i < X; i++) {
        add_edge(s, i, 1);
    }
    for (int i = 0; i < Y; i++) {
        add_edge(X+i, t, 1);
    }
    cout << max_flow(s, t) << endl;
    return 0;
}

Measured memory_bytes: 1532
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define pi acos(-1);
ll strtoint(string str);
int main(){
	fast;
	ll n,ans=0; cin>>n;
	vector<ll> arr(n); 
	for(auto &it:arr)cin>>it;
	sort(arr.begin(), arr.end());
	for(auto i=0;i<n;++i){
		for(auto j=i+1;j<n;++j){
			auto l=lower_bound(arr.begin()+j+1,arr.end(),max(arr[i],arr[j])-min(arr[i],arr[j])+1)-(arr.begin()+j+1);
			auto u=upper_bound(arr.begin()+j+1,arr.end(),arr[i]+arr[j]-1)-(arr.begin()+j+1);
			if(u-l>0)ans+=(u-l);
		}
	}
	cout<<ans<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

string alpha = "abcdefghijklmnopqrstuvwxyz";

int main() {
  int N; cin >> N;
  vector<string> result = {"a"};
  repr(i,1,N) {
    vector<string> tmp;
    for (auto x: result) {
      int ma = 0; rep(j,i) ma = max(ma,x[j]-'a');
      // cout << x << " " << ma << endl;
      rep(j,ma+2) tmp.push_back(x+alpha[j]);
    }
    result.clear();
    copy(all(tmp),back_inserter(result));
  }
  sort(all(result));
  debug(all(result));
  return 0;
}

Measured memory_bytes: 10944
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,H = map(int,input().split())
AB = list(tuple(map(int,input().split())) for _ in range(N))

# 刀を振る攻撃は、最高威力のみを使うのが最善、よって最大値が分かれば良い
attack = 0
for a,b in AB:
    attack = max(attack, a)

# 刀を投げる攻撃は、刀を振る攻撃より高威力の場合のみ使えば良い
throw = list()
for a,b in AB:
    if b > attack:
        throw.append(b)

# 刀は高威力のものから投げる
throw.sort(reverse=True)

# 敵が死ぬか、高威力の刀がなくなるまで刀を投げる
ans = 0
for dam in throw:
    H -= dam
    ans += 1
    if H <= 0:
        break

# 敵が死んでいる場合
if H <= 0:
    print(ans)
# 敵がまだ生きている場合、通常攻撃を死ぬまで繰り返す
else:
    print(ans + (H-1)//attack + 1)

Measured memory_bytes: 17688
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n;
  string s, t;
  cin >> s >> t;
  n = max(s.size(), t.size());
  loop(i,0,n) {
    if (i<s.size()) cout << s[i];
    if (i<t.size()) cout << t[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int i=0;
  while(true){
    if(i%2==0){
      c-=b;
      if(c<=0){
        cout<<"Yes"<<'\n';
        return(0);
      }
    }
    else{
      a-=d;
      if(a<=0){
        cout<<"No"<<'\n';
        return(0);
      }
    }
    i++;
  }
  return(0);
}


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

#define N 1000000


//stack
typedef struct{
  int num[N];
  int head;
}Stack;

 //add to head position
void push(int);
  //delete head position
void pop(void);
  //return head of stack
int top(void);


Stack stack;

int main(){

  string str;
  int x,y;
  stack.head=0;
  //load  and caluculation
  while(cin >> str){

    if(str=="+"){
      x=top();
      pop();
      y=top();
      pop();
      push(x+y);
    }
    else if(str=="-"){
      x=top();
      pop();
      y=top();
      pop();
      push(y-x); 
    }
    else if(str=="*"){
      x=top();
      pop();
      y=top();
      pop();
      push(x*y);
    }
    else{
      //string -> int
      x = atoi(str.c_str());
      push(x);
    }
  }

  //print
  cout <<top()<<endl;
  
  return 0;
  
}



 //add to head position
void push(int x){
  stack.head++;
  stack.num[stack.head]=x;
}
//delete head position
void pop(void){
  stack.head--;
}
//return head of stack
int top(void){
  return stack.num[stack.head];
}

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> cards(N);

    ll nusuke_sum = 0;
    ll arai_sum   = 0;
    for (auto& card : cards) {
        cin >> card;
        nusuke_sum += card;
    }
    nusuke_sum -= cards.back();
    arai_sum += cards.back();
    ll min = abs(nusuke_sum - arai_sum);
    for (ll i = cards.size() - 2; i > 0; --i) {
        nusuke_sum -= cards[i];
        arai_sum   += cards[i];
        const ll result = abs(nusuke_sum - arai_sum);
        if (result < min) min = result;
    }

    cout << min << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair
#define pdi pair<ld,int>

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

// 2分探索
// 最大サイズmidを達成できるか

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  
  int N,K; cin>>N>>K;
  ld a[N]; CINA(a,N);
  ll ok = 1e18+1;
  ll ng = 0;
  while(abs(ok-ng)>1){
    ll mid = (ok+ng)/2;
    ll count = 0;
    REP(i,N){
      count += ceil(a[i]/mid)-1;
    }
    if(count<=K){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << ok << "\n";
}

Measured memory_bytes: 6868
#include<iostream>
using namespace std;
 
int main(void){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    const int lower = max(A,C);
    const int upper = min(B,D);
    
    cout << max(0,upper-lower) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

struct UnionFindTree {
    size_t n;
    vector<int> tree;
    UnionFindTree(size_t n): n(n) {
        tree = vector<int>(n, -1);
    }
    int find_root(size_t v) {
        if (tree[v] < 0) return v;
        return tree[v] = find_root(tree[v]);
    }
    bool unite(size_t x, size_t y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return false;
        if (rank(x) < rank(y)) swap(x, y);
        tree[x] += tree[y];
        tree[y] = x;
        return true;
    }
    bool has_same_root(size_t x, size_t y) {
        return find_root(x) == find_root(y);
    }
    size_t rank(size_t v) {
        return -tree[find_root(v)];
    }
};

int main() {
    size_t n, q;
    scanf("%zu %zu", &n, &q);

    UnionFindTree tree(n);
    for (size_t i=0; i<q; ++i) {
        int com;
        size_t x, y;
        scanf("%d %zu %zu", &com, &x, &y);

        if (com) {
            printf("%d\n", tree.has_same_root(x, y));
        } else {
            tree.unite(x, y);
        }
    }

    return 0;
}

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

using namespace std;

using Int = long long;

template<Int MOD>
struct ModInt {
    constexpr static Int mod = MOD;
    Int v;

    ModInt(long long _v = 0) : v(set(_v)) {}
    ModInt(const ModInt &r) : v(set(r.v)) {}

    inline static Int set(const Int x) { return x < 0 ? (x % mod) + mod : x % mod; }
    inline void set() { v = set(v); }

    bool operator<(ModInt r) const { return v < r.v; }
    bool operator>(ModInt r) const { return r.v < v; }
    bool operator==(ModInt r) const { return v == r.v; }
    bool operator!= (ModInt r) const { return v != r.v; }

    ModInt operator-() const { return ModInt(v ? mod - v : v); }
    ModInt &operator=(const ModInt &r) { if (this != &r) v = set(r.v); return *this; }
    ModInt &operator+=(ModInt r) { (v += r.v) %= mod; return *this; }
    ModInt &operator-=(ModInt r) { (v -= r.v - mod) %= mod; return *this; }
    // ModInt &operator*=(ModInt r) { v = (__uint128_t(v) * r.v) % mod; return *this; }
    ModInt &operator*=(ModInt r) { v = 1ULL * v * r.v % mod; return *this; }
    ModInt &operator/=(ModInt r) { *this *= r.inv(); return *this; }
    ModInt operator+(ModInt r) const { return ModInt(*this) += r; }
    ModInt operator-(ModInt r) const { return ModInt(*this) -= r; }
    ModInt operator*(ModInt r) const { return ModInt(*this) *= r; }
    ModInt operator/(ModInt r) const { return ModInt(*this) /= r; }

    ModInt inv() const {
        long long a = v, b = mod, u = 1, w = 0;
        while (b) {
            long long t = a / b;
            std::swap(a -= t * b, b);
            std::swap(u -= t * w, w);
        }
        return ModInt(u);
    }

    ModInt pow(Int e) {
        ModInt a = *this, x(1);
        for ( ; 0 < e; e >>= 1) { if (e & 1) x *= a; a *= a; }
        return x;
    }
    inline ModInt pow(ModInt &e) { return pow(e.v); }
};

std::ostream &operator<<(std::ostream &os, const auto &r) { return os << r.v; }
std::istream &operator>>(std::istream &is, auto &r) { is >> r.v; r.set();return is; }

using Mod2 = ModInt<2>;
using Type = ModInt<998244353>;
using Vector = vector<Mod2>;
using Matrix = vector<Vector>;

int Rank(Matrix &A) {
    const int N = A.size(), M = A[0].size();
    int rank = 0;
    vector<bool> used(N, false);

    for (int c = 0; c < M; ++c) {
        int pivot = 0;
        while (pivot < N && (used[pivot] || A[pivot][c] == 0)) ++pivot;
        if (pivot == N) continue;

        ++rank;
        used[pivot] = true;
        Mod2 v = A[pivot][c];
        for (int j = 0; j < M; ++j) A[pivot][j] /= v;
        for (int r = 0; r < N; ++r) {
            if (r == pivot) continue;
            for (int j = c + 1; j < M; ++j)
                A[r][j] -= A[r][c] * A[pivot][j];
        }
    }

    return rank;
}

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

    int n, m;
    cin >> n >> m;
    Matrix A(n, Vector(m));
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> A[i][j];

    int rank = Rank(A);
    Type res = Type(2).pow(m + n - 1) - Type(2).pow(m + n - rank - 1);
    cout << res << endl;

    return 0;
}


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

//INSERT ABOVE HERE
signed main(){
  Int w,h,n;
  cin>>w>>h>>n;
  vector<Int> x(n),y(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i];

  struct Point{
    Int x,y,s,idx;
    Point(){};
    Point(Int x,Int y,Int s,Int idx):x(x),y(y),s(s),idx(idx){}
  };

  vector<Point> vs;
  for(Int i=0;i<n;i++) vs.emplace_back(x[i],y[i],1,i);
  vs.emplace_back(1,1,0,n);
  vs.emplace_back(w,h,0,n+1);

  vector<vector<Int> > G(n+2);
  vector<vector<Int> > vx(w+1),vy(h+1);
  for(Int i=0;i<n+2;i++){
    vx[vs[i].x].emplace_back(i);
    vy[vs[i].y].emplace_back(i);    
  }
  
  for(Int i=0;i<=w;i++){
    auto comp=[&](Int i,Int j){return vs[i].y<vs[j].y;};
    sort(vx[i].begin(),vx[i].end(),comp);
    for(Int j=1;j<(Int)vx[i].size();j++){
      G[vs[vx[i][j]].idx].emplace_back(vs[vx[i][j-1]].idx);
      G[vs[vx[i][j-1]].idx].emplace_back(vs[vx[i][j]].idx);
    }
  }
  
  for(Int i=0;i<=h;i++){
    auto comp=[&](Int i,Int j){return vs[i].x<vs[j].x;};
    sort(vy[i].begin(),vy[i].end(),comp);
    for(Int j=1;j<(Int)vy[i].size();j++){
      G[vs[vy[i][j]].idx].emplace_back(vs[vy[i][j-1]].idx);
      G[vs[vy[i][j-1]].idx].emplace_back(vs[vy[i][j]].idx);
    }
  }

  const Int INF = 1e15;
  vector<vector<Int> > dp(2,vector<Int>(n+2,INF));

  using T = tuple<Int, Int, Int>;  
  priority_queue<T,vector<T>,greater<T> > pq;
  dp[0][n]=0;
  pq.emplace(dp[0][n],0,n);

  while(!pq.empty()){
    Int d,t,v;    
    tie(d,t,v)=pq.top();pq.pop();
    if(dp[t][v]<d) continue;

    //cout<<t<<" "<<v<<":"<<d<<endl;
    
    if(vs[v].s&&dp[!t][v]>dp[t][v]+1){
      dp[!t][v]=dp[t][v]+1;
      pq.emplace(dp[!t][v],!t,v);
    }
    
    for(Int u:G[v]){
      //cout<<vs[u].x<<" "<<vs[u].y<<endl;
      //cout<<vs[v].x<<" "<<vs[v].y<<endl;
      if(!t&&vs[u].x!=vs[v].x) continue;
      if( t&&vs[u].y!=vs[v].y) continue;
      Int nd=d+abs(vs[u].x-vs[v].x)+abs(vs[u].y-vs[v].y);
      if(dp[t][u]<=nd) continue;
      dp[t][u]=nd;
      pq.emplace(dp[t][u],t,u);
    }
  }  
  
  Int ans=min(dp[0][n+1],dp[1][n+1]);
  cout<<(ans>=INF?-1:ans)<<endl;
  return 0;
}



Measured memory_bytes: 43736
def CrossProduct(x1, y1, x2, y2, xp, yp):
	x2 -= x1
	xp -= x1
	y2 -= y1
	yp -= y1
	vec = (x2*yp-xp*y2)
	return True if vec > 0 else False

while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
    except EOFError:
        break
    if CrossProduct(x1, y1, x2, y2, xp, yp) == CrossProduct(x2, y2, x3, y3, xp, yp) == CrossProduct(x3, y3, x1, y1, xp, yp):
    	print 'YES'
    else:
    	print 'NO'

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

int main()
{
	int i,j;
	for(i=1;i<10;i++)
	{
		for(j=1;j<10;j++)
		{
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  if (A+B==C+D){
    cout<<"Balanced"<<endl;
  }
  
 else if (A+B<C+D){
   cout<<"Right"<<endl;
 }
  else{
    cout<<"Left"<<endl;
  }
}
  

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a[10];
	int i,j,x;
	for(i=0;i<10;i++) {
		scanf("%d",&a[i]);
	}
	for(i=0;i<10;i++){
		for(j=0;j<9;j++){
			if(a[j]<a[j+1]){
				x=a[j];
				a[j]=a[j+1];
				a[j+1]=x;
			}
		}
	}
	printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
	
return 0;
}

Measured memory_bytes: 600
d = { 'A':10, 'B':11, 'C':12, 'D':13, 'E':14, 'F':15 }
x, y = input().split()
if d[x] > d[y]:
    print(">")
elif d[x] < d[y]:
    print("<")
else:
    print("=")

Measured memory_bytes: 3188
def read_valus():
    return map(int, input().split())


def read_list():
    return list(read_valus())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    S = input()
    res = 0
    for i in range(len(S) // 2):
        if S[i] != S[-i - 1]:
            res += 1
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import bisect
n=int(input())
l=[int(x) for x in input().rstrip().split()]
l.sort()

ans=0
comb=[]
ans=0
for i in range(n):
    for j in range(i+1,n):
        now=l[i]+l[j]
        ind=bisect.bisect_left(l,now)
        ans+=max(0,ind-j-1)

print(ans)


Measured memory_bytes: 9300