akhauriyash/Code-Regression huggingface dataset:
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define	PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vbl vector<bool>
#define vpll vector<pll>
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(),x.end()
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define mod 1000000007
#define INF 1000000000000000
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_pll;
#define ook order_of_key
#define fbo find_by_order
/*  
	Query 1 - order_of_key(k) : Number of items strictly smaller than k.
	Query 2 - find_by_order(k) : K-th element in the set (counting from zero).
	less<ll> means Query 1 will return numbers strictly less than k.
	greater<ll> means Query 1 will return numbers strictly greater than k.
*/
ll powmod(ll x, ll n){
	ll res = 1;
	while(n){
		if(n & 1){
			res *= x;
			res %= mod;
		}
		x *= x;
		x %= mod;
		n >>= 1;
	}
	return res;
}
ll invmod(ll a){
	return powmod(a, mod - 2);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int k, x;
	cin >> k >> x;
	k *= 500;
	if(k >= x){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;


int main(){
	int n, h;
	cin >> n >> h;
	vector<int> a(n), b(n);
	priority_queue<int> pq;
	for (int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		pq.push(b[i]);
	}

	int ans = 0;
	sort(a.begin(), a.end(), greater<int>());
	while (h > 0 && !pq.empty()){
		if (pq.top() < a[0]) break;
		h -= pq.top();
		pq.pop();
		ans++;
	}

	if (h > 0){
		ans += (h+a[0]-1)/a[0];
	}
	cout << ans << endl;
	return 0;
}

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

namespace AtCoder_Tutorial
{
    public class Shi
    {
        public int P;
        public int Y;
        public int O;

        public string GetID()
        {
            return P.ToString("000000") + O.ToString("000000");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split();
            int N = int.Parse(input1[0]);
            int M = int.Parse(input1[1]);
            List<Shi> shiList = new List<Shi>();
            for (int i = 0; i < M; i++)
            {
                string[] input = Console.ReadLine().Split();
                shiList.Add(new Shi { P = int.Parse(input[0]), Y = int.Parse(input[1]) });
            }

            var olist = shiList.OrderBy(_ => _.P).ThenBy(_ => _.Y).ToList();
            int x = 1;
            int prefectureNum = 0;
            for (int i = 0; i < olist.Count; i++)
            {
                if (prefectureNum != olist[i].P)
                {
                    x = 1;
                    prefectureNum = olist[i].P;
                }
                olist[i].O = x;
                x++;
            }

            foreach (var item in shiList)
            {
                Console.WriteLine(item.GetID());
            }
        }
    }
}


Measured memory_bytes: 30040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
#define chk(x) if(x>=mod) x-=mod
int n,dp[200005],w[200005],a[200005];
int main()
{
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",a+i);
    dp[0] = 1;
    rep(i,1,n){
        if(i>1 && a[i] == a[i-1]) {
            dp[i] = dp[i-1];
            continue;
        }
        dp[i] = dp[i-1] + w[a[i]]; chk(dp[i]);
        w[a[i]] += dp[i-1]; chk(w[a[i]]);
    }
    printf("%d\n",dp[n]);
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Map<Integer,ArrayList> silist = new TreeMap<Integer,ArrayList>();
		String[] ans = new String[m+1];
		int[] cnt = new int[n+1];
		Arrays.fill(cnt,0);
		for(int i = 0; i < m; i++){
			int p = sc.nextInt();
			int y = sc.nextInt();
			silist.put(y,new ArrayList<Integer>(Arrays.asList(p,i)));
		}
		int i = 0;
		for(List<Integer> ii : silist.values()){
			ans[ii.get(1)] = String.format("%06d%06d",ii.get(0),++cnt[ii.get(0)]);
			i++;
		}
		for(i = 0; i < m; i++){
			System.out.println(ans[i]);
		}
	}
}


Measured memory_bytes: 178720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for (int i = 0; i < n + 1; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		sc.close();

		long ans = 0;
		for (int i = n - 1; i >= 0; i--) {
			long val = Math.min(a[i + 1], b[i]);
			ans += val;
			b[i] -= val;
			val = Math.min(a[i], b[i]);
			ans += val;
			a[i] -= val;
		}
		System.out.println(ans);
	}
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int hpb[10] = {1,1,0,2,0,0,1,0,1,0};
string yomi[3] = {"hon", "pon", "bon"};

void solve()
{
  ll n; cin >> n;
  
  
  cout << yomi[hpb[n%10]] << endl;
  // cout << (ok?"Yes":"No") << endl;}
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 3528
import java.util.Scanner;
/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		int n=as.nextInt();
		int m=as.nextInt();
		int i,j,k;
		int b,f,r,v;
		
		int mat[][];
		mat = new int[n][m];
		int vec[];
		vec = new int[m];
		int mul[];
		mul = new int[n];
		String str;
		
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				
				mat[i][j]=as.nextInt();
				
			}
		}
		for(i=0;i<m;i++){
			
			vec[i]=as.nextInt();
			
		}
		
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				mul[i]=mul[i]+(mat[i][j]*vec[j]);
			}
		    str=String.valueOf(mul[i]);
			System.out.println(str);
		}
		

	}

}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int x = 0, ans = 0;
    for(char c : s){
        if(c == 'I') x++;
        else x--;
        if(x > ans) ans = x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int sum = (1LL+i)*i/2;
    if (sum >= n) {
      int remove = sum-n;
      for (int j = 1; j <= i; j++) {
        if (j != remove)
          cout << j << endl;
      }
      return 0;
    }
  }
}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main() {
    map<string, int> m;
    int n; cin >> n;
    m["AC"] = m["WA"] = m["TLE"] = m["RE"] = 0;
    
    rep(i,n){
        string s; cin >> s;
        m[s]++;
    }
    
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 3636
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const num = Number(inputs[0].split(' ')[0]);
  const bossNum = inputs[1].split(' ').map(Number);
  const ans = new Array(num).fill(0);

  bossNum.forEach((value) => ans[value - 1]++);

  console.log(ans.join('\n'));
}


Measured memory_bytes: 53300
#define VERNIY st();int ver=0,niy=0,hbk=0
//#pragma GCC optimize("0fast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <functional>
typedef unsigned long long LLU;
typedef long long LL;
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
typedef vector<int> vd;
typedef vector<pair<int,int> > vpd;
typedef pair<int,int> pd;
typedef queue<int> qd;
typedef queue<pair<int,int> > qpd;
typedef priority_queue<int> maxpqd;
typedef priority_queue<int, vector<int>, greater<int> > minpqd;
#define fr front
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; ++a)
#define forineq(a,b,c) for(int a=b ; a<=c ; ++a)
#define forde(a,b,c) for(int a=b ; a>=c ; --a)
#define UPC(oo) (oo>='A' && oo<='Z')
#define LWC(oo) (oo>='a' && oo<='z')
#define DGT(oo) (oo>='0' && oo<='9')
#define UPCVOC(oo) (oo=='A' || oo=='E' || oo=='I' || oo=='U' || oo=='O')
#define LWCVOC(oo) (oo=='a' || oo=='e' || oo=='i' || oo=='u' || oo=='o')
#define filein freopen("in.txt","r",stdin);
#define fileout freopen("out.txt","w",stdout);
#define setarr(a,b,c) memset(a,b,sizeof(c))

template<class Ver>
inline void in(Ver &a){cin>>a;}
template<class Ver>
inline void in(Ver &a, Ver &b){cin>>a>>b;}
template<class Ver>
inline void in(Ver &a, Ver &b, Ver &c){cin>>a>>b>>c;}

template<class Ver>
inline void out(Ver a){cout<<a<<"\n";};
template<class Ver>
inline void out(Ver a,Ver b){cout<<a<<" "<<b<<"\n";};
template<class Ver>
inline void out(Ver a, Ver b, Ver c){cout<<a<<" "<<b<<" "<<c<<"\n";};

inline void debug(){cout<<"asd"<<endl;}
template<class Ver>
inline void debug(Ver a){cout<<"--- "<<a<<endl;};
template<class Ver>
inline void debug(Ver a,Ver b){cout<<"--- "<<a<<" "<<b<<endl;};
template<class Ver>
inline void debug(Ver a,Ver b,Ver c){cout<<"--- "<<a<<" "<<b<<" "<<c<<endl;};

#define GRAVITY 9.8
#define PI 3.14159265358979323846

void st()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}


int main()
{
	VERNIY;
	double r,area,circumference;
	in(r);
	area=PI*r*r;
	circumference=2*PI*r;
	printf("%lf %lf\n",area,circumference);
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, long long D, std::vector<long long> X,
           std::vector<long long> Y) {
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if( X[i] * X[i] + Y[i] * Y[i] <= D * D ){
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long D;
    scanf("%lld", &D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &X[i]);
        scanf("%lld", &Y[i]);
    }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

map<lli,lli> cnt;

void func(long long N, long long T, std::vector<long long> A){

    lli maxH = A[N-1];
    for(lli i=N-2;i>=0;i--){
        if(maxH>A[i])cnt[-(maxH-A[i])]++;
        chmax(maxH,A[i]);
    }

    auto itr = cnt.begin();

    cout<<(*itr).second<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, T, std::move(A));
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;

int h, w;
vector<vector<char>> S(h, vector<char>(w));

int main(){

    cin >> h >> w;
    vector<vector<char>> S(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> S[i][j];
        }
    }

    int T[h][w];
    int B[h][w];
    int R[h][w];
    int L[h][w];

    for (int i = 0; i < h; i++) {
        int tmp = 0;
        for (int j = 0; j < w; j++) {
            if(S[i][j] == '#') tmp = 0;
            else tmp ++;
            L[i][j] = tmp;
        }
    }
    for (int i = 0; i < h; i++) {
        int tmp = 0;
        for (int j = w-1; j >= 0; j--) {
            if(S[i][j] == '#') tmp = 0;
            else tmp ++;
            R[i][j] = tmp;
        }
    }
    for (int i = 0; i < w ; i++) {
        int tmp = 0;
        for (int j = 0; j < h; j++) {
            if(S[j][i] == '#') tmp = 0;
            else tmp ++;
            T[j][i] = tmp;
        }
    }        
    for (int i = 0; i < w; i++) {
        int tmp = 0;
        for (int j = h-1; j >= 0; j--) {
            if(S[j][i] == '#') tmp = 0;
            else tmp ++;
            B[j][i] = tmp;
        }
    }

    int res = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (S[i][j] == '.') {
                res = max(res, (T[i][j] + B[i][j] + R[i][j] + L[i][j] - 3));
            }
        }        
    }

    cout << res << endl;

    return 0;
    
}

// WA
/*

int dfs(int x, int y) {

    int dx[4] = {1,0,0, -1};
    int dy[4] = {0,1,-1,0};

    int cnt = 1;

    for (int i = 0; i < 4; i++) {
        if (x+dx[i] >= 0 && x+dx[i] < h && y+dy[i] >= 0 && y+dy[i] < w) {

            if(S[x+dx[i]][y+dy[i]] == '.') {
                dfs(x+dx[i], y+dy[i]);
                cnt ++;
            }
        }
    }

    return cnt;
        
}

    


int main() {

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

    vector<vector<char>> S(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> S[i][j];
        }
    }

    int res = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
        
            if (S[i][j] == '.') {
                res = max(res, dfs(i, j));
            }
            
        }
    }

    cout << res << endl;

    return 0;

}
*/

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

using namespace std;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

struct Bipartite_Graph : UnionFind {
  vector< int > color;

  Bipartite_Graph(int v) : color(v + v, -1), UnionFind(v + v) {}

  bool bipartite_graph_coloring() {
    for(int i = 0; i < color.size() / 2; i++) {
      int a = find(i);
      int b = find(i + (int) color.size() / 2);
      if(a == b) return (false);
      if(color[a] < 0) color[a] = 0, color[b] = 1;
    }
    return (true);
  }

  void unite_diff(int x, int y) {
    unite(x, y + color.size() / 2);
    unite(y, x + color.size() / 2);
  }

  bool operator[](int k) {
    return (bool(color[find(k)]));
  }
};

int main() {
  int N, D1, D2;
  cin >> N >> D1 >> D2;
  vector< pair< int, int > > xs, ys;
  for(int i = -2 * N; i <= 2 * N; i++) {
    for(int j = -2 * N; j <= 2 * N; j++) {
      int sum = i * i + j * j;
      if(sum == D1) xs.emplace_back(i, j);
      if(sum == D2) ys.emplace_back(i, j);
    }
  }
  auto isin = [&](int x, int y) {
    return 0 <= x && x < 2 * N && 0 <= y && y < 2 * N;
  };
  Bipartite_Graph latte(4 * N * N), malta(4 * N * N);
  for(int i = 0; i < 2 * N; i++) {
    for(int j = 0; j < 2 * N; j++) {
      for(auto &x : xs) {
        if(isin(i + x.first, j + x.second)) {
          latte.unite_diff(i * (2 * N) + j, (i + x.first) * (2 * N) + (j + x.second));
        }
      }
      for(auto &y : ys) {
        if(isin(i + y.first, j + y.second)) {
          malta.unite_diff(i * (2 * N) + j, (i + y.first) * (2 * N) + (j + y.second));
        }
      }
    }
  }
  assert(latte.bipartite_graph_coloring());
  assert(malta.bipartite_graph_coloring());
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < 2; j++) {
      vector< int > lis;
      for(int k = 0; k < 4 * N * N; k++) {
        if(latte[k] == i && malta[k] == j) lis.emplace_back(k);
      }
      if(lis.size() >= N * N) {
        lis.resize(N * N);
        for(auto &p : lis) {
          cout << p / (2 * N) << " " << p % (2 * N) << endl;
        }
        return 0;
      }
    }
  }
}


Measured memory_bytes: 13044
n, m = map(int, input().split())

count = [0] * m
for i in range(n):
    k = list(map(int, input().split()))
    k = k[1:]
    for kk in k:
        count[kk - 1] += 1
total = 0
for c in count:
    if c == n:
        total += 1
print(total)

Measured memory_bytes: 3064
days = int(input())

prev = [0, 0, 0]
while days:
    nxt = [0, 0, 0]
    a, b, c = map(int, input().split())
    nxt[0] = a + max(prev[1], prev[2])
    nxt[1] = b + max(prev[0], prev[2])
    nxt[2] = c + max(prev[0], prev[1])
    prev = nxt
    days -= 1

print(max(prev))

Measured memory_bytes: 3064
import java.util.*;
     
    public class Main {
        public static void main(final String[] args) {
            Scanner sc = new Scanner(System.in);
            int w = sc.nextInt();
            int h = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
     
            double area = (double) w * h / 2;
            boolean flag = (w == 2 * x) && (h == 2 * y);
            System.out.println(area + " " + (flag ? 1 : 0));
        }
    }

Measured memory_bytes: 38968
# import time

N,P = list(map(int,input().split()))
S = input()

if P == 2:
    c = 0
    for i in range(N):
        u = int(S[i])
        if u % 2 == 0:
            c += i+1
    print(c)
        
elif P == 5:
    c = 0
    for i in range(N):
        u = int(S[i])
        if u % 5 == 0:
            c += i+1
    print(c)

else:
    U = [0]
    a = 0
    t = 1
    
    for i in range(N):
        t %= P
        a += int(S[-i-1])*t
        a %= P
        t *= 10
        U.append(a)
    U.append(10001)
    # print(U)
    
    # t3 = time.time()
    
    c = 0
    
    """
    for i in range(P):
        m = U.count(i)
        c += m*(m-1)//2
    print(c)
    """
    U.sort()
    # print(U)
    idx = 0
    q = -1
    for i in range(N+2):
        if q != U[i]:
            q = U[i]
            m = i - idx
            idx = i
            c += m*(m-1)//2
    print(c)
    # t4 = time.time()
    # print(t4-t3)
    
    # 10032

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

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

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    S[K-1] = tolower(S[K-1]);
    cout << S << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n)cin >> v[i];
  int L,Q;
  cin >> L >> Q;
  vector<vector<int>> next(n,vector<int>(20,n-1));
  rep(i,n){
    auto iter = lower_bound(ALL(v),v[i]+L);
    if(iter == v.end())continue;
    if(*iter <= v[i]+L)next[i][0] = iter-v.begin();
    else next[i][0] = iter-v.begin()-1;
  }
  rep(j,19)rep(i,n)next[i][j+1] = next[next[i][j]][j];
  while(Q--){
    int a,b;cin >> a >> b;
    a--,b--;
    if(a > b)swap(a,b);
    int l = 0,r = 100100;
    while(r-l > 1){
      int mid = (r+l)/2;
      int pos = a;
      for(int i = 19;i >= 0;i--)if(mid >> i & 1)pos = next[pos][i];
      if(pos >= b)r = mid;
      else l = mid;
    }
    cout << r << endl;
  }







  return 0;
}

Measured memory_bytes: 15372
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%10!=0)Cout(sum);
    else{
        pos=sum;
        sort(a,a+n);
        rep(i,n){
            if(a[i]%10!=0){
                pos=a[i];
                break;
            }
        }
        Cout(sum-pos);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int mod = 1e9 + 7;

int N;

int main() {
    cin >> N;
    vector<int> cnt(N);
    int a, zero = 0;
    long long ans = 1;
    vector<int> cnt2(N);
    for (int i = 0; i < N; i++) {
        cin >> a;
        cnt[a]++;
        cnt2[a]++;
        if (cnt2[a] > 3) {
            ans = 0;
        }
        if (a == 0) {
            zero++;
            continue;
        }
        ans = ans * cnt[a - 1] % mod;
        cnt[a - 1]--;
    }
    if (zero == 1) {
        ans = ans * 3LL % mod;
    } else {
        ans = ans * 6LL % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=ll(a);i<ll(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

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

ll n,x,cnt;

int solve(){
  cnt=0;
  rep(i,1,n+1) rep(j,i+1,n+1) rep(k,j+1,n+1){
    if(i+j+k == x)cnt++;
  }

  cout << cnt << endl;

  return 0;
}

int main(){
  for(;;){
    cin >> n >> x;
    if(n==0 && x==0)return 0;
    solve();
  }
  return 0;
}




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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {


	int n;
	cin >> n;

	VI v(n);
	REP(i, n)cin >> v[i];

	int ans = 0;

	FOR(i, 1, n - 1) {
		if (v[i - 1] < v[i] && v[i] < v[i + 1])ans++;
		else if (v[i - 1] > v[i] && v[i] > v[i + 1])ans++;

	}
	
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int key;
    struct Node *prev;
    struct Node *next;
};
   
struct Node *note;
   
void insert(int key) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key;
    note->next->prev = x;
    x->next = note->next;
    note->next = x;
    x->prev = note;
}
   
struct Node* search(int key) {
    struct Node *x = note->next;
    while(x != note && x->key != key ) {
        x = x-> next;
    }
    return x;
}
   
void deleteNode(struct Node *t) {
    if (t == note) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
}
 void deleteKey(int key) {
    deleteNode(search(key));
}  
void deleteFirst() {
    deleteNode(note->next);
}
   
void deleteLast() {
    deleteNode(note->prev);
}
   
void print() {
    struct Node *x;
    x = note->next;
    int i = 0;
    while(1) {
        if (x == note) break;
    	if(i++ > 0) printf(" ");
        printf("%d", x->key);
        x = x->next;
    }
    printf("\n");
}
   
   
int main(void) {
    int key, n;
    char order[20];
    scanf("%d", &n);
    note = (struct Node *)malloc(sizeof(struct Node));
    note->next = note;
    note->prev = note;
    for (int i = 0; i < n; i++) {
        scanf("%s%d",order, &key);
        if(order[0] == 'i') {
            insert(key);
        }else if(order[0] == 'd') {
            if(strlen(order) > 6) {
                if( strlen(order) > 10) {
                    deleteFirst();
                }else if( strlen(order) > 9) {
                    deleteLast();
                }
            }else {
                deleteKey(key);
            }
        }
    }
    print();
    return 0;
}

Measured memory_bytes: 36132
#include <iostream>
using namespace std;
int main(){
  const long long INF = 1LL << 60;
  int N;cin>>N;
  long long H[N];
  for (int i=0;i<N;++i){
    cin>>H[i];
  }
  long long dp[N];
  dp[0]=0;
  for (int i=1;i<N;++i){
    dp[i]=INF;
  }
  for (int i=1;i<N;++i){
    if (dp[i]>dp[i-1]+abs(H[i]-H[i-1]))dp[i]=dp[i-1]+abs(H[i]-H[i-1]);
    if (i>1){
      if (dp[i]>dp[i-2]+abs(H[i]-H[i-2]))dp[i]=dp[i-2]+abs(H[i]-H[i-2]);
    }
  }
  cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
void dfs(void);
void visit(int);
 
int G[N][N],n,d[N],f[N],color[N],time;
 
int main(){
   int i,j,k,u,v;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      G[i][j] = 0;
    }
  }
  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    u=u-1;
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      v=v-1;
      G[u][v] = 1;
    }
  }
  dfs();
  return 0;
}
  void dfs(){
    int u;
    for(u = 0; u < n; u++) color[u] = WHITE;
    time = 0;
    for(u =0 ; u < n; u++){
      if(color[u] == WHITE) visit(u);
    }
    for( u = 0; u < n; u++){
      printf("%d %d %d\n",u+1,d[u],f[u]);
    }
  }
  void visit(int u){
    int v;
    color[u] = GRAY; 
    d[u] = ++time;
    for(v = 0; v < n; v++){
      if(G[u][v] == 0) continue;
      if(color[v] == WHITE){
    visit(v);
      }
    }
    color[u] = BLACK;
    f[u] = ++time;
  }

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
using namespace std;
static const int N = 2000;

int main() {
    int n; cin >> n;
    int l[N];
    int out = 0;

    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l, l + n);

    for (int i = n - 1; i >= 2; i--) {
        int stop = i - 1;
        for (int j = 0; j < i - 1; j++) {
            if (j >= stop) {
                int m = i - j - 1;
                out += (m + 1) * m / 2;
                break;
            }
            int diff = l[i] - l[j];
            for (int k = stop; k > j; k--) {
                if (l[k] <= diff) {
                    break;
                }
                stop--;
            }
            out += i - stop - 1;
        }
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}else if(a<b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}
	

Measured memory_bytes: 2612
n = int(input())
a = list(map(int, input().split()))
n = max(a)
tmp = n / 2
r = n + 1
d = n + 1
for num in a:
    if num == n:
        continue
    d_tmp = abs(num - tmp)
    if d_tmp < d:
        d = d_tmp
        r = num
print(n, r)

Measured memory_bytes: 14052
def bubblesort(A, N):
    count = 0
    flag = 1
    while flag:
        flag = 0
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j-1], A[j] = A[j], A[j-1]
                flag = 1
                count += 1
    return A, count
    
N = int(input())
A = list(map(int, input().split()))
A, count = bubblesort(A, N)
print(*A)
print(count)


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int w,a,b;
  cin>>w>>a>>b;
  if(a<=b){
    if(b-(a+w)>=0){
      cout<<b-(a+w)<<endl;
    }else{
      cout<<0<<endl;
    }
  }else{
    if(a-(b+w)>=0){
      cout<<a-(b+w)<<endl;
    }else{
      cout<<0<<endl;
    }
  }
  
  
  
}
///////////////////////////






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

bool sieve[1000000];

int main() {
	int n;

	sieve[0] = true;
	sieve[1] = true;

	while (std::cin >> n) {
		if (n <= 1) {
			std::cout << 0 << std::endl;
			continue;
		}

		for (int i = 2; i*i <= n; ++i) {
			if (!sieve[i]) {
				for (int j = i + i; j <= n; j += i)
					sieve[j] = true;
			}
		}

		std::cout << std::count(sieve, sieve + n + 1, false) << std::endl;
	}
}

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

using namespace std;

int main()
{
  int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int x, y; cin >> x >> y;
  if (a[x] == a[y]) puts("Yes");
  else puts("No");
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, ll W, std::vector<ll> w, std::vector<ll> v) {
  ll sum = 0;
  rep(i, N) sum += v.at(i);

  vector<vector<ll>> dp(N + 1, vector<ll>(sum + 1, LINF));
  dp.at(0).at(0) = 0;

  rep(i, N) {
    for (int j = sum; j >= 0; j--) {
      dp.at(i + 1).at(j) = dp.at(i).at(j);
      if (j - v.at(i) >= 0)
        chmin(dp.at(i + 1).at(j), dp.at(i).at(j - v.at(i)) + w.at(i));
    }
  }

  ll ans = 0;
  rep(i, sum + 1) {
    if (dp.at(N).at(i) <= W) ans = i;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  ll W;
  scanf("%lld", &W);
  std::vector<ll> w(N);
  std::vector<ll> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &w[i]);
    scanf("%lld", &v[i]);
  }
  solve(N, W, std::move(w), std::move(v));
  return 0;
}


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

#define PAUSE system("pause")
#define LLI long long int
#define LD long double
#define PB push_back
#define PF push_front
#define MP make_pair
#define FORi(i, a, b) for(int i = a; i < b ; ++i)
#define FORd(i, a, b) for(int i = a; i > b ; --i)

using namespace std;

int main() {
	int n;
	cin >> n;
	int sum = 0, smallest_not_div_by_10 = -1, tmp;
	FORi(i,0,n){
		cin >> tmp;
		sum += tmp;
		if (tmp%10 && (smallest_not_div_by_10<0 || smallest_not_div_by_10>tmp)){
			smallest_not_div_by_10 = tmp;
		}
	}
	cout << (smallest_not_div_by_10<0?0:(sum%10?sum:sum - smallest_not_div_by_10));
	return 0;
}

Measured memory_bytes: 256
import bisect
a,b,q = input().split()
a = int(a)
b = int(b)
q = int(q)
s = []
for i in range(a):
    s.append(int(input()))
t = []
for i in range(b):
    t.append(int(input()))
x = []
for i in range(q):
    x.append(int(input()))
s = [-10**18] + s + [10**18]
t = [-10**18] + t + [10**18]

for xi in x:
    ans = 10 ** 18
    id1_rs = bisect.bisect_right(s,xi)
    id1_rt = bisect.bisect_right(t,xi)
    id1_ls = id1_rs - 1
    id1_lt = id1_rt - 1
    for i1 in [id1_ls,id1_rs]:
        id2_rt = bisect.bisect_right(t,s[i1])
        id2_lt = id2_rt - 1
        if id2_rt==len(t):
            id2_rt -= 1
        for i2 in [id2_rt,id2_lt]:
            ans_tmp = abs(xi - s[i1])
            ans_tmp += abs(s[i1] - t[i2])
            if ans > ans_tmp:
                ans = ans_tmp
    for i1 in [id1_lt,id1_rt]:
        id2_rs = bisect.bisect_right(s,t[i1])
        if id2_rs==len(s):
            id2_rs -= 1
        id2_ls = id2_rs - 1
        for i2 in [id2_rs,id2_ls]:
            ans_tmp = abs(xi - t[i1]) + abs(t[i1] - s[i2])
            if ans > ans_tmp:
                ans = ans_tmp
    print(ans)

Measured memory_bytes: 16776
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 1e5 + 10;

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
//    ifstream cin("in.txt");
    int a, b;
    cin >> a >> b;
    cout << a + (b / 2) << endl;
    return 0;
}


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


using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<int> a(n);

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

	if (n == 2) {
		cout << abs(a[0] - a[1]);
		return 0;
	}

	sort(a.begin(), a.end(), greater<int>());

	LL ans = 0;

	if (n % 2 == 0) {
		int twicenum = (n - 2) / 2;

		for (int i = 0; i < twicenum; i++) {
			ans += (LL)(2 * a[i]);
		}

		for (int i = 0; i < twicenum; i++) {
			ans -= (LL)(2 * a[n - 1 - i]);
		}

		ans += a[twicenum];
		ans -= a[twicenum + 1];
	}
	else {
		LL ans1 = 0;
		LL ans2 = 0;

		int twicenum = (n - 1) / 2;
		int twicenum2 = twicenum - 1;
		for (int i = 0; i < twicenum; i++) {
			ans1 += (LL)(2 * a[i]);
		}

		for (int i = 0; i < twicenum2; i++) {
			ans1 -= (LL)(2 * a[n-1-i]);
		}

		ans1 -= (LL)a[twicenum];
		ans1 -= (LL)a[twicenum + 1];

		for (int i = 0; i < twicenum; i++) {
			ans2 -= (LL)(2 * a[n-1-i]);
		}

		for (int i = 0; i < twicenum2; i++) {
			ans2 += (LL)(2 * a[i]);
		}

		ans2 += (LL)a[twicenum];
		ans2 += (LL)a[twicenum -1];

		ans = max(ans1, ans2);

	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    ll n,k;
    cin >> n >> k;

    vector<int> d(k);
    
    vector<int> b(n);
    for(int i=0;i<n;i++){
        b.at(i)=i+1;
    }
    rep(i,k){
        cin >> d.at(i);
        vector<int> a(d.at(i));
        rep(j,d.at(i)){
            cin >> a.at(j);
            for(int h=0;h<n;h++){
                if(b.at(h)==a.at(j)){
                    b.at(h)=-1;
                }
            }
        }
    }

    ll count=0;
    for(int i=0;i<n;i++){
        if(b.at(i)!=-1){
            count++;
        }
    }

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



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

#define INF 1000000000000


signed main(){
int n,m,x,y;
cin>>n>>m>>x>>y;
int hantei;
int a[n],b[m];
rep(i,n){cin>>a[i];}
rep(i,m){cin>>b[i];}

for(int i=x+1;i<=y;i++){
  hantei=0;
  rep(j,n){
    if(i<=a[j]){hantei++;}
  }
  rep(k,m){
    if(i>b[k]){hantei++;}
  }
  if(hantei){continue;}
  else{
  cout<<"No War";
  exit(0);
}
}
cout<<"War";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m,k; cin >> n >> m >> k;
    vector<ll> a(n),b(m);
    vector<ll> sa(n+1,0),sb(m+1,0);
    rep(i,0,n){
        cin >> a[i];
        sa[i+1] = sa[i]+a[i];
    }
    rep(i,0,m){
        cin >> b[i];
        sb[i+1] = sb[i]+b[i];
    }
    ll ans = 0;
    rep(i,0,n+1){
        ll p = k-sa[i];
        if(p<0){
            break;
        }
        ll q = lower_bound(all(sb),p)-sb.begin();
        if(sb[q]!=p){
            q--;
        }
        chmax(ans,q+i);
    }
    cout << ans << endl;
}

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

int main(){
  int N,x;cin>>N>>x;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  
  long res=0;
  
  for(int i=1;i<N;i++){
    long sum=A.at(i)+A.at(i-1);
    
    if(sum>x){
      res+=sum-x;
      int difference=x-A.at(i-1);
      
      if(difference<0){
        A.at(i)=0;
        A.at(i-1)=x;
      }
      else{
        A.at(i)=difference;
      }
    }
  }
  
  cout<<res;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

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

	int ret = -1;
	for (int i = 0; i < 2000; ++i) {
		if ((a == i * 8 / 100) && (b == i / 10)) {
			ret = i;
			break;
		}
	}

	cout << ret << endl;

	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int t_lim = a / d;
  int a_lim = c / b;
  if (a % d != 0) t_lim++;
  if (c % b != 0) a_lim++;
  
  if (t_lim >= a_lim) cout << "Yes" << endl;
  else cout << "No" <<endl;
  
  return 0;
    
}

Measured memory_bytes: 3636