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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

int H, W;

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

  while(cin >> W >> H,W){
  int N;
  cin >> N;
  vector<pair<PII,PII>> ps(N);
  {
	set<int> xs, ys;
	REP(i,N){
	  cin >> ps[i].FF >> ps[i].SS;
	  
	  FOR(d,-1,1){
		if(0 <= ps[i].FF.FF+d && ps[i].FF.FF+d <= W)
		  xs.insert(ps[i].FF.FF + d);
		if(0 <= ps[i].FF.SS+d && ps[i].FF.SS+d <= H)
		  ys.insert(ps[i].FF.SS + d);
	  }
	  FOR(d,0,2){
		if(0 <= ps[i].SS.FF+d && ps[i].SS.FF+d <= W)
		  xs.insert(ps[i].SS.FF + d);
		if(0 <= ps[i].SS.SS+d && ps[i].SS.SS+d <= H)
		  ys.insert(ps[i].SS.SS + d);
	  }
	}
	
	xs.insert(0);
	xs.insert(W-1);
	xs.insert(W);
	ys.insert(0);
	ys.insert(H-1);
	ys.insert(H);
	
  
	map<int,int> xs2ix, ys2ix;
	int it = 0;
	for(int x: xs){
	  xs2ix[x] = it++;
	}
	it = 0;
	for(int y: ys){
	  ys2ix[y] = it++;
	}

	W = SZ(xs);
	H = SZ(ys);
	for(auto& p: ps){
	  p.FF.FF = xs2ix[p.FF.FF];
	  p.SS.FF = xs2ix[p.SS.FF];
	  p.FF.SS = ys2ix[p.FF.SS];
	  p.SS.SS = ys2ix[p.SS.SS];
	}
  }

  vector<vector<short>> acc(H+1, vector<short>(W+1));
  for(auto& p: ps){
	acc[p.FF.SS][p.FF.FF]++;
	acc[p.SS.SS][p.SS.FF]++;
	acc[p.FF.SS][p.SS.FF]--;
	acc[p.SS.SS][p.FF.FF]--;
  }

  REP(y,H+1) REP(x,W+1){
	acc[y][x] += (y>0? acc[y-1][x]: 0) + (x>0? acc[y][x-1]: 0) - (y>0&&x>0?acc[y-1][x-1]: 0);
  }

  int ans = 0;
  REP(y,H-1) REP(x,W-1){
	if(!acc[y][x]){
	  ++ans;

	  queue<PII> q;
	  q.push(MP(x,y));
	  while(!q.empty()){
		PII p = q.front();
		q.pop();
		REP(d,4){
		  PII np(p.FF + dx[d], p.SS + dy[d]);
		  if(np.FF < 0 || W-1 <= np.FF || np.SS < 0 || H-1 <= np.SS) continue;
		  if(!acc[np.SS][np.FF]){
			acc[np.SS][np.FF] = 1;
			q.push(np);
		  }
		}
	  }
	}
  }
  cout << ans << endl;
}

  return 0;
}



Measured memory_bytes: 4956
#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; cin >> N;
    map<ll,int> res;
    rep(i,N) {
        ll a; cin >> a;
        if(res.count(a))
            res[a]++;
        else res[a] = 1;
    }
    int ans = 0;
    for(auto x: res) {
        if(x.second%2 != 0)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main(void) {
	int n,q;
	int seq[10000],set[500];
	int i,j,k;
	int count;

	// read sequence
	scanf("%d",&n);
	for (i = 0;i != n;++i) {
		scanf("%d",seq + i);
	}
	// read set
	scanf("%d",&q);
	for (i = 0;i != q;++i) {
		scanf("%d",set + i);
	}
	// linear search
	for (i = 0;i != n;++i) {
		j = 0;
		while (j != q) {
			if (seq[i] == set[j]) {
				++count;
				// delete this element in set
				for (k = j + 1;k != q;++k) {
					set[k - 1] = set[k];
				}
				--q;
			} else {
				++j;
			}
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
n = int(input())
dist = [list(map(int,input().split())) for i in range(n)]
ans = 0
for arr in dist:
  ans += sum(arr)

for i in range(n):
  for j in range(n):
    for k in range(n):
      if i != j and j != k and k != i:
        if dist[i][k]+dist[k][j] == dist[i][j] and dist[i][k] != 0 and dist[k][j] != 0:
          ans -= dist[i][j]
          break
        elif dist[i][k]+dist[k][j] < dist[i][j] and dist[i][k] != 0 and dist[k][j] != 0:
          print(-1)
          exit()
print(ans//2)

Measured memory_bytes: 45916
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ a, b, h, m ] :: [Double] <- map fromIntegral <$> readInts
	let
		theta1 = ( h / 12 + m / 60 / 12 ) * pi * 2
		theta2 = m / 60 * pi * 2
		y1 = a * sin theta1
		x1 = a * cos theta1
		y2 = b * sin theta2
		x2 = b * cos theta2
		d = sqrt $ ( y1 - y2 ) ^ 2 + ( x1 - x2 ) ^ 2
	printf "%.12f\n" d

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

int main() {
  unsigned long a, b;
  cin >> a >> b;
  cout << (a / b) << ' ';
  cout << (a % b) << ' ';
  cout << fixed << setprecision(6) << ((double)a / b) << endl;
  return 0;
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main() { 
    int H, W;
    string C[102];
    cin>>H>>W;
    rep(i, H) cin>>C[i];
    rep(i, H) {
        cout << C[i] << endl;
        cout << C[i] << endl;
    }
    
    return 0; 
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = list(input())
if S[K-1] == 'A':
  S[K-1] = 'a'
if S[K-1] == 'B':
  S[K-1] = 'b'
if S[K-1] == 'C':
  S[K-1] = 'c'
for i in S:
  print(i,end="")

Measured memory_bytes: 8980
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


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

int main()
{
	int n, c, k, t[100005], i, ans = 0, tim = 0, cnt = 0;

	cin >> n >> c >> k;
	for(i = 0; i < n; i++){
		cin >> t[i];
	}

	sort(t, t + i);

	for(i = 0; i < n; i++){
		if(t[i] > tim || cnt <= 0){
			tim = t[i] + k;
			ans++;
			cnt = c - 1;
		}
		else{
			cnt--;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define edge pair<ll,ll>
#define mod 1000000007
using namespace std;
 
 
// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦


int main(){

	fast;
	ll n,a,b,c;
	
	ll i,j,k;
	double pi=3.1415926535;
	cin>>n;
	cout<<fixed<<setprecision(10)<<2*pi*n<<endl;
	



	return 0;
}

Measured memory_bytes: 3804
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(string, "x", long, "y");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto Music = new Pair[](n);
    foreach (i; iota(n))
    {
        string title;
        long time;
        scan(title, time);
        Music[i] = Pair(title, time);
    }
    auto x = sread();
    bool flag;
    long ans;
    foreach (e; Music)
    {
        if (e.x == x)
        {
            flag = true;
            continue;
        }

        if (flag)
            ans += e.y;
    }
    ans.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  string s;
  cin >> s;
  if(s=="ABC")cout << "ARC";
  else cout << "ABC";
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
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;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int K;
  cin >> K;
  vector<int> A(K);
  for (int i = 0; i < K; i++)
  {
    cin >> A.at(i);
  }

  reverse(A.begin(), A.end());
  A.push_back(1);
  
  if (A.at(0) != 2)
  {
    cout << -1 << endl;
    return 0;
  }

  int M = 2, m = 2;
  for (int i = 1; i <= K; i++)
  {
    if ((M + A.at(i - 1) - 1) - m + 1 < A.at(i)
        && (M + A.at(i - 1) - 1) % A.at(i) > m % A.at(i)
        && m % A.at(i) != 0)
    {
      cout << -1 << endl;
      return 0;
    }
    
    M = (M + A.at(i - 1) - 1) / A.at(i) * A.at(i);
    m = divCeil(m, A.at(i)) * A.at(i);
  }
  
  cout << m << " " << M << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    int sum = a.back()/2;
    a.pop_back();
    rep(i,a.size()) {
        sum += a[i];
    }
    cout << sum;
}



Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N, M;
    cin >> N >> M;
    char A[N][N];
    char B[M][M];

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < M; i++)
    {
        for(int j = 0; j < M; j++)
        {
            cin >> B[i][j];
        }
    }

    bool inner = false;
    bool exist = false;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            if( i + M - 1 >= N || j + M - 1 >= N )
                continue;
                // inner = false;
            // else   
                // inner =true;

            // if(inner)
            // {
                bool match = true;
                for(int k = 0; k < M; k++)
                {
                    for(int l = 0; l < M; l++)
                    {
                        if(A[i + k][j + l] != B[k][l])
                            match = false;
                    }
                }

                if(match) exist = true;
            // }
        }
    }
 
    if(exist)
        cout << "Yes" <<endl;
    else
        cout << "No" << endl;
    return 0;

    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		try (Scanner in = new Scanner(System.in)) {
			int N = in.nextInt();

			int[] A = new int[N];
			for (int i = 0; i < N; i++) {
				A[i] = in.nextInt();
			}
			long count = 0;

			{
				int xor = 0;
				int plus = 0;
				int length = 0;
				for (int l = 0, r = 0;; l++) {
					for (;; r++) {
						if (r < N) {
							xor ^= A[r];
							plus += A[r];
						} else {
							count += length;
							break;
						}
						if (xor == plus) {
							length++;
						} else {
							count += length;
							xor ^= A[r];
							plus -= A[r];
							break;
						}
					}
					if (l >= N) {
						break;
					}
					xor ^= A[l];
					plus -= A[l];
					length--;
				}
			}
			System.out.println(count);
		}
	}
}


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

int	main()
{
  int	a;
  int	b;
  int	average;
  
  cin >> a;
  cin >> b;
  
  average = (a + b) / 2;
  if ((a + b) % 2 != 0)
    average++;
  
  cout << average << endl;
  
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;

int main(){
  ll n,m,t,tmp=0;
  cin>>n>>m;
  if(n*2<m)tmp=(m-2*n)/4;
  cout<<min(n,m/2)+tmp;
}
  

Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

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

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

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

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

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

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

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

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

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type area struct {
	h, w int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	H, W, D := sc.nextInt(), sc.nextInt(), sc.nextInt()
	A := make([]area, H*W+1)
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			A[sc.nextInt()] = area{i, j}
		}
	}
	S := make([]int, H*W+1)
	for i := 1; i <= D; i++ {
		for j := i; j <= H*W; j += D {
			if j-D >= 1 {
				S[j] += S[j-D]
				now, before := A[j], A[j-D]
				S[j] += abs(now.h-before.h) + abs(now.w-before.w)
			}
		}
	}
	//fmt.Fprintln(wtr, S)
	Q := sc.nextInt()
	for i := 0; i < Q; i++ {
		l, r := sc.nextInt(), sc.nextInt()
		fmt.Fprintln(wtr, S[r]-S[l])
	}
}


Measured memory_bytes: 5632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { 1,0,-1,0 };
P loc[1000001];
int isp[1000001];
int mp[2000][2000];
void makemap() {
	P now = { 1000,1000 }; int d = 3; loc[1] = { 1000,1000 };
	mp[1000][1000] = 1;
	Rep1(i, 2, 1000000) {
		int nx=now.first + dx[(1 + d) % 4];
		int ny = now.second + dy[(1 + d) % 4];
		if (!mp[nx][ny]) {
			d = (1 + d) % 4; now = { nx,ny }; mp[nx][ny] = i; loc[i] = { nx,ny };
		}
		else {
			nx = now.first + dx[d];
			ny = now.second + dy[d];
			now = { nx,ny }; mp[nx][ny] = i; loc[i] = { nx,ny };
		}
	}
}
void setprime() {
	fill(isp + 2, isp + 1000001, 1);
	for (int i = 2; i < 1000001; i++) {
		if (!isp[i])continue;
		for (int j = 2 * i; j < 1000001; j += i) {
			isp[j] = 0;
		}
	}
}
P ans[2000][2000];
void init() {
	rep(i, 2000) {
		rep(j, 2000) {
			ans[i][j] = { 0,0 };
		}
	}
}
int main() {
	makemap(); setprime();
	int n, m;
	while (cin >> n >> m, n) {
		init();
		for (int i = 1998; i >= 0; i--) {
			for (int j = 1; j <= 1998; j++) {
				if (mp[i][j] == 0 || mp[i][j] > n) {
					ans[i][j] = { 0,0 }; continue;
				}
				ans[i][j] = max({ ans[i + 1][j - 1],ans[i + 1][j],ans[i + 1][j + 1] });
				if (isp[mp[i][j]]) {
					if (ans[i][j].first == 0) {
						ans[i][j] = { 1,mp[i][j] };
					}
					else {
						ans[i][j].first++;
					}
				}
			}
		}
		P sta = loc[m]; P out = ans[sta.first][sta.second];
		cout << out.first << " " << out.second << endl;
	}
	return 0;
}


Measured memory_bytes: 53868
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        b += a // 2
        a //= 2
    else:
        if b % 2 == 1:
            b -= 1
        a += b // 2
        b //= 2
print(a, b)

Measured memory_bytes: 61764
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint ball[N+10]={};
    rep(i,N) ball[A[i]]++;
    lint ans=0;
    rep(i,N+10) ans+=(ball[i]*(ball[i]-1))/2;
    rep(i,N){
        lint minus=(ball[A[i]]*(ball[A[i]]-1))/2;
        minus-=((ball[A[i]]-1)*(ball[A[i]]-2))/2;
        cout << ans-minus << endl;
    }
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>

struct Node {
	int plus;
	int cost;
	int last;
};

int main() {
	int n;
	std::vector<Node>list;
	std::cin >> n;
	list.resize(n);
	for (int i = 0; i < n; i++) {
		std::cin >> list.at(i).plus;
		list.at(i).cost=-1;
		list.at(i).last=-1;
	}
	//std::cout<<"------------------"<<std::endl;
	std::vector<int>next_list;
	std::vector<int>next_list_tmp;
	next_list.push_back(0);
	int cost = 1;
	bool is_continue = true;
	while (is_continue) {
		//if (cost > 4) {
		//	break;
		//}
		std::vector<int>::iterator it = next_list.begin();
		while (it!= next_list.end()) {
			for (int i = 0; i < 6; i++) {
				int index = *it+i+1;
				//std::cout<<index<<std::endl;
				if(index >= n)break;
				if (list.at(index).cost == -1) {
					std::vector<int>node_stack;
					//for (auto v : list) {
					//	std::cout<< v.cost << ",";
					//}
					//std::cout << std::endl;
					bool is_continue_1 = true;
					while (is_continue_1) {
						//std::cout<<index<<"--";
						if (std::find(node_stack.begin(), node_stack.end(), index) != node_stack.end() || index == *it) {

							node_stack.push_back(index);
							for (auto prev : node_stack) {
								list.at(prev).cost = cost;
								list.at(prev).last = -2;
							}
							is_continue_1 = false;
							//std::cout << "loop" << std::endl;
							break;
						}
						if (list.at(index).plus == 0) {
							if (list.at(index).cost == -1 || list.at(index).cost > cost) {
								node_stack.push_back(index);
								for (auto prev : node_stack) {
									list.at(prev).cost = cost;
									list.at(prev).last = index;
									is_continue_1 = false;
									if (index == n-1) {
										is_continue = false;
									}
								}
								next_list_tmp.push_back(index);
								//std::cout<<"end:"<<index<<std::endl;
								break;
							}
						}
						node_stack.push_back(index);
						index += list.at(index).plus;
					}
				}
				if (list.at(index).cost > index && list.at(index).last > 0) {
					list.at(list.at(index).last).cost = index;
				}
			}
			++it;
		}
		next_list.clear();
		//std::cout << cost << "==================" << std::endl;
		for (auto v : next_list_tmp) {
			next_list.push_back(v);
			//std::cout<<v<<",";
		}
		//std::cout<<std::endl;
		//std::cout<<"=================="<<std::endl;
		next_list_tmp.clear();
		++cost;
	}
	//std::cout<<"result="<<cost-1<<std::endl;
	std::cout << cost - 1 << std::endl;
}

Measured memory_bytes: 4612
#include <stdio.h>

#define N 2000001
#define I 10001

void CountingSort(short*,short*,int);

int n;

int main()
{
  int i,k=0;
  short A[N],B[N];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(k < A[i]){
      k = A[i];
    }
  }

  CountingSort(A,B,k);

  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);

  return 0;
}


void CountingSort(short a[],short b[],int k)
{
  int i,j;
  int C[I];

  for(i=0;i<=k;i++){
    C[i]=0;
  }
  
  for(j=1;j<=n;j++){
    C[a[j]]++;
  }
  
  for(i=1;i<=k;i++){
    C[i] = C[i] + C[i-1];
  }
  
  for(j=n;j>=1;j--){
    b[C[a[j]]] = a[j];
    C[a[j]]--;
  }
}

Measured memory_bytes: 8448
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define MAXN (int)1e5
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)
#define inf (int)1e9

ll dp[MAXN+1];
map<int,int> b;

ll sol(int n){
	if(n == 0) return (ll)1;

	if(n < 0) return (ll)0;

	if(dp[n] != -1) return dp[n];

	ll nw = 0;

	nw = (sol(n-1) + nw)%mod;
	nw = (sol(n-2) + nw)%mod;

	dp[n] = nw;
	return dp[n];
}

int main(){

	fastio;
	int n,m;
	cin >> n >> m;

	memset(dp,-1,sizeof(dp));
	fo(m){
		int a;
		cin >> a;

		dp[a] = 0;
	}


	ll ans = sol(n);

	cout << ans << endl;

	return 0;
 }	

Measured memory_bytes: 4224
#include<stdio.h>
int main(){
	int x,y,m;
	for(;;){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0) break;
		if(x>y){
			m=x;
			x=y;
			y=m;
		}
		printf("%d %d\n",x,y);
	}	
return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> l(n);
    REP(i, n) {
        cin >> l[i];
    }
    sort(all(l));
    ll ans = 0;
    REP(i, n) {
        rep(j, i + 1, n) {
            rep(k, j + 1, n) {
                if(l[i] == l[j] or l[j] == l[k])
                    continue;
                if(l[i] + l[j] > l[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3660
using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for(int i = r; i >= l; --i)
#define fr(i, l, r) for(int i = l; i < r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair; 
priority_queue< ll, vector <ll> , greater<ll>>pq1,pq2;
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,y;
    cin>>n;

    ll mn1=maxN;
    ll mx1=-maxN;

    ll mn2=maxN;
    ll mx2=-maxN;
    ll ans;
    fr(i,0,n)
    {
        cin>>x>>y;
        ll sum1=x+y;
        ll sum2=x-y;
        mn1=min(mn1,sum1);
        mx1=max(mx1,sum1);

        mn2=min(mn2,sum2);
        mx2=max(mx2,sum2);
    }
    ans=max(mx2-mn2,mx1-mn1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
package main

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

//var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 100000)
var buf = make([]byte, 0, 100000)

func nextLine() []string {
	line := readLine()
	return strings.Split(line, " ")
}

func readLine() string {
	buf = buf[:0]
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	//sc.Split(bufio.ScanLines)
	tmp := nextLine()
	Q, _ := strconv.Atoi(tmp[1])

	S := readLine()
	foundA := false
	sum := 0
	counter := make([]int, 0, len(S))
	for _, char := range S {
		switch char {
		case 'A':
			foundA = true
		case 'C':
			if foundA {
				sum++
			}
			foundA = false
		default:
			foundA = false
		}
		counter = append(counter, sum)
	}

	//resultCh := make(chan int, Q)
	//	questionCh := make(chan int, 1)

	for i := 0; i < Q; i++ {
		//go func() {
		tmp = nextLine()
		l, _ := strconv.Atoi(tmp[0])
		r, _ := strconv.Atoi(tmp[1])
		fmt.Println(counter[r-1] - counter[l-1])

		// fmt.Println(S[l-1 : r])
		// fmt.Println(strings.Count(S[l-1:r], "AC"))
		// resultCh <- len(S[l-1 : r])
		//}()
	}
	// for i := 0; i < Q; i++ {
	// 	select {
	// 	case msg := <-resultCh:
	// 		fmt.Println(msg)
	// 	}
	// }
}

Measured memory_bytes: 6016
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
ll longinf=1ll<<60;
int inf=1<<29;

int A,B;

int main(){
    cin>>A>>B;
    cout<<A*B-(A+B-1)<<endl;
      return 0;
}

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


int main(){
  const static int NMAX=100000;
  const static int KMAX=100000;
  int N,K;
  char S[NMAX];
  int Ans;
  cin >> N >> K;
  cin >> S;

  static int num[NMAX] = {0};

  int blocks=0;
  char dir=S[0];
  int len=1;
  int idx=0;
  int citizens=0;
  for (int i=1 ; i<N ; i++){
    if (dir==S[i]){
      len++;
    }
    else{
      num[blocks]=len;
      citizens+=len-1;
      blocks++;
      len=1;
      dir=S[i];
    }
  }
  num[blocks]=len;
  citizens+=len-1;
  blocks++;

  if (blocks <= K*2+1){
    Ans=N-1;
  }
  else{
    Ans=citizens+K*2;
  }
  cout << Ans;
}


Measured memory_bytes: 384
from collections import deque
import copy
H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]
S1=copy.deepcopy(S)
ans=[]

sy=0
sx=0
for i in range(H):
    for j in range(W):
        c=0
        route=deque([(i,j,0)])
        S=copy.deepcopy(S1)
        while route:
            a,b,n=route.popleft()
            c=n
            if 0<=a<=H-1 and 0<=b<=W-1:
                if S[a][b]=='.':
                    S[a][b]='#'
                    route.append((a+1,b,n+1))
                    route.append((a-1,b,n+1))
                    route.append((a,b+1,n+1))
                    route.append((a,b-1,n+1))
                    
        ans.append(c-1)

print(max(ans))


Measured memory_bytes: 9620
def iread():
    return int(input())


def sread():
    return input()


def aread(t="int"):
    if t == "int":
        ret = [int(i) for i in input().split()]
    elif t == "str":
        ret = list(input())
    return ret


def scan():
    return list(map(int, input().split()))


def main():
    a = iread()
    s = sread()
    if a < 3200:
        print("red")
    else:
        print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w,v;
char s[500005];
ll x[800005],y[800005],z[900005];
ll sex[500005];

int main(){	
	cin>>n;
	a = n;
	for(i=0;i<n;i++){
		x[i] = a;
		if(a==1)break;
		a /= 2;
		//if(a==1)break;
	}
	c = 1;
	for(j=i;j>0;j--){
		if(x[j]*2==x[j-1]){
			sex[num] = 2;
		}else{
			sex[num] = 1;
			c *= 2;
		}
		num ++ ;
	}
	c /= 2;
	ll nagasa = rui(2,num);
	nagasa /= 2;
	ll start = 1;
	ll end = 2;	
	c = 1;
	for(i=0;i<num;i++){
		end = start + 1;
		x[d] = start;y[d] = end;z[d] = c;
		d++;
		x[d] = start;y[d]=end;z[d] = 0;
		d++;
		if(sex[i]==1){
			x[d] = 1;y[d]=end;z[d] = 2 * c;
			d++;
			c = 2 * c + 1;
		}else{
			c *= 2;
		}
		start = end;
	}
	pe(end);p(d);
	for(i=0;i<d;i++){
		pe(x[i]);pe(y[i]);p(z[i]);
	}


	

	
	return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int a[210] ;

int main() {
    int n  ,count = 0;
    scanf("%d" , &n) ;

    for(int i = 0 ;i<n ;i++)
        scanf("%d" ,&a[i]) ;

    while(true) {
        int i ;
        for(i = 0 ; i<n ;i++) {
            if(a[i] &1) break ;
            a[i]/=2;
        }
        if(i!=n)break ;
        count++;
    }
    cout << count << endl ;
    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,a[100000];
set<int> s;
int main(){
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    sort(a,a+n);
    if(k>a[n-1])return 0*puts("IMPOSSIBLE");
    for(int i=0;i<n;i++){
        if(k==a[i])return 0*puts("POSSIBLE");
        s.insert(a[i]);
        if(s.find(k%a[i])!=s.end())return 0*puts("POSSIBLE");
    }
    puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>

int gcd(int,int);

int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    printf("%d\n",gcd(x,y));
    return 0;
}


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


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

using namespace std;

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

  vector<int> sum(n + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + (s[i] == '.');
  }

  int ans = n;
  for (int i = 0; i <= n; i++) {
    int cnt = (i - sum[i]) + (sum[n] - sum[i]);
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1412
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for (i = 1; i <= n; i++){
    if(i > 1) printf(" ");
      printf("%d", A[i]);
  }  
  printf("\n");
}

int main(){
  int n, i ,j;
  int A[N + 1];
  scanf("%d", &n);
  for (i = 1; i <= n; i++){
    scanf("%d", &A[i]);
  }

  for (i = 2; i <= n; i++){
    A[0] = A[i];
    trace(A, n);
    j = i - 1;
    while (j >= 1 && A[j] > A[0]){
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = A[0];
  }
  trace(A, n);
  return 0;

}

Measured memory_bytes: 608
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define fi first
#define se second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int a, b;
	cin >> a >> b;
	if (a >= 13)cout << b << endl;
	else if (a >= 6 && a < 13)cout << b / 2 << endl;
	else cout << 0 << endl;
	return 0;
}

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

const int MAX_N=1e5;
int N,M;
ll K;

typedef vector<int> vec;

vec mul(vec a, vec b){
	vec ret(N-1);
	REP(i,N-1){
		ret[i]=a[b[i]];
	}
	return ret;
}

vec pw(vec n,ll m){
	vec ret(N-1);
	REP(i,N-1){
		ret[i]=i;
	}
	if (!m){
		return ret;
	}
	ret=pw(n,m/2);
	ret=mul(ret,ret);
	if (m&1){
		ret=mul(ret,n);
	}
	return ret;
}

int main(){
	ll x0,x1,x;
	cin>>N>>x0;
	x=x0;
	vec dif(N-1);
	REP(i,N-1){
		cin>>x1;
		dif[i]=x1-x0;
		swap(x0,x1);
	}
	cin>>M>>K;
	vec p(N-1);
	REP(i,N-1){
		p[i]=i;
	}
	REP(i,M){
		int a;
		cin>>a;
		swap(p[a-2],p[a-1]);
	}
	p=pw(p,K);
	dif=mul(dif,p);
	cout<<x<<endl;
	x1=x;
	REP(i,N-1){
		x1+=dif[i];
		cout<<x1<<endl;
	}
	return 0;
}

Measured memory_bytes: 49264
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

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

    int X;
    cin >> X;
    int ans = 1;
    for(int i=2; i<=sqrt(X); i++){
        int tmp = 1;
        while(tmp<=X){
            tmp *= i;
            if(tmp <= X) ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Pair[] pairs = new Pair[m];

        for (int i = 0; i < m; i++) {
           pairs[i] = new Pair(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(pairs, new SortByB());

        int res = 0;
        int lastBridge = 0;
        for (int i = 0; i < m; i++) {
            Pair curr = pairs[i];
            if (curr.a <= lastBridge) {
                continue;
            } else {
                lastBridge = curr.b - 1;
                res++;
            }
        }
        System.out.println(res);
    }

    public static class Pair {
        int a;
        int b;
        public Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
    }

    public static class SortByB implements Comparator<Pair> {
        public int compare(Pair a, Pair b) {
            return a.b - b.b;
        }
    }
}


Measured memory_bytes: 91128
N, K = map(int, input().strip().split())
V = list(map(int, input().strip().split()))

maxi = 0
for i in range(min(N, K)):
    for o in range(i+2):
        hand = []
        for p in range(o):
            hand.append(V[p])
        for p in range(N-(i-o)-1, N):
            hand.append(V[p])
        hand.sort()
        for j in range(K-i-1):
            if len(hand) > 0:
                if hand[0] < 0:
                    del hand[0]
                else:
                    break
        ts = 0
        for k in hand:
            ts += k
        if ts > maxi:
            maxi = ts
print(maxi)

Measured memory_bytes: 3064
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N,A,B = LI()

print(min(N*A, B))


Measured memory_bytes: 6480
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
  char S[60];
  scanf("%s", S);
  int N = strlen(S);
  bool ans = true;
  if (N >= 10) {
    ans = false;
  }
  if (S[0] == 'A') {
    if (S[1] != 'K') {
      ans = false;
    }
    if (S[2] != 'I') {
      ans = false;
    }
    if (S[3] != 'H') {
      ans = false;
    }
    if (S[4] == 'A') {
      if (S[5] != 'B') {
	ans = false;
      }
      if (S[6] == 'A') {
	if (S[7] != 'R') {
	  ans = false;
	}
	if (N == 9 && S[8] != 'A') {
	  ans = false;
	}
      } else {
	if (S[6] != 'R') {
	  ans = false;
	}
	if (N == 8 && S[7] != 'A') {
	  ans = false;
	}
      }
    } else {
      if (S[4] != 'B') {
	ans = false;
      }
      if (S[5] == 'A') {
	if (S[6] != 'R') {
	  ans = false;
	}
	if (N == 8 && S[7] != 'A') {
	  ans = false;
	}
      } else {
	if (S[5] != 'R') {
	  ans = false;
	}
	if (N == 7 && S[6] != 'A') {
	  ans = false;
	}
      }
    }
  } else {
    if (S[0] != 'K') {
      ans = false;
    }
    if (S[1] != 'I') {
      ans = false;
    }
    if (S[2] != 'H') {
      ans = false;
    }
    if (S[3] == 'A') {
      if (S[4] != 'B') {
	ans = false;
      }
      if (S[5] == 'A') {
	if (S[6] != 'R') {
	  ans = false;
	}
	if (N == 8 && S[7] != 'A') {
	  ans = false;
	}
      } else {
	if (S[5] != 'R') {
	  ans = false;
	}
	if (N == 7 && S[6] != 'A') {
	  ans = false;
	}
      }
    } else {
      if (S[3] != 'B') {
	ans = false;
      }
      if (S[4] == 'A') {
	if (S[5] != 'R') {
	  ans = false;
	}
	if (N == 7 && S[6] != 'A') {
	  ans = false;
	}
      } else {
	if (S[4] != 'R') {
	  ans = false;
	}
	if (N == 6 && S[5] != 'A') {
	  ans = false;
	}
      }
    }
  }
  if (ans) {
    printf("YES");
  } else {
    printf("NO");
  } 
  return 0;
}


Measured memory_bytes: 128
n = int(raw_input())
a = [int(x) for x in raw_input().split()]

def m():
	s = n * (n + 1) / 2
	sa = sum(a)
	if sa % s != 0:
		return False
	j = sa / s
	sj = 0
	for x, y in zip(a, a[1:] + [a[0]]):
		iN = j - (y - x)
		if iN % n != 0 or iN < 0:
			return False
		i = iN / n
		sj += i
	if sj != j:
		return False
	return True

print "YES" if m() else "NO"


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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
#define BIG(c) (c)-0x20
#define SMALL(c) (c)+0x20
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      double W, H, x, y;
      cin >> W >> H >> x >> y;
      cout << (W*H)/2.0 << " " << ((W/2.0==x)&&(H/2.0==y)?1:0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな　オーバーフローする
//開区間と閉区間どうにかしろ
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグりがち
//切り上げ：(a + (b - 1)) / b
const ll MOD = 1000000007;
const ll MAX = 10010010010;

int main(){
    string s; cin >> s;
    int n=s.size();
    int res=0;
    if(n%2==0){
        rep(i,n/2){
            if(s[i]!=s[n-i-1])res++;
        }
    }
    else{
        rep(i,(n-1)/2){
            if(s[i]!=s[n-1-i]) res++;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;

/*
各個数とったときの平均値を総当たりし、
最も高い平均値になる個数を求める
その後その個数のうちに最も値が小さいものの数を
取った個数のなかと、残った個数の中から調べて組み合わせを求める
*/

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

    vector<ll> v;

    rep(i,n){
        ll tmp;
        cin >> tmp;
        v.pback(tmp);
    }

    sort(ALL(v));
    reverse(ALL(v));

    ll sum = 0;

    rep(i, a - 1){
        sum += v[i];
    }

    long double bestavg = 0.0;
    long double d = 0.0000001;
    vector<int> bestcount;

    for(int i = a - 1; i < b; i++){

        sum += v[i];

        if(bestavg < (long double)sum / (i + 1)){
            bestavg = (long double)sum / (i + 1);
            bestcount.clear();
            bestcount.pback(i + 1);
        }else if(bestavg  == (long double)sum / (i + 1)){
            bestcount.pback(i + 1);
        }

    }

    cout << setprecision(24) << bestavg << endl;

    ll ans = 0;

    rep(i, bestcount.size()){

        int num = bestcount[i];

        ll lowest = v[num - 1];

        int innercount = 0;
        int outercount = 0;

        for(int i = 0; i < num; i++){
            if(v[i] == lowest) innercount++;
        }

        for(int i = num; i < n; i++){
            if(v[i] == lowest) outercount++;
        }

        ll tmp = 1;

        //cerr << innercount << endl;
        //cerr << outercount << endl;

        for(int i = 1; i <= innercount; i++){
            tmp = tmp * (innercount + outercount + 1 - i);
            tmp = tmp / i;
        }

        ans += tmp;

    }

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

Measured memory_bytes: 256