akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef set<char> SET;

int main() {
    string a, b, c;
    while ( cin >> a && a != "-" ) {
        cin >> b >> c;

        int na = a.size(), nb = b.size(), nc = c.size();
        string res;
        char t = b[0];
        for ( int i = 0, j = 1, k = 0; i < na || j < nb; ) {
            if ( k < nc && c[k] == t ) {
                k ++;
                t = a[i++];
            } else {
                res += t;
                t = b[j++];
            }
        }
        res += t;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MAX = 62600;
typedef unsigned long long ull;

ull ONE = 1;

int n;
vi in;

ull arr[62610], arr1[62610];

void Zero(ull* arr){
  for(int i = 0;i < MAX;++i)
    arr[i] = 0;
  //memset(arr, 0, MAX * sizeof(ull));
}

void Or(){
  for(int i = 0;i < MAX;++i)
    arr[i] |= arr1[i];
}

bool Is(ull* arr, int pos){
  int cell = pos / 64;
  int bit = pos % 64;
  return (arr[cell] & (ONE << bit));
}

void Set(ull* arr, int pos){
  int cell = pos / 64;
  int bit = pos % 64;
  arr[cell] |= (ONE << bit);
}

bool Shift(int pos){
  int cells = pos / 64;
  int bits = pos % 64;
  int left = 64 - bits;
  for(int i = 0;i + cells < MAX;++i){
    arr1[i + cells] |= (arr[i] << bits);
    if(left < 64) {
      arr1[i + cells + 1] |= (arr[i] >> left);
    }
  }
}

// TMP
bool can[100000];

int main(){
  srand(13331);
  scanf("%d", &n);
  //n = 90;
  in.resize(n);
  //for(int& e : in) e = rand() % 500 + 1;
  for(int& e : in) scanf("%d", &e);

  int sum = 0;
  for(int& e : in) sum += e;
  int start = (sum + 1) / 2;

  Set(arr, 0);
  //can[0] = true;
  int idx = -1;
  for(int& e : in){
    idx += 1;

    //cout << can[21261] << ' ' << Is(arr, 21261) << endl;

    Zero(arr1);
    Shift(e);
    Or();

    /*
    for(int i = 100000 - 10;i >= 0;--i)
      if(can[i]) can[i + e] = true;

    for(int i = 0;i < sum;++i){
      if(Is(arr, i) != can[i]){
        cout << idx << ' ' << e << endl;
        cout << i << ' ' << Is(arr, i) << ' ' << can[i] << endl;
        cout << "Bad\n";
        system("pause");
      }
    }
    */
  }

  int ans = in.back();
  for(int i = start;i <= sum;++i)
    if(Is(arr, i)){
      ans = i;
      break;
    }

  printf("%d\n", ans);

  return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll 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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    string s;
    cin>>s;
    n=s.size();
    int ans[n]={0};
    int cur=0;
    rep(i,0,n)
    {
        if(s[i]=='R')cur++;
        else if(cur!=0)
        {
            ans[i]+=cur/2;
            ans[i-1]+=cur-cur/2;
            cur=0;
        }
    }
    cur=0;
    for(i=n-1;i>=0;i--)
    {
        if(s[i]=='L')cur++;
        else if(cur!=0)
        {
            ans[i]+=cur/2;
            ans[i+1]+=cur-cur/2;
            cur=0;
        }
    }
    rep(i,0,n)cout<<ans[i]<<' ';

    return 0;
}



Measured memory_bytes: 1104
from collections import deque
# 節の定義
class Node:
    def __init__(self, x):
        self.data  = int(x)
        self.left  = None
        self.right = None
# 挿入
def insert(node, x):
    ima = node
    for i in range(len(x)):
        y = x[i]
        if y == "1":
            if ima.right is None:
                ima.right = Node(i+1)
            ima = ima.right
        else:
            if ima.left is None:
                ima.left = Node(i+1)
            ima = ima.left



class Trie:
    def __init__(self):
        self.root = Node(0)

    # 挿入
    def insert(self, x):
        insert(self.root, x)

n,l = map(int,input().split())
s = [input() for i in range(n)]

trie = Trie()
for i in s:
    trie.insert(i)
data = []
que = deque([trie.root])
def dfs(node):
    if node.right is None and node.left is None:
        return 0
    if node.right is None or node.left is None:
        if l-node.data:
            data.append(l-node.data)
    if node.right:
        que.append(node.right)
    if node.left:
        que.append(node.left)
    
while que:
    dfs(que.popleft())
xor = 0
def nimber(n):
    x = 1
    while n%2 == 0: n//= 2; x*= 2
    return x
for i in data:
    xor ^= nimber(i)
print("Alice" if xor else "Bob")

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

int main() {
  int N, W;
  cin >> N >> W;
  
  vector<int> v(N);
  vector<int> w(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i] >> w[i];
  }

  vector<vector<int> > DP(N);
  for (int i = 0; i < N; i++) {
    DP[i].resize(W + 1);
    fill(DP[i].begin(), DP[i].end(), 0);
  }

  DP[0][w[0]] = v[0];
  for (int i = 1; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j < w[i]) {
	DP[i][j] = DP[i - 1][j];
      } else {
	DP[i][j] = max(DP[i - 1][j - w[i]] + v[i], DP[i - 1][j]);
      }
    }
  }
  
  int maxVal = 0;
  for (int i = 0; i <= W; i++) {
    maxVal = max(DP[N - 1][i], maxVal);
  }
  cout << maxVal << endl;
  
  return 0;
}

Measured memory_bytes: 6804
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// AOJ DSL_3_C The Number of Windows

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q; cin >> N >> Q;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
  }
  vector<ll> X(N);
  REP(i, Q){
    cin >> X[i];
  }
  REP(i, Q){
    int right = 0;
    ll res = 0, s = 0; // sは和
    for(int left = 0; left < N; left++){
      // rightの位置決め
      while(right < N && s+A[right] <= X[i]){
        s += A[right]; // 実際にrightを1進めたときの処理
        right++;
      }
    
      // whileループをbreakした後(rightは条件を満たす最大)に行う処理
      res += (right - left); // 要素の長さを足すことで組数を求めている
    
      // leftをインクリメントする準備
      if(right == left) right++;
      else s -= A[left];
    }
    cout << res << endl;
  }
}


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


bool used[100001];
vector <int> connect[100001];




bool search_leaf(int parent, int elem) {
	for (int i = 0; i < connect[elem].size(); i++) {
		int child = connect[elem].at(i);
		if (child == parent) continue;

		bool find_leaf = search_leaf(elem, child);
		if (find_leaf) {
			if (used[elem]) {
				// out
				used[elem] = false;
				return false;
			} else {
				used[elem] = true;
			}
		}
	}

	if (!used[elem]) {
		used[elem] = true;
		return true;
	}
	else return false;
}

int main(void) {
	int N;
	cin >> N;

	if (N%2==1) {
		cout << "First" << endl;
		return 0;
	}

	for (int i = 1; i <= N; i++) {
		used[i] = false;
		connect[i].clear();
	}

	for (int i = 1; i <= N-1; i++) {
		int a, b;
		cin >> a >> b;
		connect[a].push_back(b);
		connect[b].push_back(a);
	}

	int elem = 0;
	(void)search_leaf(-1, 1);

	bool firstWin = false;
	for (int i = 1; i <= N; i++) {
		if (!used[i]) {
			firstWin = true;
			break;
		}
	}

	if (firstWin) {
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}
	return 0;
}


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

int main() {
        string S;
        string  ABC = "ABC",ARC = "ARC";
        cin >> S;
        if(S == ABC){
            cout << " " << ARC << endl;
        }
        if (S == ARC){
            cout << " " << ABC << endl;
        }
    //A();
    return 0;
}

Measured memory_bytes: 3600
import sys
import math
from typing import Tuple, List
input = sys.stdin.readline

def  print_vec (A: list):
    print (" ".join(map (str, A)))

def swap (A: List, i: int, j: int) -> None:
    temp = A [i]
    A [i] = A [j]
    A [j] = temp
 

def selection_sort(A: List) -> Tuple[List, int]:
    swap_cout = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
        if (mini != i):
            swap(A, i, mini)
            swap_cout+=1
    return (A, swap_cout)


if __name__ == "__main__":
    n = int(input())
    vec = list (map (int, input ().split ()))
    result =  selection_sort(vec)
    print_vec (result [0])
    print(result [1])



Measured memory_bytes: 7256
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  auto hw = readln.chomp.split.map!(to!int);
  int h = hw.front;
  int w = hw.back;
  int n = readln.chomp.to!int;
  alias Node = Tuple!(int, "num", int, "color");
  int[] a = readln.chomp.split.map!(to!int).array;
  int index = 0;
  foreach (i; 0 .. h)
  {
    int[] line;
    int cnt = 0;
    while (cnt < w)
    {
      int v = a[index];
      int del = min(v, w - cnt);
      line ~= (index + 1).repeat.take(del).array;
      a[index] -= del;
      if (a[index] == 0) {
        ++index;
      }
      cnt += del;
    }
    if (i % 2)
    {
      // rev
      line = line.retro.array;
    }
    foreach (j, v; line)
    {
      if (j)
        write = " ";
      write = v;
    }
    writeln;
  }
}


Measured memory_bytes: 892
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef vector<xy_t> polygon;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<string, int> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

int n;
ll dp[1010][1010];
P prob[2000];

int main(){
	cin >> n;
	for(int i = 0;i < n; i++){
		cin >> prob[i].second >> prob[i].first;
	}
	sort(prob, prob + n);
	fill(&dp[0][0], &dp[1009][1009] + 1, INF);
	for(int i = 0; i <= n; i++){
		dp[i][0] = 0;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= i; j++){
			if(dp[i-1][j-1] + prob[i-1].second <= prob[i-1].first){
				dp[i][j] = dp[i-1][j-1] + prob[i-1].second;
			}
			if(dp[i-1][j] <= prob[i-1].first){
				dp[i][j] = min(dp[i-1][j], dp[i][j]);
			}
		}
	}
	int res = 0;
	for(int i = 1; i <= n; i++){
		if(dp[n][i] != INF) res = max(res, i);
	}
	cout << res << endl;
	return 0;
}

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

int main() {
  int A,B,C ;
  cin >>A>>B>>C ;
  if ((A==5&&B==5&&C==7) || (A==5&& B==7&& C==5) ||(A==7&&B==5&&C==5 ) ) {
  cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl ;
  }
  }
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


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

    bool edge[10][10];
    rep(i,10) rep(j,10) edge[i][j] = false;
    rep(i,M){
        int a,b;cin>>a>>b;
        a--;
        b--;
        edge[a][b] = edge[b][a] = true;
    }

    vi v(N);
    iota(v.begin(),v.end(),0);

    int ans = 0;
    do{
        if(v[0] != 0) continue;
        bool ok = true;
        for(int i=0;i<N-1;i++){
            if(!edge[v[i]][v[i+1]]) ok = false;
        }
        if(ok) ans++;
    }while(next_permutation(all(v)));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll f(ll n){
    ll res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

double g(ll n){
    return (double)n/f(n);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<ll> res;
    ll base=1;
    
    rep(i,15){
        rep1(j,149){
            res.push_back(base*(j+1)-1);
        }
        base*=10;
    }
    
    sort(all(res));
    res.erase(unique(all(res)),res.end());
    
    for(ll i=0;i<res.size();i++){
        for(ll j=i+1;j<res.size();j++){
            if(g(res[i])>g(res[j])){
                res.erase(res.begin()+i--);
                break;
            }
        }
    }
    
    ll K;
    cin>>K;
    for(ll i=0;i<K;i++) cout1(res[i]);
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>

using  ll = long long;
using ull = unsigned long long;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
constexpr ll kINF = 1152921504606846976;//2^60
constexpr double kEPS = 1e-6;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

double memo[310][310][310];
bool done[310][310][310];

ll N;
ll a[300];

double rec(ll j,ll k, ll l) {
  if (done[j][k][l]) return memo[j][k][l];

  double ret = 0.0;

  ll i = N - j - k - l;

  double p = (double)i / (i + j + k + l);

  if (j > 0) ret += rec(j-1, k, l)   * (double)j / (j + k + l) + 1 / (1 - p) / (1 - p) * ((double)j / (i + j + k + l));
  if (k > 0) ret += rec(j+1, k-1, l) * (double)k / (j + k + l) + 1 / (1 - p) / (1 - p) * ((double)k / (i + j + k + l));
  if (l > 0) ret += rec(j, k+1, l-1) * (double)l / (j + k + l) + 1 / (1 - p) / (1 - p) * ((double)l / (i + j + k + l));

  done[j][k][l] = true;
  return memo[j][k][l] = ret;
}

int main(void) {
  cin >> N;
  rep (i, N) cin >> a[i];

  ll c[4];
  rep(i,4)c[i] = 0;
  rep(i, N) {
    c[a[i]]++;
  }
  printf("%.15f\n", rec(c[1], c[2], c[3]));
  return 0;
}

Measured memory_bytes: 256256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n)
    {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD (int)(1e9 + 7)
#define ll long long

map<int, bool> q;
stack<int> aa;

int f(int v) {
	if(v % 2 == 0) {
		return v / 2;
	}
	return 3 * v + 1;
}

bool a(int s, int v) {
	if(aa.empty()) {
		q[s] = true;
		aa.push(s);
		return true;
	}
	int temp = f(aa.top());
	if(!q.count(temp)) {
		q[temp] = true;
		aa.push(temp);
		return true;
	}
	return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int s;
	cin >> s;
	int cur = 1;
	while(a(s, cur)) {
		cur++;
	}
	cout << cur << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int w,n,ans[10],ansn,i;
    while(scanf("%d",&n)!=EOF){
        w=512;
        ansn=0;
        for(i=0;i<10;i++){
            ans[i]=0;
        }
        while(n!=0){
            if(n>=w){
                n=n-w;
                ans[ansn]=w;
                ansn++;
            }
            w=w/2;
        }
        for(i=ansn-1;i>=0;i--){
            printf("%d",ans[i]);
            if(i!=0){
                printf(" ");
            }else{
                printf("\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

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

    int n = s.length();

    if(n == 1){
        cout << s << endl;
        return 0;
    }
    vector<string> str(K * n );
    for(int len = 1; len < K + 1; len++){
        for(int i = 0; i <= n - len; i++){
            str[(len - 1) * n + i] = s.substr(i, len);
        }
    }

    sort(str.begin(), str.end());
    unique(str.begin(), str.end());

    if(str[0] == ""){
        cout << str[K] << endl;
    }else{
        cout << str[K - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int fr[N];
priority_queue<int> q;
int main(){
	int n;
	cin>>n;
	for(int x,i=0; i<n; ++i){
		scanf("%d",&x);
		++fr[x];
	}
	for(int i=0; i<N; ++i)
		if(fr[i])q.push(fr[i]);
	int ans=0;
	while(!q.empty()){
		int x = q.top();
		q.pop();
		if(x==1) break;
		if(!q.empty()){
			int y = q.top();
			q.pop();
			x--;
			y--;
			++ans;
			if(x)q.push(x);
			if(y)q.push(y);
		}else{
			if(x>2) x-=2;
			else break;
			++ans;
			if(x)q.push(x);
		}
	}
	cout<<n-2*ans;	
}




Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    ll a, b;
    cin >> a >> b;
    cout << a+b << endl;
  }
}

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

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N, K);
    vector<int> P(N);
    for(int i = 0; i < Q; i++){
        int p;
        cin >> p;
        P.at(p-1)++;
    }
    for(int i = 0; i < N; i++){
        int ans;
        ans = A.at(i) - (Q - P.at(i));
        if(ans > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
n,k=map(int,input().split())
p=10**9+7
def fact(n,p):
    a=[[] for _ in range(n+1)]
    a[0]=1
    for i in range(n):
        a[i+1]=(a[i]*(i+1))%p
    return a
f=fact(n,p)
invf=[]
for i in f:
    invf.append(pow(i,-1,p))
ans=[]
for i in range(1,k+1):
    if i>n-k+1:
        ans.append(0)
        continue
    ans.append(((f[n-k+1]*invf[n-k+1-i])%p)*((invf[i]*f[k-1])%p)*((invf[i-1]*invf[k-i]))%p)
for i in ans:
    print(i%p)

Measured memory_bytes: 9328
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
  ll n, a, b;
  cin >> n;
  ll ans = 0;
  for (ll i = 1LL; i <= n; i++) {
    ans += i * (n - i + 1);
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    ans -= min(a, b) * (n - max(a, b) + 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
int top=0,S[1000];
void push(int x){
	top++;
	S[top]=x;//S[++top]=xで4,5行目を1行にまとめられる
}
int pop(void){
	top--;
	return S[top+1];//return S[--top]でまとめられる
}
int main(){
	int a,b;
	top=0;
	char s[100];
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else if(s[0]=='/'){
			a=pop();
			b=pop();
			push(a/b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}


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

int main(){
	int a,b,c,d;
  	cin>>a>>b>>c>>d;
  	if(a+b>c+d)cout<<"Left"<<endl;
  	else if(a+b==c+d)cout<<"Balanced"<<endl;
  	else cout<<"Right"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
//#include <windows.h>
#include <algorithm>
#include <cstdio>
#include <list>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 1000000007
using namespace std;
typedef long long LL;
//typedef pair<int,int> P;
//typedef priority_queue<P, vector<P>, greater<P> > minPQ;
struct edge {int to,cost;};
//const int SIZE = 1<<18;

int main() {
	string s;
	cin >> s;
	REP(i,s.size()) {
		if(s[i]==',') {
			cout << " ";
		} else {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):#要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):#要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):#要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]
 
    def same(self, x, y):#要素x, yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)
 
    def members(self, x):#要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):#すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):#グループの数を返す
        return len(self.roots())
 
    def all_group_members(self):#{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):#print()での表示用 ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int,input().split())
uf = UnionFind(n)

edge = []
for i in range(m):
    a,b = map(int,input().split())
    edge.append((a-1,b-1))
    
for a,b in edge:
    uf.union(a, b)
    
print(uf.group_count()-1)

Measured memory_bytes: 82956
S = list(input())
char_before = S[0]
cnt_temp = 1
cnt_list = []

for i in range(1, len(S)):
    if char_before == S[i]:
        cnt_temp += 1
    else:
        cnt_list.append(cnt_temp)
        char_before = S[i]
        cnt_temp = 1
cnt_list.append(cnt_temp)

res = 0
for i in range(len(cnt_list) - 1):
    k = cnt_list[i] // 3
    r = cnt_list[i] % 3
    res += 2 * k + r
    if r == 2:
        cnt_list[i + 1] -= 1

k = cnt_list[-1] // 3
r = cnt_list[-1] % 3
res += 2 * k + r
if r == 2:
    res -= 1

if __name__ == "__main__":
    print(res)


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


vector<ll> unionfindInit(ll n){
    vector<ll> list(n);
    rep(i, n)   list[i] = i;
    return list;
}

ll find(vector<ll>& list, ll x){
    if(list[x] == x)    return x;
    return list[x] = find(list, list[x]);
}

void unionNodes(vector<ll>& list, ll x, ll y){
    x = find(list, x);
    y = find(list, y);
    if(x == y)  return;
    list[x] = y;
}

bool same(vector<ll>& list, ll x, ll y){
    return find(list, x) == find(list, y);
}

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

    ll n, m;
    cin >> n >> m;
    vector<ll> p(n), x(m), y(m);
    rep(i, n) cin >> p[i];
    rep(i, n) p[i]--;;
    rep(i, m) cin >> x[i] >> y[i];
    rep(i, m) x[i]--, y[i]--;

    auto uf = unionfindInit(n);
    rep(i, m) unionNodes(uf, x[i], y[i]);

    ll ans = 0;
    rep(i, n){
        if(same(uf, i, p[i])) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
#pragma region Header
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
#pragma endregion

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

    int n;
    cin >> n;
    vector<i64> a_s(n);
    rep(i, n)
    {
        cin >> a_s[i];
    }

    i64 ans = 0;
    i64 h = 0;
    rep(i, n)
    {
        if (h > a_s[i])
        {
            ans += h - a_s[i];
        }
        h = max(h, a_s[i]);
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    int64_t n, sum = 0, ans = 0;
    cin >> n;
    vector<int64_t> a(n);
    map<int64_t, int64_t> cnt;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        if (i == 0) cnt[0]++;
        sum += a[i], ans += cnt[sum], cnt[sum]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17248
#include<stdio.h>

int main()
{
  int Max = 0, temp = 0, i, N;
  scanf(" %d", &N);
  int p[N];
  for(i = 0; i < N; ++i) {
    scanf(" %d", &p[i]);
    if(Max < p[i]) {
      Max = p[i];
      temp = Max / 2;
    }
  }
  int sum = -(Max) + temp;
  for(i = 0; i < N; ++i) {
    sum += p[i];
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

void pr(bool f){
	if(f)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
}

signed main(){
	int N;
	cin>>N;
	REP(i,50001){
		int t = i * 1.08;
		if(N==t){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
}

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

int main() {
	int a, b;

	while (1) {
		cin >>a>>b;
		if (a == 0 && b == 0)break;

		if (a < b) {
			cout << a << " " << b << endl;
		}
		else {
			cout << b << " " << a << endl;

		}
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define INF (1e18)

int main(){   
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    stack<char> st;
    rep(i,0,N){
        if(st.empty()){
            st.push(S[i]);
        }else{
            char c1 = st.top();
            if(c1 != S[i]){
                st.pop();
            }else{
                st.push(S[i]);
            }
        }
    }
    print(N - st.size());

}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	//	file();
	fast();
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0)
			RT("OK" << endl);
	}
	cout << "NG" << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}



int main()
{
	int N;cin>>N;
    bool ok=false;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==N)ok=true;
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}

 
    

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

int main(){
  int h,w,ch,cw,dh,dw;
  cin>>h>>w>>ch>>cw>>dh>>dw;
  ch--,cw--,dh--,dw--;
  char s[1005][1005];
  rep(i,h) rep(j,w) cin>>s[i][j];

  int d[1005][1005];
  rep(i,h) rep(j,w) d[i][j]=1e9;
  int di[4] = {1,0,-1,0};
  int dj[4] = {0,1,0,-1};
  deque<P> q;
  q.push_front({ch,cw});
  d[ch][cw]=0;
  while(q.size()){
    auto p1=q.front(); q.pop_front();
    int i,j; tie(i,j)=p1;
    rep(k,4){
      int ni=i+di[k],nj=j+dj[k];
      if(ni<0||nj<0||ni>=h||nj>=w) continue;
      if(s[ni][nj]=='#'||d[ni][nj]<=d[i][j]) continue;
      d[ni][nj]=d[i][j];
      q.push_front({ni,nj});
    }
    for(int ni=i-2; ni<=i+2; ni++){
      for(int nj=j-2; nj<=j+2; nj++){
	if(ni<0||nj<0||ni>=h||nj>=w) continue;
	if(s[ni][nj]=='#'||d[ni][nj]<=d[i][j]+1) continue;
	d[ni][nj]=d[i][j]+1;
	q.push_back({ni,nj});
      }
    }
  }

  int ans=d[dh][dw];
  if(ans==1e9) ans=-1;
  cout<<ans<<endl;
  return 0;
}


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

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class abc126{
  static void Main(){
    var IN=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var N=IN[0];
    var K=IN[1];
    var S=Console.ReadLine();
    
    var result = "";
    
    for(int i=0;i<N;i++){
      if(i+1==K){
        if(S[i].Equals('A'))
          {
            result=result+"a";
          }
        if(S[i].Equals('B'))
          {
            result=result+"b";
          }
        if(S[i].Equals('C'))
          {
            result=result+"c";
          }
      }
      else
      {
        result=result+S[i];
      }
    }
    
    Console.WriteLine(result);
    
    return;
  }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int cas(int a, int b, int c, int d, int e) {
	return a * 10000 + b * 1000 + c * 100 + d * 10 + e;
}

int main() {
	int in;
	while (1) {
		//solve
		int ans = 0;
		int mas[10][10];

		rep(i, 10) {
			rep(j, 10) {
				if (!(cin >> in)) {
					return 0;
				}
				mas[i][j] = in;
			}
		}

		rep(i, 10000) {
			vi v;
			int a = i / 1000;
			int b = i / 100 % 10;
			int c = i / 10 % 10;
			int d = i % 10;
			int e = mas[mas[mas[mas[0][a]][b]][c]][d];
			rep(i, 10) {
				v.push_back(cas(i, b, c, d, e));
				v.push_back(cas(a, i, c, d, e));
				v.push_back(cas(a, b, i, d, e));
				v.push_back(cas(a, b, c, i, e));
				v.push_back(cas(a, b, c, d, i));
			}
			v.push_back(cas(b, a, c, d, e));
			v.push_back(cas(a, c, b, d, e));
			v.push_back(cas(a, b, d, c, e));
			v.push_back(cas(a, b, c, e, d));
			int y = cas(a, b, c, d, e);
			bool fl = true;
			for (int x : v) {
				int a = x / 10000;
				int b = x / 1000 % 10;
				int c = x / 100 % 10;
				int d = x / 10 % 10;
				int e = x % 10;
				if (y != cas(a, b, c, d, e)){
					if (mas[mas[mas[mas[mas[0][a]][b]][c]][d]][e] == 0) {
						fl = false; break;
					}
				}
			}
			if (fl)ans++;
		}
		cout << 10000-ans << endl;
		//break;
	}
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    vector<int> v(N);
    for(int i=0;i<N;i++) cin >> v[i];
    sort(v.begin(),v.end());
    double ans = (v[0]+v[1])/2.0;
    if (N>=3){
        for (int i=2;i<N;i++){
            ans = (ans + v[i])/2.0;
        }
    }
    printf("%.10f\n",ans);
    return 0;
}

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

int main ()
{
	int n, s, adv,  a[100];
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
	const int MAXN = 100;
	int a[MAXN];

	for(int i = 0 ; i < n; i++){
		cin >> a[i];
	}
	int max = a[0], min = a[0], kei = 0;
	for(int i = 0 ; i < n ; i++){
		if(max < a[i]){
			max = a[i];
		}
		if(min > a[i]){
			min = a[i];
		}
		kei += a[i];
	}
	adv = (kei - max - min) / (n - 2);
	cout << adv << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = res * a;
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}

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

map<int,int> mp;
vector<ii> v;



int main() 
{ 
    fast_io
    go();
    string s,t;cin>>s>>t;
    int c=0;
    for0(i,s.size())
    {
      if(s[i]!=t[i])
        c++;
    }
    cout << c <<"\n";
}

/*!
    You are under no obligation to be the same person you were a minute ago,
    You have the right to grow !
*/




















Measured memory_bytes: 3772
a = [int(s) for s in input().split()]
max_id = a.index(max(a[0], a[1], a[2]))
min_id = a.index(min(a[0], a[1], a[2]))
sum = 0
sum += abs(a[0] - a[1])
sum += abs(a[1] - a[2])
sum += abs(a[2] - a[0])
sum -= abs(a[max_id] - a[min_id])
print(sum)

Measured memory_bytes: 9148
import sys
range = xrange
input = raw_input

n = int(input())

ans = []

def generate(A, i = 0, j = 0):
    if j == n:
        if all(a!=n for a in A):
            return ans.append(list(A))
        return
    if i == n:
        if all(a!=n for a in A):
            return ans.append(list(A))
        i = 0
        while A[i] != n:
            i += 1
        A[i] = j + 1
        generate(A, i + 1, j + 1)
        A[i] = n
        return
    if A[i] == n:
        A[i] = j
        generate(A, i + 1, j)
        A[i] = n
    generate(A, i + 1, j)

A = [n]*n
A[0] = 0
generate(A, 1, 0)
orda = ord('a')
print '\n'.join(''.join(chr(a + orda) for a in A) for A in sorted(ans))


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

int main() {
	long int a,b;
	long int d,r;
	double f;
	std::cin>> a>>b;
	d=a/b;
	r=a%b;
	f=(double)a/b;
	std::cout << d<<" "<<r<<" "<<fixed <<setprecision(5) << f <<std::endl;
	return 0;
}

Measured memory_bytes: 3168
N = int(input())
s = [input() for i in range(N)]
a = s.count("AC")
b = s.count("WA")
c = s.count("TLE")
d = s.count("RE")
print("AC x {}".format(a))
print("WA x {}".format(b))
print("TLE x {}".format(c))
print("RE x {}".format(d))

Measured memory_bytes: 16304
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn char_to_i64(c: char) -> i64 {
    c as i64 - 48
}

fn main() {
    let s = input_char_vec();
    let mut ans = std::i64::MAX;
    for i in 0..s.len()-2 {
        let n = char_to_i64(s[i]) * 100 + char_to_i64(s[i+1]) * 10 + char_to_i64(s[i+2]);
        ans = min(ans, (753 - n).abs());
    }
    println!("{}", ans);
}

Measured memory_bytes: 2064