akhauriyash/Code-Regression huggingface dataset:
import bisect,collections,copy,heapq,itertools,math,string,decimal
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


# N = I()
_A,_B = LS()
A = decimal.Decimal(_A)
B = decimal.Decimal(_B)

print((A*B).quantize(decimal.Decimal('0'), rounding=decimal.ROUND_DOWN))

#AB = [LI() for _ in range(N)]
#A,B = zip(*AB)
#Ap = np.array(A)
#C = np.zeros(N + 1)

# if ans:
#     print('Yes')
# else:
#     print('No')

Measured memory_bytes: 27164
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

void fail() {
  cout << "No" << nl;
  exit(0);
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n;
  cin >> n;
  map<int,int> cnt;
  VI nums(n);
  forx(i,n) {
    cin >> nums[i];
    cnt[nums[i]]++;
    if (cnt.size() > 3) fail();
  }
  if (cnt.size() == 1) {
    if (!cnt.count(0)) fail();
  } else if (cnt.size() == 2) {
    if (!cnt.count(0)) fail();
    auto it = cnt.begin();
    if (it->ff == 0) { it++; }
    if (cnt[0]*2 != cnt[it->ff]) fail();
  } else {
    //only 0, 0+ any number, or 3 nums that work
    int num = -1;
    for (auto it = cnt.begin(); it != cnt.end(); it++) {
      if (num == -1) {
        num = it->ss;
      } else {
        if (num != it->ss) fail();
      }
    }
    //size 3
    auto it = cnt.begin();
    int v = it->ff;
    it++;
    v ^= it->ff;
    it++;
    if (v != it->ff) fail();
  }
  cout << "Yes" << nl;
  
  return 0;
}



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

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

  ll sum = 0;
  ll k;
  rep(i, 50001) {
    sum += i;
    if (sum >= x) {
      k = i;
      break;
    }
  }
  cout << k << endl;
}


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

#define ll long long

using namespace std;

const int MOD = 1e9+7;
ll m, n, b[100002], a[100002];
int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int tmp;
        cin >> tmp;
        b[tmp] = 1;
    }
    a[0] = 1;
    for (int i = 1; i <= n; ++i) {
        if (b[i])
            continue;
        if (!b[i - 1])
            a[i] = (a[i] + a[i - 1]) % MOD;
        if (i >= 2 &&  !b[i - 2])
            a[i] = (a[i] + a[i - 2]) % MOD;
    }
    cout << a[n];

    return 0;
}


Measured memory_bytes: 1792
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,t,n=3,j;
    string s;
    ll a[n];
    for(i=0;i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ll cost=0;
    for(i=1;i<n; i++){
        cost+=abs(a[i]-a[i-1]);
    }
        cout<<cost<<endl;
    return 0;
}





Measured memory_bytes: 3572
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int main() {
  std::ios::sync_with_stdio(false);
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  ll n, a, b;
  cin>>n>>a>>b;
  
  if(n == 1) {
  	cout<<(a == b? 1: 0)<<endl;
  	return 0;
  }
  
  if(a > b) {
  	cout<<0<<endl;
  	return 0;
  }
  
  cout<<1+(b-a)*(n-2)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int r;
  cin>>r;
  if(r<1200){
    cout<<"ABC"<<endl;
  }else if(r<2800){
    cout<<"ARC"<<endl;
  }else{
    cout<<"AGC"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
s = input()
t = input()
def gcd(a, b):
    if b == 0: return a
    if a < b: a, b = b, a
    return gcd(b, a%b)
def lcm(a, b):
    return a*b//gcd(a, b)
x = ""
nm = lcm(n, m)
N = {}
M = {}
for i in range(n):
    N[(nm//n)*i] = s[i]
for i in range(m):
    M[(nm//m)*i] = t[i]
if n > m:
    n, m = m, n
    N, M = M, N
f = True
g = lcm(nm//n, nm//m)
for i in N.keys():
    if i % g == 0:
        if N[i] != M[i]:
            f = False
if f: print(nm)
else: print(-1)


Measured memory_bytes: 20796
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] B = new int[N - 1];
		for ( int i = 0 ; i < N - 1 ; i++ ) {
			B[i] = sc.nextInt();
		}
		sc.close();

		int s = B[0];
		for ( int i = 0 ; i < N - 2 ; i++ ) {
			s += Math.min(B[i], B[i + 1]);
		}
		s += B[N - 2];
		System.out.println(s);
	}
}


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

int gcd(int m, int n) {
  while (m != n) {
    if (m > n) {
      m = m - n;
    } else {
      n = n - m;
    }
  }
  return m;
}

int lcm(int m, int n) {
  return (m / gcd(m, n)) * n;
}

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

  int a, b;

  while (cin >> a, cin >> b) {
    cout << gcd(a, b) << " " << lcm(a, b) << endl;
  }

  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

  int main(){
    int n,x,y,now;
    string s;
    x=0;y=0;
    cin >> n;
    now=0;
    rep(i,n){
      int t,b,c,dx,dy,d;
      cin >> t >> b >> c;
      dx=b-x;dy=c-y;
      d=abs(dx)+abs(dy);
      if (t >=  d && d%2 == (t-now)%2){
        now=t;x=b;y=c;
        continue;
      }
      else {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;

    
    return 0;
  }


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

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

    ll N; cin >> N;
    vector<ll> capacities(5);
    rep(i, 0, 5) cin >> capacities[i];
    
    ll bottleNeck = *min_element(capacities.begin(), capacities.end());
    ll res = ceil(static_cast<double>(N) / static_cast<double>(bottleNeck) ) + 4LL;

    cout << res << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)

signed main(){
    int n;
    string c;
    cin >> n;
    cin >> c;
    int rnum = 0;
    rep(i, n){
        if(c[i] == 'R') rnum++;
    }

    int ans = 0;
    for(int i = rnum; i < n; i++){
        if(c[i] == 'R') ans++;
    }

    cout << ans << endl;
}

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

int main() {
  int N, Alice=0, Bob=0;
  cin >> N;
  int a[109];
  for (int i = 0; i < N; i++) cin >> a[i];
  
  sort(a, a+N, greater<int>());
  
  for (int j = 0; j < N; j++) {
    if (j%2 == 1) Alice += a[j];
    else Bob += a[j];
  }  
  cout << Bob-Alice << endl;
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    VI x(5);
    REP(i, 5) cin >> x[i];
    int k;
    cin >> k;
    sort(ALL(x));
    cout << (x[4] - x[0] <= k ? "Yay!" : ":(") << ln;
    return 0;
}


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

int main()
{
	int n,a;
	cin>>n>>a;
	if (a>=n)
	 cout<<"Yes\n";
	else
	 {
	 	for (int i=0;i<=a;i++)
	 	{
	 		int sisa=n-i;
	 		if (sisa%500==0)
	 		{
	 			cout<<"Yes\n";
	 			return 0;
			 }
		}
		cout<<"No\n";
	 }
}


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

using namespace std;

// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define f first
//#define s second
#define db long double
#define pb push_back
#define sz(c) (c).size()
#define all(c) (c).begin(),(c).end()

typedef long long ll;
typedef pair <int , int> ii;
typedef pair <ii , int> iii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;
typedef vector <vii> vvii;

const ll mod = 998244353;
const int MAX = 3e3+5;
const db eps = 1e-13;


int memo[MAX][MAX] , n, m;

string s , t;

int dp( int x , int y ) {

    if( x > n || y > m )
        return -1000;

    if(x==n && y==m )
        return 0;

    int &res = memo[x][y];

    if( res!=-1 )
        return res;

    res = dp( x+1, y+1 ) + (s[x]==t[y]);
    res = max( res , dp(x+1,y) );
    res = max( res , dp(x,y+1) );

    return res;

}

void print( int x , int y ) {

    if( x > n || y > m )
        return;

    if( x==n && y==m )
        return;


    int res1 = dp( x+1, y+1 ) + (s[x]==t[y]);
    int res2 = dp(x+1,y);
    int res3 = dp(x,y+1);


    if( res1 >= max( res2, res3 ) ) {
        if(s[x]==t[y])
            cout<<s[x];
        print(x+1,y+1);
    } else if( res2 >= max( res1, res3 ) ) {
        print(x+1,y);
    } else {
        print(x,y+1);
    }

}



int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    cout<<setprecision(0)<<fixed;
    memset(memo , -1 , sizeof memo);

    cin>>s>>t;
    n = sz(s);
    m = sz(t);

    dp(0,0);
    print(0,0);
    cout<<"\n";
}


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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        a[i] = i + 1;
    }
    vector<ll> b(n);
    for (ll i = 0; i < n; i++)
    {
        if (a[i] % 15 == 0)
            b[i] = 0;
        else if (a[i] % 3 == 0)
            b[i] = 0;
        else if (a[i] % 5 == 0)
            b[i] = 0;
        else
            b[i] = i + 1;
    }
    printf("%lld\n", accumulate(b.begin(), b.end(), 0LL));
    return 0;
}

Measured memory_bytes: 18804
import collections

N = int(input())
l = [s for s in input().split()]

c = collections.Counter(l)
ans_dict = {}

l1 = list(c.values())
l2 = [(i*(i-1))/2 if i >= 2 else 0 for i in l1]
sum_l2 = sum(l2)

for i in l:
    b = c[str(i)]
    if b < 2:
        print(int(sum_l2))
    elif b == 2:
        print(int(sum_l2 - 1))
    elif b > 2:
        print(int(sum_l2 - ((b*(b-1))/2) + (((b-1) *(b-2))/2)))

Measured memory_bytes: 27140
s = list(input())
flag = 0

if len(s)%2 == 1:
    flag = 1
for i in range(len(s)//2):
    if s[2*i] == 'h' and s[2*i+1] == 'i':
        continue
    else:
        flag = 1

if flag == 0:
    print('Yes')
else:
    print('No')


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

int main(){
  string s,t;
  cin >> s;
  t = s;
  int n = s.length();
  int sum = 0,sumrev = 1;
  int i;
  
  for (i = 0;i < n-1;i++){
    if (t[i] == '0' && t[i+1] == '0'){
      t[i+1] = '1';
      sum++;
    }else if (t[i] == '1' && t[i+1] == '1'){
      t[i+1] = '0';
      sum++;
    }
  }
  if (s[0] == '0'){
    s[0] = '1';
  }else{
    s[0] = '0';
  }
  
  for (i = 0;i < n-1;i++){
    if (s[i] == '0' && s[i+1] == '0'){
      s[i+1] = '1';
      sumrev++;
    }else if (s[i] == '1' && s[i+1] == '1'){
      s[i+1] = '0';
      sumrev++;
    }
  }
  if(sum < sumrev){
    cout << sum << endl;
  }else{
    cout << sumrev << endl;
  }
}

Measured memory_bytes: 512
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()

    val count = (for {
      n <- 1 to N
      if n % 2 == 1
      count = for {
        a <- 1 to n
        if n % a == 0
      } yield a
      if count.size == 8
    } yield n)

    println(count.size)
  }

}


Measured memory_bytes: 55376
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <deque>
#include <math.h>

using namespace std;

int main()
{
    int c=0;
    int N;
    cin >> N;
    for (int i=1;i<=N;++i) {
        c += to_string(i).size() & 1;
    }

    cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;

int n,m;

vector<ll> lshx,lshy;
ll A[1100],B[1100],C[1100];
ll D[1100],E[1100],F[1100];
inline ll findx(ll v)
{
	return lower_bound(lshx.begin(),lshx.end(),v)-lshx.begin();
}
inline ll findy(ll v)
{
	return lower_bound(lshy.begin(),lshy.end(),v)-lshy.begin();
}
int blx[5500][5500],bly[5500][5500],vis[5500][5500];
queue<pii> que;
ll ans=0;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%lld%lld%lld",&A[i],&B[i],&C[i]);
		lshx.push_back(A[i]);
		lshx.push_back(B[i]);
		lshy.push_back(C[i]);
	}
	for(int i=0;i<m;i++)
	{
		scanf("%lld%lld%lld",&D[i],&E[i],&F[i]);
		lshx.push_back(D[i]);
		lshy.push_back(E[i]);
		lshy.push_back(F[i]);
	}
	lshx.push_back(0);
	lshx.push_back(-inf);
	lshx.push_back(inf);
	
	lshy.push_back(0);
	lshy.push_back(-inf);
	lshy.push_back(inf);
	
	sort(lshx.begin(),lshx.end());
	lshx.erase(unique(lshx.begin(),lshx.end()),lshx.end());
	sort(lshy.begin(),lshy.end());
	lshy.erase(unique(lshy.begin(),lshy.end()),lshy.end());
	for(int i=0;i<n;i++)
	{
		A[i]=findx(A[i]);
		B[i]=findx(B[i]);
		C[i]=findy(C[i]);
	}
	for(int i=0;i<m;i++)
	{
		D[i]=findx(D[i]);
		E[i]=findy(E[i]);
		F[i]=findy(F[i]);
	}
	for(int i=0;i<n;i++)
	{
		bly[A[i]][C[i]]++;
		bly[B[i]][C[i]]--;
	}
	for(int i=0;i<m;i++)
	{
		blx[D[i]][E[i]]++;
		blx[D[i]][F[i]]--;
	}
	n=lshx.size();
	m=lshy.size();
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<m;j++)
		{
			blx[i][j]+=blx[i][j-1];
			bly[i][j]+=bly[i-1][j];
		}
	}
	que.push(make_pair(findx(0),findy(0)));
	while(!que.empty())
	{
		int xx=que.front().first;
		int yy=que.front().second;
	//	cout<<xx<<" "<<yy<<endl;
		que.pop();
		if(xx==0||yy==0||xx==n-1||yy==m-1)
		{
			printf("INF\n");
			return 0;
		}
		if(vis[xx][yy])continue;
		vis[xx][yy]=1;
		ans+=(lshx[xx+1]-lshx[xx])*1ll*(lshy[yy+1]-lshy[yy]);
		if(!blx[xx][yy])que.push(make_pair(xx-1,yy));
		if(!bly[xx][yy])que.push(make_pair(xx,yy-1));
		if(!blx[xx+1][yy])que.push(make_pair(xx+1,yy));
		if(!bly[xx][yy+1])que.push(make_pair(xx,yy+1));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 145240
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B;
  cin>>A>>B;
  if((A==1 && B==2) || (A==2 && B==1)){
    cout<<3<<endl;
  }
  else if((A==1 && B==3) || (A==3 && B==1)){
    cout<<2<<endl;
  }
  else if((A==3 && B==2) || (A==2 && B==3)){
    cout<<1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;
  vector<vector<int>> A(10, vector<int>(10, 0));

  FOR(i, 1, n + 1) {
    int a = i;
    int b = i % 10;
    while(a >= 10) a /= 10;
    A.at(a).at(b)++;
  }

  ll ans = 0;

  REP(i, 10) {
    REP(j, 10) {
      ans += A.at(i).at(j) * A.at(j).at(i);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
paper = [input() for i in range(N)]

D = {}
for p in paper:
    if p not in D:
        D[p] = 1
    else:
        D[p] += 1

key = 0
max_value = 0
k = []
# 辞書の値を取り出す
for i in D:
    if D[i] > max_value:
        max_value = D[i]
        key = i
        k = []
    elif D[i] == max_value:
        k.append(i)

if len(k) == 0:
    print(key)
else:
    k.append(key)
    for j in sorted(k):
        print(j)

Measured memory_bytes: 35216
import sys
input = sys.stdin.readline
from heapq import *

N = int(input())
a = list(map(int, input().split()))
pq = []
s = 0
minus = [-1]*(N+1)

for i in range(3*N-1, 2*N-1, -1):
    heappush(pq, -a[i])
    s += a[i]

minus[N] = s

for i in range(2*N-1, N-1, -1):
    if a[i]<-pq[0]:
        s -= -heappop(pq)
        heappush(pq, -a[i])
        s += a[i]
    
    minus[i-N] = s

pq = []
s = 0

for i in range(N):
    heappush(pq, a[i])
    s += a[i]

ans = s-minus[0]

for i in range(N, 2*N):
    if a[i]>pq[0]:
        s -= heappop(pq)
        heappush(pq, a[i])
        s += a[i]
    
    ans = max(ans, s-minus[i-N+1])

print(ans)

Measured memory_bytes: 114192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q; cin >> N >> Q;
    vector<pair<int, string>> L;
    L.push_back(make_pair(0, "kogakubu10gokan"));
    for(int i = 0; i < N; i++)
    {
        int year; string name; cin >> year >> name;
        L.push_back(make_pair(year, name));
    }
    for(int i = 0; i < L.size() - 1; i++)
    {
        if(L[i].first <= Q and Q < L[i + 1].first)
        {
            cout << L[i].second << endl;
            return 0;
        }
    }
    cout << L.back().second << endl;
    return 0;
}




Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  vector<int> ch_list(26, 0);
  for(char ch: s){
    ch_list[ch - 'a']++;
  }
  bool flag = true;
  for(int i = 0; i < 26; ++i){
    if(ch_list[i] > 0) continue;
    flag = false;
  }
  if(flag){
    flag = true;
    for(int i = 25; i >= 0; --i){
      if(s[25 - i] - 'a' == i) continue; 
      flag = false;
    }
    if(flag){
      cout << -1 << endl;
      return 0;
    }
    int index;
    for(int i = s.length() - 2; i >= 0; --i){
      if(s[i] < s[i + 1]){
        index = i; 
        break;
      }
    }
    for(int i = 0; i < index; ++i){
      cout << s[i];
    }
    int min_ch = 26;
    for(int i = index + 1; i < 26; ++i){
      if(s[i] - 'a' < min_ch && s[index] < s[i]) min_ch = s[i] - 'a';
    }
    cout << char(min_ch + 'a') << endl; 
  }
  else {
    cout << s;
    for(int i = 0; i < 26; ++i){
      if(ch_list[i] == 0){
        cout << char(i + 'a') << endl;
        break;
      }
    }

  }
}

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

#define endl "\n"

int main ()
{
	
	
    //#define int ll
    
	int n;
	cin >> n;
	vector <double> probability(n, 0.0);
	for (int i=1; i<=n; i++) cin >> probability[i-1];
	double dp[n+1][n+1];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1.0;
	double ans = 0.0;
	
	for (int i=1; i<=n; i++){
		for (int j=0; j<=n; j++){
			if (i < j){
				dp[i][j] = 0.0;
				continue;
			}
			if (j == 0 and i > 0) dp[i][j] = (1.0 - probability[i-1])*dp[i-1][j];
			else dp[i][j] = probability[i-1]*dp[i-1][j-1] + (1.0 - probability[i-1])*dp[i-1][j]; 
		}
	}
	for (int i=n; i<=n; i++){
	    for (int j=0; j<=n; j++){
	        if (j > i - j) ans += dp[i][j];
	    }
	}

	cout << fixed << setprecision(10) << ans << endl;
	

    
	return 0;
}

Measured memory_bytes: 70528
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    ll i,j;
    cin >> N;
    ll A[N],B[N],C[N];
    for(i=0;i<N;i++){
        cin >> A[i];
    }
    for(i=0;i<N;i++){
        cin >> B[i];
    }
    for(i=0;i<N;i++){
        cin >> C[i];
    }
    sort(A,A+N);
    sort(B,B+N);
    sort(C,C+N);
    ll T[N];
    j=0;
    for(i=0;i<N;i++){
        while(B[i]>=C[j]&&j<N){
            j++;
        }
        T[i]=N-j;
    }
    for(i=1;i<N;i++){
        T[N-i-1]+=T[N-i];
    }
    ll ans=0;
    j=0;
    for(i=0;i<N;i++){
        while(A[i]>=B[j]&&j<N){
            j++;
        }
        if(j!=N)ans+=T[j];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif

static const LLONG MOD_NUM = 1000000007;

template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= base;
	}
	return ans;
}


static void ABC104D_WeLoveABC();

#if 1
int main()
{
	ABC104D_WeLoveABC();
	fflush(stdout);
	return 0;
}
#endif



static void ABC104D_WeLoveABC()
{
	int MaxLen = 100000;
	LLONG mod = 1000000007LL;
	
	auto str = new char[MaxLen + 1];
	memset(str, 0, sizeof(str[0]) * (MaxLen + 1));
	
	getstring(str);
	int len = strlen(str);
	
	auto dp = new LLONG[len + 1][4];
	memset(dp, 0, sizeof(LLONG) * (len + 1) * 4);

	dp[0][0] = 1;
	for (int i = 0; i < len; i++) {
		for (int j = 0; j < 4; j++) {
			if (str[i] == '?') {
				dp[i + 1][j] = dp[i][j] * 3;
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
			dp[i + 1][j] %= MOD_NUM;
		}

		if ((str[i] == 'A') || (str[i] == '?')) {
			dp[i + 1][1] += dp[i][0];
			dp[i + 1][1] %= MOD_NUM;
		}
		if ((str[i] == 'B') || (str[i] == '?')) {
			dp[i + 1][2] += dp[i][1];
			dp[i + 1][2] %= MOD_NUM;
		}
		if ((str[i] == 'C') || (str[i] == '?')) {
			dp[i + 1][3] += dp[i][2];
			dp[i + 1][3] %= MOD_NUM;
		}
	}

	printf("%lld\n", dp[len][3]);

	delete[] dp;
	delete[] str;
}


Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, d;
  cin >> n >> d;
  vector<vector<int>>x(n, vector<int>(d));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> x[i][j];
    }
  }
  int cnt = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++){
      int tmp = 0;
      for(int k = 0; k < d; k++){
        tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      double t1 = sqrt(tmp);
      double t2 = (int)sqrt(tmp);
      if(t1 == t2){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#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>;

struct UnionFind {
   vector<int> d;
   UnionFind(int n=0): d(n,-1) {}
   int find(int x) {
      if (d[x] < 0) return x;
      return d[x] = find(d[x]);
   }
   bool unite(int x, int y) {
      x = find(x); y = find(y);
      if (x==y) return false;
      if (d[x] > d[y]) swap(x,y);
      d[x] += d[y];
      d[y] = x;
      return true;
   }
   bool same(int x, int y) {return find(x) == find(y);}
   int size(int x) {return -d[find(x)];}
};

int deg[100005];
vector<int> to[100005];

int main() {
   int n, m, k;
   cin >> n >> m >> k;
   UnionFind uf(n);
   rep(i, m) {
      int a, b;
      cin >> a >> b;
      --a; --b;
      deg[a]++;
      deg[b]++;
      uf.unite(a,b);
   }
   rep(i,k) {
      int a, b;
      cin >> a >> b;
      --a; --b;
      to[a].push_back(b);
      to[b].push_back(a);
   }
   rep(i,n) {
      int ans = uf.size(i)-1-deg[i];
      for (int u : to[i]) {
         if (uf.same(i,u)) --ans;
      }
      printf("%d%c", ans, i==n-1?'\n':' ');
   }
   return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  rep(i, n-m+1) {
    rep(j, n-m+1) {
      bool ans = true;
      rep(k, m) {
        rep(l, m) {
          if (a[i+k][j+l] != b[k][l])
            ans = false;
        }
      }
      if (ans) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3636
s = input()
if s == 'RRR':print(3)
if s == 'RRS':print(2)
if s == 'RSS':print(1)
if s == 'RSR':print(1)
if s == 'SRR':print(2)
if s == 'SRS':print(1)
if s == 'SSR':print(1)
if s == 'SSS':print(0)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;

int main() {
    ll n;
    cin >> n;
    int a, b;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            a = i;
            b = n / i;
        }
    }
    string A, B;
    A = to_string(a);
    B = to_string(b);
    cout << max(SZ(A), SZ(B)) << endl;
}

Measured memory_bytes: 3676
<?php 
  fscanf(STDIN,"%d %d %d %d",$a,$b,$h,$m);
  $deg_m = 360 / 60 * $m;
  $deg_h = ($h * 60 + $m) * 360 / (12 * 60);
  $deg = $deg_h - $deg_m;

  $answer = pow($a,2) + pow($b,2) - 2*$a*$b*cos(deg2rad($deg));
  echo sqrt($answer);

Measured memory_bytes: 16556
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;

class AC
{

    void Solve()
    {
        var n = io.Int;
        var v = new int[n];
        var odds = new List <int>();
        var eves = new List <int>();

        for (var i = 0; i < n; ++i)
        {
            v[i] = io.Int;
            if (i % 2 == 0) { eves.Add(v[i]); }
            else
            { odds.Add(v[i]); }
        }

        var g1 = odds.GroupBy(x => x).OrderByDescending(x => x.Count()).ToArray();
        var g2 = eves.GroupBy(x => x).OrderByDescending(x => x.Count()).ToArray();
        if (g1[0].Key != g2[0].Key)
        {
            var score = odds.Count() - g1[0].Count() + eves.Count() - g2[0].Count();
            WriteLine(score);
        }
        else
        {
            if (g1.Length > 1 && g2.Length > 1)
            {
                var score1 = odds.Count() - g1[1].Count() + eves.Count() - g2[0].Count();
                var score2 = odds.Count() - g1[0].Count() + eves.Count() - g2[1].Count();
                var score = Min(score1, score2);
                WriteLine(score);
            }
            else if (g1.Length > 1)
            {
                var score = odds.Count() - g1[1].Count() + eves.Count() - g2[0].Count();
                WriteLine(score);
            }
            else if (g2.Length > 1)
            {
                var score = odds.Count() - g1[0].Count() + eves.Count() - g2[1].Count();
                WriteLine(score);
            }
            else
            {
                var score1 = odds.Count() + eves.Count() - g2[0].Count();
                var score2 = odds.Count() - g1[0].Count() + eves.Count();
                var score = Min(score1, score2);
                WriteLine(score);
            }
        }

    }

    IoTiny io = new IoTiny();

    public static void Main(string[] args) => new AC().Stream();

    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }

}

class IoTiny
{

    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };

    public IoTiny()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }

    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "") st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }

    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);

    public void Flush() => Out.Flush();

}


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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

signed main() {
  int n;
  cin >> n;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  string s;
  cin >> s;
  if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
 
int main(){
    //入力
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    vector<ll> a(x),b(y),c(z),ans(k*z+100),ab(x*y+10);
    for(int i=0;i<x;i++) cin>>a[i];
    for(int i=0;i<y;i++) cin>>b[i];
    for(int i=0;i<z;i++) cin>>c[i];
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    sort(c.rbegin(),c.rend());

    int pos=0,pos2=0;
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++) ab[pos++]=a[i]+b[j];
    }
    sort(ab.rbegin(),ab.rend());
    pos=0;
    while(pos<k*z+1){
        for(int i=0;i<z;i++){
            ans[pos++]=ab[pos2]+c[i];
            if(pos>=k*z+1) break;
        }
        pos2++;
    }
    sort(ans.rbegin(),ans.rend());
    for(int i=0;i<k;i++) cout<<ans[i]<<endl;
    return 0;
}

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

int main() {
  int N;
  string S;
  cin>>N>>S;
  
  priority_queue<int> R;
  queue<int> W;
  
  rep(i,N){if(S.at(i)=='R'){R.push(i);}else{W.push(i);}
          }
  
  int Rsize=R.size(),Rcount=0;
  int Wsize=W.size(),Wcount=0;
  
  while (!W.empty()) {
    if(W.front()<Rsize){Wcount++;}else{break;}
    W.pop();
  }
 
   while (!R.empty()) {
    if(R.top()<Rsize){break;}else{Rcount++;}
    R.pop();
  }
  cout<<max(Rcount,Wcount)<<endl;
}

Measured memory_bytes: 4704
#include <iostream>

using namespace std;

bool include3(int n) {
    while (n) {
        if (n % 10 == 3) return true;
        n /= 10;
    }
    return false;
}

void call(int n) {
    for (int i = 1; i<= n; i++) {
        if (i % 3 == 0 || include3(i)) {
            cout << ' ' << i;
        }
    }
    cout << endl;
}

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


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

int main(){
  int N;
  cin >> N;
  
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  
  int count = 0;
  
  while (count < N) {
    if (p.at(count) != count + 1) {
      swap(p.at(count), p.at(p.at(count) - 1));
      break;
    }
    count += 1;
  }
  
  for (int i = 0; i < N; i++) {
    if (p.at(i) != i + 1) {
      cout << "NO" << endl;
      break;
    }
    
    if (i == N - 1) {
      cout << "YES" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)

const int N = 1e5+10;

int h[N];
int dp[N];

int func(int ind){
	if(ind == 0)
		return 0;
	if(dp[ind] != -1)
		return dp[ind];
	int cost = abs(h[ind] - h[ind-1]) + func(ind-1);
	if(ind > 1){
		cost = min(cost, abs(h[ind] - h[ind-2]) + func(ind-2));
	}
	return dp[ind] = cost;
}

int main(){
	FIO;
	int n;
	cin >> n;
	memset(dp, -1,sizeof(dp));
	for(int i = 0; i < n; ++i){
		cin >> h[i];
	}
	cout << func(n-1);
}

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

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vunique(v) unique(v.begin(), v.end());

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

	int N, A, B;
	cin >> N >> A >> B;

	int p1 = A * N;
	int p2 = B;
	cout << min(p1, p2) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var input = "";
        string[] strinputArray;
        int[] intinputArray;
        var inputList = new List<int>();

        do
        {
            input = Console.ReadLine();
            strinputArray = input.Split(' ');
            intinputArray = Array.ConvertAll<string, int>(strinputArray, delegate (string value) { return int.Parse(value); });
            if (intinputArray[0] != 0 || intinputArray[1] != 0)
            {
                inputList.Add(intinputArray[0]);
                inputList.Add(intinputArray[1]);
            }
        } while (intinputArray[0] != 0 || intinputArray[1] != 0);

        for(int i = 1; i <= (inputList.Count / 2); i++)
        {
            if(inputList[(i * 2) - 2] <= inputList[(i * 2) - 1])
            {
                Console.WriteLine(inputList[(i * 2) - 2] + " " + inputList[(i * 2) - 1]);
            }
            else
            {
                Console.WriteLine(inputList[(i * 2) - 1] + " " + inputList[(i * 2) - 2]);
            }
        }
    }
}


Measured memory_bytes: 15940
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;


int next(int x,int y){
	while(x%10!=0){
		x=x+y;
	}

	return x/10;
}

struct edge{
	int to;
	int cost;
};

typedef pair<int, int> P;

int V;//辺の本数
static vector<edge> G[100010];//辺の情報　手で埋めておく必要あり
int d[100010];

void init(int dd[], int num){
	int i;
	for(i=0;i<num;i++){
		dd[i]=INFINT;
	}
}

void dijkstra(int s){

	priority_queue<P, vector<P>, greater<P> > que;
	init(d,100010);
	d[s]=0;
	que.push(P(0,s));

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

int main(void)
{
	//変数の宣言
	int n;
	struct edge e;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	ll int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	int ok,ng;
	int r;


	//データの読み込み


  	scanf("%d",&n);
//	scanf_s("%d",&n);

/*	for(i=0;i<n;i++){
//		scanf("%d",&a[i]);
		scanf_s("%d",&a[i]);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	while(n%2==0){
		n=n/2;
	}
	while(n%5==0){
		n=n/5;
	}

	for(i=1;i<=n;i++){
		e.to=i-1;
		e.cost=1;
		G[i].push_back(e);
		e.to=next(i,n);
		e.cost=0;
		G[i].push_back(e);
	}

	dijkstra(n);

	//	printf("計算部分終了\n");

	//出力


	printf("%d",d[0]);


	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 6780
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
const int INF=(int)(1<<30);
vector<pair<int, int> > graph[101010];
int vis[101010];
int d[101010];

void dfs(int cur, long long S) {
  if(vis[cur] == 1) {
    if(d[cur] != S) {
      cout << "No" << endl;
      exit(0);
    }
    return;
  }
  vis[cur] = 1;
  d[cur] = S;
  for(auto g:graph[cur]) dfs(g.first, S+g.second);
}

int main() {
  int N, M; cin >> N >> M;
  vector<int> L(M), R(M), D(M);
  for(int i = 0; i < M; ++i) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--, R[i]--;
    graph[L[i]].push_back(make_pair(R[i], D[i]));
    graph[R[i]].push_back(make_pair(L[i], -D[i]));
  }
  for(int i = 0; i < N; ++i) {
    if(vis[i] == 0) dfs(i, 0);
  }
  cout << "Yes" << endl;
  return 0;
}

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

// vector<bool> prime(1000002,true);
typedef long long int ll;

// void sieve(){
// 	for(ll i = 2;i<= 1000000;i++){
// 		if(prime[i]){
// 			for(ll j = i * i;j <= 1000000;j+=i)
// 				prime[j] = false;
// 		}
// 	}
// }


ll no_div(ll n){
	ll cnt = 0;
	for(ll i =1;i*i <= n;i++){
		if(n % i == 0){
			if(n / i == i)
				cnt++; // count only once
			else
				cnt+=2; //count both
		}
	}

	return cnt - 1;
}

int main(){
	ll temp;
	ll n;
	cin>>n;
	// prime[0] = false;
	// prime[1] = false;
	// sieve();
	ll x = no_div(n-1);
	//cout<<x<<endl;
	for(ll i = 2;i * i<=n;i++){
		if(n%i == 0){
			temp = n;
			while(temp % i == 0)
				temp/=i;

			if(temp % i == 1)
				x++;
		}
	}

	cout<<x+1<<"\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int mp[55][55];
int check[55][55];

int dx2[] = {-1,0,1,1,1,0,-1,-1};
int dy2[] = {1,1,1,0,-1,-1,-1,0};

int main(){

    while(true){
        int w,h;
        int ans = 0;
        cin >> w >> h;
        if(w + h == 0) break;
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                cin >> mp[i][j];
                check[i][j] = 0;
            }
        }
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                if(mp[i][j] == 1 && check[i][j] == 0){
                    ans++;
                    queue<P> que;
                    que.push(P(i,j));
                    while(!que.empty()){
                        P q = que.front(); que.pop();
                        if(check[q.fs][q.sc] != 0) continue;
                        check[q.fs][q.sc] = 1;
                        for(int k = 0;k < 8;k++){
                            int ni = q.fs + dx2[k];
                            int nj = q.sc + dy2[k];
                            if(min(ni,nj) >= 0 && ni < h && nj < w && mp[ni][nj] == 1 && check[ni][nj] == 0){
                                que.push(P(ni,nj));
                            }
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }

}


Measured memory_bytes: 3116
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	n := len(s)
	if s[n-1] == 's' {
		fmt.Fprintln(writer, fmt.Sprintf("%ses", s))
		return
	}
	fmt.Fprintln(writer, fmt.Sprintf("%ss", s))

}


Measured memory_bytes: 1828
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<stack>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
#define MAX 510000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
using namespace std;


int main(){
  string S;
  cin>>S;
  if(S!="AAA"&&S!="BBB") cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main()
{
	int deg;
	double rad;
	double pi = acos(-1);
	double a, b, c;
	cin >> a >> b >> deg;
	rad = deg * pi / 180;
	double s, l, h;
	s = sin(rad) * a * b / 2;
	l = a+b+sqrt(b*b + a*a - 2 * b * a * cos(rad));
	h = s * 2 / a;
	printf("%lf\n%lf\n%lf\n", s, l, h);

    return 0;
}



Measured memory_bytes: 3472