akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>

using namespace std;

int n,a[20],now[20]; 
set<vector<int> >s;

bool chk()
{
	for(int i=0;i<n;i++)
		if(now[i]%2==0)
			return true;
	return false;
}

int ans;

void dfs(int b)
{
	if(b==n)
	{
		if(chk())
			ans++;
		return ;
	}
	
	for(int i=-1;i<2;i++)
	{
		now[b]=i+a[b];
		dfs(b+1);
	} 
}

int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
		
	dfs(0);
	
	cout<<ans<<endl;
	return 0;
} 

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

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

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long


	
void solve(){
	int n;
	cin >> n;
	string ans;
	while(n){
		ans += 'a' + ((n - 1) % 26ll);
		n = (n - 1) / 26;
	}
	reverse(all(ans));
	cout << ans;
}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	vector<string> g;
	for (auto i = 0; i < 100; ++i)
	{
		if (i < 50)
		{
			g.push_back(string(100, '#'));
		}
		else
		{
			g.push_back(string(100, '.'));
		}
	}

	for (auto i = 0; i < A - 1; ++i)
	{
		g[i / 50 * 2][i % 50 * 2] = '.';
	}

	for (auto i = 0; i < B - 1; ++i)
	{
		g[100 - (i / 50 * 2) - 1][i % 50 * 2] = '#';
	}

	cout << "100 100" << endl;

	for (auto i = 0; i < 100; ++i)
	{
		cout << g[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    string A,B,C;
    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;
    ll count = 0;
    for(int i=0;i<N;i++){
        set<char> s = {A[i], B[i], C[i]};
        count += s.size()-1;
    }
    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
#define endl "\n"
const int mod=1e9+7;
const double pi=acos(-1.0);

int main(int argc, char const *argv[])
{
   /* #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    ll ans=(n*(n-1)/2)+(m*(m-1)/2);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using std::cout;

int main()
{
    int weight;
    while (std::cin >> weight) {
        std::vector<int> list;
        for (int bundou = 1; bundou <= 512; bundou *= 2) {
            if (weight % (bundou * 2) != 0) {
                list.push_back(bundou);
                weight -= bundou;
            }
            if (weight == 0) {
                break;
            }
        }

        for (auto i = 0; i < list.size(); i++) {
            if (i != 0) {
                cout << " ";
            }
            cout << list.at(i);
        }
        cout << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1208
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
d = {}

def fac2(n):
    if n < 2:
        return 0
    ans = n * (n-1) // 2
    return ans

for key, val in c.items():
    d[key] = fac2(val)

sum_val = sum(d.values())
for a in A:
    ans = sum_val - d[a] + fac2(c[a]-1)
    print(ans)

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> adj[n];
  int u, v;
  for (int i=0; i<m; i++)
  {
    cin >> u >> v;
    adj[u-1].push_back(v-1);
    adj[v-1].push_back(u-1);
  }
  
  int visited[n], cmp[n], freq[n];
  for (int i=0; i<n; i++)
  {
    visited[i] = 0;
    cmp[i] = -1;
    freq[i] = 0;
  }

  for (int i=0; i<n; i++)
  {
    if (visited[i]) continue;
    queue<int> q;
  	q.push(i);
    visited[i] = 1;
    cmp[i] = i;
    while (!q.empty())
    {
      u = q.front();
      q.pop();
      for (auto v: adj[u])
      {
        if (visited[v] == 0)
        {
          q.push(v);
          visited[v] = 1;
          cmp[v] = i;
        }
      }
    }
  }
  
  int count = 0;
  for (int i=0; i<n; i++)
  {
    if (cmp[i] != -1) freq[cmp[i]]++;
  }
  
  for (int i=0; i<n; i++)
  {
      //cout << "cmp and freq " << cmp[i] << " " << freq[i] << endl;
    if (freq[i] > 0) count++;
  }
  
  cout << count-1 << endl;
}


Measured memory_bytes: 9936
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    vector<ll> A{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<< A[N-1]<<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main(){
	string s;	cin>>s;
	int ans=0;
	int len=s.length()-1;
	for(int i=0;i<len;i++){
		if(s[i]!=s[len-i]){
			ans++;
			s[i]=s[len-i];
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define ll long long
using namespace std;
int fa[200005];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int l[200005],r[200005];
ll n,m,k,c,cnt;
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=1;i<=n;i++) fa[i]=i;
	cnt=0;
	while(k--){
		ll u,v,opt;scanf("%lld%lld%lld",&u,&v,&opt);u++;v++;
		if(!opt) fa[find(u)]=find(v);
		else cnt++,l[cnt]=u,r[cnt]=v;
	}
	for(int i=1;i<=cnt;i++) if(find(l[i])==find(r[i])) return puts("No"),0;
	for(int i=1;i<=n;i++) if(find(i)==i) c++;
	ll L=cnt?c:c-1ll,R=c*(c-1ll)/2ll;
	return puts((L<=m-n+c&&m-n+c<=R)?"Yes":"No"),0;
}

Measured memory_bytes: 1408
n = int(input())
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
ans = 0
prev = -1
for i in range(n):
    curr = a[i]
    ans += b[a[i] - 1]
    if curr - prev == 1:
        ans += c[prev-1]
    prev = curr
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
	int i, j, a, b;
	cin >> a >> b;
	while (a != 0 || b != 0) {
	for (i = 0; i < a; i++) {
		for (j = 0; j < b; j++) 
			cout << "#" ;
			cout << endl;
	}
	cout << endl;
	cin >> a >> b;
	}
	return 0;
}


Measured memory_bytes: 3104
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort() # ソート
print(min(h[i+K-1] - h[i] for i in range(N-K+1))) # i番目からK個めまで見た時の最小値をウインドウをスライドさせて見ていく

Measured memory_bytes: 7384
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <bitset>
#include <climits>
#include <utility>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define SZ(x) ((int)(x).size())
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 222222;
int n,c;
int A[444],B[444];

LL f[444][444];
LL p[444];
LL dp[444][444];
int main(int argc, char const *argv[])
{
    cin>>n>>c;
    REP(i,n)cin>>A[i];
    REP(i,n)cin>>B[i];
    
    for(int i=1;i<=400;++i)p[i] = 1;
    for(int i=0;i<=400;++i)
        for(int j=1;j<=400;++j) {
            f[i][j] = (f[i][j-1] + p[j])%MOD;
            p[j] = (p[j] * j) % MOD;
        }

    dp[0][0] = 1;
    for(int i=0;i<n;++i)
        for(int j=0;j<=c;++j)
            for(int k=0;k<=j;++k) {
                dp[i+1][j] += (dp[i][j-k] * ((f[k][B[i]] - f[k][A[i]-1] + MOD) %MOD))%MOD;
                dp[i+1][j] %= MOD;
            }
    cout<<dp[n][c]<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<string, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int n, k;
vector<int> w(100000);

bool check(int c)
{
    int cnt = 1, sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (sum + w[i] > c)
        {
            sum = w[i];
            cnt++;
        }
        else
        {
            sum += w[i];
        }
    }
    return cnt <= k;
}

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

    cin >> n >> k;
    int low = 0, high = 1e9;
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
        low = max(low, w[i]);
    }
    while (high - low > 1)
    {
        int mid = (low + high) / 2;
        if (check(mid))
        {
            high = mid;
        }
        else
        {
            low = mid;
        }
    }
    cout << (check(low) ? low : high) << endl;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x); i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

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

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> a_sum(n+1, 0);
    rep(i,n)a_sum[i+1] = a[i] + a_sum[i];
    ll left = 1, med = 2, right = 3;
    ll ans = INF;
    for(;med < n-1; med++){
        while(left < med - 1 && a_sum[left] < a_sum[med] - a_sum[left]) {
            left++;
        }
        ll l_l, l_r;
        l_l = a_sum[left];
        l_r = a_sum[med] - a_sum[left];
        if(left != 1){
            if(abs(l_l - l_r) > abs(a_sum[left-1] * 2 - a_sum[med])){
                l_l = a_sum[left-1];
                l_r = a_sum[med] - a_sum[left-1];
            }
        }
        while(right < n && a_sum[right] - a_sum[med] < a_sum[n] - a_sum[right]) {
            right++;
        }
        ll r_l, r_r;
        r_l = a_sum[right] - a_sum[med];
        r_r = a_sum[n] - a_sum[right];
        if(right != 1){
            if(abs(r_l - r_r) > abs(a_sum[right-1] * 2 - a_sum[med] - a_sum[n])){
                r_l = a_sum[right-1] - a_sum[med];
                r_r = a_sum[n] - a_sum[right-1];
            }
        }
        if(chmin(ans, max({l_l, l_r, r_l, r_r}) - min({l_l, l_r, r_l, r_r}))){
            // debug(left);debug(med);debug(right);
            // debug(l_l);debug(l_r);debug(r_l);debug(r_r);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
  int ans=0;
  char S[3];
  cin >> S;
  for(int i=0;i<3;i++){
  if(S[i]=='R'){
  ans++;
    }
  }
  if(S[0]=='R' && S[1]=='S' && S[2]=='R'){
    ans=1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    print(min({abs(a + b - c - d), abs(a + c - b - d), abs(a + d - b - c)}));

    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define push push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;

vector<vector<long long>> WarshallFloyd(vector<vector<long long>> &pathmatrix){
    int index=pathmatrix.size();
    vector<vector<long long >>res=pathmatrix;
    for (int a = 0; a < index; a++)
    {
        for (int b = 0; b < index; b++)
        {
            for (int c = 0; c < index; c++)
            { //res[b][c] = min(res[b][a] + res[a][c], res[b][c]);
                chmin(res[b][c], res[b][a] + res[a][c]);
            }
        }
    }
    return (res);
}

    int main()
{

    int h,w;
    cin >> h>>w;
    //long long map[10][10]={0};
    vector<vector<ll>> map(10,vector<ll>(10,0));
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >>map[i][j];
        }
    }
    map=WarshallFloyd(map);
    //WarshallFloyd
    /*
    for(int a=0;a<10;a++){
        for(int b=0;b<10;b++){
            for(int c=0;c<10;c++){
                map[b][c]=min(map[b][a]+map[a][c],map[b][c]);
            }
        }
    }
    */
    long long ans=0;
    int value;

    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            cin >>value;
            if(value>=0){
                ans+=map[value][1];
            }
        }
    }

    cout << ans;
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h>
#include <queue>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rddbuf(in.rdbuf());
    ll n,m;
    cin >> n >> m;
    ll a[n];
    REP(i,n)
    {
        cin >> a[i];
    }

    std::priority_queue<ll> que;

    REP(i,n)
    {
        que.push(a[i]);
    }

    REP(i,m)
    {
        ll value = que.top();
        que.pop();
        que.push(value/2);
    }

    ll res = 0;

    while(!que.empty())
    {
        ll value = que.top();
        res += value;
        que.pop();
    }

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



Measured memory_bytes: 2168
from heapq import heappop, heappush
MOD = 10 ** 9 + 7

N, M = map(int, input().split())
S, T = map(lambda x: int(x) - 1, input().split())

adjList = [[] for i in range(N)]
for i in range(M):
    U, V, D = map(int, input().split())
    adjList[U - 1].append((V - 1, D))
    adjList[V - 1].append((U - 1, D))

# 頂点Sから各頂点への最短路の個数
numRouteS = [0] * N
numRouteS[S] = 1

cost = [float('inf')] * N
cost[S] = 0
prev = [None] * N
vs = []

pq = []
heappush(pq, (0, S))
while pq:
    c, vNow = heappop(pq)
    if c > cost[vNow]: continue
    if c > cost[T]: break
    vs += [vNow]

    for v2, wt in adjList[vNow]:
        c2 = c + wt
        if c2 < cost[v2]:
            cost[v2] = c2
            prev[v2] = [vNow]
            numRouteS[v2] = numRouteS[vNow]
            heappush(pq, (c2, v2))
        elif c2 == cost[v2]:
            prev[v2] += [vNow]
            numRouteS[v2] = (numRouteS[v2] + numRouteS[vNow]) % MOD

# 頂点Tから各頂点への最短路の個数
numRouteT = [0] * N
numRouteT[T] = 1
cST = cost[T]
for iV, v in enumerate(reversed(vs)):
    if cost[v] * 2 < cST:
        iVLim = len(vs) - iV
        break
    for v0 in prev[v]:
        numRouteT[v0] = (numRouteT[v0] + numRouteT[v]) % MOD

# 二人の最短路の選び方の組から、途中で出会うものを引く
ans = (numRouteS[T] ** 2) % MOD

for v in vs[:iVLim]:
    x = (numRouteS[v] ** 2) % MOD
    for v2, wt in adjList[v]:
        if (cost[v2] * 2 > cST) and cost[v] + wt == cost[v2]:
            y = (numRouteT[v2] ** 2) % MOD
            ans = (ans - x * y) % MOD

for v in vs[iVLim:]:
    if cost[v] * 2 > cST: break
    x = (numRouteS[v] ** 2) % MOD
    y = (numRouteT[v] ** 2) % MOD
    ans = (ans - x * y) % MOD

print(ans)


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

using namespace std;
using ll = long long;

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i = 1LL; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            ll j = n / i;
            if(i != j)res.push_back(j);
        }
    }
    sort(res.begin(),res.end());
    reverse(res.begin(), res.end());
    res.pop_back();
    return res;
}

/***********debug tools***********/
template<class T> ostream& operator<<(ostream& os, const pair<T,T>& p){os << "{" << p.first << "," << p.second << "}";return os; }
template<class T> inline void print(pair<T,T> p){cerr << p << endl;}
template<class T> inline void print(vector<T> arr) {cerr << "["; for(int i = 0; i < (int)arr.size(); i++)cerr << arr[i] << (i == (int)arr.size() - 1 ? "]" : ",");cerr << endl;}
template<class T> inline void print(vector<vector<T>> arr) {cerr << "[-------------------" << endl; for(int i = 0; i < (int)arr.size(); i++) { print(arr[i]);} cerr << "-------------------]" << endl;}
/*********************************/

template<class T>
map<T,T> fact(T n){
    map<T,T> Map;
    for(T i = 2; i * i <= n; i++){
        while(n % i == 0){
            Map[i]++;
            n /= i;
        }
    }
    if(n == 1)return Map;
    Map[n]++;
    return Map;
}


int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(n % 2) {
        cout << b[n / 2] - a[n / 2] + 1 << endl;
    } else {
        cout << (b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1]) + 1 << endl;
    }
}

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

int main() {
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;

    while (true) {
        C -= B;
        if (C <= 0) {
            std::cout << "Yes\n";
            return 0;
        } 

        A -= D;
        if (A <= 0) {
            std::cout << "No\n";
            return 0;
        } 
    }

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void){
  int a,n;
  int min = 1000000;
  int max = -1000000;
  long long sum = 0;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a;
    sum += (long long)a;
    if(min > a) min = a;
    if(max < a) max = a;
  }
  printf("%d %d %ld\n", min, max, sum);
  return 0;
}



Measured memory_bytes: 3224
MOD = 10 ** 9 + 7

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
broken = [False] * (N + 1)
for aa in a:
    broken[aa] = True

dp = [0] * (N + 1)
dp[0] = 1

for i in range(1, N + 1):
    if broken[i]:
        continue
    if i >= 2:
        dp[i] = dp[i - 1] + dp[i - 2]
    else:
        dp[i] = dp[i - 1]
    dp[i] %= MOD
print(dp[N])


Measured memory_bytes: 53144
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define nl cout << endl
#define pb push_back
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
//debugger
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

int main() {
	fast;
	int a,b;
	cin >> a >> b;
	cout << max(0,a-2*b);nl;
	return 0;
}

//notes
/*
 use these format of input when number of inputs not provided
 *while(scanf("%lld",&n)!=EOF)
 *while using getline(cin,s) for taking input of a string which is 
 having white space characters just write cin>>ws; before geline(cin,s)
 to make it work properly
*/

/*
 use 2-D vector for representing the pair<int,pair<int,int> > kind of things
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
ll Npow(ll x, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) return Npow(x * x % 2019, n / 2);
	else return x * Npow(x, n - 1) % 2019;
}
int main() {
	string S;
	cin >> S;
	N = S.length();
	vl T(N+1);
	vl P(2019);
	T[N] = 0;
	P[T[N]]++;
	ll c = 0;
	for (i = N-1; i >= 0; i--) {
		T[i] = (T[i + 1] +ctoi(S[i])*Npow(10,c)) % 2019;
		P[T[i]]++;
		c++;
		//debug(i, T[i]);
	}
	for (i = 0; i < 2019; i++) {
		ans += P[i] * (P[i] - 1) / 2;
	}
	cout << ans;
}

Measured memory_bytes: 5136
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  long long n,a[100005]={},ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n; i++) {
    ans+=a[i]/2;
    if(a[i]%2==1&&a[i+1]!=0) {
      ans++;
      a[i+1]--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
/*
god taekyu
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

int n;
ld A[3005];
ld dp[3005][3005];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>A[i];
    dp[0][0] = 1.0;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<=i;j++) {
            dp[i][j] = dp[i-1][j] * (1.0 - A[i]) + dp[i-1][j-1] * A[i];
        }
    }
    ld ans = 0.0;
    for(int j=n/2 + 1;j<=n;j++) {
        ans += dp[n][j];
    }
    printf("%.9Lf",ans);
    return 0;
}

/*
god taekyu
*/


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

int main()
{  int cou=0;
    string t;
    string s;
    cin>>s;
    cin>>t;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cou++;
        }
    }
cout<<cou;
    return 0;
}


Measured memory_bytes: 3844
n, k = map(int, input().split())

count = 0
for i in range(k, n + 2):
  if i == k:
    tot_min = 0
    tot_max = 0
    for j in range(i):
      tot_min += j
      tot_max += n - j
  else:
    tot_min += i - 1
    tot_max += n - i + 1
  count += tot_max - tot_min + 1
count %= 10 ** 9 + 7
print(count)

Measured memory_bytes: 9164
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define pb push_back
#define ins insert
#define f first
#define se second
#define Ln 20
#define mp make_pair
#define INF (ll)1e9+5
#define dif 0.0000000001
#define pp pair<ll,ll> 
#define vv vector< pair<ll ,ll> > 
#define vi vector<ll> 
#define SZ 100005
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

vi adj[200005];

int main() {
    fastio;
    
    ll n,m,a,b;
    cin>>n>>m;
    
    while(m--)
    {
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    
    for(auto u:adj[1])
    {
        for(auto v:adj[u])
        {
            if(v==n)
            {
                cout<<"POSSIBLE";
                return 0;
            }
        }
    }
    
    cout<<"IMPOSSIBLE";
    
   
    // your code goes here
	return 0;
}

Measured memory_bytes: 12776
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        double sum = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                for (int k = 1; k <= n; ++k) {
                    sum += gcd(i, gcd(j, k));
                }
            }
        }
        DecimalFormat ft = new DecimalFormat("####");
        System.out.print(ft.format(sum));
    }

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


Measured memory_bytes: 36028
sx,sy,tx,ty=gets.chomp.split(" ").map(&:to_i)
ret=""
ret += ("U"*(ty-sy))
ret += ("R"*(tx-sx))
ret += ("D"*(ty-sy))
ret += ("L"*(tx-sx))
ret += "L"
ret += ("U"*(ty-sy+1))
ret += ("R"*(tx-sx+1))
ret += "D"
ret += "R"
ret += ("D"*(ty-sy+1))
ret += ("L"*(tx-sx+1))
ret += "U"
puts ret


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

int main () {
  int N, X, Y;
  cin >> N >> X >> Y;
  int dis[N] = {0};
  for (int i = 1; i < N; ++i) {
    int tmp = 0;
    for (int j = i+1; j <= N; ++j) {
      if (j >= Y && i <= X) {
        tmp = X - i + 1;
        tmp += j - Y;
        // ++dis[tmp];
      } 
      else if (i >= X && j - i > i - X) {
        tmp = j - i;
        int a = i - X + 1;
        a += abs(Y - j);
        if (tmp > a) {
          tmp = a;
        }
        // ++dis[tmp];
      } else if (i < X && j - i > i - X) {
        tmp = j - i;
        int a = X - i + 1;
        a += abs(Y - j);
        if (tmp > a) {
          tmp = a;
        }
      } else {
        tmp = j - i;
        // ++dis[tmp];
      }
      ++dis[tmp];
      // printf("%d\n", tmp);
    }
  }
  for (int i = 1; i < N; ++i) {
    printf("%d\n", dis[i]);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector <vector<int>> vv(10);
    for(int i = 0; i < 10; i++){
        vv[i] = vector<int>(10,0);
    }
    for(int i = 1; i <= n; i++){
        int currentNumber = i;
        int headNumber = 0;
        int tailNumber = i%10;
        while(currentNumber>0){
            headNumber = currentNumber%10;
            currentNumber/=10;
        }
        //cout <<i <<" "<< headNumber << " " << tailNumber << endl;
        vv[headNumber][tailNumber]++;
    }
    long long ans = 0;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            ans += vv[i][j]*vv[j][i];
        }
    }
    cout << ans << endl;
    #if 0
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i!=j){
                cout << vv[i][j] << " ";
            }
        }
        cout << endl;
    }
    #endif
    return 0;
}

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

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin); freopen("output1.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	int dp[n] = {};
	for (int i = 0; i < n; i++)
		dp[i] = INT_MAX;
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		if (i - 1 >= 0) {
			dp[i] =  dp[i - 1] + abs(arr[i - 1] - arr[i]);
		}
		if (i - 2 >= 0) {
			dp[i] = min(dp[i], dp[i - 2] + abs(arr[i - 2] - arr[i]));
		}
		/*for (int i = 0; i < n; ++i)
		{
			/* code
			cout << dp[i] << " ";
		}
		cout << endl;*/
	}
	cout << dp[n - 1];


}

Measured memory_bytes: 4376
function main(input) {
  const x = Number(input)
  for (let a = -118; a <= 119; a++) {
    for (let b = -119; b <= 118; b++) {
      if (a ** 5 - b ** 5 === x) {
        console.log(`${a} ${b}`)
        return
      }
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 33236
import numpy as np

n, k = map(int,input().split()) 
a = list(map(int, input().split()))
f = list(map(int, input().split()))

if k > sum(a):
    print(0)
    exit()

a.sort(reverse=True)
f.sort()

a = np.array(a)
f = np.array(f)

lb = -1
ub = a[0]*f[-1]

while ub - lb > 1:
    x = (lb+ub)//2
    cx = np.full(n, x)
    ck = a - x//f
    ck = np.where(ck < 0, 0, ck)
    ck_sum = ck.sum()
    if ck_sum > k:
        lb = x
    else:
        ub = x
print(ub)

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

void solve(int N)
{
    int ans = 0;
    for (int a = 1; a < N; a++)
    {
        ans += (N - 1) / a;
    }
    cout << ans << endl;
}

int main()
{
    int N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3632
import math
N, D = [int(x) for x in input().split()]
xs = []
for i in range(N):
  xs.append([int(x) for x in input().split()])
count = 0
for i in range(N):
  for j in range(N):
    if i < j:
      a1 = xs[i]
      a2 = xs[j]
      a3 = [a1[k] - a2[k] for k in range(len(a1))]
      a3 = math.sqrt(sum([i ** 2 for i in a3]))
      if a3 == int(a3):
        count += 1
      
print(count)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    if(a < b && n >= 2 || a==b){
        ll MAX = b*(n-1)+a;
        ll MIN = a*(n-1)+b;
        ans = MAX-MIN+1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()

    a = [0] * n

    r = 0
    for x in range(1, 100):
        t = x ** 2
        if t > n:
            break

        for y in range(1, 100):
            u = t + y ** 2 + x * y
            if u > n:
                break

            for z in range(1, 100):
                v = u + z ** 2 + y * z + z * x
                if v > n:
                    break

                a[v-1] += 1

    return JA(a, "\n")


print(main())




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

using namespace std;

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

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

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

int main()
{
	ll l,r;
	cin>>l>>r;

	ll dl = l/2019;
	ll dr = r/2019;
	if(dl != dr){
		cout<<0<<endl;
	}else{
		l %= 2019;
		r %= 2019;
		ll ans = 20000;
		for (ll	 i = l; i < r; i++){
			for (ll j = l+1; j <= r; j++){
				ans = min(ans,i*j%2019);
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

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

ans=min(max(x,y)*2*c, a*x+b*y)
if x>y:
    ans=min(ans, y*2*c+a*(x-y))
else:
    ans=min(ans, x*2*c+b*(y-x))

print(ans)

Measured memory_bytes: 38256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func check(c []int, s string) bool {
	N := len(s)
	for i := 1; i < N; i++ {
		if c[i] == 0 {
			if s[i] == 'o' {
				c[i+1] = c[i-1]
			} else {
				c[i+1] = c[i-1] ^ 1
			}
		} else {
			if s[i] == 'x' {
				c[i+1] = c[i-1]
			} else {
				c[i+1] = c[i-1] ^ 1
			}
		}
	}

	if c[0] != c[N] {
		return false
	}
	if c[0] == 0 {
		if s[0] == 'o' {
			if c[1] != c[N-1] {
				return false
			}
		} else {
			if c[1] == c[N-1] {
				return false
			}
		}
	}
	if c[0] == 1 {
		if s[0] == 'o' {
			if c[1] == c[N-1] {
				return false
			}
		} else {
			if c[1] != c[N-1] {
				return false
			}
		}
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for i := 0; i < N; i++ {
		if c[i] == 0 {
			fmt.Fprint(w, "S")
		} else {
			fmt.Fprint(w, "W")
		}
	}
	fmt.Fprintln(w)

	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	s := getString()

	c := make([]int, N+1)

	c[0] = 0
	c[1] = 0
	ret := check(c, s)
	// out(ret, c)
	// out(s)
	if ret {
		return
	}

	c[0] = 0
	c[1] = 1
	ret = check(c, s)
	// out(ret, c)
	if ret {
		return
	}

	c[0] = 1
	c[1] = 0
	ret = check(c, s)
	// out(ret, c)
	if ret {
		return
	}

	c[0] = 1
	c[1] = 1
	ret = check(c, s)
	// out(ret, c)
	if ret {
		return
	}

	out(-1)
}


Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int ans;

    int H = sc.nextInt();
    int W = sc.nextInt();

    int h = sc.nextInt();
    int w = sc.nextInt();


    if (H == h || W == w) {
      System.out.println(0);
    } else {

      ans = W*H-(h*W + w*H - h*w);

      System.out.println(ans);
    }

  }

}


Measured memory_bytes: 23636
#include<iostream>
#include<string>
using namespace std;
int main(){
  string t,h;
  int n,pt=0,ph=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> t >> h;
    if(t==h)pt++,ph++;
    else if(t>h) pt+=3;
    else ph+=3;
  }
  cout << pt << " " << ph << endl;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

int MUL(int x, int y)
{
    return (long long)x * y % MOD;
}

int FACT(int n)
{
    int result = 1;
    for (int i = 1; i <= n; i++) result = MUL(result, i);
    return result;
}

int POW(int x, int n)
{
    int result = 1;
    while (n > 0) {
        if (n & 1) result = MUL(result, x);
        x = MUL(x, x);
        n >>= 1;
    }
    return result;
}

int INV(int n)
{
    return POW(n, MOD-2);
}

int COMB(int n, int k)
{
    return MUL(FACT(n), INV(MUL(FACT(n-k), FACT(k))));
}

int main()
{
    int N, M;
    cin >> N >> M;
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<pair<int, int>> vec;
    for (int p = 2, m = M; p <= m; p++) {
        int c = 0;
        while (m % p == 0) c++, m /= p;
        if (c > 0) vec.push_back(make_pair(p, c));
    }
    int result = 1;
    for (auto p : vec) {
        result = MUL(result, COMB(p.second + N - 1, p.second));
    }
    cout << result << endl;
    return 0;
}

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

const long long MOD = 1000000007;

int main(void) {
    long long N, K;
    cin >> N >> K;
    vector< long long > A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    long long ans = 1LL;
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    bool minus = false;
    if (A[0] < 0LL && K % 2 == 1) {
        minus = true;
    }
    if (minus || K == N) {
        for (int i = 0; i < K; i++) {
            ans = (ans * A[i]) % MOD;
        }
        if (ans < 0LL) {
            ans += MOD;
        }
        printf("%lld\n", ans);
        return 0;
    }

    int i = 0, j = 0;
    while (true) {
        if (i + j == K - 1 || A[i] * A[i + 1] > A[N - 1 - j] * A[N - 2 - j]) {
            ans = (A[i] * ans) % MOD;
            i += 1;
        } else {
            ans = (((A[N - 1 - j] * A[N - 2 - j]) % MOD) * ans) % MOD;
            j += 2;
        }
        if (i + j >= K) {
            break;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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


vector<long long> v;
int main(){
	long long n,a;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	for(int i=1;i<n;i++){
		if(v[i]==v[i-1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 2420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();

            var keyence = "keyence";

            if (input == keyence)
            {
                Console.WriteLine("YES");
                return;
            }

            var result = false;

            for (int keyenceIndex = 0; keyenceIndex < keyence.Length; keyenceIndex++)
            {
                var frontResult = false;
                var backResult = false;
                if (keyenceIndex == 0)
                {
                    frontResult = Regex.IsMatch(input, $".+{keyence}\\b|\\b{keyence}.+");
                    backResult = true;
                }
                //途中に文字列が入る時
                else if (frontResult = Regex.IsMatch(input, $"\\b{keyence.Substring(0, keyenceIndex)}.+"))
                {
                    //後半側の末尾が空白
                    backResult = Regex.IsMatch(input, $".+{keyence.Substring(keyenceIndex)}\\b");
                }

                if (frontResult && backResult)
                {
                    result = true;
                    break;
                }
            }

            if (result)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 16308
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define ll long long
#define out(a) printf("%d",a)
#define writeln printf("\n")
using namespace std;
int a,b,c,x,y;
int num1,num2,num3,num4,ans;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
ll readl()
{
	ll s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	a=read(); b=read(); c=read(); x=read(); y=read();
	if (x==y) ans=min(2*x*c,a*x+b*y);
    if (x>y) {
      num1=2*y*c+(x-y)*a;
      num2=2*y*c+(x-y)*2*c;
      num3=b*y+x*2*c;
      num4=b*y+x*a;
      ans=min(num1,num2); ans=min(ans,num3); ans=min(ans,num4);
  }
  if (x<y) {
  	num1=2*x*c+(y-x)*b;
    num2=2*x*c+(y-x)*2*c;
    num3=a*x+y*2*c;
    num4=a*x+b*y;
    ans=min(num1,num2); ans=min(ans,num3); ans=min(ans,num4);
  }
  out(ans);
  return 0;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.lang.reflect.Array;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		String[] str = s.split(" ");
		long timer = 0;
		int time = 0;
		int n = Integer.parseInt(str[0]);
		int q = Integer.parseInt(str[1]);
		String name = new String();
		Queue<Integer> queue = new LinkedList<Integer>();
		Queue<String> namequeue = new LinkedList<String>();
		for(int i=0;i<n;i++){
			s = br.readLine();
			str = s.split(" ");
			namequeue.add(str[0]);
			queue.add(Integer.parseInt(str[1]));
		}
		while(queue.isEmpty()!=true){
			time=queue.poll();
			name=namequeue.poll();
			if(time>q){
				queue.add(time-q);
				namequeue.add(name);
				timer+=q;
			}
			else{
				timer+=time;
				System.out.println(name+" "+timer);
			}
		}
	}
}

Measured memory_bytes: 64232
#include<iostream>
using namespace std;
int a[50], b[50], c[50], d[50], e[50];
int n, m, q;
int ret = 0;
void dfs(int pos, int val) {
    if (pos == n) {
        int tmp = 0;
        for (int i = 0;i < q;i++) {
            tmp += d[i] * (e[b[i]] - e[a[i]] == c[i]);
        }        
        ret = max(ret, tmp);
        return;
    }        
    for (int i = val;i <= m;i++) {
        e[pos] = i;
        dfs(pos + 1, i);
    }
} 
int main() {
    cin >> n >> m >> q;
    for (int i = 0;i < q;i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }    
    dfs(0, 1);
    cout << ret << endl;
    return 0;
}

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

int main(){
	int N;
	cin>>N;
	map<long,int>amap;
	vector<long>arr;
	long tmp;
	for(int i=0;i<N;++i){
		cin>>tmp;
		if(amap[tmp]==0){
			amap[tmp]++;
			arr.push_back(tmp);
		}
		else amap[tmp]++;
	}
	long ans=0;
	for(int i=0;i<arr.size();++i){
		if(arr[i]<amap[arr[i]])ans+=amap[arr[i]]-arr[i];
		else if(arr[i]>amap[arr[i]])ans+=amap[arr[i]];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 7028
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定
#include <list> //前後に数値を入れれる配列
#include <map> //map



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

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

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

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

int a, p, ans;





int main() {
	cin >> a >> p;
	ans = (a * 3 + p) / 2;
	cout << ans << endl;




	return 0;
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split(' ');
        var ans = Math.Min(int.Parse(s[1]), int.Parse(s[3])) - Math.Max(int.Parse(s[0]), int.Parse(s[2]));
        Console.WriteLine(Math.Max(0, ans));
    }
}


Measured memory_bytes: 11092
use proconio::input;
use proconio::marker::Chars;

fn f(s: &[char]) -> i64 {
    if s.len() == 1 {
        return 0;
    }
    if (0..s.len() / 2).all(|i| s[i] == s[s.len() - i - 1]) {
        return 0;
    }
    let nx = s
        .iter()
        .filter(|&&c| c != 'x')
        .map(|&c| c)
        .collect::<Vec<char>>();
    let is_ok = {
        let mut nxr = nx.clone();
        nxr.reverse();
        nx == nxr
    };
    if !is_ok {
        return -1;
    }
    if nx.is_empty() {
        return 0;
    }
    let mut i_s = 0;
    let mut c = vec![0_i64; nx.len() + 1];
    for (i, &nx_i) in nx.iter().enumerate() {
        while s[i_s] != nx_i {
            if s[i_s] == 'x' {
                c[i] += 1;
            }
            i_s += 1;
        }
        i_s += 1;
    }
    while i_s < s.len() {
        if s[i_s] == 'x' {
            c[nx.len()] += 1;
        }
        i_s += 1;
    }
    let mut ans = 0_i64;
    for i in 0..c.len() / 2 {
        let c_l = c[i];
        let c_r = c[c.len() - i - 1];
        if c_l != c_r {
            ans += (c_l - c_r).abs();
        }
    }
    ans
}

fn main() {
    input! {
        s: Chars,
    };
    let ans = f(&s);
    println!("{}", ans);
}


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

int main() {
    int r,c;
    cin>>r>>c;
    char a[r][c];
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){cin>>a[i][j];
        }}
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){cout<<a[i][j];}
        cout<<endl;
        for(int j=0;j<c;j++){cout<<a[i][j];}cout<<endl;

        }


    return 0;
}

Measured memory_bytes: 256