akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int solve() {
    int N, M; cin >> N >> M;
    if(N == 0 and M == 0) return 1;

    vector< vector<int> > G(N);
    for(int i=0; i<M; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    int cnt1 = 0, cnt0 = 0;
    bool is_bipartite = true;
    vector<int> checked(N, -1);
    function<void(int, int)> dfs = [&](int cur, int par) {
        for(auto to : G[cur]) {
            if(to == par) continue;
            if(checked[to] >= 0) {
                is_bipartite &= ((checked[cur] ^ checked[to]) == 1);
            }
            else {
                checked[to] = 1 - checked[cur];
                if(1 - checked[cur] == 0) cnt0++;
                else cnt1++;
                dfs(to, cur);
            }
        }
    };

    checked[0] = 0; cnt0++;
    dfs(0, -1);
    
    if(!is_bipartite) {
        cout << 0 << endl;
    }
    else {
        vector<int> ans;
        if(cnt0 > cnt1) swap(cnt0, cnt1);
        if(cnt0 % 2 == 0) {
            ans.push_back(cnt0 / 2);
        }
        if(cnt1 % 2 == 0 and cnt0 != cnt1) {
            ans.push_back(cnt1 / 2);
        }

        cout << ans.size() << endl;
        for(auto a : ans) cout << a << endl;
    }
    return 0;
}

signed main() {
    while(!solve());
    return 0;
}



Measured memory_bytes: 3244
#include <stdio.h>

int main(){
  int a, b; //a<=b, a,bは共に5桁
  int ans=0;
  
  scanf("%d\t%d", &a, &b);

  for(int i=a; i<b+1; i++){
    if( (i/10000) == (i%10) ){
      if( ((i%10000)/1000) == ((i%100)/10 )){
	ans++;
      }
      
    }
  }
  
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int A = NextInt();
        int B = NextInt();
        int C = NextInt();
        Console.WriteLine(Math.Max(C - (A - B), 0));
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}
public class MinTree
{
    private List<int> table = new List<int>();
    private static int size = 1;
    private static int high = 1;
    public MinTree(int n, int k = 0)
    {
        while (size < n) size *= 2;
        high = (int)Math.Log(size, 2);
        for (int i = 0; i < 2 * size - 1; i++) table.Add(k);
    }
    public void Add(int x, int v)
    {
        x += size - 1;
        table[x] += v;
        table[x] = Math.Max(0, table[x]);
        while (x != 0)
        {
            x = (x % 2 == 0 ? x / 2 - 1 : x / 2);
            table[x] = table[x * 2 + 1] + table[x * 2 + 2];
        }
    }
    public int MLS(int k)
    {
        if (table.First() == 0) return -1;
        int index = 0;
        for (int y = 0; y < high; y++)
        {
            int left = index * 2 + 1;
            int right = index * 2 + 2;
            if (table[left] >= k) index = left;
            else { k -= table[left]; index = right; }
        }
        return index - size + 1;
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 11220
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()

    # AがBCを乗り越えて右に進むイメージ
    # それぞれのAに対して右側に連続したBCがいくつあるか
    ans = 0
    len_s = len(s)
    cnt = 0
    i = 0
    while i < len_s:
        # print(s[i], cnt)
        if s[i] == 'A':
            cnt += 1
            i += 1
        elif i + 1 < len_s and s[i] == 'B' and s[i+1] == 'C':
            ans += cnt
            i += 2
        else:
            cnt = 0
            i += 1
            
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10292
# ----- 優先度付きキュークラス ----- #
import heapq

class PriorytyQueue(object):

    def __init__(self, arr, target='min'):
        self.arr = arr
        self.target = target
        self._heapify()
    
    def _heapify(self):
        if self.target == 'max':
            self.arr = list(map(lambda x:x*(-1), self.arr))
        heapq.heapify(self.arr)
    
    def push(self, x):
        if self.target == 'max':
            x *= -1
        heapq.heappush(self.arr, x)

    def pop(self):
        res = heapq.heappop(self.arr)
        if self.target == 'max':
            return res*(-1)
        else:
            return res
    
    def get_arr(self):
        if self.target == 'max':
            return list(map(lambda x:x*(-1), self.arr))
        else:
            return self.arr
    
    def is_empty(self):
        return len(self.arr) == 0

N, M = map(int, input().split())
A = list(map(int, input().split()))
pq = PriorytyQueue(A, target='max')

for i in range(M):
    max_value = pq.pop()
    pq.push(max_value//2)

print(sum(pq.get_arr()))

Measured memory_bytes: 15380
#include<iostream>
using namespace std;
int main(){
	
	int n,a[100];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int b=n-1;b>=0;b--){
		cout<<a[b];
		if(b!=0){
			cout<<" ";
		}
		if(b==0){
			cout<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3068
# abc_111_b

# if num % 111 == 0: return num

def solve(num):             # 750
    c = num // 100          # c = 7  
    du = num - c * 100      # du = 50
    if du <= c*11:          # du <= 777
        return c*111        # return 7*111
    else:
        return (c+1)*111    # return 8*111

if __name__ == "__main__":
    print (solve(int(input(""))))


Measured memory_bytes: 3068
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;


int main() {
    llong a, b;
    cin >> a >> b;

    cout << max(0ll, a - 2 * b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt (string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS=1e-10;
const double PI=acos(-1.0);

string filldot(string &s, int w) {
	string str = s;

	REP(i, w-s.size()) {
		str.push_back('.');
	}

	return str;
}

int main(){
	int plen, cnum, width, cspace;

	bool hoge = false;

	while(cin >> plen, plen) {
		cin >> cnum >> width >> cspace;

		string str;
		vs elements;

			getline(cin,str);
		while(1) {
			getline(cin,str);
			if(str == "?")break;
			
			if(str != "") hoge = true;
			
			
			if(str.size() < width) {
				str = filldot(str, width);
				elements.push_back(str);
			} else if(str.size() == width) {
				elements.push_back(str);
			} else {
				string ss;
				for(int i=1;i<str.size()+1;i++){
					ss += str[i-1];
					if(i%width==0){
						elements.push_back(ss);
						ss="";						
					}
				}
				if(ss != "") {
					ss = filldot(ss, width);
					elements.push_back(ss);
				}
			}
		}
		
		if(elements.size() % (plen*cnum)) {
			string dots = ".";
			dots = filldot(dots, width);

			int size = elements.size() % (plen*cnum);

			REP(i, plen*cnum-size) {
				elements.push_back(dots);
			}
		}
		
		int N = elements.size()/(plen*cnum);


		if(hoge) {
		REP(k, N) {
			REP(i, plen) {
				REP(j, cnum) {
					cout << elements[k*cnum*plen + j*plen + i];

					if(j < cnum-1) {
						REP(h, cspace) {
							cout << ".";
						}
					}
				}
				cout << endl;
			}

			cout << "#" << endl;
		}
		}

		cout << "?" << endl;
					
			
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int x, a, b;

int main(){
	cin >> x >> a >> b;
	
	cout << (x-a)%b << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
for i in range(len(s)):
    if s[i] == 'I':
        s[i] = 1
    else:
        s[i] = -1
x = 0
ans = 0
for i in range(len(s)):
    x += s[i]
    if ans < x:
        ans = x
print(ans)

Measured memory_bytes: 3064
a,b,c,d,e,f = map(int,input().split())

water = []
sugar = []
for i in range(0,1000):
    for j in range(0,1000):
        if (100*i*a + 100*j*b ) <= f:
            water.append(100*i*a + 100*j*b)
        if c*i + d*j <= f:
            sugar.append(c*i+d*j)
        

water = list(set(water))
water.sort()
water.remove(0)
sugar = list(set(sugar))
sugar.sort()

concentration = 0
sgw = 0
sg = 0

x = e/100

for i in water:
    for j in sugar:
        temp = (100 * j) / (i + j)
        if concentration <= temp and i + j <= f and (i /100)*e  >= j:
            #print(i,j,concentration,temp,i*x)
            sgw = i + j
            sg = j
            concentration = temp
if sgw == 0:
    sgw = water[-1]
print(sgw,sg)



Measured memory_bytes: 12492
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    string s;
    string t;
    cin>>s;
    cin>>t;
    ll n = s.length();
    ll m = t.length();
    sort(ALL(s));
    sort(rALL(t));
    Yes(s<t);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
//    ll T;
//    cin>>T;
//    while(T--)
    solve();
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    string T;
    cin >> S >> T;
    T = T.substr(0, T.size() - 1);
    if (S == T) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


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

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

  if (s.at(s.size() - 1) != 's') {
    cout << s + 's' << endl;
  }
  if (s.at(s.size() - 1) == 's') {
    cout << s + "es" << endl;
  }

}

Measured memory_bytes: 3628
#include <stdio.h>

int main() {
    int N,D,X,i,n,Sum;

    
    scanf("%d",&N);
    
        int A[N+1];
    scanf("%d%d",&D,&X);
    
    
    for (i=1;i<N+1;i=i+1) {
    scanf("%d",&A[i]);
    }
    
    Sum = X;

    
    for (i=1;i<N+1;i=i+1) {
        for (n=0;1+n*A[i]<=D;n=n+1) {
            Sum = Sum +1;
        }
    }
    

    
      printf("%d\n",Sum);
    
    return 0;
}

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

int main() {
  int n,x;
  cin >> n >> x;
  int num=0,ans=0;
  for(int i=0; i<n; i++) {
    int a;
    cin >> a;
    num += a;
    if(num <= x) ans++;
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 256
Q = int(input())
lr = [tuple(map(int, input().split())) for _ in range(Q)]


N = 10**5
is_prime = [True] * (N+1)
is_prime[0] = False
is_prime[1] = False
for i in range(2,N+1):
    if is_prime[i]:
        j = 2
        while j * i <= N:
            is_prime[i*j] = False
            j += 1

cum_like2017 = [0] * (N+1)
for i in range(1,N+1):
    if is_prime[i] and is_prime[(i+1)//2]:
        cum_like2017[i] = cum_like2017[i-1] + 1
    else:
        cum_like2017[i] = cum_like2017[i-1] 


for l, r in lr:
    print(cum_like2017[r] - cum_like2017[l-1])


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  string S; cin >> S;
  bool bad = (S[0]==S[1]||S[1]==S[2]||S[2]==S[3]);
  string result = (bad) ? "Bad" : "Good";
  cout << result << endl;
  return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;
int n, a[21][21];
long long dp[1 << 21];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) cin >> a[i][j];
	}
	
	dp[0] = 1;
	for (int i = 1; i < (1 << n); i++) {
		for (int j = 0; j < n; j++) {
			if (i >> j && a[__builtin_popcount(i) - 1][j]) {
				dp[i] = (dp[i] + dp[i ^ 1 << j]) % mod;
			}
		}
	}
	
	cout << dp[(1 << n) - 1] << '\n';
}


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

int main() {
  int N,sum=0;
  cin >> N;
  vector<int> X(N);
  rep(i,N) {cin >> X[i]; sum+=X[i];}
  int P=round(sum*1.0/N),S=0;
  rep(i,N) {S+=(X[i]-P)*(X[i]-P);}
  
  cout << S << endl;
  
  return 0;
}


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

using namespace std;

#define ll             long long 
#define mod            1000000007
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);         

#define pi   3.14159265358979323846264338327950288419716939937510


int main() 	 	
{
	
	FIO;

	int r;
	cin>>r;

	long double circum = 2*pi*r;

	cout<<fixed<<setprecision(20)<<circum<<endl;
}



Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define vvb vector<vb>
#define pb push_back
#define inf 1e18
#define mod 1000000007
#define ps(x,y) fixed<<setpricision(y)<<x
#define w(t) int t; cin>>t; while(t--)
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
using namespace std;
const int N = 300 * 1000 + 13;
void init() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main()
{
	FIO;
	init();
	int n, k; cin >> n >> k;
	map<int, int> mp;
	while (k--) {
		int d; cin >> d;
		for (int i = 0; i < d; i++) {
			int x; cin >> x;
			mp[x]++;
		}

	}
	cout << (n - (int)mp.size()) << '\n';
}

Measured memory_bytes: 3664
// https://atcoder.jp/contests/dp/tasks/dp_k
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int main()
{
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for(int i=0 ; i<n; i++)
        cin >> a[i];
    bool dp[k+1] = {0};
    for(int i=0 ; i<=k ; i++)
    {
        for(int j=0 ; j<n ; j++)
        {
            if(i-a[j] >= 0)
                dp[i] = !dp[i-a[j]];
            if(dp[i])
                break;
        }
    }
    /*for(int i=0 ; i<=k ; i++)
        cout << dp[i] << " ";
    cout << endl;*/
    if(dp[k])
        cout << "First\n";
    else
        cout << "Second\n";
    return 0;
}


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

struct arrow{
    int direc,weight;
};

bool ans = true;

void solve(vector<int> &Node,   vector<int> &color,
           queue<int> &visit,
           vector<vector<arrow>> &tree,   int num){
    Node[num] == 0;
    color[num]++;
    visit.push(num);

    while( !(visit.empty()) ){
        int now = visit.front();
        for( arrow k : tree[now] ){
            if( color[k.direc] >= 1 ){
                if( Node[k.direc] != Node[now] + k.weight){
                    ans = false;
                }
            } else {
                Node[k.direc] = k.weight + Node[now];
                color[k.direc]++;
                visit.push(k.direc);
            }
        }
        color[now]++;
        visit.pop();
    }
}

void allsolve(vector<int> &Node,vector<int> &color,
              queue<int> &visit, vector<vector<arrow>> &tree){
    for( int i = 0; i < Node.size(); i++ ){
        if(color[i] != 2){
            solve(Node,color,visit,tree,i);
        }
    }
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int N, M; cin >> N >> M;
    vector<vector<arrow>> tree(N);

    int l, r, d;
    while(cin >> l >> r >> d){
        arrow key,backkey;
        key.direc = r-1; backkey.direc = l-1; key.weight = d; backkey.weight = -d;
        tree[l-1].push_back(key);
        tree[r-1].push_back(backkey);
    }

    vector<int> Node(N,0);
    vector<int> color(N,0);
    queue<int> visit;
    allsolve(Node,color,visit,tree);

    if(ans) cout << "Yes" << endl;
    else  cout << "No" << endl;
}

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


int main()
{
    int n,x;
    cin >> n;
    int dp[n];
    int a,b;
    cin >> a >> b;

    int L[n];
    L[0]=a; L[1]=b;
    for (int i=2;i<n;i++){
        cin >> L[i];
    }

    dp[0]=0;
    dp[1]=abs(b-a);
    for (int i=2;i<n;i++){
        dp[i]=min( dp[i-2] + abs(L[i-2]-L[i]), dp[i-1] + abs(L[i-1]-L[i]) );
    }

    cout << dp[n-1];
}


Measured memory_bytes: 1024
n = int(input())
s = list(input())

d = ""
for i in range(len(s)):
  a = ord(s[i])+n
  if a <= ord("Z"):
    d = d + chr(a)
  else:
    d = d + chr(a - (ord("Z")-ord("A"))-1)
    
print(d)

Measured memory_bytes: 3060
s = input()
if len(s) == 0:
    print("0")
    exit()

s_10 = "10" * (len(s) // 2)
if len(s) % 2 != 0:
    s_10 += "1"

s_01 = "01" * (len(s) // 2)
if len(s) % 2 != 0:
    s_01 += "0"

a = len([i for i in range(len(s)) if s[i] != s_01[i]])
b = len([i for i in range(len(s)) if s[i] != s_10[i]])
ans = min(a, b)
print(ans)


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

int main(){
    double a, l, x;
    while(scanf("%lf%lf%lf", &a, &l, &x) != EOF){
        double s_abc = a * sqrt(l * l - a * a / 4) / 2;
        double s_acd = l * sqrt(2 * l * x + x * x) / 4;
        printf("%.12f\n", s_abc + 2 * s_acd);
    }
    return 0;
}

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

namespace AtCoder_Cs
{
    public class Program
    {
        public static void Main()
        {
            int[] inp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = inp[0];
            int Y = inp[1];

            var ansList = new List<string>();

            for (int i = 0; i <= N; i++) // 1000円
            {
                for (int j = 0; j <= N - i; j++) // 5000円
                {
                    //for (int k = 0; k <= N; k++) // 10000円
                    //{
                    //    if ((i * 1000 + j * 5000 + k * 10000 == Y) && (k + j + i == N))
                    //    {
                    //        ansList.Add($"{k} {j} {i}");
                    //        break;
                    //    }
                    //}
                    //if (ansList.Any()) break;
                    int k = (N - i - j);
                    if (i * 1000 + j * 5000 + k * 10000 == Y){
                        ansList.Add($"{k} {j} {i}");
                        break;
                    }
                }
                if (ansList.Any()) break;
            }

            if (!ansList.Any())
            {
                Console.WriteLine("-1 -1 -1");
            }
            else
            {
                Console.WriteLine(ansList.First());
            }
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(x%2) {
		cout<<"first"<<endl;return 0;
	}
	}
	cout<<"second"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int n= scanner.nextInt();
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int add = 1_000_000_000;
        if (s > 500_000) add = 1;
        for(int i = 0; i < n; i++) {
            if (i < k) out.print(s + " ");
            else out.print(add + " " );
        }
        out.println();
        out.flush();
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int countDivisors(long long n, bool op) {
    if (n == 1)
        return 0;
    int ret = 0;
    for (long long i=2; i*i<=n; i++)
        if (n % i == 0) {
            if (op) {
                long long x = n;
                while (x % i == 0)
                    x /= i;
                ret += (x % i == 1);
                if (n / i != i) {
                    i = n / i;
                    x = n;
                    while (x % i == 0)
                        x /= i;
                    ret += (x % i == 1);
                    i = n / i;
                }
            } else {
                ret += 1 + (n / i != i);
            }
        }
    return ret + 1;
}

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

    long long n;
    cin >> n;

    cout << countDivisors(n - 1, false) + countDivisors(n, true) << "\n";

    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int mod = 1e9 + 7;
int n;

ll power(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int main() {
    cin >> n;
    ll tt = power(10, n);
    ll res = ((tt - power(9, n) * 2 % mod) % mod + power(8, n) + mod) % mod;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int k, s; cin >> k >> s;
    int res = 0;
    rep(x, k + 1) {
        rep(y, k + 1) {
            if(s - x - y >= 0 && s - x - y <= k) res ++;
        }
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<int, int> P;
#define peak first
#define val second

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

    //A:=val=>0のもの B:=val<0のもの
    vector<P> A, B;

    for(int i = 0; i < N; i++) {
        string s;
        cin >> s;

        P ret = P(0, 0);
        for(int j = 0; j < (int)s.size(); j++) {
            if(s[j] == '(') ret.val++;
            else ret.val--;
            ret.peak = min(ret.peak, ret.val);
        }

        ret.peak = -ret.peak;

        //cout << ret.peak << " " << ret.val << endl;

        if(ret.val >= 0) A.push_back(ret);
        else {
            ret.val = 0;
            ret.peak = 0;
            for(int j = (int)s.size() - 1; j >= 0; j--) {
                if(s[j] == ')') ret.val++;
                else ret.val--;
                ret.peak = min(ret.peak, ret.val);
            }
            ret.peak = -ret.peak;
            B.push_back(ret);
        }
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    int sum = 0;
    bool can = true;

    for(int i = 0; i < (int)A.size(); i++) {
        if(A[i].peak > sum) {
            can = false;
            break;
        }

        sum += A[i].val;
    }

    int sumb = 0;
    for(int i = 0; i < (int)B.size(); i++) {
        if(B[i].peak > sumb) {
            can = false;
            break;
        }

        sumb += B[i].val;
    }

    if(can && sum == sumb) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 11312
import sys
input = sys.stdin.readline
from operator import itemgetter
from bisect import bisect_left

def main():
	n, k = map(int, input().strip().split())
	x = list(map(int, input().strip().split()))
	zero = bisect_left(x, 0)
	# print("zero:{}".format(zero))
	ans = 10**12
	for l in range(k+1):
		r = k-l-1
		left_i = zero-l
		right_i = zero+r
		if left_i >= 0 and right_i < n:
			if x[left_i] >= 0:
				ans = min(ans, x[right_i])
			elif x[right_i] <= 0:
				ans = min(ans, abs(x[left_i]))
			else:
				ans = min(ans, min(2*abs(x[left_i])+x[right_i], 2*x[right_i]+abs(x[left_i])))
		# print("l:{}, r:{}, ans:{}".format(left_i, right_i, ans))
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 62576
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a + b >= c){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back

int d[128];

int main(void){
  int n,q,m,t;
  while( cin >> n >> q,n+q){
    fill(d,d+128,0);
    rep(i,n){
      cin >> m;
      rep(j,m){
        cin >> t;
        d[t]++;
      }
    }
    m = *max_element(d,d+128);
    rep(i,128){
      if(d[i] >= m && d[i] >= q){
        cout << i << endl;
        goto A;
      }
    }
    cout << 0 << endl;
    A:;
  }
  return 0;
}

Measured memory_bytes: 3028
#include<iostream>
using namespace std;
 
int main()
{
    // 整数の入力
    int a, b, t;
    cin >> a >> b >> t;
  	
  	int ans = 0;
  	for(int nowTime = a; (float)nowTime < (float)t + 0.5f; nowTime += a)
    {
      if(nowTime % a == 0)
      {
        ans += b;
      }
    }
   
    // 出力
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]

    # 再帰的に分割を行う
    left = merge_sort(left)
    right = merge_sort(right)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right)


def merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged


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

A = list(map(int, input().split()))

B = []
now = 0
time = 0

for i in A:
    time+=1
    if now != i:
        B.append(i*10**15 + time)
        now=i
        time=0

if(time!=0):
    B.append(now*10**15 + time)

for i in range(M):
    C, D = map(int, input().split())
    B.append(D*10**15 + C)

B = reversed(merge_sort(B))
answer = 0

for i in B:
    if(i%(10**15) <= N):
        N -= i%(10**15)
        answer += i//(10**15) * i%(10**15)
    else:
        answer += i//(10**15) * N
        break

print(answer)


Measured memory_bytes: 22832
def fn(num):
    if num%2==0:
        return int(num/2)
    else:
        return int((3*num)+1)
        
s=int(input())
ans=[s]
count=0
ns=s
while True:
    ns=fn(ns)
    if ns in ans:
        ans.append(ns)
        break
    ans.append(ns)
print (len(ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX_N = 1e7;


vector<ll> A; ll ans; ll N;
void slove(){
  vector<ll> alt;
  for(ll i = 0; i < N; i++){ alt.push_back(A[i]);} sort(alt.begin(),alt.end());
  for(ll i = 0; i < N; i++){
    ll itr = lower_bound(alt.begin(),alt.end(),A[i]) - alt.begin();
     A[i] = itr;}
  //座標圧縮
  vector<ll> num(N,0);
  for(ll i = 1; i < N; i+= 2){
    //イテレータが奇数項目に、幾つ1,3,5,,,が不足しているのかを数える
    num[i]++; num[A[i]]++;}
  ll res = 0;
  for(ll i = 1; i < N; i++){ if(num[i] == 2){ //奇数がちゃんと奇数項目に存在
    res++;}
 ans = N/2 - res;//Nが奇数の時も全体数は(N-1)/2であり、整合する
                           }
}
    
    


int main(){
   cin >> N; A.resize(N); ans = 0;
  for(ll i = 0; i < N; i++){ cin >> A[i];}
  
  slove();
  
  cout << ans << endl; return 0;}

Measured memory_bytes: 2676
val p = IntArray(100001 ) { 0 }

fun main(args: Array<String>) {
    val (n, m) = getInts()
    repeat(m) {
        val (x , y) = getInts()
        val px = parent(x)
        val py = parent(y)
        if (px != py) p[py] = px
    }
    println(p.drop(1).take(n).count { it == p[it] } - 1)
}

fun parent(k: Int): Int {
    if (p[k] == 0) return k
    return parent(p[k]).also {
        p[k] = it
    }
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").filter { it.isNotBlank() }.map { it.toInt() }

Measured memory_bytes: 64028
import Data.Bits
import Data.List
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Control.Monad
import Control.Monad.ST
import Debug.Trace

type Table = UArray (Int,Int) Bool
type DP s = STUArray s (Int,Int) Int

dp_i :: DP s -> [Int] -> Int -> Int -> ST s ()
dp_i dparr [] m w = return ()
dp_i dparr (w':ws) m w = do
  if testBit w (w'-1) then return ()
    else do
      now <- readArray dparr (m,w)
      if now == 0 then return ()
        else do
          next <- readArray dparr (m+1,setBit w (w'-1))
          writeArray dparr (m+1,setBit w (w'-1)) $ mod0 (now+next)
  dp_i dparr ws m w

solve :: Table -> Int -> ST s Int
solve table n = do
  dparr <- newArray ((0,0),(n,2^n-1)) 0
  writeArray dparr (0,0) 1
  forM_ [0..n-1] $ \m -> do
    let ws = filter (\w' -> table!(m+1,w') == True) [1..n]
    forM_ [0..2^n-1] $ \w -> if popCount w == m then dp_i dparr ws m w else return ()
  readArray dparr (n,2^n-1)

main :: IO ()
main = do
  n <- read <$> getLine
  ls <- replicateM n $ do
    ms <- map read.words <$> getLine
    return $ map (\m0 -> if m0 == 1 then True else False) ms
  let table = listArray ((1,1),(n,n)) $ concat ls
  print $ runST $ solve table n

mod0 :: Int -> Int
mod0 n = mod n 1000000007


Measured memory_bytes: 460412
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

ll ai, ao, at, aj, al, as, az;

int main(int argc, char **argv) {
	cin >> ai >> ao >> at >> aj >> al >> as >> az;
	ll res = ao;
	if (ai % 2 + aj % 2 + al % 2 >= 2 && ai > 0 && aj > 0 && al > 0) {
		res += 3;
		--ai; --aj; --al;
	}
	res += ai / 2 * 2;
	res += aj / 2 * 2;
	res += al / 2 * 2;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=1e5+5;
int n,m,id[N],fa[N],vis[N];
long long a[N],s[N],f[N];
vector<int>E[N];
bool cmp(int x,int y){
	return a[x]<a[y];
}
int find(int x){
	return x==fa[x]?x:fa[x]=find(fa[x]);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%lld%lld",&a[i],&s[i]);
		f[i]=a[i]=max(a[i]-s[i],0ll);
		id[i]=fa[i]=i;
	}
	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		E[x].push_back(y);E[y].push_back(x);
	}
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;++i){
		int x=id[i];vis[x]=1;
		for(int y:E[x])
			if(vis[y]){
				y=find(y);
				if(y==x)continue;
				fa[y]=x;
				s[x]+=s[y];
				if(s[y]+f[y]>a[x])f[x]=min(f[x],f[y]);
				else f[x]=min(f[x],a[x]-s[y]);
			}
	}
	printf("%lld\n",s[find(1)]+f[find(1)]);
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int n;
    cin>>n;
    map<int,long long> d;
    for (int i=1;i<n+1;i++){
        d[i]=0;
    }
    vector<int> vec;
    rep(i,n){
        int a;
        cin>>a;
        vec.push_back(a);
        d[a]+=1;
    }
    long long s=0;
    for (int i=1;i<n+1;i++){
        if (d[i]<=1){
            continue;
        }
        else{
            long long num=(d[i]*(d[i]-1))/2;
            s+=num;
        }
    }
    rep(i,n){
        if (d[vec[i]]<=1){
            cout<<s<<endl;
        }
        else{
            long long num;
            long long num1=d[vec[i]];
            num=s-num1*(num1-1)/2;
            cout<<num+(num1-1)*(num1-2)/2<<endl;
        }
    }


    return 0;
}

Measured memory_bytes: 16116
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	c := scanRunes()

	ans := 0

	l, r := 0, n-1
	for l < r {
		for l < r && c[l] == 'R' {
			l++
		}
		for l < r && c[r] == 'W' {
			r--
		}

		if l != r {
			ans++
			l++
			r--
		}
	}
	fmt.Fprintln(wr, ans)
}


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

main()
{
    int h,w,k; cin>>h>>w>>k;
    vector<string> grd(h);
    for(auto &r: grd) cin>>r;
    int ans=0;
    for(int s=0; s<1<<h; s++)
    {
        for(int t=0; t<1<<w; t++)
        {
            int cnt=0;
            for(int i=0; i<h; i++)
            {
                if(s>>i&1) continue;
                for(int j=0; j<w; j++)
                {
                    if(t>>j&1) continue;
                    if(grd[i][j]=='#') cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,m,a,ans;
int main(){
	scanf("%lld%*lld%*lld%*lld%lld%lld",&n,&m,&a);
	puts(m-n<=a?"Yay!":":(");
}

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

class E
{
	static long[] Read() => Console.ReadLine().Split().Select(long.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var a = Read();
		var f = Read();
		Array.Sort(a);
		Array.Sort(f);
		Array.Reverse(f);

		Console.WriteLine(First(0, a.Last() * f[0], m => a.Zip(f, (x, y) => Math.Max(0, x - m / y)).Sum() <= h[1]));
	}

	static long First(long l, long r, Func<long, bool> f)
	{
		long m;
		while (l < r) if (f(m = l + (r - l - 1) / 2)) r = m; else l = m + 1;
		return r;
	}
}


Measured memory_bytes: 44732
n,m,x=map(int,input().split())
l=[list(map(int,input().split(" "))) for i in range(n)]
ans=[]
for i in range(1<<n):
    cond = [0]*n
    for j in range(n):
        if 1&(i>>j):
            cond[j] = 1
    count=[0]*(m+1)
    for k in range(n):
        if cond[k]==1:
            for s in range(m+1):
                count[s]+=l[k][s]
    flag=0
    for a in range(1,m+1):
        if count[a]<x:
            flag=1
            break
    if flag==0:
        ans.append(count[0])
if ans==[]:
    print(-1)
else:
    print(min(ans))
            


Measured memory_bytes: 9196