akhauriyash/Code-Regression huggingface dataset:
mod = 10**9+7

def sum_interval_1d(N,X):
  # O(N)
  X_ = [X[i+1]-X[i] for i in range(N-1)]
  coef = list(range(1,N))[::-1]
  ret = (X_[0]*coef[0])%mod
  for i in range(1,N-1):
    coef[i] = (coef[i]+coef[i-1]-i)%mod
    ret = (ret + ((X_[i]*coef[i]) % mod)) % mod
  # print(X_, coef, ret)
  return ret

def solve():
  N,M = map(int, input().split())
  X = list(map(int, input().split()))
  Y = list(map(int, input().split()))
  x_sum = sum_interval_1d(N,X)
  y_sum = sum_interval_1d(M,Y)
  # print(x_sum,y_sum)
  ret = (x_sum*y_sum) % mod
  print(ret)
  
solve()

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def s():
 e=sys.stdin.readline
 n,m=map(int,e().split())
 P=[[]for _ in[0]*n]
 C=[0]*n
 k=0
 for _ in[0]*m:
  s,t=map(int,e().split());P[s]+=[t];P[t]+=[s]
 for i in range(n):
  k+=1
  if C[i]<1:
   s=[i];C[i]=k
   while s:
    u=s.pop()
    for v in P[u]:
     if C[v]<1:C[v]=k;s+=[v]
 for _ in[0]*int(e()):
  a,b=map(int,e().split())
  print(['no','yes'][C[a]==C[b]])
s()



Measured memory_bytes: 24084
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e6+ 10; 

int C[N];

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   for(int i = 1; i < N; ++i){
      for(int j = i; j < N; j += i){
         C[j]++;
      }
   }
   int ans = 0;
   int n;
   cin >> n;
   int c = n-1;
   while(c){
      ans += C[c];
      --c;
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 11448
class UnionFind:
    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        rank:ランク
        """
        self.N = N
        self.root = [-1] * N
        self.rank = [0] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        while self.root[x] >= 0:
            x = self.root[x]
        return x

    def union(self, x, y):
        """x,yが属する木をunion"""
        # 根を比較する
        # すでに同じ木に属していた場合は何もしない.
        # 違う木に属していた場合はrankを見てくっつける方を決める.
        # rankが同じ時はrankを1増やす
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = UnionFind(n)
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        print(int(uf.same(u, v)))
    else:
        uf.union(u, v)


Measured memory_bytes: 75256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[10],b[10];
    cin>>a>>b;
    if(a[0]=='H')
    {
        if(b[0]=='H')
            cout<<"H"<<endl;
        else
            cout<<"D"<<endl;
    }
    else
    {

        if(b[0]=='D')
            cout<<"H"<<endl;
        else
            cout<<"D"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    char c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    cout<<c[0][0]<<c[1][1]<<c[2][2]<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
N,A,B,C = [int(n) for n in input().split()]
# N = int(input())
l = [int(input()) for _ in range(N)]
# S = str(input())
# T = str(input())
INF = 10 **18
def dfs(p,a,b,c):
    if p == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0  else INF
    ans0 = dfs(p+1,a,b,c)
    ans1 = dfs(p+1,a+l[p],b,c) + 10
    ans2 = dfs(p+1,a,b+l[p],c) + 10
    ans3 = dfs(p+1,a,b,c+l[p]) + 10
    return min(ans0,ans1,ans2,ans3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,a[100111],b[100111];
map<int,int> mp,mpid;
vector<int> con[300111];
void adde(int x,int y){con[x].PB(y);con[y].PB(x);}
bool vis[300111];
void dfs(int x)
{
//	cerr<<"dfs:"<<x<<endl;
	vis[x]=1;
	for(int i=0;i<con[x].size();i++)
	{
		int u=con[x][i];
		if(!vis[u])dfs(u);
	}
}
int main()
{
	geti(n);n++;
	for(int i=1;i<n;i++)geti(a[i]),a[n]^=a[i];
	for(int i=1;i<n;i++)geti(b[i]),b[n]^=b[i];
	for(int i=1;i<=n;i++)mp[a[i]]++;
	for(int i=1;i<=n;i++)
	{
		mp[b[i]]--;
		if(mp[b[i]]<0)
		{
			puts("-1");
			return 0;
		}
	}
	int tot=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[i])continue;
		int &v=mpid[a[i]];
		if(!v)v=++tot;
	}
	for(int i=1;i<=n;i++)
	{
//		if(a[i]==b[i])continue;
		adde(i,n+mpid[a[i]]);
		adde(i,n+mpid[b[i]]);
	}
	int ans=0;
	bool flag=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[i])continue;
		if(a[i]==a[n])flag=1;
//		cerr<<"i="<<i<<":"<<a[i]<<" "<<b[i]<<endl;
		ans++;
		if(!vis[i])dfs(i),ans++;
	}
	if(a[n]!=b[n])ans--;
	ans-=flag;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 30208
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

signed main()
{
	int N, M;
	cin >> N >> M;
	if (N == M)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
x, n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
else:
    print(x)
    exit()

ABS = 10 ** 9
ans = 0
for i in range(102):
    if i in p:continue

    temp = abs(i - x)
    if ABS > temp:
        ABS = temp
        ans = i
print(ans)

Measured memory_bytes: 9192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vii;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf = sizeof(Def) == sizeof(ll) ? 2e18 : 1e9+10;
signed main(){
	string s;
	int n;
	while(cin>>s>>n,n){
		while(s.size()!=n)s="0"+s;
		map<string,int>ma;
		ma[s]=1;
		int co=2;
		while(1){
			string t=s;
			sort(all(t));
			int sa=atoi(&t[0]);
			reverse(all(t));
			sa=atoi(&t[0])-sa;
			t=to_string(sa);
			while(t.size()!=n)t="0"+t;
			if(ma[t]){
				cout<<ma[t]-1<<" "<<atoi(&t[0])<<" "<<co-ma[t]<<endl;
				break;
			}
			ma[t]=co;
			co++;
			s=t;
		}
	}
}








Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int main()
{
	int N,K;
	string S;

	cin >> N >> K;
	cin >> S;

	S+="_";
	string str="";
	vector<int> sum;
	int cnt=0;
	for(int i=0;i<N;i++)
	{
		cnt++;
		if(S[i]!=S[i+1])
		{
			str+=S[i];
			sum.push_back(cnt);
			cnt=0;
		}
	}

	int ans=0;
	for(auto&& i:sum)
		ans=max(ans,i);

	for(int i=0;i<sum.size();i++)
	{
		if(i!=sum.size()-1)
			sum[i+1]+=sum[i];
	}

	for(int i=0;i<str.size();i++)
	{
		int tans=0;
		int l=i;
		int r=i+2*K;
		if(str[i]=='0')r--;
		
		r=min(r,(int)str.size()-1);
		if(l==0)
			tans=sum[r];
		else
			tans=sum[r]-sum[l-1];
		ans=max(ans,tans);
	}

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


Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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;}

int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  s[k-1] = tolower(s[k-1]);
  cout << s << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; ++i) {
        if(s[i] == '<') cnt1++;
        else break;
    }
    for (int i = 0; i < n; ++i) {
        if(s[n-i-1] == '>') cnt2++;
        else break;
    }
    cout << n-min(cnt1, cnt2) << "\n";
    return 0;
}


Measured memory_bytes: 3336
N = int(input())
D1, D2 = [], []
for i in range(N):
  li = list(map(int,input().split()))
  D1.append(li[0])
  D2.append(li[1])

for i in range(N-2):
  if D1[i]==D2[i] and D1[i+1]==D2[i+1] and D1[i+2]==D2[i+2]:
    print('Yes')
    break
else:
  print('No')


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

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

    int ans = 0;
    for (int i = 0; i < S.size(); i++)
    {
        for (int j = i; j < S.size(); j++)
        {
            bool flag = true;
            for (int k = i; k <= j; k++)
            {
                if (S[k] != 'A' && S[k] != 'C' && S[k] != 'G' && S[k] != 'T')
                {
                    flag = false;
                }
            }
            if (flag)
            {
                ans = max(ans, j - i + 1);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

def F(a, b):
    return max(len(str(a)), len(str(b)))

ans = len(str(N))

a = 1
while a*a <= N:
    if N % a == 0:
        b = N // a
        cur =F(a, b)
        if ans > cur:
            ans = cur
    a += 1

print(ans)

Measured memory_bytes: 3060
from collections import Counter

N = int(input())
S = input()

counter = 0
prev = S[0]
i = 1
while i < N:
    if S[i] == prev:
        prev = S[i]
        i += 1
    else:
        if i < N - 1:
            prev = S[i + 1]        
        counter += 1
        i += 2
print(counter)


Measured memory_bytes: 6196
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
	
ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}
int main()
{
	int h,w;
	cin>>h>>w;
	string al="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	rep(i,h){
		rep(j,w){
			string s;
			cin>>s;
			if(s=="snuke"){
				cout<<al[j]<<i+1<<endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define EPS 1e-15
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 INF = 1LL << 60;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int N;

ll a[100110];
ll b[100110];
ll c[100110];
ll dpa[100110];
ll dpb[100110];
ll dpc[100110];

int main()
{
    cin >> N;
    rep(i, N)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    rep(i, 100110)
    {
        dpa[i] = -INF;
        dpb[i] = -INF;
        dpc[i] = -INF;
    }
    dpa[0] = 0;
    dpb[0] = 0;
    dpc[0] = 0;

    rep(i, N)
    {
        chmax(dpa[i + 1], a[i] + max(dpb[i], dpc[i]));
        chmax(dpb[i + 1], b[i] + max(dpc[i], dpa[i]));
        chmax(dpc[i + 1], c[i] + max(dpa[i], dpb[i]));
    }

    cout << max(max(dpa[N], dpb[N]), dpc[N]) << "\n";
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
int val[2010][2010];
int sum[2010][2010];

int main(){
    int n,k;cin >> n >> k;
    for(int i=0;i<n;i++){
        int x,y;cin >> x >> y;
        char c;cin >> c;
        if(c=='W') y+=k;
        x%=(2*k);
        y%=(2*k);
        val[x][y]++;
    }
    for(int i=0;i<=2*k;i++){
        for(int j=0;j<=2*k;j++){
            sum[i+1][j+1]=val[i][j];
            sum[i+1][j+1]+=sum[i+1][j];
            sum[i+1][j+1]+=sum[i][j+1];
            sum[i+1][j+1]-=sum[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<k;i++){
        for(int j=0;j<k;j++){
            int tmp1=sum[i][j]+sum[0][0]-sum[i][0]-sum[0][j];
            int tmp2=sum[i+k][j+k]+sum[i][j]-sum[i+k][j]-sum[i][j+k];
            int tmp3=sum[2*k][2*k]+sum[i+k][j+k]-sum[2*k][j+k]-sum[i+k][2*k];
            int tmp4=sum[i][2*k]+sum[0][j+k]-sum[i][j+k]-sum[0][2*k];
            int tmp5=sum[2*k][j]+sum[i+k][0]-sum[2*k][0]-sum[i+k][j];
            int tmp=tmp1+tmp2+tmp3+tmp4+tmp5;
            chmax(ans,tmp);
            chmax(ans,n-tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31744
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];

	int q; cin >> q;

	for (int i = 0; i < q; i++) {
		int com; cin >> com;
		if (com == 0) {
			int b,e;
			cin >> b >> e;
			int mi= 2e9;
			for (int i = b; i < e; i++) {
				mi = min(mi,a[i]);
			}
			cout << mi << endl;
		}
		else {
			int b, e;
			cin >> b >> e;
			int Ma = -2e9;
			for (int i = b; i < e; i++) {
				Ma = max(Ma, a[i]);
			}
			cout << Ma << endl;
		}
	}

}
	



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

using namespace std;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() > k) {
        for (int i = 0; i < k; i++) {
            cout << s.at(i);
        }
        cout << "..." << endl;
    } else {
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000000000LL
priority_queue<int,vector<int>,greater<int> >p;
priority_queue<int>q;
long long s[300009],t[300009];

int main(){
  int n;
  int a[300009];
  cin>>n;
  for(int i=0;i<n*3;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    p.push(a[i]);
    s[n-1]+=a[i];
  }
  for(int i=n*2;i<n*3;i++){
    q.push(a[i]);
    t[n*2]+=a[i];
  }
  
  for(int i=n;i<n*2;i++){
    int now=p.top();
    s[i]=s[i-1];
    if(a[i]>now){
      p.pop();
      p.push(a[i]);
      s[i]=s[i]-now+a[i];
    }
  }
  for(int i=n*2-1;i>=n;i--){
    int now=q.top();
    t[i]=t[i+1];
    if(a[i]<now){
      q.pop();
      q.push(a[i]);
      t[i]=t[i]-now+a[i];
    }
  }
  
  long long ans=-INF;
  for(int i=n-1;i<n*2;i++){
    ans=max(ans,s[i]-t[i+1]);
  }
  
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll cnt[200010];
int main() {
	ll a,b,x;
	cin>>a>>b>>x;
	ll cnt1=a/x+1;
	if(a%x==0){
		cnt1--;
	}
	cout << b/x+1-cnt1;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int D = sc.nextInt();
            int T = sc.nextInt();
            int S = sc.nextInt();
            System.out.println(D - T * S <= 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27036
#include<bits/stdc++.h>//头文件
using namespace std;
long long Q,H,S,D,N,ans;//一定要long long
int main(){
    cin>>Q>>H>>S>>D>>N;
    ans=(N%2==0)?(min(min(min(Q*8,H*4),S*2),D)*N/2):(min(min(Q*4,H*2),S)+min(min(min(Q*8,H*4),S*2),D)*(N-1)/2);//为什么不能直接输出，是我的问题吗
    cout<<ans<<endl;//可以不打回车，不打你试试，保证你全WA 
    return 0;
}

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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}



int32_t main()
{
	FIO;
	// c_p_c();
	int n, m;
	cin >> n >> m;
	mk(arr, n, int);
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		sum += arr[i];
	}
	sort(arr, arr + n, greater<int>());
	if (arr[m - 1] >= (double)sum / (4 * m))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define PI 3.141592653
using namespace std;

int f[100001];

void solve(){

	string s; cin>>s;
	int m=0;
	std::vector<int> v1,v2;
	for(int i=0; i<s.length(); i++){
		if(s[i] == 'R'){
			m++;
			if(s[i+1] == 'L'){
				v1.pb(i);
				v1.pb(i+1);
				v2.pb(m);
				m=0;
			}
		}
		else{
			m++;
			if(i != s.length()-1 && s[i+1] == 'R'){
				v2.pb(m);
				m=0;
			}
		}
	}
	v2.pb(m);
	for(int i=0; i<v1.size(); i++){
		if(i%2 == 0){
			f[v1[i]] += v2[i] - (v2[i]/2);
			f[v1[i+1]] += v2[i]/2;
		}
		else{
			f[v1[i]] += v2[i] - v2[i]/2 ;
			f[v1[i-1]] += v2[i]/2;
		}
	}
	for(int i=0; i<s.length(); i++) cout<<f[i]<<" ";


}

int main()
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(12);

    int t =1; //cin>>t;
    for(int i=1; i<=t; i++){
        solve();
        cout<<"\n";
    }
    return 0;

}

Measured memory_bytes: 1988
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String buf = " ";
		int N = S.length();
		int ans = 0;
		for(int i = 0;i < N;i++){
			for(int j = 0;j < i + 1;j++){
				buf = S.substring(j,N - i + j).replaceAll("[AGTC]","0");
				if(buf.matches("0*")){
					ans = S.substring(j,N - i + j).length();
					break;
				}
			}
			if(ans != 0){
				break;
			}
		}
		System.out.println(ans);
	}
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int dd[] = {1, 0, -1, 0, 1};
int h, w;
char s[50][50];

bool range(int y, int x) {
  return 0 <= y && y < h && 0 <= x && x < w;
}

int main() {
  cin.sync_with_stdio(false);
  cin >> h >> w;
  rep(i, h)rep(j, w) cin >> s[i][j];
  bool ok = true;
  rep(i, h)rep(j, w)if(s[i][j] == '#') {
    int cnt = 0;
    rep(k, 4) {
      int y = i + dd[k], x = j + dd[k + 1];
      if (range(y, x) && s[y][x] == '#') cnt++;
    }
    if (cnt == 0) ok = false;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m;
  cin>>n>>m;
  vvll t(n,vll(0));
  vvll iri(n,vll(0));
  rep(i,n+m-1){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    iri[b].pb(a);
    t[a].pb(b);
  }
  vll ans(n,-1);
  ll s;
  vll d(n,1);
  rep(i,n){
    if(sz(iri[i])==0){
      ans[i]=0;
      s=i;
    }
  }
  queue<ll> que;
  que.pu(s);
  vb ch(n,false);
  ch[s]=true;
  while(sz(que)){
    ll now=que.front();
    que.pop();
    for(auto p:t[now]){
      if(ch[p]) continue;
      if(d[p]==sz(iri[p])){
        ans[p]=now+1;
        ch[p]=true;
        que.pu(p);
      }
      else{
        d[p]++;
      }
    }
  }
  rep(i,n){
    COUT(ans[i]);
  }
}

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

int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}

Measured memory_bytes: 256
local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

local function dbgpr_t(tbl, use_pairs)
    if DBG then
        local enum = ipairs
        if use_pairs then
            enum = pairs
        end
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in enum(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end


-- binary search
-- https://golang.org/src/sort/search.go?s=2246:2286#L49
local function find_min_true(n, f)
    local function loop(i, j)
        if i == j then
            assert(i >= 1 and i <= n + 1)
            return i
        end
        local h = (i + j) // 2
        assert(h >= 1 and h <= n)
        if f(h) then
            return loop(i, h)
        else
            return loop(h + 1, j)
        end
    end
    return loop(1, n + 1)
end

--
local N = io.read("n")
local A = {}
for i=1,N do
    A[i] = io.read("n")
end

local colors = {} -- descending
local function search(a)
    local function f(i)
        return colors[i] < a
    end
    return find_min_true(#colors, f)
end
table.insert(colors, A[1])

for i=2,N do
    local a = A[i]
    local j = search(a)
    dbgpr_t(colors)
    colors[j] = a -- replace or append to last
    dbgpr(i, a, j, #colors)
end

print(#colors)


Measured memory_bytes: 25336
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
bool ans[100001];
int val[100001];
int main()
{
  //flash;
  int n,m;
  cin>>n>>m;
  for (int i = 0; i < n; ++i)
  {
    cin>>val[i];
  }
  for (int i = 0; i < m; ++i)
  {
    int x,y;
    cin>>x>>y;
    x--,y--;
    if(val[y]>=val[x])ans[x]=1;
    if(val[x]>=val[y])ans[y]=1;
  }
  int ans1=0;
  for (int i = 0; i < n; ++i)
  {
    if(!ans[i])ans1++;
  }
  cout<<ans1;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 4088
def trapizoid_light(side, bottom):
    if (bottom - side) % side == 0:
        return 2 * (bottom - side)
    next_side = bottom % side
    return 2 * ((bottom - side) // side * side) + side + next_side + trapizoid_light(next_side, side) 

N, X = map(int, input().split())

if N % 2 == 0 and N // 2 == X:
    print(3 * X)
else:
    if X <= N // 2:
        print(2 * X + N - X + trapizoid_light(X, N - X))
    else:
        print(2 * (N - X) + X + trapizoid_light(N - X, X))

Measured memory_bytes: 3060
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];

        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            a[i]--;
        }

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

        System.out.println(cnt / 2);

        return;
    }

}

Measured memory_bytes: 50660
#include<cstdio>
#include<vector>
#include<bitset>
using namespace std;int main(){typedef vector<int>::iterator V;int n,m,a,b,f;for(;scanf("%d%d",&n,&m),m;){bitset<501>B(2);vector<vector<int> >F(n+1);for(;m--;F[b].push_back(a))scanf("%d%d",&a,&b),F[a].push_back(b);V I=F[1].begin(),E=F[1].end(),i,e;for(;I!=E;++I){f=*I;B.set(f);i=F[f].begin(),e=F[f].end();for(;i!=e;++i)B.set(*i);}printf("%d\n",B.count()-1);}}

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

using namespace std;

typedef long long int ll;

const int N = (int) 1e5 + 10;

int n, k;
int a[N];
int memo[N];

bool dp(int k) {
    if(k == 0) return false;
    int &ans = memo[k];
    if(ans != -1) return ans;
    ans = false;
    for(int i = 0; i < n; ++i) {
        if(k >= a[i]) {
            ans |= !dp(k - a[i]);
        }
    }
    return ans;
}

void solve() {
    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    memset(memo, -1, sizeof(memo));
    cout << (dp(k) ? "First" : "Second") << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 5376
a, b, k = gets.split.map(&:to_i)

ma = a + k - 1
if b < ma 
  ma = b
end

mb = b - k + 1
if mb <= ma
  mb = ma + 1
end

a.upto(ma) do |i|
  puts i
end

mb.upto(b) do |i|
  puts i
end



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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};


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

    ll N;
    cin >> N;
    vll x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];

    vll idx(N);
    rep(i, N) idx[i] = i;
    sort(all(idx), [&](ll l, ll r){ return x[l]<x[r]; });

    vll p(N);
    rep(i, N) p[i] = i;
    function<ll(ll)> root = [&](ll x){
        if(p[x]==x) return x;
        return p[x] = root(p[x]);
    };
    function<void(ll, ll)> unite = [&](ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx!=ry) p[rx] = ry;
    };
    ll m = y[idx[0]];
    ll mi = 0;
    function<bool(pair<ll, ll>, pair<ll, ll>)> comp = [](pair<ll, ll> l, pair<ll, ll> r){
        return l.first>r.first;
    };
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, decltype(comp)> q(comp);
    REP(i, 1, N){
        if(y[idx[i]]>m){
            unite(i, mi);
            while(!q.empty()){
                auto p = q.top();
                if(p.first<y[idx[i]]){
                    unite(p.second, i);
                    q.pop();
                }
                else break;
            }
        }
        else{
            q.push({m, mi});
            m = y[idx[i]];
            mi = i;
        }
    }
    unordered_map<ll, ll> mp;
    rep(i, N) ++mp[root(i)];

    vll inv(N);
    rep(i, N) inv[idx[i]] = i;
    rep(i, N) cout << mp[root(inv[i])] << endl;
}


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


void solve(long long N, long long M, long long C, std::vector<long long> B, std::vector<std::vector<long long>> A){
    int count = 0;
    REP(i, N) {
        int sum = 0;
        REP(j, M)
            sum += B[j] * A[i][j];
        if (sum + C > 0) count++;
    }
    cout << count << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, M, C, std::move(B), std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX=30;
struct Node{
	int parent, left ,right,deg;
	Node():parent(-1),left(-1),right(-1),deg(0){}
}T[MAX];
int N;
void preorder(int i){
	printf(" %d",i);
	if(T[i].left!=-1)preorder(T[i].left);
	if(T[i].right!=-1)preorder(T[i].right);
}
void inorder(int i){
	if(T[i].left!=-1)inorder(T[i].left);
	printf(" %d",i);
	if(T[i].right!=-1)inorder(T[i].right);
}
void postorder(int i){
	if(T[i].left!=-1)postorder(T[i].left);
	if(T[i].right!=-1)postorder(T[i].right);
	printf(" %d",i);
}
int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		int id,l,r;
		cin>>id>>l>>r;
		T[id].left=l;
		T[id].right=r;
		if(l!=-1)T[l].parent=id,T[id].deg++;
		if(r!=-1)T[r].parent=id,T[id].deg++;
	}
	int p=0;
	while(T[p].parent!=-1) p=T[p].parent;
	printf("Preorder\n");
	preorder(p);
	printf("\nInorder\n");
	inorder(p);
	printf("\nPostorder\n");
	postorder(p);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 3228
#include "bits/stdc++.h"
using namespace std;

// #define int long long

signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int N;
  // int M;
  // array<int, 10000> A;
  string yes = "Yes";
  string no = "No";
  // string S;
  // string T;

  cin >> N;

  for (int i = 1; i <= N; ++i) {
    if (i % 2 == 0) continue;
    
    int tmp = 0;
    


    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) ++tmp;
    }
    

    if (tmp == 8) {

      ++num;
    }
    
    
  }
  

  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   cin >> *it;

  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   if (*it % 2 == 0) ++num;

  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define L 1001
 
int n;
 
int lcs(char X[],char Y[]){
  int i,j,c[L][L];
  int m=strlen(X);
  int n=strlen(Y);
  for(i=1;i<=m;i++) c[i][0]=0;
  for(j=0;j<=n;j++) c[0][j]=0;
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1]){
    c[i][j]=c[i-1][j-1]+1;
      } else if(c[i-1][j]>=c[i][j-1]){
    c[i][j]=c[i-1][j];
      } else c[i][j]=c[i][j-1];
    }
  }
  return c[m][n];
}
 
int main(){
  int k,U[L];
  char S[L],T[L];
  scanf("%d",&n);
  for(k=0;k<n;k++){
    scanf("%s",&S);
    scanf("%s",&T);
    U[k]=lcs(S,T);
  }
  for(k=0;k<n;k++) printf("%d\n",U[k]);
  return 0;
}

Measured memory_bytes: 4524
from math import gcd
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
max_A = max(A)
# happend_numbers = [False]*(max_A+1)  # 0~NのN+1個
happend_numbers = defaultdict(int)
for a in A:
    happend_numbers[a] += 1
    # happend_numbers[a] = True

for i in range(2, max_A+1):
    true_count = 0
    for j in range(i, max_A+1, i):
        # if happend_numbers[j]:
        true_count += happend_numbers[j]
    if true_count >= 2:
        break
else:
    print("pairwise coprime")
    exit()

now = A[0]
for a in A[1:]:
    now = gcd(a, now)
if now == 1:
    print("setwise coprime")
    exit()
print("not coprime")


Measured memory_bytes: 242008
import itertools
n,m,q = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(q)]
ans = 0
list_ = list(itertools.combinations_with_replacement(range(1, m + 1), n))
for i in list_:
    tmp = 0
    for a,b,c,d in arr:
        if (i[b-1] - i[a-1]==c):
            tmp+=d
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 21620
import java.util.Scanner;

public class Main
{
    public static void main(String arg[])
    {
        Scanner sc = new Scanner(System.in);
        int array[] = new int[3];
        for (int i = 0; i < 3; i++)
        {
            array[i] = sc.nextInt();
        }

        for (int j = 1; j < array.length; j++)
        {
            int key = array[j];
            int i = j - 1;
            while (i >= 0 && array[i] > key)
            {
                array[i + 1] = array[i];
                --i;
            }
            array[i + 1] = key;
        }

        System.out.println(array[0] + " " + array[1] + " " + array[2]);

    }

}



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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<ll> A, B, C;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    if(N%2==1) {
        for(int i=0;i<(N-1)/2;i++) {
            B.push_back(-2);
        }
        B.push_back(1);
        B.push_back(1);
        for(int i=0;i<(N-3)/2;i++) {
            B.push_back(2);
        }
        for(int i=0;i<N;i++) {
            ans += A[i]*B[i]; 
        }
        for(int i=0;i<(N-3)/2;i++) {
            C.push_back(-2);
        }
        C.push_back(-1);
        C.push_back(-1);
        for(int i=0;i<(N-1)/2;i++) {
            C.push_back(2);
        }
        for(int i=0;i<N;i++) tmp += A[i]*C[i];
        //cout << tmp << " " << ans << endl;
        ans = max(ans, tmp);
    }
    else {
        for(int i=0;i<N/2-1;i++) {
            B.push_back(-2);
        }
        B.push_back(-1);
        B.push_back(1);
        for(int i=0;i<N/2-1;i++) {
            B.push_back(2);
        }
        for(int i=0;i<N;i++) ans += A[i]*B[i]; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    int ans;
    if (A >= 13)
    {
        ans = B;
    }
    else if (A >= 6 && A <= 12)
    {
        ans = B / 2;
    }
    else
    {
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


int n, x[10], y[10];

int kai(int a){
	int b = 1;
	for(int i = 2; i <= a; i++) b *= i;
	return b;
}

double dfs(int now, int X, int Y, int c){
	double ans = 0.0;
	for(int i = 0; i < n; i++){
		if((now >> i) & 1) continue;
		ans += dfs(now+(1 << i), x[i], y[i], c-1) + ( now == 0 ? 0 : sqrt( pow(X-x[i],2) + pow(Y-y[i],2) ) * kai(c) );
	}
	return ans;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	
	printf("%.10f\n", dfs(0, 0, 0, n-1) / kai(n));
	
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int n; cin>>n;
  std::vector<int> v(n);
  rep(i,n) cin>>v[i];
  int cnt=0;
  for(int i=0; i<n-2; i++){
    if (v[i] < v[i+1] && v[i+1] < v[i+2]) cnt++;
    else if (v[i] > v[i+1] && v[i+1] > v[i+2]) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

ll N, S, dp[3030][3030];

int main()
{
	cin >> N >> S;
	vector<int> a(N);

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

	dp[0][0] = 1;

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= S; j++)
		{
			if (j + a[i] <= S)
				dp[i + 1][j + a[i]] = (dp[i][j] + dp[i + 1][j + a[i]]) % mod2;
			dp[i + 1][j] = (2 * dp[i][j] + dp[i + 1][j]) % mod2;
		}
	}
	cout << dp[N][S] << "\n";
}

Measured memory_bytes: 74632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, M;
    cin >> N >> M;

	vector<Int> term1(N+1);
	vector<Int> termN(N+1);

	Int a, b;
	for (Int i = 0; i < M; i++) {
		cin >> a >> b;
		if (a == 1) {
			term1[b]++;
		}
		if (b == N) {
			termN[a]++;
		}
	}

	Int flag = 0;
	for (Int i = 1; i < N; i++) {
		if (term1[i]) {
			if (termN[i]) {
				flag = 1;
				break;
			}
		}
	}

	cout << (flag ? "POSSIBLE\n" : "IMPOSSIBLE\n");
}

Measured memory_bytes: 3328
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    P = list(map(int, args[1].split()))

    count = 0
    small = P[0]
    for i in range(n):
        if P[i] <= small:
            count += 1
        small = min(small, P[i])

    return str(count)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 26012
package main

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

const BUFSIZE = 10000000

var rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)

func main() {
	var s string
	var f1, f2 bool = true, true
	fmt.Scanf("%s", &s)

	prefix, _ := strconv.Atoi(s[:2])
	sufix, _ := strconv.Atoi(s[2:])

	if prefix > 12 || prefix == 0 {
		f1 = false
	}
	if sufix > 12 || sufix == 0 {
		f2 = false
	}

	if f1 && f2 {
		fmt.Println("AMBIGUOUS")
	} else if f1 {
		fmt.Println("MMYY")
	} else if f2 {
		fmt.Println("YYMM")
	} else {
		fmt.Println("NA")
	}

}

func NextLineInt() []int {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}

		buf = append(buf, l...)

		if !p {
			break
		}
	}
	str := strings.Split(string(buf), " ")
	l := len(str)

	ret := make([]int, l)

	for i := range str {
		// ret[i], ok = strconv.Atoi(str[i])
		v, ok := strconv.Atoi(str[i])

		if ok == nil {
			ret[i] = v
		}
	}

	return ret
}

func Bool2Int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func Min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func Max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func Distance(a, b int) int {
	return Abs(a - b)
}


Measured memory_bytes: 2944