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

using namespace std;

using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;


pair<long long,long long> dp[110][110*1100];
//long long dpv[110][110*11000];
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);

	int n = 0;
	int w = 0;
	cin >> n >> w;
	vector<pll> data(n);
	long long vs = 0;
	for(int i = 0;i < n;++i){
		cin >> data[i].first >> data[i].second;
		vs+=data[i].second;
	}
	for(int i = 0;i < 110; ++i){
		for(int j = 0; j < 110*1100; ++j){
			dp[i][j].first = 1e18;
		}
	}
/*	for(int i = 0;i < 110; ++i){
		dp[i][0].first = 0;
	}*/
	dp[0][0].first = 0;
/*	for(int i = 0;i < 110 * 1100; ++i){
		dp[0][i].first = 0;
	}*/

	//dp[0][0].first = 0;

	for(int i = 0;i <= vs;++i){
		for(int j = 0;j < n; ++j){
			if(dp[j][i].first /*+ data[j].first*/ < w){
				dp[j + 1][i + data[j].second].first = min(dp[j + 1][i + data[j].second].first,dp[j][i].first + data[j].first);
				dp[j+1][i].first = min(dp[j+1][i].first,dp[j][i].first);
			}
		}
	}
	for(int i = vs; i >=0; --i){
		for(int j = 0; j <=n; ++j){
			if(dp[j][i].first <= w)
			{
				cout << i;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 208256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
LL MOD=1000000007;
int main(){
  int N,M;cin>>N>>M;
  vector<int>A(N),B(M);
  for(int &a:A)cin>>a;
  for(int &b:B)cin>>b;
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  LL as=0,bs=0;
  LL ans=1;
  for(int C=N*M;C>=1;C--){
    vector<int>::iterator ita=lower_bound(A.begin(),A.end(),C);
    vector<int>::iterator itb=lower_bound(B.begin(),B.end(),C);
    if(*ita==C)as++;
    if(*itb==C)bs++;
    if(*ita==C && *itb==C)ans*=1;
    else if(*ita==C && *itb!=C)ans=(ans*bs)%MOD;
    else if(*ita!=C && *itb==C)ans=(ans*as)%MOD;
    else if(*ita!=C && *itb==C)ans=(ans*as)%MOD;
    else ans=(ans*(as*bs-(N*M-C)))%MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define MAXN 110
#define MAXW 110000
using namespace std;

int N, W;
long long dp[MAXW];
long long v[MAXN];
int w[MAXN];

int main()
{
    cin >> N >> W;
    for (int i = 1; i <= N; i++)
    {
        cin >> w[i] >> v[i];
    }
    for (int i = 1; i <= N; i++)
    {
        for (int j = W; j >= w[i]; j--)
        {
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    cout << dp[W];
    return 0;
}

Measured memory_bytes: 1024
N = input()
if N[-1] == "3":
  print("bon")
elif N[-1] == "0":
  print("pon")
elif N[-1] == "1":
  print("pon")
elif N[-1] == "6":
  print("pon")
elif N[-1] == "8":
  print("pon")
else:
  print("hon")

Measured memory_bytes: 9120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0;i<n;i++){
        int x,y;
        cin >> x >> y;
        ans += y-x+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int w, h, x, y, r;
  std::cin >> w >> h >> x >> y >> r;

  bool inside = true;
  if (x - r < 0 || x + r > w || y - r < 0 || y + r > h) {
    inside = false;
  }

  std::string result = (inside) ? "Yes" : "No";
  std::cout << result << std::endl;
  
  return 0;
}


Measured memory_bytes: 3204
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
  int N,X; cin>>N>>X;
  vector<int>L(N);
  rep(i,N)cin>>L[i];
  int count=0;
  int ans=1;
  rep(i,N){
    count+=L[i];
    if(X>=count)ans++;
  }
  cout<<ans<<endl;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

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

    lint sum = 0;
    for (int i = 0; i < N.size(); i++) {
        int k = int(N[i] - '0');
        sum += k;
    }

    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graph;
int n, m;
int main() {
    cin >> n >> m;
    graph = vector<vector<int>>(n);
    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }

    int cnt = 0;
    bool flg = true;
    while(flg) {
        flg = false;
        for(int i = 0; i < n; ++i) {
            if(graph.at(i).size() == 1) {
                flg = true;
                cnt++;
                int now = graph.at(i).at(0);
                graph.at(i).pop_back();
                int nowlen = graph.at(now).size();
                for(int j = 0; j < nowlen; ++j) {
                    if(graph.at(now).at(j) == i) {
                        graph.at(now).erase(graph.at(now).begin()+j);
                        break;
                    }
                }
            }
        }
    }

    cout << cnt << endl;
}

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

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(v) (v).begin(),(v).end()
#define endl '\n'

using namespace std;

const int N = 200005;
const int INF = 2000000000;
const ll INFLL = 1LL * INF * INF;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0;
    else cout << 10 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		Time[] times = new Time[n];
		int maxTime = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int x = sc.nextInt();
			maxTime = Math.max(maxTime, b);
			times[i] = new Time(a, b, x);
		}
		Arrays.sort(times, new Comparator<Time>() {
		public int compare(Time t1, Time t2) {
			if (t1.channel == t2.channel) {
				return t1.start - t2.start;
			} else {
				return t1.channel - t2.channel;
			}
		}
        });
		
		ArrayList<Time> list = new ArrayList<>();
		Time prev = times[0];
		for (int i = 1; i < n; i++) {
			if (times[i].channel == prev.channel && prev.end == times[i].start) {
				prev.end = times[i].end;
			} else {
				list.add(prev);
				prev = times[i];
			}
		}
		list.add(prev);
		int[] imos = new int[maxTime + 1];
		for (Time t : list) {
			imos[t.start - 1]++;
			imos[t.end]--;
		}
		int max = 0;
		for (int i = 1; i <= maxTime; i++) {
			imos[i] += imos[i - 1];
			max = Math.max(max, imos[i]);
		}
		System.out.println(max);
		
	}
	
	static class Time {
		int start;
		int end;
		int channel;
		
		public Time(int start, int end, int channel) {
			this.start = start;
			this.end = end;
			this.channel = channel;
		}
	}
}


Measured memory_bytes: 93944
n = gets.split("").map(&:to_i)
cat = 0
t2 = n[0] * 10 + n[1]
e2 = n[2] * 10 + n[3]
if 1 <= t2 && t2 <= 12 && 1 <= e2 && e2 <= 12
  puts "AMBIGUOUS"
elsif 1 <= t2 && t2 <= 12
  puts "MMYY"
elsif 1 <= e2 && e2 <= 12
  puts "YYMM"
else
  puts "NA"
end
  

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define int long long
using namespace std;

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

  int x[n];

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

  int ans =1e18;

  for(int i=1;i<=100;i++){
  	int sum =0;
  	for(int j=0;j<n;j++){
        sum += (i-x[j])*(i-x[j]);
  	}

  	ans = min(ans,sum);
  }

  cout<<ans<<endl;
	return 0;
}

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

int main() {
	int s;cin>>s;
	vector<int> c(1000000,0);
	int ans=1;
	while(c[s]==0){
		c[s]=1;
		if(s%2){
			s=s*3+1;
		}else{
			s/=2;
		}
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<array>

using namespace std;

int main(){
    int N;
    cin >> N;
    int X=N;
    int count;
    while(1){
        count=0;
        for(int i=2;i<sqrt(N);i++){
            if(X%i==0) {
                count++;
                break;
            }
        }
        if(count==0) {
            cout << X << endl;
            break;
        }
        else X++;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  ll n,a,b,m=inf,c=1;
  cin>>n>>a>>b;
  if(abs(b-a)%2==0){
    cout<<abs(b-a)/2<<endl;
  }else{
    if(a>b){
      swap(a,b);
    }
    if(a-1>n-b){
      m=n-a;
    }else{
      m=b-1;
    }
    if(c){
      cout<<m-abs(b-a-1)/2<<endl;
    }

  }
  return 0;
}


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

int main(){
    long long n,m;
    cin>>n>>m;
    if(n == 1 && m == 1){
        cout<<"1\n";
    }else if(n == 1){
        cout<<m-2<<endl;
    }else if(m == 1){
        cout<<n-2<<endl;;
    }else{
        cout<<((n-2)*(m-2))<<endl;;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

vector<vector<int>> e;
vector<ll> s;
vector<bool> used;

void dfs(int p){
    used[p] = true;
    for(auto&& i : e[p]){
        if(used[i]) continue;
        s[i] += s[p];
        dfs(i);
    }
}

int main(){
    int n, q;
    cin >> n >> q;
    e = vector<vector<int>>(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    s = vector<ll>(n);
    for(int i = 0; i < q; i++){
        int p, x;
        cin >> p >> x;
        p--;
        s[p] += x;
    }
    used = vector<bool>(n);
    dfs(0);
    cout << s[0];
    for(int i = 1; i < n; i++){
        cout << " " << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 24320
#include<iostream>
#include<functional>
#include<iomanip>
#include<algorithm>
#include<vector>

using namespace std;
using ll = long long;

#define rep(i,n) for(int i = 0; i <(n); ++i)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

int main(){
  int n,a,b,c;  cin >> n >> a >> b >> c;
  ll ans = 100000000000000000LL;
  vector<int> l(n);  rep(i,n) cin >> l[i];
  rep(i,700000){
    ll tans = 0;
    int ta = 0;
    int tb = 0;
    int tc = 0;
    rep(j,n){
      int mask = 3 & (i >> (2 * j));
      if(mask == 0)
        ;
      if(mask == 1){
        if(ta != 0)  tans += 10;
        ta += l[j];
      }
      if(mask == 2){
        if(tb != 0)  tans += 10;
        tb += l[j];
      }
      if(mask == 3){
        if(tc != 0)  tans += 10;
        tc += l[j];
      }
    }
    if(ta == 0 || tb == 0 || tc == 0)  continue;
    tans += abs(a-ta) + abs(b-tb) + abs(c-tc);
    //cerr << tans << endl;
    ans = min(ans, tans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll n;
    cin >> n;
    string S[n];
    rep(i,n) cin >> S[i];
    string out = "";
    ll N = S[0].length();
    rep(i,N){
        ll cnt = 0;
        for(ll j=1;j<n;j++){
            ll M = S[j].length();
            rep(k,M){
                if(S[j][k]==S[0][i]){
                    S[j].erase(k,1);
                    cnt++;
                    break;
                }
            }
        }
        if(cnt==n-1) out += S[0][i];
    }
    sort(out.begin(),out.end());
    cout << out << endl;
    return 0;
}


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

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    vector<int> p_count(102, 0);
    for (int i=0; i<N; i++) {
        cin >> p[i];
        if (p_count.at(p[i]) == 0) {
            p_count.at(p[i]) = 1;
        }
    }
    int check_b = 0;
    for (int i=X+1; i<102; i++) {
        if (p_count[i] == 0) {
            check_b = i;
            break;
        }
    }
    int check_s = 0;
    for (int i=X; i>=0; i--) {
        if (p_count[i] == 0) {
            check_s = i;
            break;
        }
    }
    if (check_b- X < X - check_s) {
        cout << check_b << endl;
    }
    else if (check_b - X >= X - check_s) {
        cout << check_s << endl;
    }
}

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

int gcd(int a, int b){
    if(a < b) gcd(b, a);
    int r;
    while((r = a % b)){
        a = b;
        b = r;
    }
    return b;
}

int main(){

    int N, X, D = INT_MAX;
    cin >> N >> X;
    
    vector<int> x(N);
    for(int i = 0; i < N; i++) cin >> x[i];

    x.push_back(X);
    sort(x.begin(), x.end());

    set<int> max;
    for(int i = 0; i < N; i++) max.insert(x[i + 1] - x[i]);

    D = *max.begin();
    for(auto itr = max.begin(); itr != max.end(); itr++){
        D = gcd(D, *itr);
    }
    cout << D << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

bool isok(char c){
  return c=='A'||c=='C'||c=='G'||c=='T';
}


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

  int ret = 0;
  int b = -1;
  rep(i,S.size()){
    if(isok(S[i])){
      ret = max(ret, i-b);
    }else{
      b = i;
    }
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
// 5
// 4 4 9 7 5
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
		ll n;
		cin>>n;
		ll a[n];
		for(ll p=0;p<n;p++)
		{
			cin>>a[p];
		}
		ll co=0;
		for(ll j=0;j<n-2;j++)
		{
			for(ll h=j+1;h<n-1;h++)
			{
				for(ll d=h+1;d<n;d++)
				{
					if(a[j]!=a[h]&&a[h]!=a[d]&&a[d]!=a[j])
					{
						if((a[j]+a[h])>a[d]&&(a[h]+a[d])>a[j]&&(a[j]+a[d])>a[h])
						{
							//cout<<j+1<<" "<<h+1<<" "<<d+1<<endl;
							co++;
						}
					}
				}
			}
		}
		cout<<co<<endl;
}

Measured memory_bytes: 3636
/*
  This C++ Source Is
  Writen By syksykCCC
  (2020)
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for(register int i = x; i < y; i++)
#define REP(i, x, y) for(register int i = x; i <= y; i++)
#define per(i, x, y) for(register int i = x; i > y; i--)
#define PER(i, x, y) for(register int i = x; i >= y; i--)
#define repl(i, x, y) for(register long long i = x; i < y; i++)
#define REPL(i, x, y) for(register long long i = x; i <= y; i++)
#define perl(i, x, y) for(register long long i = x; i > y; i--)
#define PERL(i, x, y) for(register long long i = x; i >= y; i--)
#define LLL __int128
#define int128 __int128
#define DEBUG(x) cerr << #x << " : " << x << endl
using namespace std;
typedef unsigned int uint;
typedef long long int64;
typedef long long LL;
typedef unsigned long long uint64;
typedef long long ULL;
typedef long double LLF;
template<typename T> inline void read(T &val)
{
	val = 0; char c = getchar(); int f = 1;
	while(!isdigit(c)) { if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)) { val = (val << 3) + (val << 1) + (c ^ 48); c = getchar(); }
	val *= f;
}
template<typename T> void write_(T val) { if(!val) return; write_(val / 10); putchar(val % 10 + 48); }
template<typename T> inline void write(T val)
{
	if(val == 0) putchar(48);
	else if(val < 0) { putchar('-'); write_(-val); }
	else write_(val);
}

const int N = 55;
int n, t[N], ans, sum;
string s[N], X;

int main()
{
#ifdef LOCAL
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin >> n;
	REP(i, 1, n)
	{
		cin >> s[i] >> t[i];
		sum += t[i];
	}
	cin >> X;
	REP(i, 1, n)
	{
		ans += t[i];
		if(s[i] == X) break; 
	}
	cout << sum - ans << endl;
	return 0;
}


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

using namespace std;

long long A[1000];
long long B[1000];
long long TMP1[1000000];
long long A_B[3000];
long long TMP2[3000000];
long long C[1000];
long long result[3000];

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

    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    for (int i = 0; i < X; ++i)
        cin >> A[i];
    for (int i = 0; i < Y; ++i)
        cin >> B[i];
    for (int i = 0; i < Z; ++i)
        cin >> C[i];

    for(int i=0; i<X; ++i){
        for(int j=0; j<Y; ++j){
            TMP1[i*Y + j] =  A[i] + B[j];
        }
    }
    sort(TMP1, TMP1 + 1000000, greater<long>());
    for(int i =0; i < K; ++i){
        A_B[i] = TMP1[i];
    }

    for(int i=0; i<K; ++i){
        for(int j=0; j<Z; ++j){
            TMP2[i*Z + j] = A_B[i] + C[j];
        }
    }
    sort(TMP2, TMP2 + 3000000, greater<long>());
    for(int i =0; i < K; ++i){
        cout << TMP2[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 32248
//2019.5.15 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s*w;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=1e5+10;
namespace MAIN {
    int n,a[N];
    LL dp[N][2];
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)a[i]=read();
        dp[1][0]=a[1],dp[1][1]=-a[1];
        for(res i=2;i<n;i++)dp[i][0]=max(dp[i-1][0]+a[i],dp[i-1][1]-a[i]),dp[i][1]=max(dp[i-1][0]-a[i],dp[i-1][1]+a[i]);
        printf("%lld\n",max(dp[n-1][0]+a[n],dp[n-1][1]-a[n]));
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main(void){
    int h,w;
    while(1){
        cin >> h >> w;
        if( h == 0 && w == 0){
            break;
        }
        for(int i = 0;i<h;i++){
            for(int j = 0;j<w;j++){
                cout << '#';
            }
            cout << endl;
    }
    cout << endl;
    }
    
}



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

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

    long long index_a, index_z;

    for(long long i = 0; i < s.size(); i++){
        if(s[i] == 'A'){
            index_a = i;
            break;
        }
    }

    for(long long i = s.size(); i >= 0; i--){
        if(s[i] == 'Z'){
            index_z = i;
            break;
        }
    }

    cout << index_z - index_a + 1 << endl;

    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    string s, t;
    cin >> s >> t;
    int sol = 0;
    for(int i=0; i<3; i++){
        if(s[i] == t[i])
            sol++;
    }
    cout << sol;
}

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

int main(){
    int n;//候補の数
    double t;//温度の定数
    double a;//温度の目標
    double h;//標高
    int index;
    double min_val = 1000000;

    cin >> n >> t >> a;

    for(int i=0; i<n; i++){
        cin >> h;
        double val = abs(a - (t - h*0.006));
        if(val < min_val){
            min_val = val;
            index = i+1;
        }
    }
    cout << index << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

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

    map<long long, long long> T;

    long long x;

    for(int i = 0; i < n; i++){
        cin >> x;
        if(T.find(x) == T.end()){
            T[x] = 1;
        }
        else{
            T[x] +=1;
        }
    }

    //printf("insert\n");

    map<long long, long long>::iterator it;
    long long count = 0;
    long long max1 = 0;
    long long max2 = 0;
    for(it = T.begin(); it != T.end(); it++){
        if(it->second >= 2){
            count++;
            max1 = max(it->first, max1);
        }
    }

    if(count < 2){
        printf("0\n");
        return 0;
    }

    if(T[max1] >= 4){
        max2 = max1;
    }
    else{
        T.erase(max1);
        for(it = T.begin(); it != T.end(); it++){
            if(it->second >= 2){
                count++;
                max2 = max(it->first, max2);
            }
        }
    }

    printf("%lld\n", max1*max2);

    return 0;

}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int rs = 0, ar[101] = {};
int main()
{
	int n, k; cin >> n >> k;
	for (int i = 0; i < k; i++)
	{
		int x; cin >> x;
		while (x--) {int a; cin >> a; ar[a]++;}
	}
	for (int i = 1; i <= n; i++)
	{
		if (ar[i] == 0) {rs++;}
	}
	cout << rs << "\n";
	return 0;
}

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

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

  vector<vector<int>> a(n, vector<int>(n - 1));
  rep(i, n) rep(j, n - 1) {
      cin >> a[i][j];
      a[i][j]--;
  }

  vector<int> itr(n, 0);
  queue<int> que;
  set<int> end;

  for (int i = 0; i < n; i++) que.push(i);

  int day = 0;
  while(end.size() < n) {
    set<int> played;
    que.push(n);
    while(1) {
     int i = que.front();
     que.pop();
     if(i == n) break;

     if(played.count(i)) continue;
     if(end.count(i)) continue;

     int opp = a[i][itr[i]];
     if(played.count(opp)) continue;
     if(end.count(opp)) continue;

     if(a[opp][itr[opp]] == i) {

       que.push(i);
       que.push(opp);

       itr[i]++;
       itr[opp]++;

       if(itr[i] == n - 1) end.insert(i);
       if(itr[opp] == n - 1) end.insert(opp);

       played.insert(i);
       played.insert(opp);
     }
    }
    if(played.empty()) {
      cout << -1 << '\n';
      return 0;
    }
    day++;
  }
  cout << day << '\n';
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll A,B,C,D,E,F,G,H,I,J,K,N,i=0,j=0;
ll abc=0;
ll arc=0;
ll cnt=0;
string S,T;
map<char,ll> m;
bool flag;
int main()
{
	scanf("%lld",&N);
	vector<ll> v(N);
	for(i=0;i<N;i++) scanf("%lld",&v[i]);
	sort(v.begin(),v.end());
	for(ll K=1;K<=v[N-1];K++){
		auto ite=(upper_bound(v.begin(),v.end(),K));
		arc=ite-v.begin();
		abc=N-arc;
		if(abc<arc) break;
		if(abc==arc) cnt++;
	}
	printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s; cin >> s;
  ll n = s.size();

  Vll cnt(26);
  for (auto c : s) {
    int x = c - 'a';
    ++cnt[x];
  }

  ll ans = n*(n+1)/2 + 1;
  rep(i, 26) ans -= cnt[i]*(cnt[i]+1)/2;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3792
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let rec f n = if n mod 2 = 1 then 0 else 1 + f (n / 2)
let _ = Array.map f a_s |> Array.fold_left min max_int |> Printf.printf "%d\n"

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String abcd = in.next();
            int a = Integer.parseInt(abcd.substring(0, 1));
            int b = Integer.parseInt(abcd.substring(1, 2));
            int c = Integer.parseInt(abcd.substring(2, 3));
            int d = Integer.parseInt(abcd.substring(3, 4));

            char op[] = {'+', '-'};

            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < 2; j++) {
                    for (int k = 0; k < 2; k++) {
                        int ans = calc(a, op[i], b, op[j], c, op[k], d);
                        if (ans == 7) {
                            // 出力
                            out.println(a + String.valueOf(op[i]) + b + String.valueOf(op[j]) + c + String.valueOf(op[k]) + d + "=7");
                            return;
                        }
                    }
                }
            }

        }

        public static int calc(int a, char op1, int b, char op2, int c, char op3, int d) {
            int ret = 0;
            if (op1 == '+') {
                ret = a + b;
            } else {
                ret = a - b;
            }
            if (op2 == '+') {
                ret = ret + c;
            } else {
                ret = ret - c;
            }
            if (op3 == '+') {
                ret = ret + d;
            } else {
                ret = ret - d;
            }
            return ret;
        }

    }
}



Measured memory_bytes: 21844
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation
#include<complex>
#include<math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, j, n) for (int i = j; i < (int)(n); i++)

int main() {
	int N;
	cin >> N;
	long double answer;
	answer = N * 2 * 3.14159265;
	cout << answer << endl;
}


Measured memory_bytes: 3784
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,1);
  var genka1 = Math.floor(input / 1.08);
  var genka2 = Math.ceil(input / 1.08);
  var tmp1 = Math.floor(genka1 * 1.08);
  var tmp2 = Math.floor(genka2 * 1.08);
  if(input == tmp1){
     myout(genka1);
  }else if(input == tmp2){
    myout(genka2);
  }else{
    myout(":(");
  }
}

Main(myin());


Measured memory_bytes: 21064
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int y = sc.nextInt();
		
		int temp = 0;
		int a= 0 , b= 0 , c= 0;
		otosi :for( a = 0; a <= n ; a++) {
			for(b = 0 ; b <= n-a ; b++) {
				 c = n - a - b;
				int sum = 10000*a + 5000*b + 1000*c;
				if(sum == y) {
					temp = 1;
					break otosi;
				}
			}
		}
		if(temp == 1) {
		System.out.println(a+" "+b+" "+c);
		}
		if(temp == 0) {
	    System.out.println(-1+" "+-1+" "+-1);
		}

	}

}


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

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i = 0;i < N;i++)cin >> D[i];
    int sum = 0;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            if(i > j){
                sum += D[i] * D[j];
            }
        }
    }
    cout << sum << endl;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int m;
    Scd(m);
    printf ("%d\n", 48-m);

    return 0;
}



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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> A(n);
    for(i=0;i<n;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    ll ret = 1;
    ll now = 0;
    i=0;
    if(n%2==0)now++;
    if(n%2==1 && A[0]==0){
        i++;
        now+=2;
    }
    ll cnt = 0;
    for(;i<n;i++){
        if(now==A[i])cnt++;
        else{
            cout << 0 << endl;
            return 0;
        }
        if(cnt==2){
            ret*=2;
            cnt=0;
            now+=2;
        }
        ret%=MOD;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int translate(char Head){
	switch(Head){
	case 'R':return 0;
	case 'Y':return 1;
	case 'B':return 2;
	case 'M':return 3;
	case 'G':return 4;
	case 'C':return 5;
	}
	return -1; //must not reach here
}

class Dice{
public:
	Dice(){
		num_of_data = 0;
	};

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isNewPattern(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";

		for(int i = 0; i < num_of_data; i++){
			for(int k = 0; k < 6; k++)number[k] = data_bank[i][k];
			for(int k = 0; k < 24; k++){
				roll(order[k]);
				for(int j = 0; j < 6; j++){
					if(inputed[j] != number[j])
						break;
					if(j == 5)
						return false;
				}
			}
		}
		return true;
	}

	void init(){
		num_of_data = 0;
	}

	int getNumOfData(){
		return num_of_data;
	}

	void addData(int table[6]){
		data_bank[num_of_data][0] = table[0];
		data_bank[num_of_data][1] = table[1];
		data_bank[num_of_data][2] = table[2];
		data_bank[num_of_data][3] = table[3];
		data_bank[num_of_data][4] = table[4];
		data_bank[num_of_data][5] = table[5];
		num_of_data++;
	}

private:

	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}
private:
	int number[6];
	int data_bank[30][6];
	int num_of_data;
};

int main(){
	int n,tmp[6];
	char c1[10],c2[10],c3[10],c4[10],c5[10],c6[10];
	Dice dice;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		dice.init();

		for(int i = 0; i < n; i++){
			scanf("%s %s %s %s %s %s",c1,c2,c3,c4,c5,c6);
			tmp[0] = translate(c1[0]);
			tmp[1] = translate(c2[0]);
			tmp[2] = translate(c3[0]);
			tmp[3] = translate(c4[0]);
			tmp[4] = translate(c5[0]);
			tmp[5] = translate(c6[0]);

			if(dice.isNewPattern(tmp)){
				dice.addData(tmp);
			}
		}
		printf("%d\n",n-dice.getNumOfData());

	}
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var incList = new List<Tuple<int, int>>[n + 1];
        for (int i = 0; i < incList.Length; ++i)
        {
            incList[i] = new List<Tuple<int, int>>();
        }
        for (int i = 0; i < n - 1; ++i)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var a = ab[0];
            var b = ab[1];
            incList[a].Add(Tuple.Create(i, b));
            incList[b].Add(Tuple.Create(i, a));
        }

        var indices = E.Range(0, incList.Length).ToArray();
        var ds = incList.Select(x => x.Count).ToArray();
        Array.Sort(ds, indices);
        Array.Reverse(indices);

        var cs = new int[n - 1];
        var vs = new HashSet<int>[incList.Length];
        for (int i = 0; i < vs.Length; ++i)
        {
            vs[i] = new HashSet<int>();
        }
        var queue = new Queue<int>();
        queue.Enqueue(1);
        while (queue.Any())
        {
            int i = queue.Dequeue();
            var c = 1;
            for (int j = 0; j < incList[i].Count; ++j)
            {
                var e = incList[i][j];
                if (cs[e.Item1] > 0)
                {
                    continue;
                }
                queue.Enqueue(e.Item2);
                while (vs[e.Item2].Contains(c) || vs[i].Contains(c))
                {
                    ++c;
                }
                vs[i].Add(c);
                vs[e.Item2].Add(c);
                cs[e.Item1] = c;
            }
        }
        Console.WriteLine(cs.Max());
        Console.WriteLine(string.Join(Environment.NewLine, cs));
    }
}


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

int N;
vector<bool> d;
vector<vector<int>> h;
vector<int> color;
vector<int> path;
int count_d;

bool search(int u, int v) {
  for (int x : h.at(u)) {
    if (d.at(x))
      continue;
    d.at(x) = true;
    if (x == v) {
      path.push_back(x);
      return true;
    }
    if (search(x, v)) {
      path.push_back(x);
      return true;
    }
  }
  return false;
}

void dfs(int u, int v) {
  if (u == v)
    return;
  d.at(u) = true;
  count_d++;
  for (int x : h.at(u)) {
    if (!d.at(x))
      dfs(x, v);
  }
}

int main() {
  cin >> N;
  int u, v;
  d = vector<bool>(N + 1);
//  path = vector<int>(N);
  h = vector<vector<int>>(N + 1);
  color = vector<int>(N + 1);
  for (int i = 0; i < N + 1; i++)
    d.at(i) = false;
  for (int i = 0; i < N - 1; i++) {
    cin >> u >> v;
    h.at(u).push_back(v);
    h.at(v).push_back(u);
  }
  d.at(1) = true;
  search(1, N);
  for (int i = 0; i < N + 1; i++)
    d.at(i) = false;
  d.at(1) = true;
  dfs(1, path.at((path.size() + 1) / 2 - 1));
  if ( count_d > N / 2 )
    cout << "Fennec" << endl;
  else
    cout << "Snuke" << endl;
}


Measured memory_bytes: 13052
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int a,b,c,n,m,j;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        j=0;
        m=0;
        while(1){
            if(c>0&&b>0&&a>0){
                c--;b--;a--;m++;
            }
            else j++;
            if(j>0&&a>1&&b>0){
                b--;a--;a--;m++;
            }
            else if(j>0&&a<2||j>0&&b<1)break;
        }
        cout<<m+a/3<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#![allow(non_snake_case)]

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

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let q: usize = read();
    let mut sum: usize = a.iter().sum();
    use std::collections::HashMap;
    let mut map: HashMap<usize, usize> = HashMap::new();
    for v in a {
        let entry = map.entry(v).or_insert(0);
        *entry += 1;
    }
    for _ in 0..q {
        let b: usize = read();
        let c: usize = read();
        match map.get(&b) {
            None => {}
            Some(count) => {
                sum -= b * count;
                sum += c * count;
            }
        }
        let entry = map.entry(b).or_insert(0);
        let count = *entry;
        *entry = 0;
        let entry = map.entry(c).or_insert(0);
        *entry += count;
        println!("{}", sum);
    }
}


Measured memory_bytes: 6352
use io::*;
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        N : i64
    }
    let mut res = 0;
    for x in 1..=N {
        let y = N / x;
        res += (x * y * (y + 1)) / 2
    }
    print!("{}", res);
}


Measured memory_bytes: 2184
HP_t, ATK_t, HP_a, ATK_a = [int(x) for x in input().split()]
while True:
    HP_a = HP_a - ATK_t
    if HP_t <= 0:
        print('No')
        break
    HP_t = HP_t - ATK_a
    if HP_a <= 0:
        print('Yes')
        break

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
const int INF=1<<30;
int N;
int main()
{
	cin>>N;
	int Min=INF;
	int Ans=0;
	for (int i=1;i<=N;++i)
	{
		int v;
		scanf("%d",&v);
		Min=min(Min,v);
		if (v==Min) ++Ans;
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
import itertools

n,m = map(int, input().split())
XYZ = [list(map(int, input().split())) for _ in range(n)]
X = np.array([xyz[0] for xyz in XYZ])
Y = np.array([xyz[1] for xyz in XYZ])
Z = np.array([xyz[2] for xyz in XYZ])

ans_list = []

for i,j,k in itertools.product([1,-1], repeat=3):
  temp_ans = i*X+j*Y+k*Z
  ans_list.append(sum(np.sort(temp_ans)[::-1][:m]))
  
print(max(ans_list))

Measured memory_bytes: 12584
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, t = 0, x = 0, y = 0;
	scanf("%d", &n);
	for(int i = 0, j, k, l, m; i < n; ++i)
	{
		scanf("%d %d %d", &j, &k, &l);
		m = abs(k - x) + abs(l - y);
		if(m % 2 != (j - t) % 2 || m > j - t)
		{
			printf("No\n");
			return 0;
		}
		t = j;
		x = k;
		y = l;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long
#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define FORQ(i, b, e) for (int i = (b); i <= (e); ++i)
#define REP(x, n) for (int x = 0; x < (n); ++x)

using namespace std;

int n;
int a[10000];

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

    cin >> n;
    REP(i, n) cin >> a[i];

    sort(a,a+n);

    cout << (a[n-1] - a[0]) << "\n";
    
}

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

int main()
{   
    int n, a, b;
    cin >> n >> a >> b;  
    string s;
    cin >> s;
    int passed = 0;
    int bp = 0;
    for(int i=0; i< n; i++)
    {
       if(s[i] == 'c')
       cout << "No" << endl;
       if (s[i] == 'a')
       {
         if( passed < (a+b))
         {
           cout << "Yes" << endl;
           passed ++ ;
          }
         else 
           cout << "No" << endl;
       }
       if(s[i] == 'b')
       {
          if(passed < (a+b) )
          {
            if(bp+1 <= b)
            {
               cout << "Yes" << endl;
               bp ++;
               passed ++;
            }
            else{
               cout << "No" << endl;
            }

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

Measured memory_bytes: 1024
a, b = map(int, input().split())
if a > 0 and b > 0:
  print('Positive')
elif a == 0 or b == 0:
  print('Zero')
elif a * b < 0:
  print('Zero')
else:
  if (b - a) % 2 == 0:
    print('Negative')
  else:
    print('Positive')

Measured memory_bytes: 2940
K = int(input())
# ルンルン数の作成
L = [1,2,3,4,5,6,7,8,9]
nL = [1,2,3,4,5,6,7,8,9]
nL2 = []

def D1(a):
    if a == 0:
        return [0,1]
    elif a == 9:
        return [8,9]
    else:
        return [a-1,a,a+1]
        
for _ in range(9):

    for l in nL:
        for l2 in D1(int(str(l)[-1])):
            nL2.append(int(str(l)+str(l2)))
    # print("nL:",nL)
    # print("nL2:",nL2)
    nL = nL2.copy()
    L += nL
    nL2.clear()
    
    # print("nL:",nL)
    # print("nL2:",nL2)
    
    # print(len(L))

print(L[K-1])

Measured memory_bytes: 13072
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
  if(m==0)return 1;
  if(i >=n)return 0;
  int res =solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

int main(){
  int q,M,i;

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M)>0)printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2108
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        boolean[][] g = new boolean[8][8];
        boolean[] r = new boolean[8];
        boolean[] c = new boolean[8];
        boolean[] m = new boolean[15];
        boolean[] p = new boolean[15];
        for (int i = 0; i < k; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            g[x][y] = true;
            r[x] = true;
            c[y] = true;
            m[x-y+7] = true;
            p[x+y] = true;
        }
        g = dfs(g,r,c,m,p,8-k);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                sb.append(g[i][j] ? "Q" : ".");
            }
            sb.append("\n");
        }
        System.out.print(sb.toString());
        sc.close();

    }

    private static boolean[][] dfs(boolean[][] g, boolean[] r, boolean[] c, boolean[] m, boolean[] p, int i) {
        if(i == 0)return g;
        for (int j = 0; j < 8; j++) {
            if(r[j])continue;
            for (int k = 0; k < 8; k++) {
                if(c[k] || m[j-k+7] || p[j+k])continue;
                g[j][k] = true;
                r[j] = true;
                c[k] = true;
                m[j-k+7] = true;
                p[j+k] = true;
                boolean[][] t = dfs(g,r,c,m,p,i-1);
                if(t != null) return t;
                g[j][k] = false;
                r[j] = false;
                c[k] = false;
                m[j-k+7] = false;
                p[j+k] = false;
            }
        }
        return null;
    }

}



Measured memory_bytes: 26516
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
SP = [input().split() for _ in range(N)]

for i in range(1, N+1):
	SP[i-1].append(i)

SP.sort(key = lambda x: (x[0], -int(x[1])))

for i in range(N):
	print(SP[i][2])

Measured memory_bytes: 5200