akhauriyash/Code-Regression huggingface dataset:
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        var s = sc.Next();

        int a = (s[0] - '0') * 10 + (s[1] - '0');
        int b = (s[2] - '0') * 10 + (s[3] - '0');

        if (a > 12 || a == 0)
        {
            if (b > 12 || b == 0)
            {
                Console.WriteLine("NA");
            }
            else
            {
                Console.WriteLine("YYMM");
            }
        }
        else
        {
            if (b > 12 || b == 0)
            {
                Console.WriteLine("MMYY");
            }
            else
            {
                Console.WriteLine("AMBIGUOUS");
            }
        }
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140
package main

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

const maxBuf = 200100

var buf []byte = make([]byte, maxBuf)
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 readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}
func main() {

	//fmt.Scan(&n)
	n := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		//fmt.Scan(&a[i])
		a[i] = readInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	ans := a[0]
	c := 1
	for i := 1; i < n-1; i++ {
		ans += a[c]
		if i%2 == 0 {
			c++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6216
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,c=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;++i)cin>>a[i];
  for(int i=0;i<n;++i){
    for(int j=n-1;i<j;--j){
      if(a[j]<a[j-1]){swap(a[j-1],a[j]);++c;}
    }
  }
  for(int i=0;i<n;++i) cout<<a[i]<<((i==n-1)?"\n":" ");
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int A,B,M;cin>>A>>B>>M;
  vector<int>Q(A);for(int i=0; i<A;i++)cin>>Q[i];
  vector<int>W(B);for (int i=0;i<B;i++)cin>>W[i];
  vector<pair<pair<int,int>,int>>C(M);for(int i=0;i<M;i++)cin>>C[i].first.first>>C[i].first.second>>C[i].second;
  int MIN=200000000000;
  auto Q2=Q;auto W2=W;
  sort(Q.begin(),Q.end());sort(W.begin(),W.end());
  MIN=min(MIN,Q[0]+W[0]);
  for(int i=0;i<M;i++){
    MIN=min(MIN,Q2[C[i].first.first-1]+W2[C[i].first.second-1]-C[i].second);
  }
  cout<<MIN<<endl;
}


Measured memory_bytes: 8684
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iX = int.Parse(sS[0]);
            int iY = int.Parse(sS[1]);
            int iA = int.Parse(sS[2]);
            int iB = int.Parse(sS[3]);
            int iC = int.Parse(sS[4]);
            List<ClsApl> lstApl = new List<ClsApl>();
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++) { lstApl.Add(new ClsApl() { iCol = 2, iDes = int.Parse(sS[i]) }); }     // 赤
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++) { lstApl.Add(new ClsApl() { iCol = 1, iDes = int.Parse(sS[i]) }); }     // 緑
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++) { lstApl.Add(new ClsApl() { iCol = 0, iDes = int.Parse(sS[i]) }); }     // 無

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstApl.Sort(delegate (ClsApl mca1, ClsApl mca2) { return mca2.iDes - mca1.iDes == 0 ? mca2.iCol - mca1.iCol : mca2.iDes - mca1.iDes; });   // 美味さの降順の色の降順
            int iXiY = iX + iY;
            int iRedZ = iX, iGrnZ = iY, iLesC = 0;                  // それぞれの色の数
            long iRedS = 0L, iGrnS = 0L, iLesS = 0L;                // それぞれの色の美味さの合計
            for (int i = 0; i < lstApl.Count; i++)
            {
                if (iRedZ > 0 && lstApl[i].iCol == 2) { iRedZ -= 1; iRedS += (long)lstApl[i].iDes; }
                if (iGrnZ > 0 && lstApl[i].iCol == 1) { iGrnZ -= 1; iGrnS += (long)lstApl[i].iDes; }
                if (             lstApl[i].iCol == 0) { iLesC += 1; iLesS += (long)lstApl[i].iDes; }
                if (iRedZ + iGrnZ == iLesC) { break; }
                if (iRedZ == 0 && iGrnZ == 0) { break; }
            }
            long iSum = iRedS + iGrnS + iLesS;

            // 出力
            System.Console.WriteLine("{0}", iSum.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        private class ClsApl
        {
            public int iCol { get; set; } = 0;          // 色 0:無色 1:赤 2:緑
            public int iDes { get; set; } = 0;          // 美味さ
        }

}


Measured memory_bytes: 43972
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll z = 0;
    cin >> n;
    int a[n + 1], b[n + 1], c[n + 1];
    for (int i = 0 ; i < n ; i++) cin >> a[i];
    for (int i = 0 ; i < n ; i++) cin >> b[i];
    for (int i = 0 ; i < n ; i++) cin >> c[i];
    a[n] = b[n] = c[n] = 1000000007;
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    for (int i = 0; i < n; i++) z += 1ll * (lower_bound(a, a + n + 1, b[i]) - a) * (n - (upper_bound(c, c + n + 1, b[i]) - c));
    cout << z;
}

Measured memory_bytes: 4732
object Main extends App {
	val N = scala.io.StdIn.readLine

	val a = N.split(" ")(0).toInt
	val b = N.split(" ")(1).toInt
	val c = N.split(" ")(2).toInt

	val t = List(a,b,c)

	println(a+b+c - t.max)

}

Measured memory_bytes: 27184
n = int(input())
a = [list(input().split()) for i in range(n)]
x = input()
#print(a)

res = 0
start = 0
for i in range(n):
    if a[i][0] == x:
        start = i+1
for i in range(start,n):
    res += int(a[i][1])
print(res)

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vin l(n),miman(2050),lnum(1050);
    rep(i,n){
        cin>>l[i];
        miman[l[i]+1]++;
        lnum[l[i]]++;
    }
    rep(i,2030)miman[i+1]+=miman[i];
    sort(all(l));
    map<int,int> lfirst;
    int tmp=0;
    rep(i,n){
        if(l[i]!=tmp){
            lfirst[l[i]]=i;
            tmp=l[i];
        }
    }
    ll ans=0;
    rep(i,n)rep2(j,i+1,n){
        ans+=(ll)(miman[l[i]+l[j]]-miman[l[j]]);
        ans-=j-lfirst[l[j]]+1;
    }
    cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;

inline int Loss(const auto &p1, const auto &p2) {
    return abs(p1.first - p2.first) + abs(p1.second - p2.second);
}

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

    int h, w, d;
    cin >> h >> w >> d;

    vector<pair<int, int>> pos(h * w);
    for (int i = 0; i < h; ++i) {
        for (int j = 0, a; j < w; ++j) {
            cin >> a;
            pos[a - 1] = make_pair(i, j);
        }
    }

    const int len = (h * w) / d + 2;
    vector<vector<int>> s(d, vector<int>(len + 1));
    for (int i = 0; i < d; ++i) {
        int cur = 0;
        while (d * (cur + 1) + i < h * w) {
            s[i][cur + 1] = Loss(pos[i + cur * d], pos[i + (cur + 1) * d]);
            ++cur;
        }
    }

    for (int i = 0; i < d; ++i)
        for (int j = 1; j < len; ++j)
            s[i][j] += s[i][j - 1];

    int q, l, r;
    cin >> q;
    while (q--) {
        cin >> l >> r;
        --l; --r;
        int li = l % d, lj = l / d;
        int ri = r % d, rj = r / d;

        if (lj == 0)
            cout << s[ri][rj] << '\n';
        else
            cout << s[ri][rj] - s[li][lj] << '\n';
    }

    return 0;
}


Measured memory_bytes: 6144
if __name__ == "__main__":
    n, m, x = map(int, input().split())

    c = []
    a = []

    for _ in range(n):
        cost, *rikaido = map(int, input().split())
        c.append(cost)
        a.append(rikaido)

    INF = float("inf")
    ans = INF
    
    for bit in range(1 << n):
        price_total = 0
        learn_total = [0] * m

        for i in range(n):
            if (bit >> i) & 1:
                # 買う場合
                price_total += c[i]
                for j in range(m):
                    learn_total[j] += a[i][j] 
        
        # 判定
        judge = True
        for j in range(m):
            if learn_total[j] < x:
                judge = False
                break
        
        if judge:
            ans = min(ans, price_total)
        
    if ans == INF:
        print(-1)
    else:
        print(ans)

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

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


if(A == 1) A =14;
if(B == 1) B =14;

if(A>B){
  cout << "Alice" << endl;
}else if(A<B){
  cout << "Bob" << endl;
}else{
  cout << "Draw" << endl;
}
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;

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

    int y = 0;
    int c = x;


    while(c >= 15) {
            y += 200;
            c -= 15;
    }

    cout << x*800 - y << endl;

    

    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    P = list(map(int, input().split()))
    cnt = 0
    for i in range(N - 1):
        if P[i] == i + 1:
            cnt += 1
            P[i + 1], P[i] = P[i], P[i + 1]
    if P[N - 1] == N:
        cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20564
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s[1000] = {""};
	int m[1000] = {0};
	int h[1000][1000] = {0};
	int i = 0;
        int j = 0;
	while(1){
		cin >> s[i];
		if(s[i] == "-") break;
		cin >> m[i];
		for (int k = 0; k < m[i]; ++k)
		{
			cin >> h[i][k];
		}
		i++;
	}
	i = 0;
	while(1){
		if(s[i] == "-") break;
		for (int k = 0; k < m[i]; ++k)
		{
			for (int l = 0; l < h[i][k]; ++l)
			{
				s[i] += s[i][0];
				s[i].erase(0,1);
			}
		}
		cout << s[i] << endl;
		i++;
	}
}

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

int main() {
  int N; cin >> N;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  int ans = 0;
  int cnt = 0;
  for (int i = 1; i < N; i++) {
    if (H[i-1] >= H[i]) cnt += 1;
    else cnt = 0;
    ans = max(cnt, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
using namespace std;
using ll = long long;

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n);
  ll ave = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    ave += a[i];
  }
  
  ave /= n;
  
  ll ans1 = 0;
  ll ans2 = 0;
  for(int i = 0; i < n; i++){
    ans1 += pow(a[i] - ave, 2);
  }
  
  for(int i = 0; i < n; i++){
    ans2 += pow(a[i] - ave - 1, 2);
  }
  cout << min(ans1, ans2) << endl;
  
  return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,t,vec[200000],sum;
  cin>>n>>t;
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  for(int i=0;i<n-1;i++){
    sum+=min(t,vec[i+1]-vec[i]);
  }
  cout<<sum+t<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const ll inf = (ll)1e13;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, k; cin >> n >> k;
	vi h(n + 1);
	rep(i, n) cin >> h[i + 1];
	
	vector<vector<ll>> dp(n + 1, vector<ll>(k + 1, inf));
	dp[0][0] = 0;
	rep(i, n){
		vector<vector<ll>> next(n + 1, vector<ll>(k + 1, inf));
		rep(p, n + 1) rep(u, k + 1){
			if(u < k) next[p][u + 1] = min(next[p][u + 1], dp[p][u]);
			next[i + 1][u] = min(next[i + 1][u], dp[p][u] + max(0, h[i + 1] - h[p]));
		}
		dp = next;
	}
	ll ans = inf;
	rep(i, n + 1) rep(j, k + 1) ans = min(ans, dp[i][j]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
int arr[100005];

void rage(){
	cout<<"-1"<<endl;
	exit(0);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll total=0;
	
	cin>>n;
	rep(x,0,n+1){
		cin>>arr[x];
		total+=arr[x];
	}
	
	if (n==0){ //are you fucking
		if (arr[0]!=1) rage();
		cout<<1<<endl;
		return 0;
	}
	
	if (arr[0]!=0) rage();
	if (arr[n]==0) rage();
	
	ll curr=1;
	ll ans=1;
	rep(x,1,n+1){
		if (curr==0) rage();
		
		curr=min(2*curr,total);
		ans+=curr;
		
		if (arr[x]>curr) rage();
		curr-=arr[x];
		total-=arr[x];
	}
	
	cout<<ans<<endl;
}


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

int main() {
  int n;
  cin >> n;
  long long mod = pow(10, 9) + 7;
  long long result = 1;
  int i;
  for (i = 1; i <= n; i++) {
    result *= i;
    result %= mod;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
#define F first
#define S second
#define sz(x) ((int)x.size())
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'

#ifdef LOCAL
#define cerr cout
#else
#endif
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int mod = 1e9 + 7;
const int N = 4e5 + 5;

inline int add(int x, int y, int mod = mod) {
   if (x >= mod) x %= mod;
   if (y >= mod) y %= mod;
   x  += y;
   return (x >= mod ? x - mod : x);
} 
inline int mul(int x, int y, int mod = mod) {
  if (x >= mod) x %= mod;
  if (y >= mod) y %= mod;
  return (x*y) % mod;
}
inline int sub(int x, int y, int mod = mod) {
  x -= y;
  if (x + mod <= 0) {
    x %= mod;
  }
  return (x < 0 ? x+mod : x);
}
int po(int x, int n, int mod = mod) {
  int res = 1;
  for (;n > 0;) {
    if (n & 1) {
      res = mul(res, x, mod);
    }
    x = mul(x, x, mod);
    n /= 2;
  }
  return res;
}

int get(vector<int> &v, int val) {
  int n = v.size()-1;
  int x = 0, y = 0, ans = 0;
  for (int &i: v)x += (i==1), y += (i==0);
  for (int &i: v) {
    x -= i==1;
    y -= i==0;
    if (i == 0)
      ans = add(ans, mul(x, po(2,val)));
    else 
      ans = add(ans, mul(y, po(2, val)));
  }
  return ans;
}
 
inline void solve() {
   int n, x, ans(0);
   cin >> n;
   vector<int>v(n);
   for (int &x: v) cin >> x;
   for (int i = 0; i < 60; ++i) {
    vector<int> tmp;
    for (int &x: v)
      tmp.push_back(((1LL<<i)&x)>0);
    ans = add(ans, get(tmp, i));
   }
   cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL); 
  //int t = 1;cin >> t; while(t--)
  solve();
  E;
  return 0;
}

Measured memory_bytes: 10196
#include<bits/stdc++.h>
#define pii pair<int,int>
#define mo 1000000007
#define ll long long
#define pll pair<ll,ll>
#define db double
#define fi first
#define se second
#define For(i,j,k) for (int i=j;i<=k;i++)
using namespace std;
int f[200005];
int n,x,ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		f[x]=f[x-1]+1;
	}
	int ans=0;
	for (int i=1;i<=n;i++)
		ans=max(ans,f[i]);
	printf("%d",n-ans);
}

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

#define N 100

int main() {
  int M[N][N];
  int i, j, n, u, k, v;

  cin >> n;

  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) M[i][j] = 0;
  }

  for(i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for(j = 0; j < k; j++) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      if(j) cout<<" ";
      cout<<M[i][j];
    }
    cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

vector<bool> ans(100010);
vector<vector<pair<int,int>>> to(100010);
void dfs(int a, int p = -1, int l = 0){
    for(pair<int,int> r:to[a]){
        if(r.first == p) continue;
        if((l+r.second)%2 == 0) ans[r.first] = true;
        else ans[r.first] = false;
        dfs(r.first,a,l+r.second);
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> can(n);
    ans.resize(n);
    to.resize(n);
    ans[0] = true;

    for(int i = 0; i < n-1; i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;

        if(w%2 == 0){
            can[u] = true;
            can[v] = true;
        }
        to[u].push_back({v,w});
        to[v].push_back({u,w});
    }

    dfs(0);

    for(int i = 0; i < n; i++){
        if(ans[i]) cout << 1 << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 9216
#include <stdio.h>

int main()
{
 int k,a,b;
  
  scanf("%d%d%d",&k,&a,&b);
  
  int i;
  
  for(i=1;i<=b;i++)
  {
    if(a<=k*i&&k*i<=b)
    {
      printf("OK\n");
      return 0;
    }
  }
  
  printf("NG\n");
  return 0;
}

Measured memory_bytes: 1612
#include<iostream>
using namespace std;
const long mod=1e9+7;
string C;
long p10[10101];
long f(string A)
{
	long a[10101]={};
	a[A.size()]=1;
	for(int i=A.size();i--;)
	{
		a[i]=(a[i+1]+p10[A.size()-i-1]*(A[i]-'0'))%mod;
	}
	int zf=C=="0"?1:0;
	long ret=zf,cur=0;
	for(int i=0;i+C.size()<=A.size();i++)
	{
		int t=0;
		for(int j=0;j<C.size();j++)
		{
			if(A[i+j]!=C[j])
			{
				t=A[i+j]<C[j]?-1:1;
				break;
			}
		}
		(ret+=(cur+(t==1)-zf)*p10[A.size()-i-C.size()])%=mod;
		if(t==0)(ret+=a[i+C.size()])%=mod;
		cur=(cur*10+A[i]-'0')%mod;
	}
	return ret;
}
main()
{
	p10[0]=1;
	for(int i=1;i<10101;i++)p10[i]=p10[i-1]*10%mod;
	string A,B;
	cin>>A>>B>>C;
	long b=f(B);
	if(A!="0")
	{
		A[A.size()-1]--;
		for(int i=A.size();i--;)
		{
			if(A[i]<'0')
			{
				A[i]+=10;
				A[i-1]--;
			}
			else break;
		}
		b+=mod-f(A);
	}
	cout<<b%mod<<endl;
}



Measured memory_bytes: 3408
#include<cstdio>

int n;
double x[21],y[21];

double fabs(double x){
	if(x<0)return -x;
	return x;
}

int main(void){
	while(~scanf("%lf,%lf",&x[n],&y[n]))n++;
	double sum=0.0;
	for(int i=0;i<n;i++)sum+=0.5*(x[i]-x[(i+1)%n])*(y[i]+y[(i+1)%n]);
	printf("%0.7f\n",fabs(sum));
	return 0;
}

Measured memory_bytes: 1084
# ABC_129 C

def stairs(n, a):
    num_list = set(i for i in range(n+1) if i not in a)
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in num_list:
        if i > 1:
            dp[i] = dp[i-1] + dp[i-2]
            
    result = dp[n] % 1000000007

    print(result)

    
n, m = list(map(int, input().split()))
a = set(int(input()) for _ in range(m))


if __name__ == '__main__':
    stairs(n, a)

Measured memory_bytes: 467304
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashMap <String,Integer> map = new HashMap<>();
        ArrayList<String> list = new ArrayList<>();
        
        for(int i=0; i<N; i++){
            String tmp = sc.next();
            
            if(map.containsKey(tmp)){
                map.put(tmp,map.get(tmp)+1);
            }else{
                map.put(tmp,1);
            }
        }
        
        int max = 0;
        for(String key : map.keySet()){
            if(map.get(key)>max){
                max = map.get(key);
            }
        }   
        
        for(String key : map.keySet()){
            if(max == map.get(key)){
                list.add(key);
            }
        }
        
        Collections.sort(list);
        
        for(String str : list){
            System.out.println(str);    
        }
    }
}

Measured memory_bytes: 82404
'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let L = input[0].split(' ').map(Number);

  let total = L.reduce((ttl, data) => { return ttl + data });
  let maxL = Math.max(...L);
  console.log(total - maxL);

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


Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  if(S == "Cloudy"){
    cout << "Rainy" << endl;
  }
  if(S == "Rainy"){
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())

i = 1
ans = 0
UL = M / N
while i * i <= M:
    if M % i == 0:
        j = M // i
        if i <= UL:
            ans = max(ans, i)
        if j <= UL:
            ans = max(ans, j)
    i += 1

print(ans)


Measured memory_bytes: 2940
function Main(input) {
	input = input.split("\n");
	tmp = input[1].split(" ");
	var n = parseInt(input[0], 10);
    var arr = tmp.map(x=> parseInt(x, 10));
	var B = new Array(n).fill(-1);
    for (var i = 0; i < n; i++) {
        var inserted = arr[n-1-i];
        var toIndex;
        if (i % 2 == 0) {
            toIndex = i / 2;
        } else {
            toIndex = n - 1 - Math.floor(i/2);
        }
        B[toIndex] = inserted
    }
	console.log(B.join(" "));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 55972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  ull n;
  string s, t;
  cin >> n;
  cin >> s >> t;

  string res = "";
  for (ull i=0; i < n; i++) {
    res.append(1, s[i]);
    res.append(1, t[i]);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int a[101]={},r;
		rep(i,n)	scanf("%d",a+i+1);
		double b,v,e,f;	scanf("%lf%d%lf%lf%lf",&b,&r,&v,&e,&f);
		n++;

		static double t[10001];
		rep(x,a[n-1]){
			if(x<r)	t[x+1]=t[x]+1/(v-f*(r-x));
			else	t[x+1]=t[x]+1/(v-e*(x-r));
		}

		static double dp[101][10001];
		rep(i,n)rep(x,a[n-1]+1)	dp[i][x]=1e60;
		dp[0][0]=0;
		for(int i=1;i<n;i++){
			int dis=a[i]-a[i-1];
			for(int x=dis;x<=a[n-1];x++){
				dp[i][x]=min(dp[i][x],dp[i-1][x-dis]+t[x]-t[x-dis]);
				dp[i][0]=min(dp[i][0],dp[i][x]+b);
			}
		}

		printf("%.9f\n",*min_element(dp[n-1],dp[n-1]+a[n-1]+1));
	}

	return 0;
}

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


int main(){
	long long a,b,c,k,ans=0;
	cin >> a >> b >> c >> k;
	if(a>=k){
		cout << k << endl;
		return 0;
	}
	else{
		k-=a;
		ans+=a;
		
		if(b>=k){
			cout << ans << endl;
			return 0;
		}
		else{
			k-=b;
			
			ans-=k;
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] w = scan.next().split("");
		for(String s1:w) {
			int c = 0;
			for(String s2:w) {
				if(s1.equals(s2))c++;
			}
			if(c%2==1) {
				System.out.println("No");
				System.exit(0);
			}
		}
		System.out.println("Yes");
	}

}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int d[100001] = { 0 };
map<int, vector<int> > idx;

int main()
{
	int N, M, X, Y, Z, cnt = 0;
	int no = 100001;
	int rep_no, rep_idx;

	cin >> N >> M;
	rep(i, M) {
		cin >> X >> Y >> Z;
		if (d[X] == 0 && d[Y] == 0) {
			cnt++;
			d[X] = d[Y] = no;
			idx[no].push_back(X);
			idx[no].push_back(Y);
			no++;
		}
		else if (d[X] != 0 && d[Y] == 0) {
			d[Y] = d[X];
			idx[d[X]].push_back(Y);
		}
		else if (d[X] == 0 && d[Y] != 0) {
			d[X] = d[Y];
			idx[d[Y]].push_back(X);
		}
		else if (d[X] != d[Y]) {
			cnt--;
			rep_no = d[Y];
			rep(j, idx[rep_no].size()) {
				rep_idx = idx[rep_no][j];
				d[rep_idx] = d[X];
				idx[d[X]].push_back(rep_idx);
			}
			idx[rep_no].clear();
		}
	}

	repc(i, 1, N) {
		if (d[i] == 0) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    int n;
    cin>>n;

    if(n%2==0){
        cout<<n/2-1<<endl;
    }
    else cout<<n/2<<endl;
    
 }

Measured memory_bytes: 256
def find_j(h):
    p = []
    psum = 0
    for i in range(13):
        pi = 26**i
        psum += pi
        p.append(psum)
    
    n_p = len(p)
    for i in range(n_p):
        if p[i] > h:
            return i
    return 1

def find_k(h, j):
    n_block = 26**j
    
    for i in range(1,27):
        div_fin = n_block // 26 * i
        if h <= div_fin:
            return i

def main():
    n = int(input())
    
    alp_ = "abcdefghijklmnopqrstuvwxyz"
    alp = [alp_[i] for i in range(26)]
    
    h = n
    j = find_j(h)
    h = h - (26**j - 1)//25 + 1
    k = j
    ans = ""
    #print(h,k)
    
    for _ in range(j):
        k = find_k(h, j)
        ans = ans + alp[k-1]
        h = h - 26**(j-1) * (k - 1)
        j -= 1
        #print(h,k)
    
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int num = 100 * a + 10 * b + c;
  
  if(num % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
    long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    Array.Sort(nums);
    long answer = 0;

    for(int i = 0; i < n; i++)
    {
      answer += nums[2*i];
    }
    
		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 13268
/*********************
*  Author: xuziyuan  * 
*********************/
 
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

LL n,a[300010],suml[300010],sumr[300010],sum=0,ans=-1e18;
multiset <LL> st;

int main()
{
	cin>>n;
	rep(i,n*3) cin>>a[i];
	rep(i,n)
	{
		st.insert(a[i]);
		sum+=a[i];
	}
	suml[n-1]=sum;
	for(int i=n;i<n*2;i++)
	{
		st.insert(a[i]);
		sum+=a[i];
		sum-=*st.begin();
		st.erase(st.begin());
		suml[i]=sum;
	}
	st.clear();
	sum=0;
	for(int i=n*3-1;i>=n*2;i--)
	{
		st.insert(-a[i]);
		sum+=a[i];
	}
	sumr[n*2]=sum;
	for(int i=n*2-1;i>=n;i--)
	{
		st.insert(-a[i]);
		sum+=a[i];
		sum+=*st.begin();
		st.erase(st.begin());
		sumr[i]=sum;
	}
	for(int i=n-1;i<n*2;i++) ans=max(ans,suml[i]-sumr[i+1]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10752
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var ans = 6 - GetInt() - GetInt();

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 13140
#coding: utf-8

s = input()
q = int(input())
for i in range(q):
    order = input().split(" ")
    if   order[0] == "print":
        print(s[int(order[1]) : int(order[2])+1])
    elif order[0] == "reverse":
        r = s[int(order[1]) : int(order[2])+1]
        r = r[::-1]
        s = s[:int(order[1])] + r + s[int(order[2])+1:]
    elif order[0] == "replace":
        s = s[:int(order[1])] + order[3] + s[int(order[2])+1:]



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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    vec.at(i) = a;
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int s = 1;
  for (int i = 1; i < N; i++) {
    if (vec.at(i-1) != vec.at(i)) s++;
  }
  cout << s << endl;
}

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

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

  int ans = 0;
  for (int i = 0; i <= A; ++i) {
    for (int j = 0; j <= B; ++j) {
      for (int k = 0; k <= C; ++k) {
        if (i * 500 + j * 100 + k * 50 == X) ++ans;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    a, b, c, d = i_map()

    if abs(a-b) <= d and abs(b-c) <= d:
        Yes()
        exit()

    if abs(a-c) <= d:
        Yes()
        exit()

    No()

if __name__ == '__main__':
    main()


Measured memory_bytes: 3816
from itertools import combinations

count_dict = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}

n = int(input())
for _ in range(n):
    s = input()
    if s[0] in count_dict:
        count_dict[s[0]] += 1

ans = 0
for a, b, c in list(combinations(count_dict.keys(), 3)):
    ans += count_dict[a] * count_dict[b] * count_dict[c]
print(ans)

Measured memory_bytes: 3064
import java.util.*;

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

		Scanner sc = new Scanner(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();
		int x=a+b;
		int y=a-b;
		int z=a*b;
		if(x>=y && x>=z){
			System.out.println(x);
		}else if(y>=x && y>=z){
			System.out.println(y);
		}else{
			System.out.println(z);
		}




	}
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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;}

int main()
{
    lol result{0};
    lol x; cin >> x;
    int y; cin >> y;
    if(y%2 == 1)
    {
        cout << "No" << endl;
        return 0;
    }
    /*
    vector<int> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    */
    if((4*x - y >= 0) && (y - 2*x >= 0))
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    

    //cout << result << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define db double
using namespace std;
const int N=500100;
inline int read(){
	int x=0,c=getchar(),f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
int n,i,m,a[N],A,B,ans;
signed main(){
	//freopen("1.in","r",stdin);
	n=read();
	while(n)a[++m]=n%10,n/=10;
	for(i=m;i;i--){
		if(a[i]>0){
			ans+=a[i];
		}
	}if(ans==1)ans+=9;printf("%d\n",ans);
	return 0;
}

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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

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

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const ll INF = 1e+18;
const ll MOD = 1e+9+7;

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

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

    ll A, V, B, W, T; cin >> A >> V >> B >> W >> T;
    if(A < B)
    {
        B = B+T*W;
        A = A+T*V;
        if(A >= B) cout << "YES" << endl;
        else cout << "NO" << endl;        
    }
    else
    {
        B = B-T*W;
        A = A-T*V;
        if(A <= B) cout << "YES" << endl;
        else cout << "NO" << endl;        
    }
}

Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))
A = A * 2

s = [0] * (2 * N)
s[0] = A[0]
s[1] = A[1]

for i in range(2, 2*N):
    s[i] = s[i-2] + A[i]
s.append(0)
ss = s[2 * N - 1]

for i in range(N):
    print(ss - 2 * (s[i + N - 2] - s[i-1]), end=" ")


Measured memory_bytes: 24816
#ABC067C
N=int(input())
a=list(map(int,input().split()))
x=a[0]
y=sum(a)-x
ans=abs(x-y)
for i in range(N-2):
    x+=a[i+1]
    y-=a[i+1]
    if ans>abs(x-y):
        ans=abs(x-y)
print(ans)

Measured memory_bytes: 24832
use std::io::*;
use std::str::FromStr;
use std::collections::HashSet;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let di: Vec<u32> = (0..n).map(|_| read()).collect();
    let uniq: HashSet<u32> = di.into_iter().collect();
    println!("{}", uniq.into_iter().count());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int d;
typedef int v[10];
v p[10];
int dq(v &a,v &b){
	int s=0;
	for(int i=0;i<d;++i)
		s+=(a[i]-b[i])*(a[i]-b[i]);
	return s;
}
bool besq(int x){
	int q=sqrt(x);
	return q*q==x;
}
int main(){
	int n;
	cin>>n>>d;
	for(int i=0;i<n;++i){
		for(int j=0;j<d;++j)cin>>p[i][j];
	}
	int c=0;
	for(int i=0;i<n;++i)
	for(int j=i+1;j<n;++j)
	if(besq(dq(p[i],p[j])))c++;
	cout<<c;
	return 0;
}


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

using namespace std;

vector<vector<int>> g;
vector<pair<int, int>> dat;
map<pair<int, int>, int> mp;
int k = 0;

void dfs(int u, int v, int c) {
    int cur = 1;
    for (int t : g[v]) {
        if (t == u)
            continue;
        if (cur == c)
            cur++;
        k = max(k, cur);
        mp[make_pair(min(v, t), max(v, t))] = cur;
        dfs(v, t, cur);
        cur++;
    }
}

int main() {
    int n, a, b;
    cin >> n;
    g.resize(n);
    dat.resize(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        cin >> a >> b;
        a--; b--;
        dat[i] = make_pair(a, b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(-1, 0, 0);
    cout << k << endl;
    for (int i = 0; i < n - 1; ++i) {
        cout << mp[dat[i]] << endl;
    }

    return 0;
}

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

#define LL long long

const int N = 1020;
const long long mod = 998244353;

using namespace std;

LL n,k;

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    cin>>n>>k;
    LL t = k;
    int ans = 1;
    k += k;
    k++;
    while( k < n ){
        ans++;
        k += t * 2;
        k++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    if(k == 0) {
        ans = n * n;
    }
    else {

        ll ct = 1;
        for(ll i = k + 1; i <= n; i++) {
            ans += (n / i) * ct;
            if(n % i != 0) {
                ll ex = n - (n % i);
                ll low = ex + k;
                ans += max((ll)0, n - low + 1);
            }
            ct++;
        }
    }
    cout << ans;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int n;
vector<long long> v1;
long long v;
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) 
	{
		cin >> v;
		v1.push_back(v);
	}
	for (i = n - 1; i > 0; i--) 
	{
		if (v1[i] < v1[i - 1]) v1[i - 1]--;
		if (v1[i] < v1[i - 1]) break;
	}
	if (i > 0) { cout << "No" << endl; return 0; }
	for (i = 0; i < n - 1; i++)
	{
		if (v1[i] > v1[i + 1]) 
		{
			cout << "No" << endl; 
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1400
import numpy as np 
N = int(input())
A =list(map(int, input().strip().split()))
Ap = np.abs(A)
i = 0
m = 0
s = 0
M = np.sum(Ap)
while i <= N - 1:
    if A[i] < 0:
        m += 1
    i += 1
if m % 2 ==0:
    print(M)
else:
    Ma = 0
    while s <= N - 1:
        M1 = M - 2 * Ap[s]
        if M1 >= Ma:
            Ma = M1
        s += 1
    print(Ma)

Measured memory_bytes: 23284