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

#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll M   = 1e9+7;
const ll mxn = 1e5+7;

int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,h,u,v,x,y,z;
    cin>>n>>x>>t;
    m = ceil((double)n/x)*t;
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;


int main(void) {
	double a, b;

	cin >> a >> b;
	cout << ceil((a + b) / 2) << endl;


	return 0;
}

Measured memory_bytes: 384
package main

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

const MaxBuf = 200100
var buf []byte
var sc = bufio.NewScanner(os.Stdin)

func init() {
   sc.Split(bufio.ScanWords)
   sc.Buffer(buf,MaxBuf)
}

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

func readInt64() int64 {
   sc.Scan()
   r,_ := strconv.ParseInt(sc.Text(),10,64)
   return r
}

func readInt() int {
   sc.Scan()
   r,_ := strconv.Atoi(sc.Text())
   return r
}

func main() {
	//s := readString()
	//t := readString()
	var s,t string
	fmt.Scan(&s)
	fmt.Scan(&t)

	ms := make(map[rune][]int)	//runeはunicodeのコードポイント
	for i,v := range s {		// vはrune型 
	    ms[v] = append(ms[v],i)
	}
	imp := false
	loop := 0
	c := -1

	for _,v := range t {
		if len(ms[v]) == 0 {
			imp = true
			break
		}
		idx := sort.SearchInts(ms[v],c+1)	// 見つからない場合maxindex+1(=len)が返る
		if idx == len(ms[v]) {
			loop++
			c = ms[v][0]
		} else {
			c = ms[v][idx]
		}
	}

	ans := loop * len(s) + c + 1
	if (imp) {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}

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

int main() {
    int k;
    vector<int> a(5);
    for(int i = 0; i < 5; ++i) cin >> a[i];
    cin >> k;
    bool f = false;
    for(int i = 0; i < 5; ++i) {
        for(int j = 0; j < 5; ++j) {
            f |= abs(a[i] - a[j]) > k;
        }
    }

    cout << (f ? ":(" : "Yay!") << endl;
}

Measured memory_bytes: 256
N = int(input())
masu = []
for n in range(2):
    t = list(map(int, input().split()))
    masu.append(t)

ans = 0

for n in range(N):
    s = sum(masu[0][0:n+1])
    #for k in range(n,N)
    p = sum(masu[1][n:N+1])
    t = s + p
    ans = max(ans, t)

print(ans)


Measured memory_bytes: 3060
from collections import defaultdict
from functools import reduce

P = 10**9 + 7

N = int(input())

rem = list(range(2, N+1))
dic = defaultdict(int)

while len(rem) > 0:
  n = rem[-1]
  for d in range(2, int(n**0.5) + 1):
    if n % d == 0:
      dic[d] += 1
      rem[-1] //= d
      break
  else:
    dic[n] += 1
    rem.pop()

print(reduce(lambda x, y: x*(y+1)%P, dic.values(), 1))


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	vector<int> dp(n,INT_MAX);
	for(auto &x: v)	{
		cin>>x;
	}
	dp[0]=0;
	for(int i{};i<n;i++){
		for(int j:{i+1,i+2}){
			if(j<n){
				dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));
			}
		}
	}
	cout<<dp[n-1];
}



Measured memory_bytes: 3988
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>

using namespace std;

bool sortBySecond(pair<int, long> a, pair<int, long> b) {
    return (a.second < b.second);
}

int main() {

    int N, M;
    cin >> N >> M;
    vector<long long> As;
    for (int i = 0; i < N; i++) {
        long long A;
        cin >> A;
        As.push_back(A);
    }

    vector<pair<int, long>> BCs;

    for (int i = 0; i < M; i++) {
        int B;
        long C;
        cin >> B >> C;
        BCs.emplace_back(B, C);
    }

    sort(As.begin(), As.end());

    sort(BCs.rbegin(), BCs.rend(), sortBySecond);

//    for (int i = 0; i < M; i++) {
//        cout << BCs[i].first << ",";
//    }

//    cout << "\n";
    int aP = 0;

    bool end = false;

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

        if (end) {
            break;
        }

        for (int j = 0; j < BCs[i].first; j++) {

            if (aP >= N) {
                end = true;
                break;
            }

            if (As[aP] < BCs[i].second) {
                As[aP] = BCs[i].second;
                aP += 1;
            } else {
                end = true;
                break;
            }
        }
    }

    long long sum = 0;

    for (int i = 0; i < N; i++) {
//        cout << As[i] << ",";
        sum += As[i];
    }

//    cout << "\n";

    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout<<((s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi")?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define Max 9999999999
int n;
int a[200000];
int l[100002];
int r[100002];
typedef long long llong;

llong mergelr(int left,int mid,int right){
    int n1=0,n2=0;
    for(int i=left;i<mid;i++){
        l[n1++]=a[i];
    }
    l[n1]=Max;
    for(int i=mid;i<right;i++){
        r[n2++]=a[i];
    }
    r[n2]=Max;
    int x=0,y=0;
    llong re=0;
    for(int i=left;i<right;i++){
        if(r[y]<l[x]){
            a[i]=r[y];
            re+=n1-x;
            y++;
        }
        else{
            a[i]=l[x];
            x++;
        }
    }
    return re;
}
llong Merge(int left,int right){
    if(left+1<right){
        int mid=(right+left)/2;
        llong v1=Merge(left,mid);
        llong v2=Merge(mid,right);
        llong v3=mergelr(left,mid,right);
        return v1+v2+v3;
    }
    return 0;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    llong re=Merge(0,n);
    cout<<re<<endl;
    return 0;
}



Measured memory_bytes: 4668
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n,k;
    cin>>n>>k;
    vector<int>l(n);
    cin>>l;
    sort(RALL(l));
    int ans=0;
    REP(i,k) {
        ans+=l[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main() {
    string st;
    cin >> st;
    bool c, f;
    c = f = false;
    for (int i=0; i<st.length(); i++) {
        if (st[i] == 'C') c = true;
        if (c && st[i] == 'F') f = true;
    }
    if (!f) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

int main() {

	int X;

	int digit = 0;

	cin >> X;

	int a = 0;
	int b = 0;
	int c = 0;

	a = X / 100;
	b = (X - a * 100) / 10;
	c = X - a * 100 - b * 10;

	if (a == 7 || b == 7 || c == 7) {
		cout << "Yes" << endl;

	}
	else { 
		cout << "No" << endl; 
	}

}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
#define pii pair<lli,lli>
#define vi vector <lli>
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y);
lli modInverse(lli b, lli m)
{
    lli x, y;
    lli g = gcdExtended(b, m, &x, &y);
    if (g != 1)
        return -1;
    return (x%m + m) % m;
}
lli modDivide(lli a, lli b, lli m)
{
    a = a % m;
    lli inv = modInverse(b, m);
    return (inv * a) % m;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
    lli x1, y1;
    lli gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    string s;
    lli cnta=0,cntb=0,cntc=0,cntd=0;
    rep(i,n){
    	cin>>s;
    	if(s=="AC")
    	cnta++;
    	if(s=="WA")
    	cntb++;
    	if(s=="TLE")
    	cntc++;
    	if(s=="RE")
    	cntd++;
	}
	cout<<"AC x "<<cnta<<"\n";
	cout<<"WA x "<<cntb<<"\n";
	cout<<"TLE x "<<cntc<<"\n";
	cout<<"RE x "<<cntd;
    return 0;
}


Measured memory_bytes: 3656
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int par[N],siz[N];

int findset(int a)
{
    if(par[a]==a)
    return a;
    return par[a]=findset(par[a]);
}
void unionset(int a, int b)
{
    a=findset(a);
    b=findset(b);
    if(a==b)
    return;
    if(siz[a]>siz[b])
    swap(a, b);
    par[a]=b;
    siz[b]+=siz[a];
}

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    vector <pair<pii, int> > v(n);
    for(int i=0;i<n;i++)
    {
        siz[i]=1;
        par[i]=i;
    }
    for(int i=0;i<n;i++)
    {
        cin>>v[i].ff.ff>>v[i].ff.ss;
        v[i].ss=i;
    }
    sort(all(v));
    stack <pii> s;
    for(int i=0;i<n;i++)
    {
        int x=v[i].ff.ff, y=v[i].ff.ss, ind=v[i].ss;
        //cout<<x<<" "<<y<<" "<<ind<<"\n";
        int z=y;
        while(!s.empty() && s.top().ff<y)
        {
            z=min(z, s.top().ff);
            unionset(ind, s.top().ss);
            s.pop();
        }
        s.push({z, ind});
    }
    for(int i=0;i<n;i++)
    cout<<siz[findset(i)]<<"\n";
}

Measured memory_bytes: 11108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((a + b) < (c + d))
 	    cout << "Right" << endl;
    else if ((a + b) > (c + d))
        cout << "Left" << endl;
    else
        cout << "Balanced" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = unsigned long long;
const long long INF = 1LL << 60;
 
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;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    int r; cin >> r;
    cout << 3 * pow(r, 2) << endl;;
}

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

int main() {
  int n,d;
  cin >> n >> d;
  boost::multi_array<int,2> x(boost::extents[n][d]);
  rep(i,n){
    rep(j,d){
      cin >> x[i][j];
    }
  }
  int count = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      double distance = 0;
      rep(k,d){
        distance += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      distance = sqrt(distance);
      if(distance == floor(distance)) count++;
    }
  }

  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
<?php
    list($H,$N) = array_map('intval',explode(" ",trim(fgets(STDIN))));

    $A_array = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    if($H<=array_sum($A_array)){
        echo "Yes\n";
    }else{
        echo "No\n";
    }
?>

Measured memory_bytes: 25808
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int money = scan.nextInt();
		int y500 = money / 500;
		int y5 = money%500 / 5;
		System.out.println(1000*y500 + y5*5);
	}
}

Measured memory_bytes: 21844
"use strict";
function Main(input) {
  const args = input.split('\n');
  const N = parseInt(args.shift());
  let count = 0;
  let countA = 0;
  let countB = 0;
  let both = 0;
  args.forEach(f => {
    count += (f.length - f.replace(/AB/g, '').length) / 2;
    let endB = f.charAt(0) === 'B';
    if (endB) {
      countB ++;
    }
    let startA = f.charAt(f.length - 1) === 'A';
    if (startA) {
      countA ++;
    }
    if (startA && endB) {
      both ++;
    }
  });
  count += countA < countB ? countA : countB;
  count += (both > 0 && both === countA && both === countB) ? -1 : 0;
  console.log(count);
}

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

Measured memory_bytes: 22088
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    ll h; cin>>h;
    vector<pii> a(n);
    vector<pii> b(n);
    rep(i,0,n){
        cin>>a[i].first>>b[i].first;
        a[i].second=i;b[i].second=i;
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    ll cnt=0;
    int amx=a[0].first;
    int amxi=a[0].second;
    int bmx=b[0].first;
    int bmxi=b[0].second;
    ll res=0;
    rep(i,0,n){
        if(amx<=b[i].first){
            res+=b[i].first;
            cnt++;
        }
        else{
            break;
        }
        if(res>=h){
            cout<<cnt<<endl;
            return 0;
        }
    }
    cnt+=(h-res+(amx-1))/amx;
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 1792
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a, b = List.fill(n)(sc.nextInt()-1)
  val c = Array.fill(n)(0)
  val d = Array.fill(n)(0)
  for (i <- a) {
    c(i) += 1
  }

  for (i <- b) {
    d(i) += 1
  }

  if ((0 until n).exists(i => c(i) + d(i) > n)) {
    println("No")
  } else {
    val cc = c.scanLeft(0)(_+_)
    val cd = d.scanLeft(0)(_+_)
    var m = 0
    for (i <- 1 to n) {
      m = m.max(cc(i) - cd(i-1))
    }
    println("Yes")
    println((b.takeRight(m) ++ b.dropRight(m)).map(_+1).mkString(" "))
  }
}


Measured memory_bytes: 104404
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<cctype>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;

int main()
{
	int taro,hanako;
	taro = hanako = 0;
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		string s1,s2;
		cin >> s1 >> s2;
		if(s1==s2){
			taro++;hanako++;
		}else if(s1>s2){
			taro += 3;
		}else{
			hanako += 3;
		}
	}
	cout << taro << " " << hanako << endl;
    return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define drp(i,st,ed) for (int i=st;i>=ed;--i)

typedef long long LL;
const int N=200005;

LL a[N],b[N];
LL x[N],v[N];
LL s1[N],s2[N],mx1[N],mx2[N];

int main(void) {
	int n; LL m; scanf("%d%lld",&n,&m);
	rep(i,1,n) scanf("%lld%lld",&x[i],&v[i]);
	rep(i,1,n) {
		s1[i]=s1[i-1]+v[i]-(x[i]-x[i-1]);
		mx1[i]=std:: max(mx1[i-1],s1[i]);
	}
	x[n+1]=m;
	drp(i,n,1) {
		s2[i]=s2[i+1]+v[i]-(x[i+1]-x[i]);
		mx2[i]=std:: max(mx2[i+1],s2[i]);
	}
	LL ans=0;
	ans=std:: max(ans,mx1[n]);
	ans=std:: max(ans,mx2[1]);
	rep(i,1,n) {
		ans=std:: max(ans,s1[i]-x[i]+mx2[i+1]);
		ans=std:: max(ans,s2[i]-(m-x[i])+mx1[i-1]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            long N;
            long[] listA;
            
            N = Read(Console.ReadLine())[0];
            int[] ansCollection = new int[N];
            listA = Read(Console.ReadLine());

            //find negative number
            long[] data = Negative_Min(listA);
            long negNum = data[0];
            long min = data[1];

            long ans = 0;

            if (negNum % 2 == 0)
            {
                foreach (long item in listA) ans += Math.Abs(item);
            }
            else
            {
                foreach (var item in listA) ans += Math.Abs(item);
                ans -= 2 * min;
            }
            Console.WriteLine(ans);

        }


        public static long[] Negative_Min(long[] array)
        {
            int neg = 0;
            long min = Math.Abs(array[0]);

            foreach (var num in array) 
            {
                if (num < 0) neg++;
                long ab = Math.Abs(num);
                if (min > ab) min = ab;
            }
            long[] ans = new long[2] { neg, min };
            return ans;
        }

        private static long[] Read(string input)
        {
            string[] inputs = input.Split(' ');
            long num = inputs.Length;
            long[] ints = new long[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = long.Parse(inputs[i]);
            }
            
            return ints;
        }


    }
}


Measured memory_bytes: 31452
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
long long n, a, x[51], dp[51][51][2501] = {}, ans = 0;
int main(){
	cin >> n >> a;
	for (int i = 1; i <= n; i++)
		cin >> x[i];
	dp[0][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int k = 0; k < i; k++) {
			for (int j = 0; j < 2500; j++) {
				if (dp[i - 1][k][j]) {
					if (j + x[i] <= 2500)
						dp[i][k + 1][j + x[i]] += dp[i - 1][k][j];
					dp[i][k][j] += dp[i - 1][k][j];
				}
			}
		}
	}
	for (int i = 1; i <= n; i++){
		ans += dp[n][i][i * a];
	}
	cout << ans << endl;
}



Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define int long long
using namespace std;
using P = pair<double, int>;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, w;
    cin >> n >> w;
    vector<int> wt(n);
    vector<int> va(n);
    for (int i = 0; i < n; i++) {
        cin >> wt[i];
        cin >> va[i];
    }
    vector<vector<int>> dp(n + 1, vector<int>(w + 1, 0));
    for (int i = 1; i < n + 1; i++) {
        for (int j = 1; j < w + 1; j++) {
            if (j < wt[i - 1]) {
                dp[i][j] = dp[i - 1][j];
                continue;
            }
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wt[i - 1]] + va[i - 1]);
        }
    }
    cout << *max_element(dp[n].begin(), dp[n].end()) << "\n";
}

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

using namespace std;
int main(void){
    int n, cnt=0;
    cin >> n;
    vector<int>L(n);
    rep(i, n) cin >> L[i];
    sort(L.begin(), L.end());
    rep(i, n-1){
        cnt += L[i+1]-L[i];
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        long[][] array = new long[n][3];
        for (int i = 0; i < n; i++) {
            array[i][0] = sc.nextLong();
            array[i][1] = sc.nextLong();
            array[i][2] = sc.nextLong();
        }
        
        
        long best = 0;
        int combinationCount = (int)Math.pow(2, 3);
        for (int i = 0; i < combinationCount; i++) {
            String binaryNumber = Integer.toBinaryString(i);
            while (binaryNumber.length() < 3) {
                binaryNumber = "0" + binaryNumber;
            }
            
            long[][] array2 = new long[n][2];
            for (int s = 0; s < n; s++) {
                array2[s][1] = s;
            }
            
            for (int j = 0; j < 3; j++) {
                String str = String.valueOf(binaryNumber.charAt(j));
                
                for (int s = 0; s < n; s++) {
                    if (str.equals("0")) {
                        array2[s][0] += array[s][j];
                    } else {
                        array2[s][0] -= array[s][j];
                    }
                }
            }
            
            Arrays.sort(array2, (a, b) -> Long.compare(a[0], b[0]));
            
            long tmp = 0;
            
            for (int s = n - 1; s > n - 1 - k; s--) {
                tmp += array2[s][0];
            }
            
            best = Math.max(best, tmp);
        }
        System.out.println(best);
    }
}


Measured memory_bytes: 29220
#include <stdio.h>
#include <stdlib.h>

/*
void attempt(int H, int W, int row_0, int row_1, int col_0, int col_1) {
*/
void attempt(int H, int W, int row_x, int col_x, int row_x_is_0, int col_x_is_0) {
	char* haiti_data;
	char** haiti;
	int* count_0;
	int i, j;

	/*
	if (row_0 * H != col_0 * W || row_1 * H != col_1 * H) return;
	if ((row_0 + row_1) != W || (col_0 + col_1) != H) return;
	*/

	haiti_data = malloc(sizeof(char) * (W + 1) * H);
	if (haiti_data == NULL) {
		perror("malloc 1");
		exit(1);
	}
	haiti = malloc(sizeof(char*) * H);
	if (haiti == NULL) {
		perror("malloc 2");
		exit(1);
	}
	count_0 = malloc(sizeof(int) * W);
	if (count_0 == NULL) {
		perror("malloc 3");
		exit(1);
	}

	for (i = 0; i < H; i++) {
		haiti[i] = &haiti_data[(W + 1) * i];
		haiti[i][W] = '\0';
	}
	for (i = 0; i < W; i++) {
		count_0[i] = 0;
	}

	for (i = 0; i < H; i++) {
		int row_0_left = (i < row_x_is_0 ? row_x : W - row_x);
		for (j = 0; j < W; j++) {
			if (row_0_left > 0 && count_0[j] < (j < col_x_is_0 ? col_x : H - col_x)) {
				haiti[i][j] = '0';
				count_0[j]++;
				row_0_left--;
			} else {
				haiti[i][j] = '1';
			}
		}
		if (row_0_left > 0) {
			/* failed */
			free(haiti_data);
			free(haiti);
			free(count_0);
			return;
		}
	}
	for (i = 0; i < W; i++) {
		if (count_0[i] != (i < col_x_is_0 ? col_x : H - col_x)) {
			/* failed */
			free(haiti_data);
			free(haiti);
			free(count_0);
			return;
		}
	}
	/* OK */
	for (i = 0; i < H; i++) {
		puts(haiti[i]);
	}
	free(haiti_data);
	free(haiti);
	free(count_0);
	exit(0);
}

int main(void) {
	int H, W, A, B;
	int n, m;
	if (scanf("%d%d%d%d", &H, &W, &A, &B) != 4) return 1;
	/*
	attempt(H, W, A, W-A, B, H-B);
	attempt(H, W, W-A, A, B, H-B);
	*/
	/* col_0はcol_1より小さいことを仮定し、必要に応じて反転 */
	/*
	attempt(H, W, A, W-A, H-B, B);
	attempt(H, W, W-A, A, H-B, B);
	*/
	/*
	attempt(H, W, A, B, 0);
	attempt(H, W, W-A, B, 0);
	attempt(W, H, B, A, 1);
	attempt(W, H, H-B, A, 1);
	*/
	for (n = 0; n < H; n++) {
		for (m = 0; m < W; m++) {
			int row_0_num = A * n + (W-A) * (H-n);
			int col_0_num = B * m + (H-B) * (W-m);
			if (row_0_num == col_0_num) {
				attempt(H, W, A, B, n, m);
			}
		}
	}
	puts("No");
	return 0;
}

/*
0がA → 0がA*H個、1が(W-A)*H個
1がA → 1がA*H個、0が(W-A)*H個

0がB → 0がB*W個、1が(H-B)*W個
1がB → 1がB*W個、0が(H-B)*W個

0か1の割当は固定ではない！
*/

/*
2 2 0 1
で落ちたので、反転する仕組みを入れた。
*/

/*
上からn行は0がA個、1が(W-A)個
残りの(H-n)行は0が(W-A)個、1がA個

左からm列は0がB個、1が(H-B)個
残りの(W-m)列は0が(H-B)個、1がB個
*/


Measured memory_bytes: 2176
from collections import deque;

count, time_slice = map(int, input().split(" "));

data = [];
for i in range(count):
    data += input().split(" ");

def round_robin(data, count, time_slice):
    t = 0;
    data = [[data[i], int(data[i + 1])] for i in range(0, len(data), 2)];
    que = deque(data);
    while len(que) > 0:
        current = que.popleft();
        if current[1] > time_slice:
            current[1] -= time_slice;
            t += time_slice;
            que.append(current);
        else:
            t += current[1];
            print(current[0], t);


round_robin(data, count, time_slice);


Measured memory_bytes: 14644
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int a, b, c;
    cin>>a>>b>>c;
    if(a==b){
        cout<<c<<endl;
    }else if(a==c){
        cout<<b<<endl;
    }else{
        cout<<a<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int n, d, a[500005];
int pos[500005], mxp[500005];

int main(){
	scanf("%d %d",&n,&d);
	pos[0] = d;
	for(int i=1; i<=n; i++){
		scanf("%d",&a[i]);
		pos[i] = min(pos[i-1], abs(pos[i-1] - a[i]));
	}
	for(int i=n; i; i--){
		int st = 0, ed = 1e9 + 5;
		while(st != ed){
			int m = (st+ed+1)/2;
			if(max(m - a[i], min(m, a[i] / 2)) <= mxp[i+1]) st = m;
			else ed = m-1;
		}
		mxp[i] = st;
	}
	int q;
	scanf("%d",&q);
	while(q--){
		int x;
		scanf("%d",&x);
		puts(pos[x-1] > mxp[x+1] ? "YES": "NO");
	}
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int a,b;

int main(){
	cin >> a >> b;
	
	cout << ((a*b)%2?"Odd":"Even") << endl;
	return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
static const bool TAKAHASHI_TURN = false;
static const bool AOKI_TURN = true;

class Monster {
public:
    Monster() = default;

    void attack(Monster& enemy) {
        enemy.m_hitPoint -= min(enemy.m_hitPoint, m_attackPoint);
    }

    bool isDead() {
        return m_hitPoint == 0;
    }

    void read() {
        cin >> m_hitPoint >> m_attackPoint;
    }

private:
    int m_hitPoint;
    int m_attackPoint;
};

int main() {
    Monster takahashi, aoki;
    takahashi.read();
    aoki.read();

    for (bool turn = TAKAHASHI_TURN; !takahashi.isDead() and !aoki.isDead(); turn = !turn) {
        switch (turn) {
            case TAKAHASHI_TURN:
                takahashi.attack(aoki);
                break;
            case AOKI_TURN:
                aoki.attack(takahashi);
                break;
        }
    }

    cout << (aoki.isDead() ? "Yes" : "No") << endl;

    return 0;
}



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

const int N = 2005, mod = 924844033;
typedef long long LL;

void reduce(int &x) { x += x >> 31 & mod; }

int n, k, dp[N][N], s[N][N], max, f[N];
void calc(int n) {
	dp[0][0] = 1, s[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= i; ++j) {
			dp[i][j] = 0;
			if (j >= 1) reduce(dp[i][j] += dp[i - 1][j - 1] - mod);
			if (i >= 2) reduce(dp[i][j] += dp[i - 2][j] - mod);
			if (i > 1 && j) reduce(dp[i][j] -= 2LL * s[i - 2][j - 1] % mod);
			reduce(s[i][j] = dp[i][j] - s[i - 1][j]);
		}
	}
}
void update(int *A) {
	static int B[N];
	for (int i = 0; i <= n; ++i) B[i] = 0;
	for (int i = 0; i <= max; ++i)
		for (int j = 0; j <= n - i; ++j)
			B[i + j] = (B[i + j] + (LL) A[i] * f[j]) % mod;
	for (int i = 0; i <= n; ++i) f[i] = B[i];
}
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> k, calc(max = (n + k - 1) / k);
	int t = (n - 1) % k + 1;
	f[0] = 1;
	for (int i = 0; i < t; ++i) update(dp[max]);
	for (int i = t; i < k; ++i) update(dp[max - 1]);
	int factor = 1, ans = 0;
	for (int i = 0; i <= n; ++i) {
		ans = (ans + (LL) f[i] * factor) % mod;
		factor = (LL) factor * (i + 1) % mod;
	}
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 30848
#include <stdio.h>

int main(void){
  int i,t,N;
  int a[100];
  t = 0;
  scanf("%d", &N);
  for(i=0;i<N;i++){
    scanf("%d", &a[i]);
    if(a[i]%2==0 && t == 0){
      if(a[i]%3!=0 && a[i]%5!=0)
        t = 1;
    }
  }
  if(t==1)
      printf("DENIED");
  else
      printf("APPROVED");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int n, m;
    cin >> n >> m;
    vi a[n + 1];
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for(int i = 1; i <= n; i++) cout << a[i].size() << "\n";
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

struct A {
	int x, y, z;
};
bool operator>(A a, A b) {
	if (a.x != b.x) return a.x > b.x;
	if (a.y != b.y) return a.y > b.y;
	return a.z > b.z;
}
bool operator<(A a, A b) {
	if (a > b) return 0;
	return 1;
}
int n;
int a[200000], b[200000];
bool c[200000];
signed main() {
	cin >> n;
	priority_queue<A>p, q;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		p.push(A{ a[i] + b[i],a[i],i });
		q.push(A{ a[i] + b[i],b[i],i });
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			A t = p.top(); p.pop();
			while (c[t.z]) {
				t = p.top(); p.pop();
			}
			ans += t.y;
			c[t.z] = 1;
		}
		else {
			A t = q.top(); q.pop();
			while (c[t.z]) {
				t = q.top(); q.pop();
			}
			ans -= t.y;
			c[t.z] = 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 7468
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<int, int> P;

long long int b[2001][2001];

int main(void) {
	long long int n;
	long long int x;
	long long int a[2001];
	long long int c[2001] = {};
	
	long long int count = 0;


	cin >> n >> x;
	FOR(i, 1, n) {
		cin >> a[i];
	}

	FOR(i, 1, n) {
		b[0][i] = a[i];
		c[0] += a[i];
	}
	//cout << c[0] << endl;
	for(long long int k=1;k<=n-1;k++){
		long long int d = 0;
		FOR(i, 1, n) {
			int q;
			if (i - k > 0) {
				if (b[k - 1][i] > a[i - k]) {
					b[k][i] = a[i - k];
				}
				else {
					b[k][i] = b[k - 1][i];
				}
			}
			else {
				q = k - i;
				if (b[k - 1][i] > a[n - q]) {
					b[k][i] = a[n - q];
				}
				else {
					b[k][i] = b[k - 1][i];
				}
			}
			d += b[k][i];
		}
		c[k] = k*x + d;
		//cout << k << " " << c[k] << " " << d << endl;
	}
	
	/*FOR(i, 0, n - 1) {
		cout << c[i] << endl;
	}*/

	long long int r = 1e18 + 1;
	FOR(i, 0, n - 1) {
		if (r > c[i]) {
			r = c[i];
		}
	}
	cout << r << endl;

	return 0;
}

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

using namespace std;

int main() {
	int a , b , c , k;
	cin >> a >> b >> c >> k;
	if(k <= a) cout << k << "\n";
	else if(k > a && k <= a + b) cout << a << "\n";
	else {
		cout << a - (k - a - b) << "\n";
	}
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
int main(void){
    
    int n;
    std::cin >> n;
    std::vector<std::vector<std::pair<int, bool>>> testimony(n);
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        for (int j = 0; j < a; j++) {
            int num;
            int ToF;
            std::cin >> num >> ToF;
            if (ToF == 1) testimony[i].push_back({num, true});
            else testimony[i].push_back({num, false});
        }
    }
    
    int ans = 0;
    
    for (int bit = 0; bit < (1<<n); bit++) {
        int cnt = 0;
        std::vector<bool> check(n);
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) check[i] = true;
            else check[i] = false;
        }
        bool flag = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < testimony[i].size(); j++) {
                if (!check[i]) break;
                if (check[testimony[i][j].first-1] != testimony[i][j].second) flag = false;
            }
        }
        if (flag) {
            for (int i = 0; i < n; i++) {
                if (check[i]) cnt++;
            }
        }
        ans = std::max(ans, cnt);
    }
    
    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 3636
import java.io.PrintWriter;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		boolean[][] a = new boolean[H][W];
		for(int i=0; i<H; i++) {
			String str = sc.next();
			for(int j=0; j<W; j++)
				a[i][j] = str.charAt(j)=='#';
		}

		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				pw.print((i==0 || (i<H-1 && (j%2==0 || a[i][j]))) ? '#' : '.');
			}
			pw.println();
		}
		pw.println();
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				pw.print((i==H-1 || (i>0 && (j%2==1 || a[i][j]))) ? '#' : '.');
			}
			pw.println();
		}
		
		sc.close();
		pw.close();
	}
}


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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"
#define llevel 20
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}

int _runtimeTerror_()
{
	ll n,ans=0;
	cin>>n;
	map<ll,ll> m;
	ll num[n];
	for(ll i=0;i<n;++i)
	{
		cin>>num[i];
		m[num[i]]++;
	}
	for(auto j:m)
	{
		ans+=j.S*(j.S-1)/2;
	}
	for(int i=0;i<n;++i)
	{
		ll x=m[num[i]];
		cout<<ans-x*(x-1)/2+(x-1)*(x-2)/2<<endl;
	}
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	return 0;
}


Measured memory_bytes: 11136
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, A, B;
    scan(N, A, B);
    writeln((MOD * 2 + powmod(2, N) - 1 - c(N, A) - c(N, B)) % MOD);
}

long c(long n, long k)
{
    long a = 1, b = 1;
    foreach (i; 0 .. k)
    {
        a = a * (n - i) % MOD;
        b = b * (i + 1) % MOD;
    }
    return a * powmod(b, MOD - 2) % MOD;
}

/// x^^n % m
T powmod(T = long)(T x, T n, T m = 10 ^^ 9 + 7)
{
    if (n < 1)
        return 1;
    if (n & 1)
    {
        return x * powmod(x, n - 1, m) % m;
    }
    T tmp = powmod(x, n / 2, m);
    return tmp * tmp % m;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
en=1000
kab=0
for i in range(len(a)-1):  
  if a[i]<a[i+1]:
    kab=en//a[i]
    en=en-kab*a[i]
    en+=kab*a[i+1]
print(en)

Measured memory_bytes: 9176
#include <cstring>
#include <cstdio>
const int mo=1000000007;
int f[1<<19],g[1<<19],a[25][25];
int lowbit(int x){return x&-x;}
int main(){
	memset(a,-1,sizeof a);
	int n,m,k;
	scanf("%d%d%d\n",&n,&m,&k);n--;
	for (int i=1;i<=k;i++){
		int x,y,z;
		scanf("%d%d%d\n",&x,&y,&z);
		a[x][y-1]=z;
	}
	f[0]=1;
	int L=1<<n;
	for (int i=1;i<=m;i++)
		for (int j=0;j<n;j++){
			memset(g,0,sizeof g);
			if (a[i][j]!=1)
				for (int s=0;s<L;s++)
					if (!((s>>j)&1)) g[s]=f[s];
			if (a[i][j])
				for (int s=0;s<L;s++)
					(g[(lowbit(s>>j)^1)<<j^s]+=f[s])%=mo;
			memcpy(f,g,sizeof f);
		}
	int ans=0;
	for (int i=0;i<L;i++) (ans+=f[i])%=mo;
	printf("%d\n",ans);
}

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

typedef long long ll;

ll f(ll a, ll b)
{
    if (a == b) return a;
    if (a != 0) return f(0, a-1) ^ f(0, b);
    return ((((b+1)/2) & 1) ? 1 : 0) ^ ((b & 1LL) ? 0 : b); 
}

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

    cout << f(A, B) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int x,y,z,tmp;
    scanf("%d %d %d",&x,&y,&z);

    if(x>y){
        tmp=y;
        y=x;
        x=tmp;
    }
    tmp=0;
    if(y>z){
        tmp=z;
        z=y;
        y=tmp;
    }
    if(x>y){
        tmp=y;
        y=x;
        x=tmp;
    }
    printf("%d %d %d\n",x,y,z);

    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
    using namespace std;
        
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double db;
        
    #define MOD 1000000007
    #define mi 18446744073709551615
    #define ff first
    #define ss second
    #define pb push_back
    #define vii vector<int>
    #define pii pair<int,int>
    #define vpii vector<pii>
     
    int main()
    {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	int T=1;
    	// cin>>T;
    	while(T--)
    	{
            int n;
			cin>>n;
			if(n>=30)
				cout<<"Yes\n";
			else
				cout<<"No\n";
    	}  
    	return 0;
    }

Measured memory_bytes: 3604
import java.util.PriorityQueue;
import java.util.Scanner;

class MyClass implements Comparable<MyClass>{
	String s;int p;
	int i;
	@Override
	  public int compareTo( MyClass o ){
	    return this.s.compareTo(o.s)*100-Integer.compare(this.p,o.p);
	  }
}

public class Main {
	//B Guidebook


	public static void main(String[] args){
		int N;
		Scanner sc = new Scanner(System.in);
		N=sc.nextInt();
		String[]S=new String[N];
		int []P=new int[N];
		PriorityQueue<MyClass> q=new PriorityQueue<MyClass>();

		for(int i=1;i<=N;i++) {
			MyClass m=new MyClass();
			m.s=sc.next();
			m.p=sc.nextInt();
			m.i=i;
			q.add(m);
		}
		for(;!q.isEmpty();) {
			MyClass m=q.poll();
			System.out.println(m.i);
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
using namespace std;
const int N = 2e5+150;
int n,i,j,a[N],balls[N];
vector <int> rez;
int main()
{
    cin>>n;
    for (i=1;i<=n;++i) cin>>a[i];
    for (i=n/2+1;i<=n;++i)
        if (a[i]) balls[i]=1;
    for (i=n/2;i>=1;--i)
    {
        if (a[i]==0)
        {
            int mingi=0;
            for (j=2*i;j<=n;j+=i)
                 if (balls[j]) mingi++;
            if (mingi%2) balls[i]=1;
        }
        if (a[i]==1)
        {
            int mingi=0;
            for (j=2*i;j<=n;j+=i)
                 if (balls[j]) mingi++;
            if (mingi%2==0) balls[i]=1;
        }
    }
    for (i=1;i<=n;++i)
         if (balls[i]) rez.push_back(i);
    cout<<rez.size()<<"\n";
    for (i=0;i<rez.size();++i)
         cout<<rez[i]<<" ";
}




Measured memory_bytes: 2936
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007,inv2=500000004;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
inline int pl(int x,int y){return (x+=y)>=mod?x-mod:x;}
int n,q,a[3030],x[3030],y[3030],dp[3030][3030],tmp[3030][3030],ans;
int main()
{
	scanf("%d %d",&n,&q);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=q;++i)scanf("%d %d",&x[i],&y[i]);
	for(int i=1;i<=n;++i)for(int j=1;j<i;++j)dp[i][j]=1;
	for(int i=q;i;--i)
	{
		int tmp;
		for(int j=1;j<=n;++j)
			if(j!=x[i]&&j!=y[i])
			{
				dp[x[i]][j]=dp[y[i]][j]=1ll*(dp[x[i]][j]+dp[y[i]][j])*inv2%mod;
				dp[j][x[i]]=dp[j][y[i]]=1ll*(dp[j][x[i]]+dp[j][y[i]])*inv2%mod;
			}
		dp[x[i]][y[i]]=dp[y[i]][x[i]]=1ll*(dp[x[i]][y[i]]+dp[y[i]][x[i]])*inv2%mod;
	}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			if(a[i]<a[j])add(ans,dp[i][j]);
	for(int i=1;i<=q;++i)add(ans,ans);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 37120
#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];
  }
  vector<int> sorted_a=a;
  sort(sorted_a.begin(),sorted_a.end());
  map<int,bool> is_odd;
  for(int i=0;i<n;i++){
    is_odd[sorted_a[i]]=(i%2);
  }
  int ir=0;
  for(int i=0;i<n;i++){
    if(i%2!=is_odd[a[i]])ir++;
  }
  cout<<ir/2+(ir%2)<<endl;
  return 0;
}


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

const int Maxn = 105;

int n, x;
int a[Maxn];

int main()
{
    scanf("%d %d", &n, &x);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    sort(a, a + n);
    int res = 0;
    for (int i = 0; i < n; i++)
        if (i + 1 < n && a[i] <= x || i + 1 == n && a[i] == x) { res++; x -= a[i]; }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
# A - Cookie Exchanges
a,b,c = map(int,input().split())

if a==b==c and c%2==0:
    print(-1)
else:
    ans = 0
    while a%2==b%2==c%2==0:
        ans += 1
        a,b,c = (b+c)//2,(c+a)//2,(a+b)//2
    print(ans)

Measured memory_bytes: 61760