akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 500100;

int n;
char s[maxn + 5];

int dp[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	scanf("%s", s);
	int lst0 = -1, lst1 = -1;
	dp[0] = 0;
	REP(i, 0, n)
	{
		chkmax(dp[i + 1], dp[i]);
		if (s[i] == '0') lst0 = lst1, lst1 = i;
		else if (lst0 < lst1 - 1)
		{
			if (i == lst1 + 1)
			{
				REP(j, lst0 + 1, lst1)
				{
					chkmax(dp[i + 1], dp[j] + lst1 - j);
				}
			} 
			chkmax(dp[i + 1], dp[lst1 - 1] + i - lst1);
		}
	}
	printf("%d\n", dp[n]);
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int p[40002],p2[502];
int r[40002],r2[502];

void init(int n){
    for (int i = 0; i < n; ++i) {
        p[i]=i;
        r[i]=0;
    }
}


int find(int x){
	if(x != p[x]){
		p[x] = find(p[x]);
    }
   	return p[x];
}
     
void union_set(int x,int y){
	x = find(x);
	y = find(y);
	if(x==y) return;
	if(r[x] < r[y]){
		p[x] = y;	
	}else{
		p[y] = x;
		if(r[x] == r[y])r[x]++;
	}
	return ;
}


int main(){
	int n,m;
	cin >> n >> m;
	vector<pair<double,double> > v;
	rep(i,n){
		double a,b;
		cin >> a >> b;
		v.PB(MP(a,b));
	}
	priority_queue<pair<double,pair<int,int> > >node;
	double ans = 0;
	rep(i,m){
		int p,q;
		cin >> p >> q;
		p--;
		q--;
		double w;
		double x,y;
		x = v[p].first - v[q].first;
		y = v[p].second - v[q].second;
		w = sqrt(x*x+y*y);
		ans += w;
		node.push(MP(w,MP(p,q)));
	}
	init(n+2);
	while(!node.empty()){
		pair<double,pair<int,int> > k = node.top();
		node.pop();
		double w1 = k.first;
		int x,y;
		x = k.second.first;
		y = k.second.second;
		if(find(x)==find(y))continue;
		union_set(x,y);
		ans -=w1;
	}
	cout.precision(15);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3752
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int size = scanner.nextInt();
        int[] heapArray = new int[size + 1];

        // Populate array
        for(int i = 1; i <= size; i ++){
            heapArray[i] = scanner.nextInt();
        }

        for(int i = 1; i <= size; i ++){
            System.out.print("node " + i + ": key = " + heapArray[i] + ", ");
            
            // If not the first node, has a parent
            if(i >= 2){
                System.out.print("parent key = " + heapArray[i/2] + ", ");
            }

            // Left index
            if(i*2 <= size){
                System.out.print("left key = " + heapArray[i*2] + ", ");
            }
            
            // Right index
            if((i*2 + 1) <= size){
                System.out.print("right key = " + heapArray[i*2 + 1] + ", ");
            }
            System.out.println();
        }

    }


}


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

x,n = map(int, input().split())
p = list(map(int, input().split()))

ans = [x]
if x in p:
    ans.remove(x)
    i = x
    while i in p:
        i -= 1
    ans.append(i)
    i = x
    while i in p:
        i += 1
    ans.append(i)
    if abs(ans[0] - x) > abs(ans[1] - x):
        ans = [ans[1]]
    else:
        ans = [ans[0]]

print(ans[0])

Measured memory_bytes: 61936
import copy

N=int(input())
ABC=[list(map(int,input().split())) for i in range(N)]

NOW=[0,0,0]#最後にしたことそれぞれについての幸福度

NEXT=[None]*3
for i in range(N):
    NEXT[0]=max(NOW[1],NOW[2])+ABC[i][0]
    NEXT[1]=max(NOW[0],NOW[2])+ABC[i][1]
    NEXT[2]=max(NOW[1],NOW[0])+ABC[i][2]

    NOW=copy.copy(NEXT)
    #print(NOW)
        
print(max(NOW))

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

int main(void){
    long long  a,b,x,r ;
    cin >> a >> b ;
    x=a*b ;
    if (a<b){
        swap(a,b) ;
    }
    r=a%b ;
    while(r!=0){
        a=b ;
        b=r ;
        r=a%b ;
    }
    cout << x/b << endl ; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>

using std::string;
using std::vector;
using std::map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N{}; cin >> N;
  vector<ui> V(N);
  for(size_t i = 0; i < V.size(); ++i) cin >> V[i];

  boost::sort(V);

  double sum = V[0];
  for(size_t index = 1; index < V.size(); ++index)
  {
    sum = (sum + V[index]) / 2;
  }
  cout << sum << CRLF;

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const int oo = 1e9 + 7;
const int mod = 1e9 + 7;
const double PI = acos(-1);
vector<int> adj[100100], path;

int dfsa(int v, int busca, int prev){
    if (v == busca) {
        path.push_back(v);
        return 1;
    }
    int tmp = -1;

    for (auto it: adj[v]){
        if (it != prev){
            tmp = dfsa(it, busca, v);
        }
        if (tmp == 1) {
            path.push_back(v);
            return 1;
        }
    }
    return -1;
}

int dfs(int v, int prev, int dist){
    if (v == -1) return -1;
    int ans = 0;
    for (auto it: adj[v]){
        if (it != prev and it != -1) ans = max(ans, dfs(it, v, dist+1));
    }
    return max(ans, dist);
}

int main (){
    int n, u, v, a, b;
    cin >>  n >> u >> v;

    for (int i=0; i<n-1; i++){
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfsa(v, u, -1);
    int pos = path.size()/2 - 1, carry = 0;
    carry = (path.size()&1);
    for (auto& it: adj[path[pos]]){
        if (it == path[pos+1]){
            it = -1;
            break;
        }
    }
    // cout << "caba" << endl;

    cout << pos + dfs(path[pos], -2, 0) + carry << endl;
    return 0;
}


Measured memory_bytes: 11648
import java.io.*;
import java.util.*;

public class Main {
    void run() {
        HashSet<String> set = new HashSet<String>();
        char last = 'a';
        for (char a = 'a'; a <= 'z'; a++) {
            for (char b = 'a'; b <= 'z'; b++) {
                sysout.printf("?%c%c%ca\n", last, a, b);
                String w = read();
                if (set.contains(w)) {
                    sysout.println("!OUT");
                    return;
                }
                if(w.charAt(0) != 'a') {
                    sysout.println("!OUT");
                    return;
                }
                set.add(w);
                last = w.charAt(w.length() - 1);
            }
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = new StringTokenizer("");

    String read() {
        if (!buffer.hasMoreTokens()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }

    String readLine() {
        buffer = new StringTokenizer("");
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Measured memory_bytes: 17092
import java.io.BufferedReader;
//import java.io.FileReader;
//import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
//import java.util.TreeSet;


public class Main {

  /**
   * @param args
   * @throws IOException 
   * @throws NumberFormatException 
   */
  public static void main(String[] args) throws NumberFormatException, IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    //BufferedReader reader = new BufferedReader(new FileReader("//users/islam/Desktop/InputData.txt"));
    String line;
    
    ArrayList<Integer> numbers = new ArrayList<Integer>();
    
    while((line = reader.readLine()) != null){
      numbers.add(Integer.parseInt(line));
    }
    Collections.sort(numbers);
    for(int i = 0; i< 3; i++){
      System.out.println(numbers.get(numbers.size()-(i+1)));
      
    }
  }

}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
    bool ret = true;
    if (x < 2) {
        ret = false;
    }
    for (LL i = 2; i <= sqrt(x); i++) {
        if (x%i == 0) {
            ret = false;
        }
    }
    return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    set<string> st[5];
    vector<char> cv = {'M','A','R','C','H'};
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < 5; j++) {
            if (cv[j] == s[0]) {
                st[j].insert(s);
            }
        }
    }

    LL ans = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = i+1; j < 4; j++) {
            for (int k = j+1; k < 5; k++) {
                ans += st[i].size() * st[j].size() * st[k].size();
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll x,k,d;
int32_t main(){
CODE_START;
ll ans=0;
cin>>x>>k>>d;
x=abs(x);
ll nr=x/d;
if(nr>=k){
    cout<<abs(x-k*d)<<endl;
    return 0;
}
k-=nr;
if(k%2==1){
    cout<<abs(x-(nr+1)*d)<<endl;
}else {
cout<<abs(x-nr*d)<<endl;
}
}


Measured memory_bytes: 3644
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        List<Tuple<int, int>>[] tells = new List<Tuple<int, int>>[n];
        for (int i = 0; i < n; i++)
        {
            int count = int.Parse(Console.ReadLine());
            List<Tuple<int, int>> tell = new List<Tuple<int, int>>();
            for (int j = 0; j < count; j++)
            {
                var line = Console.ReadLine();
                var words = line.Split(' ');
                int x = int.Parse(words[0]);
                int y = int.Parse(words[1]);
                tell.Add(Tuple.Create(x, y));
            }
            tells[i] = tell;
        }

        int answer = 0;

        for (int i = 0; i < Math.Pow(2, n); i++)
        {
            int honest = 0;

            for (int j = 0; j < n; j++)
            {
                if ((1 & (i >> j)) == 1)
                {
                    honest++;
                    List<Tuple<int, int>> tell = tells[j];
                    foreach (var t in tell)
                    {
                        int x = t.Item1;
                        int y = t.Item2;
                        if ((1 & (i >> (x - 1))) != y)
                        {
                            honest = -1;
                            break;
                        }
                    }
                }
                if (honest == -1)
                {
                    break;
                }
            }

            answer = Math.Max(answer, honest);
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 13268
n,a,b=map(int,input().split())
s=input()
passed=0
oversea=0
yep=False
cnt=0
for i in range(n):
    if s[i]=="c":
        print("No")
    elif s[i]=="a":
        if passed<(a+b):
            print("Yes")
            passed+=1
        else:
            print("No")
    else:
        if oversea<b and passed<(a+b):
            print("Yes")
            passed+=1
            oversea+=1
        else:
            print("No")
#     if passed>=(a+b):
#         yep=True
#         cnt=len(s)-(i+1)
#         break
# if yep:
#     for i in range(cnt):
#         print("No")

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  while (true) {
    int n;
    cin >> n;
    if (!n)
      break;
    int cnt = 0;
    bool luf = false, ruf = false, up = false;
    REP(i, n) {
      string f;
      cin >> f;
      if (f == "lu")
        luf = true;
      else if (f == "ru")
        ruf = true;
      else if (f == "ld")
        luf = false;
      else if (f == "rd")
        ruf = false;

      if (!up && luf && ruf) {
        cnt++;
        up = true;
      } else if (up && !luf && !ruf) {
        cnt++;
        up = false;
      }
    }

    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
int main () {
    long long int x, k, d;
    cin >> x >> k >> d;
    x=abs(x);
    if (x/d>k) {
        cout << x-k*d << endl;
        return 0;
    }
    k-=x/d;
    if (k%2==0) {
        cout << x%d << endl;
    }
    else {
        cout << abs(x%d-d) << endl;
    }
}

Measured memory_bytes: 3632
@in1=in();
for($i=0;$i<$in1[2];$i++){
@in2=in();
if($in2[1]<=$in2[0]){
${$s[$in2[1]]}[@{$s[$in2[1]]}]=$in2[0];

}
}

$ans=$in1[0]+1;
$now=1;
for($i=1;$i<=$in1[1];$i++){
foreach $item (sort {$a <=> $b} @{$s[$i]}){
if($now==$item){
$now++;}elsif ($now < $item and $ans >$item){
$ans=$item;}
}$now++;
}
$ans--;
print "$ans";

sub in{
$t=<STDIN>;
$t=~s/[¥r¥n]+//;
return split / /, $t;
}

Measured memory_bytes: 24064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	for(int n;cin>>n,n;){
		vi a(n);
		rep(i,n)
			cin>>a[i];
		
		vi sum(1);
		rep(i,n)
			sum.push_back(sum.back()+a[i]);
		
		int res=INT_MIN;
		rep(i,n)
			repi(j,i+1,n+1)
				res=max(res,sum[j]-sum[i]);
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import math
import collections
import sys
n = int(input())
c = list(map(int, input().split()))
a = collections.Counter(c)

if len(a.most_common()) > 3:
    print("No")
    sys.exit()

if len(a.most_common()) == 1:
    if a.most_common()[0][0] == 0:
        print("Yes")
        sys.exit()
    else:
        print("No")
        sys.exit()
    
if len(a.most_common()) == 2:
    if a.most_common()[1][0] == 0 and 2 * a.most_common()[1][1] == a.most_common()[0][1]:
        print("Yes")
        sys.exit()
    else:
        print("No")
        sys.exit()

if len(a.most_common()) == 3:
    if a.most_common()[0][1] == a.most_common()[1][1] == a.most_common()[2][1]:
        if a.most_common()[0][0] ^ a.most_common()[1][0] == a.most_common()[2][0]:
            print("Yes")
            sys.exit()
        else:
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()










                                        




    




        


    







        



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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;


int mean(vector<int> v) {
    int size = v.size();
    int sum = 0;
    for (int i = 0; i < size; i++){
        sum += v[i];
    }
    return sum / size;
}

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

  int n;
  int ave;
  std::vector<int> v;
  while(cin >> n,n){
    for(int i=0;i<n;i++){
      int a;
      cin >> a;
      v.push_back(a);
    }
    sort(v.begin(),v.end());
    v.pop_back();
    v.erase(v.begin());
    ave = mean(v);
    cout << ave << endl;
    v.clear();
  }
}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9+7;
const long double PI=acos(-1);



void solve(int T){
    int n,cnt=0;
    cin>>n;
    double ans=1.0;
    for(int i=1;i<=n;i+=2)cnt++;
    ans=double(cnt)/double(n);
    cout<<fixed<<setprecision(12)<<ans<<"\n";
}

int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;cin >>N;vector<int> a(N);
  for (int i=0;i<N;i++){cin>>a.at(i);}
  A=0;B=0;int MAX=0;
  for (int i=0;i<N/2+1;i++){
    
    //Aの操作
    MAX=0;
    for(int j=0;j<N;j++){
      if (MAX<a.at(j)){
        MAX=a.at(j);
      }
    }
    for(int j=0;j<N;j++){
      if(MAX==a.at(j)){A+=MAX;a.at(j)=0;break;}
    }
    //Aここまで
    MAX=0;
    //Bの操作
    for(int k=0;k<N;k++){
      if (MAX<a.at(k)){
        MAX=a.at(k);
      }
    }
    for(int k=0;k<N;k++){
      if(MAX==a.at(k)){B+=MAX;a.at(k)=0;break;}
    }
    //Bここまで
  }
  cout<<A-B<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a == c) cout << (a % 2 ? 0 : -1) << endl;
  else{
    int n = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
      int x = a, y = b, z = c;
      a = (y + z) / 2;
      b = (x + z) / 2;
      c = (x + y) / 2;
      n++;
    }
    cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, M;
	cin >> N >> M;
	vector<lint>A(N);
	vector<lint>B(M);
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, M) {
		cin >> B[i];
	}
	lint bsum = 0;
	rep(i, M) {
		bsum += B[i];
	}
	lint ans = 0;
	rep(i, N) {
		ans += A[i] * bsum;
	}
	cout << ans << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> h(n), cnt(n);
	rep (i, n) cin >> h[i];
	rrep (i, n) {
	  if (i == n - 1) {
		cnt[i] = 0;
		continue;
	  }
	  if (h[i] >= h[i + 1]) {
		cnt[i] = cnt[i + 1] + 1;
	  } else {
		cnt[i] = 0;
	  }
	}
	int res = 0;
	rep (i, n) res = max(res, cnt[i]);
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    cin >> N >> M;
    if(abs(N-M)>1){
        cout << 0 << endl;
        return 0;
    }
    // 同数の場合→ N! * M! * 2
    // 1個違いの場合→ N! * M!
    ll Nkaijo = 1;
    ll Mkaijo = 1;
    if(N==M){
        rep(i,N){
            Nkaijo *= (i+1);
            Nkaijo %= MOD;
        }
        ll ans = (2*Nkaijo*Nkaijo)%MOD;
        cout << ans << endl;
    }else{
        rep(i,N){
            Nkaijo *= (i+1);
            Nkaijo %= MOD;
        }
        rep(i,M){
            Mkaijo *= (i+1);
            Mkaijo %= MOD;
        }
        ll ans = (Nkaijo*Mkaijo)%MOD;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>

#include<cstdlib>
using namespace std;
int top, S[1000];
void push(int x) {
	S[++top] = x;
}
int pop() {
	top--;
	return S[top + 1];
}
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 {
			push(atoi(s));
		}
		
	}
	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

const double pi=3.14159265358979323846;
int n;
double ans;

int main()
{
	n=read();
	ans=2.0*n*pi;
	printf("%.20lf",ans);
	return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
typedef pair<int,int> pii;
typedef long long ll;

int n,a,sum;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
		
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a;
		if (a % 2 == 1 && i % 2 == 1) sum++;
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
#define debug(x) cerr << #x << ":" << x << endl;

int main()
{
  int64 N, x;
  cin >> N >> x;
  vector< int64 > a(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];

  int64 ans = 0LL;
  for (int i = 0; i < N - 1; ++i) {
    if (a[i] + a[i + 1] > x) {
      ans += a[i] + a[i + 1] - x;
      if (a[i] > x) {
	a[i + 1] = 0;
      } else {
	a[i + 1] = x - a[i];
      }
    }
  }

  cout << ans << endl;

  /*
  for(auto &ai : a)
    debug(ai);
  */
  return 0;
}


Measured memory_bytes: 1024
// Squid Ink
// ??R???¬??p??C???¢?????C++11???£???w???????????????¢???????R???¬??p??C???£??G???¢??[

#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>

typedef struct{
	int to, cost;
} Edge;

typedef std::pair<int, int> P;	//<cost, pos>

const int kMaxSize	= 32;
const int kMaxField = kMaxSize*kMaxSize;
const int kCostFriendlyInk = 1;
const int kCostShot = 2;
const int kCostBlank = 2;
const int kShotRange = 3;

const char kWall = '#';
const char kFriend = 'o';
const char kEnemy = 'x';
const char kStart = 'S';
const char kGoal = 'G';
const char kBlank = '.';

char field[kMaxField];
int way[4] = { -1, 1, -kMaxSize, kMaxSize };

const int kInf = 1 << 16;
int d[kMaxField];
std::vector<Edge> cost[kMaxField];
int R, C;

inline int xy2pos(const int x, const int y){
	return x + y*kMaxSize;
}

void initCost(){
	for (int y = 1; y <= R; y++){
		for (int x = 1; x <= C; x++){
			int pos = xy2pos(x, y);
			if (field[pos] == kWall) continue;
			for (int i = 0; i < 4; i++){
				for (int j = 1; j <= kShotRange; j++){
					int newpos = pos + j*way[i];
					if (field[newpos] == kWall) break; //?????????????????????????????????????¢
					if (j == 1){
						if (field[newpos] == kFriend) cost[pos].push_back({ newpos, kCostFriendlyInk });
						else if (field[newpos] == kEnemy) cost[pos].push_back({ newpos, kCostShot + kCostFriendlyInk });
						else cost[pos].push_back({ newpos, kCostBlank });
					}else{
						int newcost;
						if (field[newpos] == kFriend)
							newcost = std::min(kCostShot + kCostFriendlyInk * j, cost[pos].back().cost + kCostFriendlyInk);
						else if (field[newpos] == kEnemy)
							newcost = kCostShot + kCostFriendlyInk * j;
						else
							newcost = std::min(kCostShot + kCostFriendlyInk * j, cost[pos].back().cost + kCostBlank);
						cost[pos].push_back({ newpos, newcost });
					}
				}
			}
		}
	}
}

void dijkstra(int spos){
	std::priority_queue<P, std::vector<P>, std::greater<P>> q;
	std::fill(d, d + kMaxField, kInf);
	d[spos] = 0;
	q.push({ 0, spos });

	while (!q.empty()){
		P p = q.top(); q.pop();
		if (d[p.second] < p.first) continue;
		for (unsigned int i = 0; i < cost[p.second].size(); i++){
			Edge e = cost[p.second][i];
			if (d[e.to] > d[p.second] + e.cost){
				d[e.to] = d[p.second] + e.cost;
				q.push({ d[e.to], e.to });
			}
		}
	}
}

int main(){
	int start, goal;

	std::fill(field, field + kMaxField, kWall);

	std::scanf("%d %d", &R, &C);
	for (int y = 1; y <= R; y++)
		for (int x = 1; x <= C; x++){
			int pos = xy2pos(x, y);
			std::scanf(" %c", &field[pos]);
			if (field[pos] == kStart) start = pos;
			else if (field[pos] == kGoal) goal = pos;
		}
	initCost();
	dijkstra(start);
	printf("%d\n", d[goal]);
	return 0;
}

Measured memory_bytes: 2848
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(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;

int main(){
  ios::sync_with_stdio(false);
  int n; cin >> n;
  int ans1 = 0, ans2;
  vector<int> a(n, 0);
  REP(i, n){
    cin >> a[i];
    ans1 = max(ans1, a[i]);
  }
  int tmp = ans1/2, m = 1e9 + 1000;
  REP(i, n){
    if(ans1%2 == 0){
      if(abs(a[i] - tmp) == 0){
        if(a[i] == ans1) continue;
        ans2 = a[i];
        cout << ans1 << " " << ans2 << endl;
        return 0;
      }else if(abs(a[i] - tmp) < m && a[i] != ans1){
        if(a[i] == ans1) continue;
        m = abs(a[i] - tmp);
        ans2 = a[i];
      }
    }else{
      if(a[i] == tmp || a[i] == tmp+1){
        if(a[i] == ans1) continue;
        ans2 = a[i];
        cout << ans1 << " " << ans2 << endl;
        return 0;
      }else if(a[i] < tmp && abs(a[i] - (tmp+1)) < m){
        if(a[i] == ans1) continue;
        m = abs(a[i] - (tmp+1));
        ans2 = a[i];
      }else if(a[i] > tmp && abs(a[i] - tmp) < m){
        if(a[i] == ans1) continue;
        m = abs(a[i] - tmp);
        ans2 = a[i];
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
using namespace std;

int main()
{
	set<int> st;
	int n, m;
	cin >> n >> m;
	while (m--) {
		int x;
		cin >> x;
		st.insert(x);
	}

	int mi = 0x7fffffff, ans = -1;
	for (int i = 0; i <= 101; i++) {
		if (st.count(i)) continue;
		if (abs(i - n) < mi) {
			mi = abs(i - n);
			ans = i;
		}
	}

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


Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(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 pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m,l;
    cin >> n >> m >> l;
    vvi dist(n,vi(n,inf));
    rep(i,n) dist[i][i] = 0;
    rep(_,m) {
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    rep(k,n) rep(i,n) rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]);
    rep(i,n) rep(j,n) {
        dist[i][j] = (dist[i][j] <= l ? 0 : inf);
    }
    rep(k,n) rep(i,n) rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]+1);
    int q;
    cin >> q;
    while(q--) {
        int s,t;
        cin >> s >> t;
        s--; t--;
        cout << (dist[s][t] == inf ? -1 : dist[s][t]) << "\n";
    }
}

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

bool is_equal_number(int i, int j, int k, int X) {
    if (500 * i + 100 * j + 50 * k == X) {
        return true;
    }
    return false;
}

int main() {
    int A, B, C;
    int X;
    cin >> A >> B >> C >> X;

    int counter = 0;
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
                if (is_equal_number(i, j, k, X)) {
                    ++counter;
                }
            }
        }
    }

    cout << counter << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int test=in.nextInt();
        int n[]=new int[test];
        for (int i = 0; i < test; i++) {
            n[i]=in.nextInt();
        }
        int query=in.nextInt();
        for (int i = 0; i <query; i++) {
            int x=in.nextInt();
            int check=0;
        int right=test-1,left=0,mid=0,rifat=0;
        while(left<=right){
            mid=(left+right)/2;
            if(n[mid]==x || x<n[mid]){
                check=1;
                rifat=mid;
            }
            if(n[mid]<x){
                left=mid+1;
            }
            else{
                right=mid-1;
            }
        }
        if(check==0){
            System.out.println(n.length);
        }
        else{
            System.out.println(rifat);
        }
        }
    }
}


Measured memory_bytes: 102080
#include<bits/stdc++.h>
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))  
#define lli long long int
#define ll long long 
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define BS binary_search
#define pii pair<lli,lli>
const long long int mod=1000000007;
//const long long int mod=998244353;
const long double PI=3.141592653589793;
const long long int inf=1e18;
const long long int inf2=LLONG_MAX;
#define setBitCount(x) __builtin_popcountll(x)
#define all(a) (a).begin(), (a).end()
#define all_r(a) (a).rbegin(), (a).rend()
lli gcd(lli a,lli b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}
// calculating (x^y)%p
lli power(lli x,lli y,lli p)
{
    lli res = 1;      
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) //y is odd  
        res = (res*x) % p;
        y = y>>1; 
        x = ( (x%p)*(x%p) )% p;  
    }
    return res%p;
}
// calculating modular inverse using fermat little theorem
lli modInverse(lli n,lli p) 
{
    return power(n, p-2, p)%p;
}

// policy based data structures !!
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
// s.order_of_key (k) : Number of items strictly smaller than k
// *(s.find_by_order(k)) : K-th element in a set (counting from zero)
lli fact[200015];
lli inv[200015];
lli fun(lli a,lli b,lli c,lli d)
{
   lli ans=fact[c-a+d-b]%mod;
   ans=(ans*inv[c-a])%mod;
   ans=(ans*inv[d-b])%mod;
   return ans%mod;
}
void solve()
{
   lli n,m;
   cin>>n>>m;
   
   lli k;
   cin>>k;
   
   vector<pii>v;
   for(lli i=1;i<=k;i++)
   {
      lli x,y;
      cin>>x>>y;
      v.pb(mp(x,y));
   }
   v.pb(mp(n,m));
   sort(all(v));
   
   vector<lli>ans;
   for(lli i=0;i<v.size();i++)
   {
      lli tp=fun(1LL,1LL,v[i].F,v[i].S)%mod;
      ans.pb(tp);
   }
   for(lli i=0;i<v.size()-1;i++)
   {
      for(lli j=i+1;j<v.size();j++)
      {
         if(v[j].S<v[i].S || v[j].F<v[i].F)
         continue;
         
         ans[j]=(ans[j]-(ans[i]*fun(v[i].F,v[i].S,v[j].F,v[j].S))%mod+mod)%mod;
      }
   }
   cout<<ans[k]%mod;
}
int main()
{
   
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    fact[0]=1;
    for(lli i=1;i<200015;i++)
    fact[i]=(fact[i-1]*i)%mod;
    
    inv[200010]=power(fact[200010],mod-2,mod)%mod;
    for(lli i=200009;i>=0;i--)
    {
       inv[i]=((i+1)*inv[i+1])%mod;
    }
    
    lli T;
    //cin>>T;
    T=1;
    while(T--)
    {
        solve();
    }




    return 0;
}

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

int N, M, Q, L[200009], R[200009], X[509][509], C[509][509];

int main() {
	cin >> N >> M >> Q;
	for (int i = 1; i <= M; i++) {
		cin >> L[i] >> R[i]; X[L[i]][R[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) C[i][j] = C[i][j - 1] + X[i][j];
	}
	for (int i = 1; i <= Q; i++) {
		int p, q; cin >> p >> q;
		int sum = 0;
		for (int j = p; j <= q; j++) sum += C[j][q] - C[j][p - 1];
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>

int main(){
  int H, W;
  scanf("%d", &H);
  scanf("%d", &W);
  char map[H][W];
  std::string s;
  for (int i=0; i<H; i++){
    std::cin >> s;
    for (int j=0; j<W; j++){
      map[i][j]=s[j];
    }
  }
  bool ok = true;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      if (map[i][j]=='.'){
        continue;
      }
      bool surround = false;
      if(i<H-1){
        if(map[i+1][j]=='#'){
          surround = true;
        }
      }
      if (i>=1){
        if (map[i-1][j]=='#'){
          surround = true;
        }
      }
      if (j<W-1){
        if(map[i][j+1]=='#'){
          surround = true;
        }
      }
      if (j>=1){
        if(map[i][j-1]=='#'){
          surround = true;
        }
      }
      if (!surround){
        ok = false;
      }
    }
  }
  printf("%s\n",ok?"Yes":"No");
  return 0;
}


Measured memory_bytes: 384
s = list(input())
x = []
for i in s:
    if i in ('A' 'C' 'G' 'T'):
        x.append(1)
    else:
        x.append(0)

z = len(x)
y = [0]
a = 1
if z == 1:
    if x[0] == 1:
        y.append(a)
else:
    for j in range(1,z):
        if x[j] == 1:
            if x[j-1] == 1:
                a += 1
                if j == z-1:
                    y.append(a)
            else:
                y.append(a)
                a = 1
        else:
            if x[j-1] == 1:
                y.append(a)
                a = 1
print(max(y))


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

int main(){
    int n,m; cin>>n>>m;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    vector<int> ans(n);
    rep(i,n) ans[i]=0;
    rep(i,m){
        int a,b; cin>>a>>b;
        if(h[a-1]>h[b-1]) ans[b-1]++;
        else if(h[a-1]<h[b-1]) ans[a-1]++;
        else{
            ans[a-1]++;
            ans[b-1]++;
        }
    }
    int cnt=0;
    //rep(i,n) cout<<ans[i]<<endl;
    rep(i,n){
        if(ans[i]==0) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 4052
n = int(input())
a = 0
b = 0
ans = 0
ab = 0
for i in range(n):
  s = input()
  for j in range(len(s)-1):
    if s[j:j+2] == "AB":
      ans += 1
  if s[-1] == "A":
    a += 1
  if s[0] == "B":
    b += 1
  if s[-1] == "A" and s[0] == "B":
    ab += 1
k = min([a, b])

if k == a and k == b and k == ab:
  k -= 1
if k == n:
  k -= 1
if k < 0:
  k = 0
ans += k
print(ans)

Measured memory_bytes: 3064
def cmb(n, r):
    if n < r:
        return 0
    a = 1
    for i in range(n, n - r, -1):
        a *= i
    b = 1
    for i in range(1, r + 1):
        b *= i
    return int(a / b)


N, M = [int(i) for i in input().split()]
ans = cmb(N, 2) + cmb(M, 2)

print(ans)


Measured memory_bytes: 3188
import math
A, B, H, M = map(int, input().split(' '))
deg = abs(M * 6 - (H * 30 + 0.5 * M))
if deg > 180:
    deg = 360 - deg
deg = math.radians(deg)
print(math.sqrt((B - A * math.cos(deg)) ** 2 + (A * math.sin(deg)) ** 2))

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

using namespace std;

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

const ll INF=1e9+7;
int c['z'+1];
int f['z'+1];
int n;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	for(int i='a';i<='z';i++){
		f[i]=INF;
	}
	rep(i,n){
		string s;
		cin>>s;
		memset(c,0,sizeof(c));
		rep0(i,s.size()){
			c[s[i]]++;
		}
		for(int j='a';j<='z';j++){
			f[j]=min(f[j],c[j]);
		}
	}
	for(int i='a';i<='z';i++){
		rep(j,f[i]){
			char t=i;
			cout<<t;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 public static void main (String[] args)  {
  Scanner sc = new Scanner(System.in);
  while(true) {
   int a = sc.nextInt(), b = sc.nextInt();
   if(a == 0 && b == 0) break;
   for(int i = 1; i <= a; i++) {
    for(int j = 1; j <= b; j++) {
      if((i+j)%2==0)
     System.out.print("#");
      else 
     System.out.print(".");
    }
    System.out.println();
   }
   System.out.println();
  }
 }
}


Measured memory_bytes: 35008
s_code = gets.chomp!

s_code = s_code.split("")

#連続するnum があるか判断
#とりあえずeach メソッド
#print(s_code, "\n")

count = 3
while count > 0
  if s_code[count].to_i - s_code[count-1].to_i == 0
    print("Bad\n")
    break
  else
    count = count-1
    #print(count, "\n")
    if count == 0
      print("Good\n")
    end
  end
end

Measured memory_bytes: 1788
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(int[] prices) {
    int sum = 0;
    int max = 0;
    for (int p : prices) {
      sum += p;
      max = Math.max(max, p);
    }
    return sum - max;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int[] prices = reader.nextInt(3);
    out.println(solve(prices));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 20820
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

ll func(ll x){
	if(x%4==0) return x;
	else if(x%4==1) return 1LL;
	else if(x%4==2) return (1LL^x);
	else if(x%4==3) return 0LL;

	return 0;
}



int main()
{
	ll a,b;
	cin>>a>>b;

	if(a==b){
		cout<<a<<endl;
		return 0;
	}

	cout << (func(b)^func(a-1)) << endl;

	return 0;
}

Measured memory_bytes: 256