akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
   
/* brownsands :Arpit */			

void solve()
{    int x,y;
   cin >> x;
   y=(x/500)*1000;
   x=x%500;
   y+=(x/5)*5;
   cout<<y;
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[200003],b[200003],fsum[200003],bsum[200003],ans=-2e18,sum,su;
signed main()
{
	scanf("%lld",&n);
	for(int i=1; i<=n; i++)
		scanf("%lld",&a[i]);
	fsum[1]=a[1],fsum[2]=a[2],bsum[n]=a[n],bsum[n-1]=a[n-1];
	for(int i=3; i<=n; i++)
		fsum[i]=fsum[i-2]+a[i];
	for(int i=n-2; i>=1; i--)
		bsum[i]=bsum[i+2]+a[i];
	sum=fsum[n];
	if(n%2==0)
	{
		ans=max(fsum[n-1],fsum[n]);
		for(int i=1; i<=n; i+=2)
			ans=max(ans,fsum[i]+bsum[i+3]);
		cout<<ans;
		return 0;
	}
	for(int i=1; i<=n; i++)
		if(i%2==1)
			b[i]=-a[i];
		else
			b[i]=a[i];
	for(int i=1; i<=n; i++)
		if(i%2==0)
			su+=b[i];
		else
		{
			if(su<0)
				su=b[i];
			else
				su+=b[i];
			ans=max(ans,sum+su);
		}
	cout<<ans;
	return 0;
}

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

int main() {
    ll n, p;
    cin >> n >> p;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    vector<pair<ll, ll>> dp(60);
    dp[0].first = 1;
    dp[0].second = 0;
    for (int j = 0; j < n; ++j) {
        if (a[j] % 2 == 0) {
            dp[j + 1].first = dp[j].first * 2;
            dp[j + 1].second = dp[j].second * 2;
        } else {
            dp[j + 1].first = dp[j].first + dp[j].second;
            dp[j + 1].second = dp[j].second + dp[j].first;
        }
    }
    cout << (p == 0 ? dp[n].first : dp[n].second) << endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/arc074/tasks/arc074_c
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=310;
int n,m;
ll f[N][N][N];
struct node
{
	int l,w;
};
vector<node>G[N];
const int p=1e9+7;
void add(ll &x,ll y){x=(x+y)%p;}
bool check(int x,int y,int z)
{
	int r=max(x,max(y,z));
	for(int i=0;i<G[r].size();i++)
	{
		int l=G[r][i].l,w=G[r][i].w,s=0;
		s=(x>=l)+(y>=l)+(z>=l);
		if(s!=w) return 0;
	}
	return 1;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1,x,y,w;i<=m;i++) 
	{
		cin>>x>>y>>w;
		G[y].push_back({x,w});
	}
	f[0][0][0]=1;
	ll ans=0;
	for(int i=0;i<=n;i++) 
	 for(int j=0;j<=n;j++)
	  for(int k=0;k<=n;k++)
	  {
	  	 if(!f[i][j][k]) continue;
	  	 if((i&&j&&i==j)||(j&&k&&j==k)||(i==k&&i&&k)) continue;
	  	 if(check(i,j,k)==0) 
	  	 {
	  	 	f[i][j][k]=0;
	  	 	continue;
	  	 }
	  	 int r=max(i,max(j,k));
	  	 add(f[r+1][j][k],f[i][j][k]);
	  	 add(f[i][r+1][k],f[i][j][k]);
		 add(f[i][j][r+1],f[i][j][k]);
		 if(r==n) add(ans,f[i][j][k]); 
	  }
    cout<<ans<<endl;
    return 0;
	 
}

Measured memory_bytes: 227584
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;

#define pi acos(-1.0)
#define ms(x,n) memset(x,n,sizeof(x));

typedef long long ll;//string::npos
typedef long long iint;

ll gcd(ll a,ll b) {
	return a%b==0?b:gcd(b,a%b);
}
ll lcm(ll x,ll y) {
	ll z=gcd(x,y);
	return x*y/z;
}

const int MAXX=2e5+5;
const int INF=1e7+5;
const int mod=998244353;

vector<int> vt;
map<int,int> m1;

int main() {
	ios::sync_with_stdio(false);
	string a;
	while(cin>>a){
		int q=0,e=0;
		for(int i=0;i<3;i++){
			if(a[i]=='A'){
				q++;
			}else{
				e++;
			}
		}
		if(q&&e){
			cout<<"Yes\n";
		}else{
			cout<<"No\n";
		}
	}
	
	
	
	return 0;
}




//	getline(cin,a);
//	scanf("%[^\n]",a);getchar();
//	cin.getline(a,sizeof(a));

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.StringBuilder;

/*Question
/??????????????????????????????????????¨?????????????????????Bubble???????°´??¢???????????£???????????????????????????????´??????????????????????????????????????????????????¬???????????????¢?????´???????????§??°????????????????????????????????????
/1 bubbleSort(A, N) // N ??????????´?????????? 0-????????????????????? A
/2 flag = 1 // ????????£??\????´?????????¨??????
/3 while flag
/4 flag = 0
/5 for j ??? N-1 ?????? 1 ?????§
/6 if A[j] < A[j-1]
/7 A[j] ??¨ A[j-1] ?????????
/8 flag = 1
/??°??? A ??????????????????????????????????????§?????????????????????????????????????????°?????????????????????????????????????????????????????????????????§????????????????´???????????????°?????±???????????????????????? 
*/

/*Input
/??\??????????????????????????°?????????????????¨?????´??° N ???????????????????????????????????????N ????????´??°????????????????????§?????????????????????
*/

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		//???????????°????¢??????¨
		int k;
		/*??\???
		/??????????´???°?????\???????¬??????°????????\???
		*/
		int n = Integer.parseInt(sc.readLine());
		int[] a = new int[n];
		String[] st = sc.readLine().split(" ");
		for(int i = 0;i < n;i++){
			a[i] = Integer.parseInt(st[i]);
		}
		/*??°??????Bubble???????????????
		/????????????????????§?????????????????????
		/??????????????£??????????????§??????
		*/
		k = Bubble(a);
		System.out.println(k);
	}

	/*Bubble????????????
	/???????????????????????????
	@return int
	*/

	public static int Bubble(int[] a) {
		//????????¨
		StringBuilder br = new StringBuilder();
		//?????°???????????????
		int s = 0;
		//????????????????????????????????\????????¨
		int t;
		for (int i = 0;i < a.length-1;i++) {
			for (int j = a.length-1;j > i;j--) {
				if (a[j] < a[j-1]){
					t = a[j];
					a[j] = a[j-1];
					a[j-1] = t;
					s++;
				}
			}
		}
		//??????
		for (int n:a)
			br.append(n+" ");
		br.deleteCharAt(br.lastIndexOf(" "));
		System.out.println(br);
		return s;
	}
}

Measured memory_bytes: 24308
import math
while True:
    st_num = int(input())
    if st_num == 0:
        break
    st_score = [0]*st_num
    st_score = list(map(int,input().split()))
    st_mean=0
    for i in range(st_num):
        st_mean += st_score[i]
    st_mean /= st_num
    st_variance = 0
    for i in range(st_num):
        st_variance += (st_score[i]-st_mean)**2
    st_variance /= st_num
    standard_devi = math.sqrt(st_variance)
    print("%f"%(standard_devi))



Measured memory_bytes: 5708
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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(){
    ll n; cin>>n;
    vector<ll> box(100002,0);
    ll sum=0;
    rep(i,0,n){
        ll a; cin>>a;
        box[a]++;
        sum+=a;
    }
    ll q; cin>>q;
    rep(i,0,q){
        ll b,c; cin>>b>>c;
        ll sa=(c-b)*box[b];
        sum+=sa;
        box[c]+=box[b];
        box[b]=0;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 4048
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
typedef long long Long;
typedef double Double;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

const int N = 3003;
const int MOD = 998244353;
int memo[N][N];

int c, d;
int count(int a, int b) {
  if (a == c && b == d) return 1;
  if (a > c || b > d) return 0;
  int& res = memo[a][b];
  if (res != -1) return res;
  res = 1LL * b * count(a + 1, b) % MOD;
  res = (res + 1LL * a * count(a, b + 1)) % MOD;
  int tmp = 1LL * a * b % MOD;
  tmp = 1LL * tmp * count(a + 1, b + 1) % MOD;
  res = (res - tmp + MOD) % MOD;
  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif
  memset(memo, -1, sizeof memo);
  int a, b;
  cin >> a >> b >> c >> d;

  cout << count(a, b) << endl;

  return 0;
}

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

const int END = -1;
struct StNod
{
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
     m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

enum EnDir
{
  D_Left,
  D_Right,
};

void fnInput(vector<int> &rvnPodr, vector<int> &rvnIodrSeq)
{
  int nMaxSiz;

  cin >> nMaxSiz;
  rvnPodr.resize(nMaxSiz);
  rvnIodrSeq.resize(nMaxSiz + 1);

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nNode;
    cin >> nNode;
    rvnPodr[i] = nNode;
  }

  for (int i = 1; i < nMaxSiz + 1; i++)
  {
    int nNode;
    cin >> nNode;
    rvnIodrSeq[nNode] = i;
  }
}

void fnStructTree(const vector<int> &cnrvnPodr, const vector<int> &cnrvnIodrSeq, vector<StNod> &rvoNod)
{
  int nRoot = cnrvnPodr[0];

  for (int i = 1; i < cnrvnPodr.size(); i++)
  {
    int nParnt = END;
    int nx = nRoot;
    EnDir enDir;
    while (nx != END)
    {
      nParnt = nx;
      if (cnrvnIodrSeq[ cnrvnPodr[i] ] < cnrvnIodrSeq[nx])
      {
        nx = rvoNod[nx].m_nLeft;
        enDir = D_Left;
      }
      else
      {
        nx = rvoNod[nx].m_nRigt;
        enDir = D_Right;
      }
    }

    rvoNod[ cnrvnPodr[i] ].m_nParnt = nParnt;
    if (enDir == D_Left)
      rvoNod[nParnt].m_nLeft = cnrvnPodr[i];
    else
      rvoNod[nParnt].m_nRigt = cnrvnPodr[i];
  }
}

void fnPostOrder(const vector<StNod> &cnrvoNod, int nx, int &nOCnt)
{
  if (nx == END)  return;

  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nLeft, nOCnt);
  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nRigt, nOCnt);
  if (nOCnt++) cout << " ";
  cout << nx;
}

void fnResult(const vector<StNod> &cnrvoNod, int &nOCnt)
{
  int nx = 1;
  while (cnrvoNod[nx].m_nParnt != END)
    nx = cnrvoNod[nx].m_nParnt;

  fnPostOrder(cnrvoNod, nx, nOCnt);
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPodr, vnIodrSeq;
  vector<StNod> voNod;

  fnInput(vnPodr, vnIodrSeq);

  StNod oNod;
  voNod.resize(vnIodrSeq.size(), oNod);
  fnStructTree(vnPodr, vnIodrSeq, voNod);
  
  int nOCnt = 0;
  fnResult(voNod, nOCnt);
  return 0;
}

Measured memory_bytes: 1204
import scala.io.StdIn.{readLine,readInt}
import scala.language.postfixOps

object Main {
  private[this] var cnt = 0
  private[this] val l = new Array[Int](255000)
  private[this] val r = new Array[Int](255000)

  def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {
    val n1 = mid-left
    val n2 = right-mid
    Array.copy(a,left,l,0,n1)
    l(n1) = Int.MaxValue
    Array.copy(a,mid,r,0,n2)
    r(n2) = Int.MaxValue
    var i=0
    var j=0
    for(k<-left until right) {
      if(l(i)<=r(j)){
        a(k) = l(i)
        i += 1
      } else  {
        a(k)=r(j)
        j += 1
      }
      cnt += 1
    }
  }

 def getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {
    var w = n
    var h = 0
    while(w>1) {
      h += 1
      w = w/2
    }

    def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] = {
      if(h==0) l
      else
        scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)
    }
    scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val l = getSortIndex(n)
    for(e2<-l) {
      for(e<-e2) {
        val mid = (e._2+e._1)/2
        if(e._2-e._1>1)
          merge(a,e._1,mid,e._2)
      }
    }
    merge(a,0,n/2,n)
    println(a.mkString(" "))
    println(cnt)
  }
}

Measured memory_bytes: 315896
/*
Looking from a window above
It's like a story of love
Can you hear me?
Came back only yesterday
I'm moving further away
Want you near me
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you
Sometimes when I think of her name
When it's only a game
And I need you
Listen to the words that you say
It's getting harder to stay
When I see you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you
Uh uh uh only you, only you
Only you, only you, only you
This is going to take a long time
And I wonder what's mine
Can't take no more
Wonder if you'll understand
It's just the touch of your hand
Behind a closed door
And all I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
Only you
*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) ((int)(x.size()))
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 3e18;
const int N = 5e5 + 100;




int32_t main(){ 
   FAST;
   string s, t;
   cin >> s >> t;
   int a, b;
   cin >> a >> b;
   string u;   cin >> u;
   if(u == s) a--;
   else if(u == t) b--;
   cout << a << ' ' << b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    string s;
    string t;
    cin >> s >> t;
    ll n = sz(s),m = sz(t);
    ll ans = inf;
    fo(i, n - m + 1){
        ll c = 0;
        fo(j, m){
            if(t[j] != s[i + j])c++;

        }
        ans = min(c, ans);
    }
    cout << ans << nl;
}
int main(){ 
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3848
n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]

ans = 0
for i in t:
    left = 0
    right = n-1
    mid = 0
    while left <= right:
        mid = (left + right)//2
        if s[mid] == i:
            ans += 1
            break
        elif s[mid] < i:
            left = mid+1
        else:
            right = mid-1
 
print(ans)


Measured memory_bytes: 16896
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
	VAR(int,n,m);
  VEC(int,a,n);

  sort(ALL(a));

  // cj, bj
  vector< pair<int,int> > ow(m);
  REP(i,m){
    VAR(int,b,c);
    ow[i] = make_pair(c,b);
  }
  sort(ALL(ow), greater<pair<int,int>>());

  int now=0;
  REP(i,m){
    FOR(j,now,now+ow[i].second){
      if (j > a.size()-1) break;
      if (a[j] > ow[i].first){
        break;
      }
      a[j] = ow[i].first;
    }
    now += ow[i].second;
  }

  int ans = accumulate(ALL(a), 0LL);
  OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip> 



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int a;

int main(){
  cin >> a;
  if(a==7||a==5||a==3) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

using namespace std;

vector<int>y[200005];
int z[200005];
int main()
{
	int a,b,c,d,e,f,T;
	{
		memset(z,0x3f,sizeof(z));
		scanf("%d%d",&a,&e);
		
		for(int i=0;i<e;i++)
		{
			scanf("%d%d",&b,&c);
			y[b].push_back(c);
			y[c].push_back(b);
		}
		queue<int>q;
		q.push(1);
		int n=1;z[1]=0;
		while(q.size()&&n!=a)
		{
			b=q.front();
			q.pop();
			for(auto x : y[b])
			{
				if(z[x]==0x3f3f3f3f)
				{
					n++;
					z[x]=b;
					q.push(x);
				}
				if(n==a)break;
			}
		}
		d=0;
		for(int i=2;i<=a;i++)
		{
			if(z[i]==0x3f3f3f3f)
			{
				d=1;break;
			}
		}
		if(d)printf("No\n");
		else
		{
			printf("Yes\n");
			for(int i=2;i<=a;i++)printf("%d\n",z[i]);
		}
		
	}
	
}

Measured memory_bytes: 13340
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=INT_MAX;
    
 for(int pos=1;pos<=100;pos++)
 {
int temp=0;
for(int i=0;i<n;i++)
        {
            temp+=(a[i]-pos)*(a[i]-pos);
        }
        ans=min(ans,temp);
 }
        
        
    
    cout<<ans<<endl;
    return 0;
}


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

map<string, int> freq;

bool custom(const pair<string, int> &a, const pair<string, int> &b) {
    if (a.second == b.second) {
        return (a.first < b.first);
    } else {
        return (a.second > b.second);
    }
}

int main() {
    //freopen("../input.txt", "r", stdin);
    long long int N;
    cin >> N;

    for (int i = 0; i < N; ++i) {
        string input;
        cin >> input;
        if (freq.find(input) == freq.end()) {
            freq.insert(make_pair(input, 1));
        } else {
            freq[input] = freq[input] + 1;
        }
    }

    vector<pair<string, int> > freq_vec(freq.size());
    copy(freq.begin(), freq.end(), freq_vec.begin());
    sort(freq_vec.begin(), freq_vec.end(), custom);
    //long long int highest = (*max_element(freq_vec.begin(), freq_vec.end())).second;

    long long int highest = freq_vec[0].second;

    for (int j = 0; j < freq_vec.size(); ++j) {
        if (freq_vec[j].second == highest) {
            cout << freq_vec[j].first << "\n";
        } else {
            break;
        }
    }
}

Measured memory_bytes: 26736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define loop(i,k,n) for (ll i = k ; i < n ; ++i)
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

int h , w , k;
vector <vector<char>> c;

ll calc2 (int idx , vector <vector<char>> v){

    if (idx == w){
        int t = 0;
        for (int i = 0 ; i < h ; ++i)
            for (int j = 0 ; j < w ; ++j)
                t += (v[i][j] == '#');

        return (t == k);
    }

    int ans = calc2(idx+1,v);
    for (int i = 0 ; i < h ; ++i)
        v[i][idx] = '.';
    ans += calc2(idx+1,v);

    return ans;

}

ll calc (int idx , vector <vector<char>> v){

    if (idx == h)
        return calc2(0,v);

    int ans = calc(idx+1,v);
    for (int i = 0 ; i < w ; ++i)
        v[idx][i] = '.';
    ans += calc(idx+1,v);

    return ans;
}

void Suhaib_Sawalha (){

    cin >> h >> w >> k;
    c.resize(h , vector<char>(w));
    for (int i = 0 ; i < h ; ++i)
        for (int j = 0 ; j < w ; ++j)
            cin >> c[i][j];

    cout << calc(0,c);
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


Measured memory_bytes: 3588
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;

vector<vector<ll>> c(55,vector<ll>(55,0));

void mk_c(){
    for(ll i=0;i<52;i++){
        c[i][i]=1;
        c[i][0]=1;
        for(ll t=1;t<i;t++){
            c[i][t]=c[i-1][t-1]+c[i-1][t];
        }
    }
}



int main(){
    cout<<fixed<<setprecision(12);
    mk_c();
    ll n;
    ll a,b;
    cin>>n;
    cin>>a>>b;
    vector<ll> v;
    for(ll i=0;i<n;i++){
        ll c;
        cin>>c;
        v.push_back(c);
    }
    sort(v.begin(),v.end(),greater<ll>());
    ll sum=0;
    ll count=0;
    for(ll i=0;i<a;i++){
        sum+=v[i];
    }
    double av=(double)sum/a;
    ll t=v[a-1];
    ll ans=0;
    ll big=0;
    for(int i=0;i<n;i++){
        if(v[i]==t){count++;}
        if(v[i]>t){big++;}
    }
    ans+=c[count][a-big];
    for(ll i=a;i<b && v[i]==v[0] && i<n;i++){
        ans+=c[count][i+1];
    }
    cout<<av<<endl;
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;


int main(){

	char T[1001],P[1001];
	int t_length,p_length;
	vector<int> V[26];

	scanf("%s",T);
	scanf("%s",P);

	for(t_length = 0; T[t_length] != '\0'; t_length++);
	for(p_length = 0; P[p_length] != '\0'; p_length++){
		V[P[p_length] - 'a'].push_back(p_length+1);
	}

	int** dp = new int*[t_length];
	for(int i = 0; i < t_length; i++){
		dp[i] = new int[p_length+1];
		for(int k = 0; k < p_length+1; k++)dp[i][k] = 0;
	}

	dp[0][0] = 1;
	if(T[0] == P[0]){
		dp[0][1] = 1;
	}

	for(int i = 1; i < t_length; i++){
		for(int k = 0; k < p_length+1; k++){
			dp[i][k] = dp[i-1][k]%1000000007;
		}
		for(int k = 0; k < V[T[i] - 'a'].size();k++){
			dp[i][V[T[i]-'a'][k]] += dp[i-1][V[T[i]-'a'][k]-1]%1000000007;
		}
	}

	printf("%d\n",dp[t_length-1][p_length]%1000000007);

    return 0;
}

Measured memory_bytes: 6704
#include <bits/stdc++.h>
#define fast_io ios :: sync_with_stdio(false);
using namespace std;

int main() {
	cout << fixed << setprecision(3);
	fast_io;
	int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a<=k)cout<<"Yay!";
    else cout<<":(";

	return 0;	
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
int main()
{
	int n;
	cin>>n;
	string s;
	map<string,int> m;
	for(int i=0;i<n;i++)
	{
		s.clear();
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
} 

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

const string wb = ".#";
int N = 50;

int main() {
  int A, B; cin >> A >> B;
  vector<string> ans(N, string(N, '.'));
  ans.resize(2 * N, string(N, '#'));
  for (int i = 0, C[] = {A - 1, B - 1}; i < 2 * N; ++i) {
    for (int j = 0; j < N; ++j) {
      if ((i % N + 1) % 2 || (i % N + j) % 2) continue;
      if (C[i < N]) {
        ans[i][j] = wb[i < N];
        --C[i < N];
      }
    }
  }
  cout << 2 * N << ' ' << N << endl;
  for (int i = 0; i < 2 * N; ++i) {
    for (int j = 0; j < N; ++j) cout << ans[i][j];
    cout << endl;
  }
  return 0;
}


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

int main(){
  char a,b,c;
  cin>>a>>b>>c;
  int count=0;
  if(a=='1')
    count++;
  if(b=='1')
    count++;
  if(c=='1')
    count++;
  cout<<count<<endl;
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];

            //愚直にループを回して、合致するインデックスから高さを計算
            //計算量は高々999回なので、充分に余裕がある。
            // var list = new List<int>();
            // list.Add(1);
            // for (int i = 2; i < 1000; i++) list.Add(i + list.Last());
            // var ans = list[dist-1] - ab[1];
            // Console.WriteLine(ans);
            
            //塔の高さは等差数列の和となる。
            //等差数列の和の公式(初項+末項)*項目数/2　より
            //(1+ b-a) * (b-a)/2が塔の高さ。これから雪の高さを計算するため、見えてる部分を引く。
            var ans = ((b - a) * (b - a + 1) / 2) - b;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
using System;
using System.Linq;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ABCK = Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
            int sum = 0;
            if (ABCK[3] > 0)
            {
                bool end = false;
                if (ABCK[0] > 0)
                {
                    if (ABCK[0] <= ABCK[3])
                    {
                        sum += ABCK[0];
                        ABCK[3] -= ABCK[0];
                        ABCK[0] = 0;
                    }
                    else if (ABCK[0] > ABCK[3])
                    {
                        sum += ABCK[3];
                        ABCK[0] -= ABCK[3];
                        ABCK[3] = 0;
                        end = true;
                    }
                }

                if (ABCK[1] > 0 && !end)
                {
                    if (ABCK[1] <= ABCK[3])
                    {
                        ABCK[3] -= ABCK[1];
                        ABCK[1] = 0;
                    }else if (ABCK[1] > ABCK[3])
                    {
                        ABCK[1] -= ABCK[3];
                        end = true;
                    }
                }

                if (ABCK[2] > 0 && !end)
                {
                    if (ABCK[2] <= ABCK[3])
                    {
                        sum += ABCK[2] * -1;
                        ABCK[3] -= ABCK[2];
                        ABCK[2] = 0;
                    }else if (ABCK[2] > ABCK[3])
                    {
                        sum += ABCK[3] * -1;
                        ABCK[2] -= ABCK[3];
                        end = true;
                    }
                }

            }

            Console.WriteLine(sum);
        }
    }
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

ll gcd(ll a, ll b);

ll sum(int n);

void go(){
   int x,a;cin>>x>>a;
   int ans=x<a?0:10;
   cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

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

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


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

long long gcd(long long a, long long b){
  return a % b ? gcd(b, a % b) : b;
}

map<long long, int> prime_factor(long long n){
  map<long long, int> res;
  for(long long i = 2; i * i <= n; ++i){
    while(n % i == 0){
      res[i]++;
      n /= i;
    }
  }
  if(n > 1) res[n]++;
  return res; 
}


int main(){
  long long a, b;
  cin >> a >> b;
  long long GCD = gcd(a, b);
  auto rec = prime_factor(GCD);
  int ans = rec.size() + 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
ps = gets.split(" ").map(&:to_i)
q = gets.split(" ").map(&:to_i)

permu = []
(1..n).each do |i|
    permu.push(i)
    i += 1
end

flag_p = 0
flag_q = 0
count = 0

permu.permutation(n) do |a|
    current_permu = a
    if current_permu == ps
        flag_p = count
    end
    if current_permu == q
        flag_q = count
    end
    count = count + 1
end

puts (flag_p - flag_q).abs

Measured memory_bytes: 2172
#include <iostream>
using namespace std;
int color[9] = {0};
void count(int rate) {
    if (1 <= rate && rate <= 399) color[0]++;
    else if (400 <= rate && rate <= 799) color[1]++;
    else if (800 <= rate && rate <= 1199) color[2]++;
    else if (1200 <= rate && rate <= 1599) color[3]++;
    else if (1600 <= rate && rate <= 1999) color[4]++;
    else if (2000 <= rate && rate <= 2399) color[5]++;
    else if (2400 <= rate && rate <= 2799) color[6]++;
    else if (2800 <= rate && rate <= 3199) color[7]++;
    else color[8]++;
}
int main() {
    int N, a[100], ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        count(a[i]);
    }
    for (int i = 0; i < 8; i++) if (color[i]) ans++;
    if (color[8] == N) cout << "1 " << N << endl;
    else cout << ans << " " << ans + color[8] << endl;
}

Measured memory_bytes: 256
import static java.lang.Math.max;
import static java.lang.Math.min;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final int n = scanner.nextInt();
    final List<Integer> a = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      a.add(scanner.nextInt());
    }
    if(a.stream().distinct().count() == a.size()) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 92644
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  set<int> a;
 
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
 
    if (a.count(tmp) == 1) {
      a.erase(tmp);
    } else {
      a.insert(tmp);
    }
  }
 
  cout << a.size() << endl;
}


Measured memory_bytes: 4864
import bisect
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()
s = 0
for b_ in b:
    t = bisect.bisect_right(a, b_-1)
    tt = len(c) - bisect.bisect_right(c, b_)
    d = tt * t
    s += d
print(s)

Measured memory_bytes: 23292
num_limit = int(input())
num_list = [0] * num_limit
j_limit = int(num_limit ** 0.5)
for j in range(1,j_limit+1):
    for k in range(1,j + 1):
        for l in range(1,k+1):
            if num_limit >= j**2 + k**2 + l**2 + j*k + k*l + l*j:
                if j > k:
                    if k > l:
                        num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 6
                    else:
                        num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 3
                elif k > l:
                    num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 3
                else:
                    num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 1
for i in num_list:
    print(i)

Measured memory_bytes: 9608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int m; cin>>m;
	int n; cin>>n;
	set<int> s;
	rep(i,0,n){
		int a; cin>>a;
		s.insert(a);
	}
	int cnt=0;
	while(true){
		if(!s.count(m-cnt)){
			cout<<m-cnt<<endl;
			return 0;
		}
		if(!s.count(m+cnt)){
			cout<<m+cnt<<endl;
			return 0;
		}
		cnt++;
	}
	
	return 0;
}

Measured memory_bytes: 3548
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
using PII = pair<ll, ll>;
#define FOR(i,a,n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i,n) FOR(i,0,n)
const ll INF = 1LL << 60;
template<typename T> void chmin(T &a, T b) { a = min(a, b); }

struct min_cost_max_flow {
	struct edge {
		int to;
		ll cap, cost;
		int rev;
		bool isrev;
	};

	int n, s, t;
	ll neg;
	vector<vector<edge>> g;
	vector<ll> d, h, dist, prevv, preve;

	ll flow(vector<ll> d0) {
		ll res = 0;
		priority_queue<PII, vector<PII>, greater<PII>> que;
		h.assign(n, 0);
		preve.assign(n, -1);
		prevv.assign(n, -1);
		ll f = 0;
		REP(i, d.size()) {
			if (i < (ll)d0.size()) d[i] += d0[i];
			if (d[i] > 0) add_edge(s, i, d[i], 0), f += d[i];
			else if (d[i] < 0) add_edge(i, t, -d[i], 0);
		}
		while (f > 0) {
			dist.assign(n, INF);
			dist[s] = 0;
			que.push({ 0, s });
			while (que.size()) {
				PII p = que.top(); que.pop();
				int v = p.second;
				if (dist[v] < p.first) continue;
				REP(i, g[v].size()) {
					edge &e = g[v][i];
					if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
						dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
						prevv[e.to] = v;
						preve[e.to] = i;
						que.push({ dist[e.to], e.to });
					}
				}
			}
			if (dist[t] == INF) return -1;
			REP(v, n) h[v] += dist[v];
			ll d = f;
			for (int v = t; v != s; v = prevv[v]) {
				chmin(d, g[prevv[v]][preve[v]].cap);
			}
			f -= d; res += d * h[t];
			for (int v = t; v != s; v = prevv[v]) {
				edge &e = g[prevv[v]][preve[v]];
				e.cap -= d;
				g[v][e.rev].cap += d;
			}
		}
		return neg + res;
	} 

	min_cost_max_flow(int n0) : n(n0+2), s(n0), t(n0+1), neg(0), g(n0+2), d(n0+2) {}

	void add_edge(int from, int to, ll cap, ll cost) {
		if (cost >= 0) {
			g[from].push_back({ to, cap, cost, (int)g[to].size(), false });
			g[to].push_back({ from, 0, -cost, (int)g[from].size() - 1, true });
		}
		else {
			d[from] -= cap;
			d[to] += cap;
			neg += cap * cost;
			add_edge(to, from, cap, -cost);
		}
	}

	ll flow(int S, int T, ll f) {
		vector<ll> d0(n);
		d0[S] = f, d0[T] = -f;
		return flow(d0);
	}
};

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), T(m);
	vector<vector<ll>> b(m, vector<ll>(n));
	REP(i, n) cin >> a[i];
	REP(i, m) REP(j, n) cin >> b[i][j];
	REP(i, m) cin >> T[i];

	min_cost_max_flow graph(n + m + 4);
	ll s = n + m + 2, t = n + m + 3, x = n + m, y = n + m + 1;
	graph.add_edge(s, x, n, 0);
	graph.add_edge(s, y, n-k, 0);
	REP(i, m) graph.add_edge(y, i, T[i], 0);
	REP(i, n) graph.add_edge(m + i, t, 1, 0);
	REP(i, n) graph.add_edge(x, m + i, 1, -a[i]);
	REP(i, m) REP(j, n) graph.add_edge(i, m + j, 1, -b[i][j]);

	cout << -graph.flow(s, t, n) << endl;
}


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

int main(){
    char c;
    do{
        scanf("%c", &c);
        if (('A'<=c) && (c<='Z'))
            c += 32;
        else if (('a'<=c) && (c<='z'))
            c -= 32;
        cout << c;
    }while(c!='\n');
}


Measured memory_bytes: 3152
N=int(input())
A=list(map(int,input().split()))
from collections import Counter
c=Counter(A)
r=0
from math import log2
for n in sorted(list(c),reverse=True):
    m=2**int(log2(n)+1)
    if m==2*n:
        r+=c[n]//2
    else:
        r+=min(c[n],c[m-n])
        c[m-n]=max(c[m-n]-c[n],0)
print(r)

Measured memory_bytes: 58488
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,cnt,ans,now;
char mp[1005][1005];
struct board{
	int x,y;
}t[50000005];
signed main() {
	cin>>n>>m;
	for (int i=1;i<=n;++i) {
		for (int j=1;j<=m;++j) {
			cin>>mp[i][j];
			if (mp[i][j]=='#') {
				t[++cnt]=(board){i,j};
			}
		}
	}
	now=1;
	for (;;) {
		if (cnt>=n*m) break;
		int cur_cnt=cnt;
		for (int i=now;i<=cur_cnt;++i) {
			int x=t[i].x,y=t[i].y;
			if (x-1>=1) {
				if (mp[x-1][y]=='.') {
					mp[x-1][y]='#';
					t[++cnt]=(board){x-1,y};
				}
			}
			if (y-1>=1) {
				if (mp[x][y-1]=='.') {
					mp[x][y-1]='#';
					t[++cnt]=(board){x,y-1};
				}
			}
			if (x+1<=n) {
				if (mp[x+1][y]=='.') {
					mp[x+1][y]='#';
					t[++cnt]=(board){x+1,y};
				}
			}
			if (y+1<=m) {
				if (mp[x][y+1]=='.') {
					mp[x][y+1]='#';
					t[++cnt]=(board){x,y+1};
				}
			}
		}
//		for (int i=1;i<=n;++i) {
//			for (int j=1;j<=m;++j) {
//				cout<<mp[i][j]<<' ';
//			}
//			cout<<endl;
//		}
//		cout<<endl;
		now=cur_cnt+1;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17664
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  vector<ll> h(n);
  REP(i, n)
  {
    cin >> h[i];
  }
  ll res = 0;
  ll tmp = 0;
  REP(i, n - 1)
  {
    if (h[i] >= h[i + 1])
    {
      tmp++;
    }
    else
    {
      res = max(res, tmp);
      tmp = 0;
    }
  }
  res = max(tmp, res);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
function Main(input) {
  input = input.split("\n");
  input[0] = input[0].split(" ");
  input[1] = input[1].split(" ");
  var N=parseInt(input[0][0]);
  var M=parseInt(input[0][1]);
  var path=Math.max(M-N,0);
  if(path===0){
    console.log(0);
    return;
  }
  (function(){for(var i=0;i<M;i++){
    input[1][i]=parseInt(input[1][i]);
  }})();
  var Xs=input[1];
 
  var x_axis=[];
  var delta=[];
  (function(){for(var j=0;j<200001;j++){
    x_axis[j]=0;
    delta[j]=0;
  }})();
  (function(){for(var k=0;k<M;k++){
    x_axis[Xs[k]+100000]++;
  }})();
  (function(){
    var counter=0;
    var i=0;
    while(x_axis[i]===0){
      i++;
    }
    for(i=i+1;i<200001;i++){
      if(x_axis[i]===0){
        counter++;
        continue;
      }
      delta[counter+1]++;
      counter=0;
    }
  })();

  (function(){
    var counter=0;
    var deltax=0;
    for(var i=0;i<path;i++){
      while(delta[deltax]===0){
        deltax++;
      }
      delta[deltax]--;
      counter+=deltax;
      deltax=0;
    }
    console.log(counter);
  })();  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22188
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
long double xs,xt,ys,yt,x[1010],y[1010],r[1010];
long double d[1010],cost[1010][1010];int n;
bool used[1010];
void dij(int S,int T)
{
	for(int i=1;i<=T;i++)d[i]=10000000000000000.0;d[S]=0.0;
	memset(used,0,sizeof(used));
	while(1)
	{
		int u=-1;
		for(int i=1;i<=T;i++)if(used[i]==0&&(u==-1||d[i]<d[u]))u=i;
		if(u==-1)break;used[u]=1;
		for(int i=1;i<=T;i++)d[i]=min(d[i],d[u]+cost[u][i]);
	}
}
int main()
{
	cin>>xs>>ys>>xt>>yt>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i]>>r[i];
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)cost[i][j]=cost[j][i]=max((long double)0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]);
	int S=n+1,T=n+2;cost[S][T]=sqrt((xt-xs)*(xt-xs)+(yt-ys)*(yt-ys));cost[S][S]=cost[T][T]=0;
	for(int i=1;i<=n;i++)cost[S][i]=cost[i][S]=max((long double)0.0,sqrt((x[i]-xs)*(x[i]-xs)+(y[i]-ys)*(y[i]-ys))-r[i]);
	for(int i=1;i<=n;i++)cost[T][i]=cost[i][T]=max((long double)0.0,sqrt((x[i]-xt)*(x[i]-xt)+(y[i]-yt)*(y[i]-yt))-r[i]);
	dij(S,T);printf("%.15lf",(double)d[T]);return 0;
}

Measured memory_bytes: 16128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0)
				break;
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++)
					System.out.printf("#");
				System.out.println();
			}
			System.out.println();
		}
	}
}	


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

int main() {
    int x, y;
    scanf("%d %d", &x, &y);
    string ans;
    if (x == 0) {
        if (y < 1912) {
            ans = "M" + to_string(y-1867);
        } else if (y < 1926) {
            ans = "T" + to_string(y-1911);
        } else if (y < 1989) {
            ans = "S" + to_string(y-1925);
        } else {
            ans = "H" + to_string(y-1988);
        }
    } else if (x == 1) {
        ans = to_string(y+1867);
    } else if (x == 2) {
        ans = to_string(y+1911);
    } else if (x == 3) {
        ans = to_string(y+1925);
    } else {
        ans = to_string(y+1988);
    }
    printf("%s\n", ans.c_str());
}


Measured memory_bytes: 3332
#include <iostream>
#define LL long long
using namespace std;

LL N,L,a[100010],ans[100010],K;

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

    int i;
    for (i=1; i<=N; i++) cin >> a[i];

    int p=0;
    for (i=1; i<N; i++)
        if (a[i]+a[i+1]>=L) p=i;

    if (p==0){
        cout << "Impossible\n";
        return 0;
    }

    K=1;
    ans[1]=p;
    for (i=p-1; i>=1; i--)
        ans[++K]=i;

    for (i=p+1; i<N; i++)
        ans[++K]=i;

    cout << "Possible\n";
    for (i=K; i>0; i--)
        cout << ans[i] << "\n";

    return 0;
}


Measured memory_bytes: 2432
K, T = list(map(int,input().split()))
a = list(map(int,input().split()))

a.sort()

maxi = a[-1]
if K /2>= maxi+1:
    print(0)
    exit()

ans =None
if K%2==0:
    ans =(maxi - K//2)*2 -1

else:
    ans = (maxi - K//2 - 1)*2
if ans<0:
    ans=0


print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int64_t X,K,D;
 cin >> X >> K >> D;
 
 int64_t Q=abs(X)/D;
 int64_t mod=abs(X)%D;
 int64_t ans;
 
 if(Q>=K) {
     ans=abs(X)-D*K;
 }
 else {
     if((K-Q)%2==0) {
         ans=mod;
     }
     else{
         if(abs(mod+D)<abs(mod-D)) {
             ans=abs(mod+D);
         }
         else {
             ans=abs(mod-D);
         }
     }
 }
       
 cout << ans << endl;
 }
 


Measured memory_bytes: 3608