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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += (n - 1) / i;
    }

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

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

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

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


Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	string s;
	scan(s);
	if(s[1]=='B') s[1]='R';
	else s[1]='B';
	prin(s);
	return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int A,B,N;cin>>A>>B>>N;
    int x=B-1;
    int d;
    if(N>=B-1){
        d=A*x/B;
    }
    else{
        d=N*A/B;
    }
    cout<<d<<endl;
}

Measured memory_bytes: 3636
function Picker(input) {
  var lines = input.split('\n');
  var fields = lines.reduce(function(all, line) { return all.concat(line.split(' ')); }, []);
  var p = 0;

  return {
    int: function() {
      return parseInt(fields[p++], 10);
    },
    float: function() {
      return parseFloat(fields[p++]);
    },
    str: function() {
      return fields[p++];
    }
  };
}

function Main(input) {
  var pick = Picker(input);
  var n = pick.int();

  var max = 0;
  var c = 0;
  for (var i = 0; i < n; ++i) {
    var h = pick.int();
    if (h >= max) {
      max = h;
      c++;
    }
  }

  console.log(c);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int res[5000];
int arr[5000][15];
vector<int>v[15];
int ar[15];
int totalsub;
void solve(int n,int m)
{
    totalsub=(1<<n)-1;
    for(int i=1;i<=totalsub;i++)
    {
        int temp=i,j=0;
        while(temp>0)
        {
            if(temp&1)
            {
                res[i]+=ar[j];
                for(int k=0;k<m;k++)
                {
                    arr[i][k]+=v[j][k];
                }
            }
            j++;
            temp=temp>>1;
        }
    }
}
int main()
{
    memset(res,0,sizeof(res));
    memset(arr,0,sizeof(arr));
    int n,m,k;cin>>n>>m>>k;

    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        for(int j=0;j<m;j++)
        {
            int a;cin>>a;
            v[i].push_back(a);
        }
    }
    solve(n,m);
    int ans=INT_MAX;
   for(int i=1;i<=totalsub;i++)
   {
      /* cout<<res[i]<<" ";
       for(int j=0;j<m;j++)
        cout<<arr[i][j]<<" ";
       cout<<endl;*/
       if(ans>res[i])
       {
           int f=0;
           for(int j=0;j<m;j++)
           {
               if(arr[i][j]<k)
               {
                   f=1;break;
               }
           }
           if(f==0)
           ans=res[i];
       }
   }
   if(ans==INT_MAX)
    cout<<-1;
   else
   cout<<ans<<endl;

}


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

#define ll long long
#define pb push_back
#define F first
#define S second

int inf =1e9+10;
const int N=1e5+10 , L = 7;
int n, a[N][8], k;
int mem[N][10];

int dp(int i, int mask)
{
    if (i == n+1)
        return 0;

    int &ret = mem[i][mask];
    int p = -inf;

    if (ret != -1)
        return ret;

    for (int j = 0; j<3; j++)
    {
        if (mask & (1<<j) )
        {
                p = max(p, a[i][j] + dp(i+1, L& (~( 1<<j )))) ;
                //cout<<a[i][j]<<"\n";
        }
    }
   return ret = p;
}

int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n ;
    for (int i =1; i<=n; i++)
        for (int j = 0;j<3;j++)
        cin >> a[i][j];
    memset(mem, -1, sizeof mem);
    cout<<dp(1 , L);
}


Measured memory_bytes: 15104
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
#define ll long long
#define vel vector<int>
#define vvel vector<vel>
#define vvvel vector<vvel>
#define veb vector<bool>
#define pin pair<int,int>
#define mkp make_pair
#define mot pair<D,D>//time,dist
#define root pair<int,mot>
using namespace std;
vvel ta_min(0);
vvel ta_max(0);
int leth = 1024 * 512;
int siz = leth * 2;
void mmax(ll &a, ll b) { a = max(a, b); }
void mmin(ll &a, ll b) { a = min(a, b); }
int main() {
	string s; cin >> s;
	bool fl = true;
	int n = s.size();
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += s[i] - '0';
		if((i==0 and s[i]=='1')or(i!=0 and s[i]=='0') ){}
		else { fl = false; }
	}
	if (fl) { ans += 9; }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

long long solve(long long n) {
	if (n == 0)
		return 0;
	return 1 + 2 * solve(n / 2);
}
int main() {

	long long n;
	cin >> n;
	cout << solve(n);

}



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

int main(){
  int n, a;
  cin >> n >> a;
  int x = n%500;
  if(x <= a) cout << "Yes";
  else cout << "No";
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    int p[100];
    int count[3] = {0};//count[0]:number <A,..

    for(int i=0;i<n;i++){
      cin >> p[i];
      if(p[i] <= a) count[0] += 1;
      else if(a < p[i] && p[i] <= b) count[1] += 1;
      else count[2] += 1;
    }
    int min = 5000;
    for(int i=0;i<3;i++){
      if(count[i] < min) min = count[i]; 
      //cout << min << endl;
    }
    cout <<  min << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
template <class _Tv> inline string join(const _Tv &v,string sep=" "){
    ostringstream s;for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

int tbl[] = { 0,1,2,3,4,5,6,7,8,9,5,4,3,2,1 };

vector<int> solve(int st, int ed){
    vector<int> r;
    int n = sizeof(tbl)/sizeof(tbl[0]);
    bool f = false;
    for(int i = 0; i < n*2; ++i){
        if(tbl[i%n] == st){
            f = true; r.clear();
        }
        if(f){
            r.push_back(tbl[i%n]);
            if(tbl[i%n] == ed) break;
        }
    }
    return r;
}

int main(){
    int n,a,b;
    cin >> n;
    while(cin >> a >> b){
        cout << join(solve(a,b)) << endl;
    }
    return 0;
}

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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	map<ll, ll> mp;
	set<ll> se;
	vl a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		se.insert(a[i]);
		mp[a[i]]++;
	}

	ll res = 0;
	for (auto v : se) {
		if (v == mp[v]) {
			continue;
		}

		if (v < mp[v]) {
			res += abs(v - mp[v]);
		} else {
			res += mp[v];
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 11520
#include <iostream>
     
    using namespace std;
     
    int main()
    {
      int a,b,c,d,e,k;
      cin >> a >> b >> c >> d >> e >> k;
      
      if (e - a <= k)
      {
        cout << "Yay!" << endl;
      }
      else
      {
        cout << ":(" << endl;
      }
      
      return 0;
      
    }

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp!
x = 0

if s.size % 2 == 1
  puts "No"
else
  for i in 0..((n/2) -1)
    if s[i] == s[i+(n/2)]
      x += 0
    else
      x += 1
    end
  end
  if x == 0
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 1788
from collections import deque

n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]
conn = [[] for _ in range(n)]
for a,b in ab:
    conn[a-1].append(b)
    conn[b-1].append(a)
q = deque([1])
#for x in conn[0]:
#    q.append(x)
ans = [-1 for _ in range(n)]
depth = ans[:]
depth[0] = 0
while q:
    v = q.popleft()
    d = depth[v-1]
    #print(v)
    for w in conn[v-1]:
        if depth[w-1] != -1:
            continue
        depth[w-1] = d + 1
        ans[w-1] = v
        q.append(w)
        #print(v,w,d)

print('Yes')
for i in range(1,n):
    print(ans[i])
#print(conn)

Measured memory_bytes: 58840
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int a1,a2,a3,count1=0,count2=0,c,c1,c2;
  char b1,b2;
  while(cin>>a1>>b1>>a2>>b2>>a3){
    c=2*(sqrt((a1*a1-a3*a3/4)));
    c1=2*(sqrt(a3*a3+c*c));
    c2=(a1+a2)*2;
    if(a1*a1+a2*a2==a3*a3)
      count1++;
    else if(c2==c1)
      count2++;
  }
  cout<<count1<<endl<<count2<<endl;
  return 0;
}

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

int main()
{
    int n;
    cin >> n;
    int degree[n+5]={0};
    FOR(i,2,n){
        int a;
        cin >> a;
        degree[a]++;
    }
    FOR(i,1,n) cout << degree[i] << '\n';
}


Measured memory_bytes: 4404
inf = float('inf')

N, T = map(int, input().split())
A = list(map(int, input().split()))

cm = [inf] * N
m = inf
for i, a in enumerate(A):
    m = min(m, a)
    cm[i] = m

cM = [-inf] * N
M = -inf
for i, a in enumerate(A[::-1]):
    M = max(M, a)
    cM[i] = M
cM.reverse()

diff = 0
for m, M in zip(cm, cM):
    diff = max(diff, M - m)

ans = 0
for a, M in zip(A, cM):
    if a + diff <= M:
        ans += 1
print(ans)

Measured memory_bytes: 14940
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    N = Number(tmp0[0])
    Aorg=[]
    A = []
    for(var i=1; i<=N; i++)
    {
        Aorg.push(input[i])
        A.push(input[i])
    }
    A.sort((a,b) => b-a)

    for(var i=0; i<N;i++)
    {
        var ai = Aorg[i]
        if(ai === A[0]){
            console.log(A[1])
        }else{
            console.log(A[0])
        }
    }
}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("2\n5\n10\n");

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

int main(){

    //エラトステネスの篩
    vector<bool> prime(1000000, true);     //1000000までで、素数ならtrue
    prime[0] = prime[1] = false;
    for(int i = 2; i < 1000000; i++){
        if(prime[i] == true){
            for(int j = 2*i; j < 1000000; j += i){
                prime[j] = false;
            }
        }
    }

    vector<int> sosuu;                     //素数の表
    for(int i = 0; i < 1000000; i++){
        if(prime[i]) sosuu.push_back(i);
    }

    while(1){

        int m, a, b; cin >> m >> a >> b;
        if(!m) break;

        int max = 0;
        int p, q;
        int end = (int)(m / 2) + 3;
        for(int i = 0; sosuu[i] < end; i++){
            for(int j = i; sosuu[j] < end; j++){
                if(sosuu[i]*sosuu[j] <= m && sosuu[j]*a <= sosuu[i]*b){
                    if(max < sosuu[i] * sosuu[j]){
                        max = sosuu[i]*sosuu[j];
                        p = sosuu[i];
                        q = sosuu[j];
                    }
                }

                if(sosuu[i]*sosuu[j] >= m) break;
            }
            if(sosuu[i]*sosuu[i] >= m) break;
        }

        cout << p << " " << q << endl;
    }

    return 0;

}


Measured memory_bytes: 3476
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;


int main(){
  int n; cin >> n; ll a[n]; ll sum = 0;
  rep(i, n){
    cin >> a[i]; sum^=a[i];
  }
  rep(i, n){
    ll ans = sum^a[i]; cout << ans; cout << " ";
  }
  cout << endl;
}


Measured memory_bytes: 5084
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int l , r;

int main(){
    cin >> l >> r;
    int mnn = 2e9;
    for(int i = l; i <= min(l+2019 , r); i++){
        for(int j = max(i + 1 , (l , r - 2019)); j <= r; j++){
            mnn = min(1ll*mnn , (1ll*i*j) % 2019);
        }
    }
    for(int i = l; i <= min(l+2019 , r); i++){
        for(int j = i+1; j <= min(i+2019 , r); j++){
            mnn = min(1ll*mnn , (1ll*i*j) % 2019);
        }
    }
    for(int i = max(l , r - 2019); i <= r; i++){
        for(int j = i+1; j <= min(i+2019 , r); j++){
            mnn = min(1ll*mnn , (1ll*i*j) % 2019);
        }
    }
    cout << mnn << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	ll W, H, ans=0;

	cin >> W >> H;
	vector<int> p(W), q(H);
	rep(i,W) cin >> p[i];
	rep(i,H) cin >> q[i];
	sort( all(p) );
	sort( all(q) );
	reverse( all(p) );
	reverse( all(q) );

	ll cw=1, ch=1, a=0, b=0;
	while( a<W || b<H ){
		//cout << a << " " << b << endl;
		if( a==W ){
			ans += ch * q[b];
			b++;
		}else if( b==H ){
			ans += cw * p[a];
			a++;
		}else if( p[a] > q[b] ){
			ans += cw * p[a];
			ch++;
			a++;
		}else{
			ans += ch * q[b];
			cw++;
			b++;
		}
		//cout << "ans=" << ans << endl;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,x;
  cin >> n >> x;
  vl v;
  inputv(v,n);
  ll count=0;
  ll sum = 0;
  for(int i=0;sum<=x && i<n+1;i++){
    sum += v[i];
    count++;
  }
  cout << count;
 return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter


def main():
    N,K,Q = map(int,input().split())
    a = [int(input()) for _ in range(Q)]
    d = Counter(a)
    L = [(K+d[i+1]-Q)>0 for i in range(N)] 
    for i in range(N):
        print("Yes" if L[i] else "No")

if __name__ == '__main__':
    main()

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

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;

#define trav(a, A) for (auto & a : A)

const int INF = 1e9;
const ll INFLL = 1e18;

int da[] = {0, 1, 2}, db[] = {1, 0, 2}, dc[] = {2, 0, 1};

int main ()
{
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    int i, j, n, w;
    cin >> n >> w;
    vll W (n), V (n);
    for (i = 0; i < n; ++i)
        cin >> W[i] >> V[i];
    vll dp (1e5+7, INFLL);
    dp[0] = 0;
    for (i = 0; i < n; ++i)
        for (j = 1e5+6 - V[i]; j >= 0; --j)
            dp[j + V[i]] = min (dp[j + V[i]], dp[j] + W[i]);
    ll value = 0;
    for (i = 0; i < 1e5+7; ++i)
        if (dp[i] <= w)
            value = max (value, (ll)i);
    cout << value << '\n';

    return 0;
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    string x;
    cin >> x;
    vector<int> s{x[0] - '0', x[1] - '0', x[2] - '0', x[3] - '0'};
    for (int i = 0; i < 1 << 3; i++) {
        int t = s[0];
        for (int j = 0; j < 3; j++) {
            if ((1 & i >> j) == 1) {
                t += s[j + 1];
            } else {
                t -= s[j + 1];
            }
        }
        if (t == 7) {
            cout << s[0];
            for (int j = 0; j < 3; j++) {
                if ((1 & i >> j) == 1) {
                    cout << "+";
                } else {
                    cout << "-";
                }
                cout << s[j + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


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

ll gcd(ll a, ll b){return b==0 ? a : gcd(b, a%b);}

int main()
{
  int x, y; cin >> x >> y;
  cout << gcd(x, y) << endl;

  return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

int main(){
  int N, M;
  ll ans = 1;
  cin >> N >> M;
  if(abs(N-M) == 1){
    rep(i, N){
      ans *= i+1;
      ans %= MOD;
    }
    rep(i, M){
      ans *= i+1;
      ans %= MOD;
    }
    cout << ans << endl;
  }
  else if(N == M){
    rep(i, N){
      ans *= i+1;
      ans %= MOD;
    }
    ans = ans*ans*2%MOD;
    cout << ans << endl;
  }
  else cout << 0 << endl;
  
    
  
    
      
  
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }

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

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	// 1/R1 + 1/R2 = 1/R3
	// R3(1/R1+1/R2)=1
	// R3 = 1 / (1/R1+1/R2)
	// R3 = 1 / ((R1+R2)/R1R2)
	// R3 = 1 * R1R2/(R1+R2)

	LL R1, R2;
	cin >> R1 >> R2;
	double R3 = 1.0*R1*R2 / (R1 + R2);
	cout << setprecision(20) << R3 << endl;


	return 0;
}

Measured memory_bytes: 256
list1 = [int(s) for s in input().split()]
list2 = [int(s) for s in input().split()]
list3 = [int(s) for s in input().split()]
flag = 0
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (list1[0] - a1) == (list2[0] - a2) == (list3[0] - a3):
                if (list1[1] - a1) == (list2[1] - a2) == (list3[1] - a3):
                    if (list1[2] - a1) == (list2[2] - a2) == (list3[2] - a3):
                        print('Yes')
                        flag = 1
        if flag == 1:
            break
if flag == 0:
    print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * Created by malone on 2018/3/8.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.printf("%d %d\n", a * b, 2 * (a + b));
    }
}



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

int top = 0;
vector<int> S(100);

void push(int x) {
    S[++top] = x;
}

int pop() {
    return S[top--];
}

int main() {
    string tmp = "";
    cin >> tmp;
    while (tmp != "") {
        if (tmp == "+") {
            int a = pop();
            int b = pop();
            push(a + b);
        } else if (tmp == "-") {
            int a = pop();
            int b = pop();
            push(b - a);
        } else if (tmp == "*") {
            int a = pop();
            int b = pop();
            push(a*b);
        } else {
            push(stoi(tmp));
        }
        tmp = "";
        cin >> tmp;
    }
    cout << pop() << endl;
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
int main() {
    int N;
    cin>>N;
    string S;
    cin>>S;
    for(int i=0; i<S.size(); i++){
        int num=S[i]-'A';
    num=(num+N)%26;
    S[i]=num+'A';
    cout << S[i];
    }
    cout<<""<<endl;
}


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

using namespace std;

const int max_n = 5555, inf = 1000111222;

int n, k;
string s;

string getr(const string &s, int pos, int mx) {
    if (mx + (mx << k) >= n) {
        return "";
    }
    //cout << "$" << mx << endl;
    return {s.rbegin() + s.length() - 1 - pos + mx, s.rbegin() + s.length() - 1 - pos + n - (mx << k) };
}

string one_step(const string &s) {
    string rs = s;
    reverse(rs.begin(), rs.end());
    string t = s + rs;
    string res = s;
    for (int i = 1; i <= n; ++i) {
        res = min(res, t.substr(i, n));
    }
    return res;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k >> s;
    --k;
    char mn = s[0];
    for (char c : s) {
        mn = min(mn, c);
    }
    if (k) {
        k = min(k, 20);
        --k;
        string rs = s;
        reverse(rs.begin(), rs.end());
        int mx = 0, pos = 0;
        string t = s + rs;
        for (int i = 0; i < t.length(); ++i) {
            int st = i;
            while (i < t.length() && t[i] == mn) {
                ++i;
            }
            int cnt = i - st;
            if (cnt == 0) {
                continue;
            }
            if (i < n) {
                continue;
            }
            if (cnt == 1) {
                //cout << i << ": " << getr(t, i - 1, cnt) << endl;
            }
            if (i >= n && (mx < cnt || mx == cnt && getr(t, pos, mx) > getr(t, i - 1, mx))) {
                pos = i - 1;
                mx = cnt;
            }
        }
        //cout << t << endl;
        //cout << mx << " " << pos << " " << getr(t, pos) << endl;
        s = t.substr(pos - n + 1, n);
        //reverse(s.begin(), s.end());
        //cout << "$" << s << " " << k << endl;
        mx = min(mx, n);
        while (k--) {
            string rs = s;
            reverse(rs.begin(), rs.end());
            string t = s + rs;
            s = t.substr(s.length() + mx - n, n);
            mx *= 2;
            mx = min(mx, n);
            if (mx == n) {
                break;
            }
        }
        //cout << s << endl;
    }
    cout << one_step(s) << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

vector<int> divisor(int n)
{
    vector<int> ret;
    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main()
{

    ll N,Q;

    cin >> N;


    vector<ll> A(100001,0);


    for(int i=0;i<N;i++){


        ll a;

        cin >> a;

        A[a]++;

    }


     ll sum=0;

    for(int i=0;i<A.size();i++){


        sum +=i*A[i];



    }


    cin >> Q;






    for(int i=0;i<Q;i++){


        ll b,c;
        cin >> b>> c;

        ll K= A[b];

        A[b] =0;

        A[c] = K +A[c];


        sum = sum - b*K + c*K;



        


        cout <<  sum << endl;
    }


   


    





    return 0;

}

Measured memory_bytes: 4032
s = list(input())

for i in range(len(s)-2):
    if s[i] == s[i+1]:
        print(i+1,i+2)
        exit()
    elif s[i] == s[i+2]:
        print(i+1,i+3)
        exit()

if s[-2] == s[-1]:
    print(len(s)-1,len(s))
    exit()
print(-1,-1)

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

using namespace std;
using ll = long long;



int main()
{
    int n;
    cin >> n;
    string s; cin >> s;
    cout << (count(s.begin(), s.end(), 'R') > count(s.begin(), s.end(), 'B') ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define S_N 1010
using namespace std;

int dataN, cmdN;
string text, cmd1,cmd2;
char s[S_N];
int pos, index;

void pr(){
  string s1 = text.substr(0,pos);
  string s2="";

  if( pos<text.length() )
    s2 = text.substr(pos);

  cout << s1<< "^" << s2 << endl;
}

int main(){

  cin >> dataN;
  fgets( s, S_N, stdin ); // üsÇÝÝ
  for( int loop=0;loop<dataN;loop++ ){
    fgets( s, S_N, stdin );
    text=s;
    text = text.substr( 0,text.length()-1 );

    pos=0;
    cin >> cmdN;
    for( int cmdL=0;cmdL<cmdN;cmdL++ ){
      cin >> cmd1 ;
      fgets( s,S_N,stdin );      cmd2=s;
      // æªÌXy[XÆöÌüsðí
      cmd2 = cmd2.substr( 1,cmd2.length()-2 );

      if( cmd1=="forward" ){
	if( cmd2=="char" ){
	  pos = min( pos+1,(int)text.length() );
	}else{
	  // wordÌÅãöÖÚ® (space ðw·æ¤ÉÚ®)
	  for( ;pos<text.length() && text[pos]==' ';pos++ );
	  for( ;pos<text.length() && text[pos]!=' ';pos++ );
	}
      }else if( cmd1=="backward" ){
	if( cmd2=="char" ){
	  pos = max( pos-1,0);
	}else{
	  // word ÌæªÖÚ®
	  for( ;pos>0 && text[pos-1]==' ';--pos );
	  for( ;pos>0 && text[pos-1]!=' ';--pos );
	}
      }else if( cmd1=="insert" ){
	if( cmd2.length()>2 ){ // cmd2=="" ÅÍÈ¢
	  cmd2 = cmd2.substr( 1,cmd2.length()-2 );
	  string s1=text.substr(0,pos), s2="";
	  if( pos<text.length() )
	    s2=text.substr(pos);
	  text = s1 + cmd2 + s2;
	  pos += cmd2.length();
	}
      }else if( cmd1=="delete" ){
	if( cmd2=="char" ){
	  if( pos<text.length() )
	    text.erase( text.begin()+pos );
	}else{
	  int s=pos, t;
	  for( ;text[s]==' ';s++ );
	  if( s<text.length() ){
	    for( t=s;text[t]!=' ' && t<text.length();t++ );
	    text = text.substr(0,pos) + text.substr(t);
	  }
	}
      }
    }
    pr();
  }

  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            //ここから
            string str = IO.ReadLineToString();
            string ans;

            if (str == "A") ans = "T";
            else if (str == "T") ans = "A";
            else if (str == "C") ans = "G";
            else ans = "C";

            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
    
    class Func
    {
        long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }
        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    class IO
    {
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }   
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int n, m;
    sf(n, m);
    int ans = n * (n - 1) / 2;
    ans += m * (m - 1) / 2;
    out(ans);
    return 0;
}

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

using namespace std;

char grid[10][10], tmp[10][10];
int a[20];
int tot, h, w, k;

void search(int x)
{
	int s, i, j;
	if (x == h + w)
	{
		for (i=0; i<h; i++) for (j=0; j<w; j++) tmp[i][j] = grid[i][j];
		for (i=0; i<h; i++) if (a[i] == 1) for (j=0; j<w; j++) tmp[i][j] = 'r';
		for (i=h; i<h+w; i++) if (a[i] == 1) for (j=0; j<h; j++) tmp[j][i-h] = 'r';
		s = 0;
		for (i=0; i<h; i++) for (j=0; j<w; j++) if (tmp[i][j] == '#') s ++;
		if (s == k) tot ++;
		return;
	}
	a[x] = 0;
	search(x + 1);
	a[x] = 1;
	search(x + 1);
}

int main()
{
	int i, j;
	cin>>h>>w>>k;
	for (i=0; i<h; i++) cin>>grid[i];
	tot = 0;
	search(0);
	cout<<tot<<endl;
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

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

    char color = S[0];
    int res = 0;
    for(int i = 1; i < S.size(); i++){
        if(color != S[i]){
            color = S[i];
            res++;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;

int main(){
  int s,w;
  cin>>s>>w;
  if(w>=s)cout<<"unsafe";
  else cout<<"safe";
  

}


Measured memory_bytes: 3580
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(N):
    A=list(map(int,input().split()))
    if sum([a*b for (a,b) in zip(A,B)])+C>0:
        ans+=1
    
print(ans)


Measured memory_bytes: 9196
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <map>


#define ALL(obj) begin(obj), end(obj)
using namespace std;
 
using ll = long long;
using ull = unsigned long long;

int main() {
    const int P = 2019;
    string S;
    cin >> S;
    const int N =S.size();
    
    vector<ll> sum(N + 1, 0), ten(N + 1, 1);
    for (int i = N - 1; i >= 0; i--) {
        ten[i] = ten[i + 1] * 10 % P;
    }
    for (int i = N - 1; i >= 0; i--) {  // sum の計算
        sum[i] = ((ll)(S[i] - '0') * ten[i + 1] % P + sum[i + 1]) % P;
    }
 
    map<ll, ll> m;
    for (auto i : sum) {
        m[i]++;
    }
 
    ll ans = 0;
    for (auto i : m) {
        ans += i.second * (i.second - 1) / 2;
    }
    cout << ans << endl;
 
    return 0;
}

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

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;

    for(int i = 0; i <= x; i++)
        if(2 * i + 4 * (x - i) == y)
            return 0 * puts("Yes");

    puts("No");
}


Measured memory_bytes: 3636
#include<iostream>
#include<cmath>

using namespace std;
int main()
{
    int ax,ay,az,aw,bx,by,bz,bw;
    cin >> ax >> ay >> az >> aw >> bx >> by >> bz >> bw;
    int max=ax+ay+az+aw;
    if(max<bx+by+bz+bw){
        max=bx+by+bz+bw;
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 3088
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define SIZE 100005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
using namespace std;


int main()
{	
	ll N, M;
	scanf("%lld %lld", &N, &M);
	ll A[N], B[M];
	for(ll i=0;i<N;i++){
		scanf("%lld", &A[i]);
	}
	for(ll i=0;i<M;i++){
		scanf("%lld", &B[i]);
	}
	
	sort(A,A+N);
	sort(B,B+M);
	ll Asoeji=N-1;
	ll Bsoeji=M-1;
	ll suuji=N*M;
	ll open=0;
	ll answer=1;
	while((suuji>0)&&(answer!=0))
	{
		if( (suuji==A[Asoeji]) && suuji==B[Bsoeji] )
		{
			suuji--;
			Asoeji--;
			Bsoeji--;
			open+=(N-1-Asoeji)-1+(M-1-Bsoeji)-1;
		}
		if( (suuji==A[Asoeji]) && suuji!=B[Bsoeji] )
		{
			suuji--;
			Asoeji--;
			open+=(M-1-Bsoeji)-1;
			answer=(answer*(M-1-Bsoeji))%1000000007;
		}
		if( (suuji!=A[Asoeji]) && suuji==B[Bsoeji] )
		{
			suuji--;
			Bsoeji--;
			open+=(N-1-Asoeji)-1;
			answer=(answer*(N-1-Asoeji))%1000000007;
		}
		if( (suuji!=A[Asoeji]) && suuji!=B[Bsoeji] )
		{
			suuji--;
			answer=(answer*open)%1000000007;
			open--;
		}
	}
	printf("%lld", answer);
}


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

int main(){
    
    int x, y;
    
    for( ; ; ){
        
        cin >> x >> y;
        
        if(x == 0 && y == 0) break;
        
        if(x < y){
            cout << x << " " << y << endl;
        } else{
            cout << y << " " << x << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
    int n;
    cin>>n;
    vll a(n);
    cin>>a;
    sort(a.begin(),a.end());
    reverse(a.begin(), a.end());
    map<ll,int> ma;
    priority_queue<ll> pque;
    pque.push(a[0]);
    ll ans = 0;
    FOR(i,1,n){
        ll now = pque.top();
        pque.pop();
        ans += now;
        pque.push(a[i]);
        pque.push(a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6928
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define e cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m;
ll x,y;
ll a,b,c;

ll ans=0;
ll sum=0;
ll memo,num;
 
int main(){
	cin>>a>>b>>c;
	cin>>k;
	m=max(a,max(b,c));
	for(i=0;i<k;i++){
		m*=2;
	}
	p(a+b+c-max(a,max(b,c))+m)

	return 0;
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            double weight = Double.parseDouble(line);
            for (int i = 0; i < limits.length; i++) {
                if (weight <= limits[i]) {
                    out.println(names[i]);
                    break;
                }
            }
        }
    }

    private static final double[] limits = { 48.00, 51.00, 54.00, 57.00, 60.00,
            64.00, 69.00, 75.00, 81.00, 91.00, Double.MAX_VALUE };

    private static final String[] names = { "light fly", "fly", "bantam",
            "feather", "light", "light welter", "welter", "light middle",
            "middle", "light heavy", "heavy" };
}

Measured memory_bytes: 9748
using System;
using System.Collections.Generic;
using System.Linq;

// https://atcoder.jp/contests/abc155/tasks/abc155_a
namespace ABC155A
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split().Select(int.Parse).ToList();

            var res = abc.Distinct().ToList();

            if (res.Count == 2)
            {
                Console.WriteLine("Yes");
                return;
            }
            
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 28236
import java.util.*;
public class Main {

		static void solve() {
			Scanner sc = new Scanner (System.in);
			int n = sc.nextInt();
			int max = Integer.MIN_VALUE;
			int min = Integer.MAX_VALUE;
			int[] array = new int [n];
			for(int i = 0;i<n;i++) {
				array[i] = sc.nextInt();
			}
			sc.close();
			for(int i = 0;i<n;i++) {
				if(array[i]<=min) {
					min = array[i];
				}
				if(array[i]>=max) {
					max = array[i];
				}
			}
			System.out.println(max - min);
		}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 21716
N,K = map(int,input().split())
A = list(map(int,input().split()))
L = 0
R = max(A)
while R-L > 0.001:
    X = (L+R)/2
    m = 0
    for i in range(N):
        c = A[i]/X
        if c == int(c):
            m += int(c) - 1
        else:
            m += int(c)
    if m <= K:
        R = X
    else:
        L = X
if int(R) - int(L) == 0:
    print(int(R)+1)
else:
    print(int(R))

Measured memory_bytes: 104556
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int read()
{  int f=1,x=0;
   char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x = x * 10 + ch - '0';
   return x*f;
}
int main()
{
      ll s, a, end, b, t;
      cin >> s >> a >> end >> b>>t;
      ll x = a - b;
      ll y = abs(s - end);
      if(x*t>=y)
            printf("YES");
            else
                  printf("NO");

      return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
long long n,a[100002],z,zs;//z是出现奇数次，还是偶数次，zs是留下了多少个数
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
      cin>>a[i];
    sort(a+1,a+n+1);z=1;//输入排序不解释初值定1，方便以后运算
    for(int i=2;i<=n;i++){//因为和前一个比较，所以从2开始。
        if(a[i]==a[i-1])z=(z+1)%2;//相等则加一个，看看是奇数次，还是偶数次，奇数次就还有，偶数次就没有。
        else zs+=z,z=1;}//否则加上它，赋值为1。
    if(z%2)zs++;//最后一次特判
    cout<<zs<<endl;//输出答案
    return 0;
}

Measured memory_bytes: 1024
S = input()
acgt = ["A", "C", "G", "T"]
cnts = []
cnt = 0
for i in range(len(S)):
	if S[i] in acgt:
		cnt += 1
		cnts.append(cnt)
	else:
		cnts.append(cnt)
		cnt = 0
print(max(cnts))


Measured memory_bytes: 2940