akhauriyash/Code-Regression huggingface dataset:
H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
B = [list(map(int,input().split())) for _ in range(H)]

C = [[0 for j in range(W)] for i in range(H)]

for i in range(H):
    for j in range(W):
        C[i][j] = abs(A[i][j]-B[i][j])

dp = [[0 for k in range(6400)] for g in range(H*W)]
dp[0][C[0][0]] = 1

for g in range(H*W):
    i,j = divmod(g,W)
    for k in range(6400):
        if not dp[i*W+j][k]:
            continue
        ni,nj = i+1,j+1
        if ni < H:
            if k+C[ni][j]<6400:
                dp[ni*W+j][k+C[ni][j]] = 1
            dp[ni*W+j][abs(k-C[ni][j])] = 1
        if nj < W:
            if k+C[i][nj]<6400:
                dp[i*W+nj][k+C[i][nj]] = 1
            dp[i*W+nj][abs(k-C[i][nj])] = 1

for k in range(6400):
    if dp[-1][k]:
        print(k)
        break

Measured memory_bytes: 379400
k = gets.to_i
a = (1..9).to_a
ans = 0
k.times do
  ans = a[0]
  a.shift
  a.push(10*ans+(ans%10)-1) if ans%10 != 0
  a.push(10*ans+(ans%10))
  a.push(10*ans+(ans%10)+1) if ans%10 != 9
end
puts ans

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, K;
	cin >> N >> K;
	LL x = floor((LD)N/K);
	cout << min(abs(N - x * K), abs(N - (x + 1) * K)) << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
using namespace std;
using ll =long long;

int main (void) {
  int N;
  cin >> N;
  int t=0;
  do {
    t++;
  }
  while(N>(t+1)*t/2);
  cout <<t;
}

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

int cnt = 0;

void selectionsort(vector<int> &A){
    for(int i=0; i<A.size(); ++i){
        int minj = i;
        for(int j=i+1; j<A.size(); ++j){
            if( A[minj] > A[j]){
                minj = j;
            }
        }
        if( i!= minj){
            ++cnt;
            swap(A[i],A[minj]);
        }
    }
}

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

    vector<int> A(n,0);
    for(auto&& x: A){
        cin >> x;
    }
    selectionsort(A);

    for(int i=0; i<n; ++i){
        if( i!= 0)
            cout << ' ';
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 3116
#include<stdio.h>
#define ci(x) ((x)-(48))
int main(){
  int n,i;
  char s[4];
  scanf("%d",&n);
  sprintf(s,"%d",n);
  for(i=0;i<3;i++){
    if(s[i]==49)s[i]=57;
    else if(s[i]==57)s[i]=49;
  }
  printf("%d",ci(s[0])*100+ci(s[1])*10+ci(s[2]));
  getchar();
}

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

int main (void) {
	cin.tie(0);
	cin.sync_with_stdio(false);
	string ipt;
	cin >> ipt;
	int a = 0, b = 0;
	for (int i = 0; i < ipt.length(); i ++) {
		if (ipt.at(i) == '0')
			a ++;
		else if (ipt.at(i) == '1')
			b ++;
	}
	cout << min(a, b) * 2 << '\n';
	return 0;
}

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

using namespace std;
int ar[200005];
int main()
{

    int n;
    cin >> n;
    int x;
    for(int i=1;i<=n-1;i++)
      {
          cin >> x;
          ar[x]=ar[x]+1;
      }

      for(int i=1;i<=n;i++)
      {
          cout << ar[i]<< endl;
      }
     return 0;
}


Measured memory_bytes: 4372
#include<iostream>
#include<string>

using namespace std;

int main(void){
    int N;
    int result=0;
    long a[10010];
    cin>>N;

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

    for(int i=0;i<N;i++){
        for(int j=0;j<31;j++){
            if(a[i]%2==0){
                a[i]=a[i]/2;
                result++;
            }else{
                break;
            }
        }
    }

   
    cout<<result<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> w(n);
    int i,j;
    ll ans=1000000;
    for(i=0;i<n;i++)cin >> w.at(i);
    for(i=0;i+1<n;i++){
        ll ab;
        ll z=0;
        ll ko=0;
        for(j=0;j<=i;j++)z+=w.at(j);
        for(j=i+1;j<n;j++)ko+=w.at(j);
        ab=abs(z-ko);
        ans=min(ab,ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a ,b = map(int, input().split())

if a == b:
    print('Draw')
elif a !=1 and b!=1 and a > b:
    print('Alice')
elif a!=1 and b!=1 and b > a:
    print('Bob')
elif a == 1 and b!=1:
    print('Alice')
else:
    print('Bob')


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>

int n,m;
int w[111],v[111];
int dp[111][111][333];

int main(void)
{
    int i,j,k;
    int z;
    int answer = 0;

    //freopen("x.in","r",stdin);

    scanf("%d %d",&n,&m);
    for(i = 0;i < n;++i)
        scanf("%d %d",&w[i],&v[i]);

    for(i = 0;i < n;++i)
    {
        z = w[0];
        for(j = 1;j <= i + 1 && z <= m;++j,z += w[0])
        {
            for(k = 0;k <= (i + 1) * 3 && z + k <= m;++k)
            {
                dp[i][j][k] = i ? dp[i - 1][j][k] : 0;
                if(k >= w[i] - w[0])
                    dp[i][j][k] = std::max(dp[i][j][k],(i ? dp[i - 1][j - 1][k - w[i] + w[0]] : 0) + v[i]);
                answer = std::max(answer,dp[i][j][k]);
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <queue>
#include <stack>
#include <time.h>
using namespace std;


int main(){
	int A,B;
	cin>>A>>B;
	if(B%A==0){
		cout<<A+B<<endl;
	}
	else{
		cout<<B-A<<endl;
	}
	
	return 0;
}


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

using namespace std;

int main()
{
    int h, w;
    int a[500][500];

    cin >> h >> w;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }

    int count = 0;
    vector<tuple<int, int, int, int>> move;
    for (int i = 0; i < h; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; j++) {
                if (i == h-1 && j == w-1) {
                    break;
                }
                if (a[i][j] % 2 == 1) {
                    if (j == w - 1) {
                        a[i][j] -= 1;
                        a[i+1][j] += 1;
                        move.push_back(make_tuple(i, j, i+1, j));
                    } else {
                        a[i][j] -= 1;
                        a[i][j+1] += 1;
                        move.push_back(make_tuple(i, j, i, j+1));
                    }
                }
            }
        } else {
            for (int j = w - 1; j >= 0; j--) {
                if (i == h-1 && j == 0) {
                    break;
                }
                if (a[i][j] % 2 == 1) {
                    if (j == 0) {
                        a[i][j] -= 1;
                        a[i+1][j] += 1;
                        move.push_back(make_tuple(i, j, i+1, j));
                    } else {
                        a[i][j] -= 1;
                        a[i][j-1] += 1;
                        move.push_back(make_tuple(i, j, i, j-1));
                    }
                }
            }
        }
    }

    cout << move.size() << endl;
    for (auto& a : move) {
        printf("%d %d %d %d\n", get<0>(a)+1, get<1>(a)+1, get<2>(a)+1, get<3>(a)+1);
    }

    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    ll count = 0;
    REP(i, N){
        ll a;
        cin >> a;
        count++;
        if(a == 1){
            break;
        }
    }

    ll ans = 0;
    while(ans*K - (ans-1) < N){
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
f = 0
li.append(10**9+1)
if li[0] - 1 <= li[1]:
    li[0] = li[0] - 1
else:
    print("No")
    exit()
for i in range(n-1):
    if li[i] <= li[i+1] - 1:
        li[i+1] = li[i+1] - 1
    elif li[i] == li[i+1]:
        continue
    else:
        print("No")
        f += 1
        break
if f == 0:
    print("Yes")

Measured memory_bytes: 63984
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	string s; cin >> s;
	ll n = s.size();
	vl v(2020,0);
	v[0] = 1;
	ll mul = 1;
	ll now = 0;
	ll ans = 0;
	for(ll i=n-1; i>=0; i--){
		ll t = s[i] - '0';
		now = (now + t * mul) % 2019;
		ans += v[now];
		v[now]++;
		mul *= 10;
		mul %= 2019;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

ll N;
char bit[100];

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

  cin >> N;
  ++N;
  int n = 0;
  for (ll i = 0; (N>>i) > 0; ++i) {
    ++n;
    if ((N>>i)&1) bit[i] = 1;
    else bit[i] = 0;
  }

  vector<int> ans;
  int count = 0;
  for (int i = n-1; i >= 1; --i) {
    ans.push_back(i);
    if (bit[i-1]) {
      ++count;
      ans.push_back(n+count-1);
    }
  }
  reverse(all(ans));

  for (int i = 1; i <= n+count-1; ++i) {
    ans.push_back(i);
  }

  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) printf("%d%c", ans[i], (i+1 == ans.size() ? '\n' : ' '));

  return 0;
}


Measured memory_bytes: 888
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    return max(A+B, A-B, A*B)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(A, B))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9076
#include<stdio.h>
#include<stdlib.h>
/*
int main(void){

	long long int a,b;

	scanf("%lld %lld",&a,&b);

	printf("%lld %lld\n",a,b);


	return 0;
}
*/


int main(void){
	int n;
	int a[100000];
	int b[100000];
	int i,j;
	int buff;
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&buff);
		a[buff-1] = i;
	}

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

	printf("\n");



}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    ll n, d, x;
    cin >> n >> d >> x;
    ll a, res = x;
    REP(i, n){
        cin >> a;
        res += (d - 1) / a + 1;
    }
    cout << res << endl;
    return 0;
}

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

int main(){
    int a,b,q;
    cin >> a >> b >> q;
    vector<ll> s(a),t(b);
    for(int i = 0;i < a;i ++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    s.insert(s.begin(),-1e18);
    s.push_back(1e18);
    for(int i = 0;i < b;i ++){
        cin >> t[i];
    }
    sort(t.begin(),t.end());
    t.insert(t.begin(),-1e18);
    t.push_back(1e18);
    for(int i = 0;i < q;i ++){
        ll x,ans=1e18;
        cin >> x;
        auto itr0 = lower_bound(s.begin(),s.end(),x);
        auto itr1 = lower_bound(t.begin(),t.end(),x);
        for(int i = 0;i < 2;i ++){
            for(int j = 0;j < 2;j ++){
                ll d0,d1;
                d0 = abs(x-*(itr0-i))+abs(*(itr0-i)-*(itr1-j));
                d1 = abs(x-*(itr1-j))+abs(*(itr0-i)-*(itr1-j));
                ans = min(ans,min(d0,d1));
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main()
{
    int N, K;
    cin>>N>>K;
    vector<vector<int>> E(N);
    for (int i=0; i<N-1; i++)
    {
        int a, b;
        cin>>a>>b;
        E[a-1].push_back(b-1);
        E[b-1].push_back(a-1);
    }

    long long M = 1000000007LL;
    function<int (int, int, int, int)> f = [&](int c, int p, int d, int k)
    {
        long long ans = k;
        int t = d==0 ? K-1 : K-2;
        for (int e: E[c])
        if (e != p)
        {
            ans *= f(e, c, d+1, t);
            ans %= M;
            t = max(0, t-1);
        }
        return ans;
    };
    cout<<f(0, -1, 0, K)<<endl;
}


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

int main()
{
	string S;
	cin >> S;
	int n = S.size();
	int res = 0;
	vector<int> dp(n + 1), cnt(n + 1);
	for (int i = 0; i < n; i++) {
		cnt[i + 1] = 1 + (i - 1 >= 0 && S[i] == S[i - 1] ? cnt[i] : 0);
		if (S[i] == 'J') {
			dp[i + 1] = cnt[i + 1];
		}
		else if (S[i] == 'O') {
			dp[i + 1] = (i - cnt[i + 1] >= 0 && S[i - cnt[i + 1]] == 'J' && cnt[i + 1] <= dp[i + 1 - cnt[i + 1]]) ? cnt[i + 1] : 0;
		}
		else {
			dp[i + 1] = (i - cnt[i + 1] >= 0 && S[i - cnt[i + 1]] == 'O' && cnt[i + 1] == dp[i + 1 - cnt[i + 1]]) ? cnt[i + 1] : 0;
			res = max(res, dp[i + 1]);
		}
	}
	cout << res << endl;
	return 0;
}



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

int main() {
	int a = 1, b = 1, i, j;
	while(a != 0 && b != 0) {	
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		for(i = 1; i <= a; i++) {
			for(j = 1; j <= b; j++) {
				if (i == 1 || i == a || j == 1 || j == b) {
					printf("#");
				}else if (i >= 2 && j >= 2) {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	} 
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int A,B;cin>>A>>B;
    if(A>8 || B>8){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }
}

Measured memory_bytes: 3612
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

def readvars():
    k = map(int,input().split())
    return(k)

def readlist():
    li = list(map(int,input().split()))
    return(li)

def anslist(li):
    ans = " ".join([str(v) for v in li])
    return(ans)

def main():

	t = 1
#	t = int(input())

	for xx in range(t):
		n = int(input())
		if n%10 == 2 or n%10 == 4 or n%10 == 5 or n%10 == 7 or n%10 == 9:
			print("hon")
		elif n%10 == 0 or n%10 == 1 or n%10 == 6 or n%10 == 8:
			print("pon")
		else:
			print("bon")

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 62688
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));

 
int main() {
	int N;
	cin>>N;
	vec(V);
	map<int,int> ODD;
	map<int,int> EVEN;
	fx(N){
		vecp(V);
		if(x%2==0){
			EVEN[V.at(x)]++;
		}else{
			ODD[V.at(x)]++;
		}
	}
	int emax=0,esub=0,esum=0,emaxnum=0,esubnum=0;
int omax=0,osub=0,osum=0,omaxnum=0,osubnum=0;
    fx(100001){
   if(EVEN[x]>emax){
      esum+=esub;
      esub=emax;esubnum=emaxnum;
      emax=EVEN[x];emaxnum=x;
    }else if(EVEN[x]>esub){
esum+=esub;esubnum=x;
esub=EVEN[x];
}else{
      esum+=EVEN[x];
}


    if(ODD[x]>omax){
      osum+=osub;
      osub=omax;osubnum=omaxnum;
      omax=ODD[x];omaxnum=x;

    }else if(ODD[x]>osub){
osum+=osub;osubnum=x;
osub=ODD[x];
}else{
      osum+=ODD[x];
}
}
int ans=0;
if(omaxnum==emaxnum){
if(omax>emax){
ans+=osum+osub+esum+emax;
}else if(omax==emax){
  if(osub>esub){
ans+=osum+omax+esum+esub;
}else{
ans+=osum+osub+esum+emax;
}
}else{
ans+=osum+omax+esum+esub;
}
}else{
ans+=osum+esum+osub+esub;
}
	ce(ans)
}

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

#define ll   long long int
#define ull   unsigned long long int
#define PI 3.14159265358979
#define zig ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

const ll N=1e18;

int main()
{
    zig
    ull a, ans;
    double b;
    cin>>a>>b;
    ans=a*(ll)(b*100+0.5);
    cout<<ans/100;
    return 0;
}


Measured memory_bytes: 3704
#include<stdio.h>

int main(void){
int N;
scanf("%d", &N);
int a[N];
for (int i = 0; i < N; i++) {
scanf("%d", &a[i]);
}

//printf("before \n");
//for (int i = 0; i < N; i++) {
//printf("%d\n", a[i]);
//}

int b[N];
for (int i = 0; i < N; i++){
 int max = 0;
 int flag = 0;
  for (int j = 0; j < N; j++){
     if (a[j] > max) {
     max = a[j];
     flag = j;
     }
  }
  b[i] = max;
  a[flag] = 0;
}

//printf("after \n");
//for (int i = 0; i < N; i++) {
//printf("%d\n", a[i]);
//}

//printf("b \n");
//for (int i = 0; i < N; i++) {
//printf("%d\n", b[i]);
//}

int Alice = 0;
int Bob = 0;
for (int i = 0; i < N; i++) {
if (i % 2 == 0) Alice += b[i];
else Bob += b[i];
}

//printf("%d %d\n", Alice, Bob);
printf("%d", Alice-Bob);

return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int N; cin >> N;
    map<string, int> mp;
    rep(i,N){
        string s; cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    } 
    int64_t ans = 0;
    for(auto v : mp){
        if(v.second == 1)continue;
        ans += (int64_t)v.second*(v.second-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
while True:
    x,y,z = map(str,input().split())
    x = int(x)
    z = int(z)

    if y == '+':
        print(x + z)
    elif y == '-':
        print(x - z)
    elif y == '*':
        print(x * z)
    elif y == '/':
        print(x // z)
    elif y == '?':
        break


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

ll ans = LLINF;
void dfs(ll now, ll cou, ll a, ll b, ll sum){
	if(a <= 0)return;
	if(ans < now)return;
	if(cou == 50){
		ans = min(ans, now);
		return;
	}
	ll A = (a >> cou) & 1;
	ll B = (b >> cou) & 1;
	ll C = (sum >> cou) & 1;

	if((A + B + C) % 2){
		return;
	}

	ll tmp = (1LL << cou);
	dfs(now, cou+1, a, b, sum);
	dfs(now + tmp, cou+1, a - tmp, b + tmp, sum);
}

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

	ll n;cin >> n;
	vector<ll> v(n);REP(i, n)cin >> v[i];
	ll sum = 0;
	for(ll i = 2;i < n;i++)sum ^= v[i];

	dfs(0, 0, v[0], v[1], sum);
	if(ans < v[0]){
		cout << ans << endl;
	}
	else{
		cout << -1 << endl;
	}

	return 0;
}


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

int main(){
  int a,b,n,e=0;
  cin>>a>>b>>n;
  for(int i=0;i<n;i++){
    int c,d;
    cin>>c>>d;
    if(a<=c && d<=b){
      e++;
    }else if(a<=c && c<b){
      e++;
    }else if(a<d && d<=b){
      e++;
    }else if(c<=a && b<=d){
      e++;
    }
   
  }
  if(e>0){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


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

  ll ans=N/11*2;

  ll d=N%11;

  if(6>=d&&d>=1) ans++;

  else if(10>=d&&d>=7) ans+=2;

  cout << ans << endl;

  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);
#define max3(a,b,c) max(a,max(b,c)) 
#define mix3(a,b,c) mix(a,mix(b,c))

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int n,m;cin>>n>>m;
    vvi to(n);
    int s,t;
    rep(i,m){
        cin>>s>>t;
        to[s-1].push_back(t-1);
    }

    double ans=n;
    vd dp(n);
    rep(i,n-1){
        dp[n-1]=0;
        rrep(j,n-2){
            int s=to[j].size();
            double tmp=0,mx=0;
            rep(k,s){
                maxs(mx,dp[to[j][k]]);
                tmp+=dp[to[j][k]];
            }
            if(i==j && s!=1){
                tmp-=mx;
                s--;
            }
            dp[j]=1+tmp/s;
        }
        mins(ans,dp[0]);
    }

    printf("%.10f\n",ans);
    
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool ask(ll x){
    printf("? %lld\n",x);
    fflush(stdout);
    char res;scanf(" %c",&res);
    if(res=='Y')return true;
    else return false;
}
int p[11];
int main(){
    p[1]=1;
    for(int i=2;i<=10;i++)p[i]=p[i-1]*10;
    ll ans;
    if(ask(1000000000)){
        int l=1,r=10;
        int mid,res;
        while(l<=r){
            mid=l+r>>1;
            if(ask(p[mid]*2))res=mid,r=mid-1;
            else l=mid+1;
        }
        ans=p[res];
    }
    else{
        int l=1,r=9;
        int mid,res;
        while(l<=r){
            mid=l+r>>1;
            if(ask(p[mid]))res=mid,l=mid+1;
            else r=mid-1;
        }
        l=p[res],r=p[res+1]-1;
        while(l<=r){
            mid=l+r>>1;
            if(ask(1ll*mid*10))res=mid,r=mid-1;
            else l=mid+1;
        }
        ans=res;
    }
    printf("! %lld\n",ans);
    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main(){
        int a,b,c,cnt=0;
        scanf("%d %d %d",&a,&b,&c);
        for(int i=a;i<=b;++i){
                if(c%i==0)++cnt;
        }
        printf("%d\n",cnt);
        return 0;
}


Measured memory_bytes: 2748
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string S;
    cin>>S;
    int N=S.size();
    bool ok=true;
    if(S[0]!='A') ok=false; 
    int counter=0;
    for(int i=2; i<=N-2; i++) {
        if(S[i]=='C') counter++;
    }
    if(counter!=1) ok=false; 
    if(S[1]<97||S[1]>122) ok=false;
    if(S[N-1]<97||S[N-1]>122) ok=false;
    if(ok) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
}

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

int main () {
  string S;
  cin >> S;
  
  int size;
  size = S.size();
  string ans(size, 'x');
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int n, k;
vector<int> h;
 
int solve();
 
int main() {
  cin >> n >> k;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    h.push_back(x);
  }
  sort(h.begin(), h.end());
  cout << solve() << endl;
  return 0;
}
 
int solve() {
  int ans = 2000000000;
  for(int i = 0; i + k - 1 < n; ++i)
    ans = min(ans, h[i + k - 1] - h[i]);
  return ans;
}

Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int K;
    cin >> K;

    string ss = S.substr(K-1, 1);

    for(int i = 0; i < N; i++){
        if(S.substr(i, 1) != ss){
            cout << "*" ;
        }else{
            cout << S.substr(i, 1);
        }
    }
    cout << endl;
} 

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
	InitIO() {
		cin.tie(nullptr);
		ios_base::sync_with_stdio(false);
		cout << fixed << setprecision(30);
	}
} init_io;

//main code

int main(int argc, char const* argv[])
{
	int a,p;
	cin >> a >> p;
	cout << (a*3+p)/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,q,a[100010],b[100010],c[100010];
long long sum;
map<int,int>cnt;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		cnt[a[i]]++;sum+=a[i];
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++) {
		scanf("%d %d",&b[i],&c[i]);
		cnt[c[i]]+=cnt[b[i]];
		sum+=(c[i]-b[i])*cnt[b[i]];
		cnt[b[i]]=0;
		printf("%lld\n",sum);
	}
	
	return 0;
} 

Measured memory_bytes: 9280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	int k; cin >> k;
	string s; cin >> s;
	int ans = 0;
	for(int i = 1; i < n; ++i) {
		if(s[i - 1] == s[i]) ans++;
	}
	cout << min(ans + 2 * k, n - 1) << endl;
	return 0;
}

Measured memory_bytes: 512
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.16 16:54:53
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 3608
def main() -> None:
    A, B = map(int, input().split())
    print("Yay!" if f(A, B) else ":(")


def f(A: str, B: str) -> bool:
    if A > 8 or B > 8:
        return False
    else:
        return True


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  string s;
  while(cin>>n>>m,n){
    vector<int>v;
    for(int i=0;i<n;i++)v.push_back(i+1);
    for(int i=1;i<=m;i++){
      cin>>s;
      if(i%3==0&&i%5==0){
        if(s!="FizzBuzz")v.erase(v.begin());
        else{
          v.push_back(v[0]);
          v.erase(v.begin());
        }
      }
      else if(i%3==0){
        if(s!="Fizz")v.erase(v.begin());
        else{
          v.push_back(v[0]);
          v.erase(v.begin());
        }
      }
      else if(i%5==0){
        if(s!="Buzz")v.erase(v.begin());
        else{
          v.push_back(v[0]);
          v.erase(v.begin());
        }
      }
      else{
        stringstream ss(s);
        int p;ss>>p;
        if(p!=i)v.erase(v.begin());
        else{
          v.push_back(v[0]);
          v.erase(v.begin());
        }
      }
      if((int)v.size()==1){
        for(;i<m;i++)cin>>s;
        break;
      }
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
      if(i)cout<<' ';
      cout<<v[i];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define N 200000 + 5
#define M 
#define inf 123456789
#define Inf 1000000000000000000
#define Mod 1000000007
#define int long long
#define rep(i, l, r) for(register int i = l; i <= r; ++i)
#define dep(i, l, r) for(register int i = r; i >= l; --i)
#define Next(i, u) for(register int i = h[u]; i; i = e[i].next)
#define mem(f, x) memset(f, x, sizeof(f))
#define file(a) freopen(#a".in","r",stdin); freopen(#a".out","w",stdout);
typedef long long ll;
typedef double D;
int n, m, k, l, r, pos1, pos2, pos, pre, len, a[N], b[N];
int read(){
	char c; int x = 0, f = 1;
	c = getchar();
	while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9'){ x = (x << 3) + (x << 1) + c - '0'; c = getchar();}
	return x * f;
}
int Mul(int a, int b) { return 1ll * a * b % Mod; }
int Inc(int a, int b) { return (a += b) >= Mod ? a - Mod : a; }
int Dec(int a, int b) { return (a -= b) < 0 ? a + Mod : a; }
bool check(int Mid){
    int sum = 0;
    if(Mid < 0){
        if(pos > n) return false;
        rep(i, 1, pos - 1){
            int l = pos, r = n;
            while(l < r){
                int mid = (l + r) >> 1;
                if(a[i] * a[mid] <= Mid) r = mid;
                else l = mid + 1; 
            }
            if(a[i] * a[r] > Mid) r++;
            if(r == i) r++;
            if(n >= r) sum += n - r + 1;
        }
        if(sum >= k) return true;
        else return false;
    }
    else if(Mid == 0){
        sum = (pos - 1) * (n - pos + 1) + pre;
        if(sum >= k) return true;
        else return false;
    }
    else{
        sum = (pos - 1) * (n - pos + 1) + pre;
        rep(i, 1, pos - 1){
            int l = i, r = pos - 1;
            while(l < r){
                int mid = (l + r) >> 1;
                if(a[i] * a[mid] <= Mid) r = mid;
                else l = mid + 1; 
            }
            if(a[i] * a[r] > Mid) r++;
            if(r == i) r++;
            if(pos > r) sum += pos - r;
        }
        rep(i, pos, n){
            int l = i, r = n;
            while(l < r){
                int mid = (l + r) >> 1;
                if(a[i] * a[mid] < Mid) l = mid + 1;
                else r = mid;
            }
            if(a[i] * a[r] > Mid) r--;
            if(r > i) sum += r - i;
        }
        if(sum >= k) return true;
        else return false;
    }
}
signed main(){
	//file(data);
	n = read(), k = read();
    rep(i, 1, n) b[i] = read();
    sort(b + 1, b + n + 1);
    b[n + 1] = 1;
    rep(i, 1, n){
        if(b[i] == 0 && !pos1) pos1 = i;
        if(b[i] == 0 && b[i + 1] != 0 && !pos2) pos2 = i;
    } 
    if(pos1) len = pos2 - pos1 + 1, pre += len * (len - 1) / 2 + (n - len) * len;
    m = n, n = 0;
    rep(i, 1, m) if(!(i >= pos1 && i <= pos2)) a[++n] = b[i];
    rep(i, 1, n) if(a[i] > 0 && !pos) pos = i;
    if(!pos) pos = n + 1;
    l = -Inf, r = Inf;
    while(l < r){
        int Mid = (l + r) >> 1;
        if(check(Mid)) r = Mid;
        else l = Mid + 1;
    }
    printf("%lld\n", r);
	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define MAX 100

int n;
long d[MAX], C[MAX][MAX];
vector<int> M[MAX];

struct Edge{
    int u;
    Edge(int u): u(u){}
    bool operator < (const Edge &e) const {
        if(d[u] != d[e.u]) return d[u] < d[e.u];
        else return u < e.u;
    }
};

void dijkstra(){
    bool seen[n], todo[n];
    list<Edge> E;
    fill(seen, seen + n, false);
    fill(todo, todo + n, false);
    seen[0] = true;
    E.push_front(Edge(0));
    
    while(!E.empty()){
        E.sort();
        int u = E.begin()->u;
        seen[u] = true;
        E.pop_front();
        vector<int>::iterator it;
        
        for(it = M[u].begin(); it != M[u].end(); it++){
            int v = *it;
            if(!seen[v]) d[v] = min(d[v], d[u] + C[u][v]);
            if(!seen[v] && !todo[v]){
                E.push_back(Edge(v));
                todo[v] = true;
            }
        }
    }
    return;
}

int main(){
    cin >> n;
    fill(d, d + n, LONG_MAX);
    d[0] = 0;
    for(int i = 0; i < n; i++){
        fill(C[i], C[i] + n, LONG_MAX);
        int u, q, v, cost;
        cin >> u >> q;
        for(int j = 0; j < q; j++){
            cin >> v >> cost;
            C[u][v] = cost;
            M[u].push_back(v);
        }
    }
    dijkstra();
    for(int i = 0; i < n; i++)
        cout << i << " " << d[i] << endl;
    return 0;
}



Measured memory_bytes: 3204
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

typedef struct{
	long *A;
	long n;
}heap;

int p(int i){return (i/2);}
int l(int i){return (2*i);}
int r(int i){return (2*i+1);}

void swap (long *i,long *j){
	long tmp;
	tmp=*i;
	*i=*j;
	*j=tmp;
}

void maxHeapify(heap *H,long i){
	long *A;
	long n,largest,temp;
	A=H->A;n=H->n;
	if(l(i)<=n && A[l(i)] > A[i]){
		largest = l(i);
	}else{
		largest = i;
	}
	if(r(i)<=n && A[r(i)] > A[largest]){
		largest = r(i);
	}
	if(largest!=i){
		swap(&A[i],&A[largest]);
		maxHeapify(H,largest);
	}
}

void insert(heap *H,long key){
	long n,i;
	long *A;
	n=H->n;A=H->A;
	A[n+1]=key;
	i=n+1;
	while(p(i)>=1 && A[p(i)]<A[i]){
		swap(&A[p(i)],&A[i]);
		i=p(i);
	}
	H->n++;
}

long extMax(heap *H){
	long max,n;
	long *A;
	n=H->n;A=H->A;
	max=A[1];
	A[1]=A[n];
	maxHeapify(H,1);
	H->n--;
	return max;
}
	
main(){
	long n,i,m;
	heap *H;
	char s[10];
	mymalloc(H,1);
	H->n=0;
	mymalloc(H->A,2000000);
	while(1){
		scanf(" %s",s);
		if(strcmp(s,"insert")==0){
			scanf(" %ld",&m);
			insert(H,m);
		}else{
		if(strcmp(s,"extract")==0){
			m=extMax(H);
			printf("%ld\n",m);
		}else{
		if(strcmp(s,"end")==0){
			break;
		}}}
	}
	return 0;
}

Measured memory_bytes: 10312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int dp[500010][13];

int main() {
    string s;
    cin >> s;
    
    reverse(s.begin(), s.end());
    
    int base = 1;

    dp[0][0] = 1;
    for (int i=0; i<s.size(); i++) {
        for (int n=0; n<=9; n++) {
            if (s[i] != '?' && s[i]-'0' != n) continue;
            for (int j = 0; j < 13; j++) {
                dp[i+1][(j+base*n)%13] += dp[i][j];
                dp[i+1][(j+base*n)%13] %= (int)1e9+7;
            }
        }
        base = base*10%13;
    }
    
    cout << dp[s.size()][5] << endl;
         
    
    return 0;
}


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

int main() {
	// your code goes here
	double r,a,b;
	cin>>r;
	a=r*r*3.141592653589;
b=2*r*3.141592653589;
printf("%.5lf ",a);
printf("%.5lf\n",b);
	return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c;
int x, y;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> a ;
  if(a<1200)pr("ABC");
  else pr("ARC");
}

Measured memory_bytes: 3636
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
int main(void){
  int p,q;
  while(cin>>p>>q){
    vector<int> mod;
    mod.push_back(p);
    int count=0;
    while(true){
      p*=10;
      cout << p/q;
      p=p%q;
      if(!p){
        cout<<endl;
        break;
      }
      if(find(mod.begin(),mod.end(),p)!=mod.end()){
        int div = distance(mod.begin(),find(mod.begin(),mod.end(),p));
        cout<<endl;
        REP(i,div) cout<<' ';
        REP(i,count-div+1) cout<<'^';
        cout<<endl;
        break;
      }
      mod.push_back(p);
      count++;
    }
  }
  return  0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        ArrayList<Point> li = new ArrayList<Point>();
        for(int i = 0; i < n; i++){
            li.add(new Point(sc.nextLong(),sc.nextLong()));
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i == j) continue;
                Point p1 = li.get(i);
                Point p2 = li.get(j);
                long dx = p1.x-p2.x;
                long dy = p1.y-p2.y;
                int tmp = 0;
                for(int k = 0; k < n; k++){
                    for(int l = 0; l < n; l++){
                        if(k == l) continue;
                        Point p3 = li.get(k);
                        Point p4 = li.get(l);
                        if(p3.x-p4.x == dx && p3.y-p4.y == dy){
                            tmp++;
                        }
                    }
                }
                ans = Math.max(ans,tmp);
            }
        }
        System.out.println(n-ans);
    }
}

class Point{
    long x, y;
    public Point(long x, long y){
        this.x = x;
        this.y = y;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

using namespace std;

int main()
{
    int n, m, a;
    cin >> n >> m;
    int g[n+1];
    long long D[n+1], MOD=1000000007;
    D[0] = 1;
    for (int i = 0; i <= n; i++)
    {
        g[i] = 1;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> a;
        g[a] = 0;
    }
    if (g[1] == 1)
    {
        D[1] = 1;
    }
    else
    {
        D[1] = 0;
    }
    for (int i = 2; i <= n; i++)
    {
        D[i] = 0;
        if (g[i] == 1)
        {
            D[i] = D[i-1] + D[i-2];
            D[i] %= MOD;
        }
    }
    cout << D[n];
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
	int N;
	long W;
	cin >> N >> W;
	const int V = N * 1000;
	vector<vector<long> > dp(N, vector<long>(V + 1, LONG_MAX));
	vector<pair<long, int> > a(N);
	for(auto& x: a) cin >> x.first >> x.second;

	for(int i = 0; i < N; i++) {
		for(int j = 0; j <= V; j++) {
			if(j == 0) {
				dp[i][j] = 0;
			 }else if(i == 0) {
				if(j <= a[i].second) dp[i][j] = a[i].first;
			}
			else {
				if(dp[i - 1][j - a[i].second] != LONG_MAX) {
					dp[i][j] = min(dp[i - 1][j], a[i].first + dp[i - 1][j - a[i].second]);
				} else {
					dp[i][j] = dp[i - 1][j];
				}
			}
		}
	}

	int res = 0;
	for(int j = 0; j <= V; j++) {
		if(dp[N - 1][j] <= W)  {
			res = j;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 79488
S_list = list(map(int,input().split()))

#S = input("入力：")
#S_list = S.split()
A, B, C= S_list[0], S_list[1], S_list[2]
AB, BC, CA = A-B, B-C, C-A
if AB*BC !=0 :
    print(B)
elif CA*AB !=0 :
    print(A)
else:
    print (C)


Measured memory_bytes: 9184