akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define f first
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define ar array
#define N 200005

using namespace std;

ll bit[N];
void upd(int i, ll val){
    for(;i<N;i+=i&-i){
        bit[i] = max(bit[i], val);
    }
}
ll query(int i){
    ll val = 0;
    for(;i;i-=i&-i){
        val = max(val, bit[i]);
    }
    return val;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	int h[n];
    ll a[n];
	for(int i=0;i<n;i++){
        cin>>h[i];
	}
	for(int i=0;i<n;i++){
        cin>>a[i];
	}
	ll ans = 0, mx = 0;
	for(int i=0;i<n;i++){
        mx = query(h[i]) + a[i];
        ans = max(ans, mx);
        upd(h[i], mx);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll N_MAX = 2 * 1e9;


int main() {
	ll N;
	cin >> N;
	vll W(N);
	for (auto& e : W)cin >> e;
	ll T;
	ll s1 = W[0];
	ll s2 = accumulate(W.begin(), W.end(), 0) - s1;
	ll ans = abs(s1 - s2);
	for (ll t = 1; t < N - 1; t++) {
		s1 += W[t];
		s2 -= W[t];
		ans = min(ans, abs(s1 - s2));
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main()
{
	string str = "", res = "";
	getline (cin, str );

	for (int i = 0; i < str.length(); ++i){
		res += (26 + str[i] - 'A' - 3 ) % 26 + 'A';
	} // end for
	cout << res << endl;
		
	return 0;
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    int n;
    cin>>n;
    map <ll,ll> m;
    vector <ll> a(n);
    rep(i,n)
    cin>>a[i],m[a[i]]++;
    ll ans=0;
    for (auto to:m)
    {
        ans+=to.se*(to.se-1)/2;
    }
    for (int i=0;i<n;i++)
    {
        ll x=a[i];
        ans-=m[x]*(m[x]-1)/2;
        ans+=(m[x]-1)*(m[x]-2)/2;
        cout<<ans<<'\n';
        ans-=(m[x]-1)*(m[x]-2)/2;
        ans+=m[x]*(m[x]-1)/2;
    }




}

Measured memory_bytes: 11136
#include "bits/stdc++.h"

using namespace std;

const int MSIZE  = 100100;

long long dp[MSIZE];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(dp, 0x3f, sizeof dp);
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    dp[0] = 0;

    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= 2; j++) {
            if (i - j < 0) continue;
            dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const n = spi[0];
    const a = spi[1].split(' ').map(e => BigInt(e));

    a.sort(function(a, b){
        return (a < b ? -1 : 1);
    });

    const MAX = 1000000000000000000n;
    let ans = a[0];
    for (let i = 1; i < n; i++) {
        ans *= a[i];
        if (ans > MAX) {
            console.log("-1");
            return ;
        }
    }

    console.log(ans.toString());

};

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


Measured memory_bytes: 46440
k=int(input())
index=0
chk_num=0
keta=0
str_num=""
while index<k:
  chk_num+=1
  str_num=str(chk_num)
  keta=len(str_num)
  index+=1
  if keta!=1:
    for nn_index in range(keta-1,-2,-1):
      if nn_index==-1:
        break
      if str_num[nn_index]!="9":
        break
    num_chr=0
    bk=str(chk_num+1)
    if nn_index==-1:
      bk=""
      for j in range(keta):
        if j==0:
          num_chr=10
        else:
          num_chr=0
        bk+=str(num_chr)
    elif int(str_num[keta-2])+1==int(str_num[keta-1]) or (str_num[keta-2]=="9" and str_num[keta-1]=="9"):
      for asc_index in range(nn_index-1,-2,-1):
        if asc_index==-1:
          break
        if int(str_num[asc_index])+1!=int(str_num[asc_index+1]):
          break
      bk=""
      for j in range(keta):
        if j<asc_index+1:
          num_chr=int(str_num[j])
        elif j==asc_index+1:
          num_chr=int(str_num[j])+1
        else:
          num_chr=num_chr-1 if num_chr-1>0 else 0
        bk+=str(num_chr)
    chk_num=int(bk)-1
print(str_num)

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

int main() {
    int N;
    int x=0;
    cin >> N;

    for(int i=0;i<N;i++){
        int l,r;
        cin >> l >> r;
        x += (r-l+1);
    }

    cout << x << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ull = unsigned long long;

int a[8] = {1,1,2,3,5,8,13,21};

int h, w, k;

int mv[8][8];
ull dp[8][105];

void fillmv() {
    for (int i = 0; i < w - 1; i++) {
        mv[i][i + 1] = mv[i + 1][i] = a[i] * a[w - i - 2];
    }
    for (int i = 0; i < w; i++) {
        mv[i][i] = a[i] * a[w - i - 1];
    }
}

int main() {
    cin >> h >> w >> k;
    fillmv();
    dp[0][0] = 1;
    for (int i = 1; i <= h; i++) {
        for (int j = 0; j < w; j++) {
            ull tmp = 0;
            for (int k = j - 1; k <= j + 1; k++) {
                if (k >= 0 && k < w) {
                    tmp += dp[k][i - 1] * mv[k][j];
                }
            }
            dp[j][i] = tmp % 1000000007;
        }
    }

    cout << dp[k - 1][h] << endl;
}


Measured memory_bytes: 256
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair<int,int>

typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl pi = acos(-1);
const ll inf = 1LL<<30;
const dbl eps = 1e-9;
const ll mod = 1e9+7;

/** /////////// ** Code ** /////////// **/

const int N=111;
int a[N];

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0 ; i<n ; i++)
        scanf("%d",&a[i]);


    sort(a,a+n);

    int ans=0;
    for(int i=0 ; i<n ; i++){
        for(int j=i+1 ; j<n ; j++){
            for(int k=j+1 ; k<n ; k++){
                if(a[i] == a[j]) continue;
                if(a[j] == a[k]) continue;
                if(a[i] == a[k]) continue;
                if(a[k] < a[i]+a[j])
                    ans++;
            }
        }
    }

    printf("%d",ans);

}


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

using namespace std;



int main(){
    int64_t h , n;
    cin >> h >> n;
    int64_t dam[n], mana[n];
    for(int64_t i = 0; i < n; i++){
        cin >> dam[i] >> mana[i];
    }
    int64_t minmana[h+1];
    for(int64_t i = 0; i <= h; i++){ minmana[i] = INT_MAX;}
    for(int64_t i = 1; i <= h; i++){
        for(int64_t j = 0; j < n; j++){
            int64_t temp;
            if(dam[j] >= i){
                temp = mana[j];
            }
            else{
                temp = mana[j] + minmana[i-dam[j]];
            }
            if(temp < minmana[i]) minmana[i] = temp;
        }
    }
    cout << minmana[h] << endl;
    return 0;
}

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

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

template <class Abel> struct BIT {
private:
	vector<Abel> node; int n;
    Abel UNITY_SUM = 0; //to be set
public:
	BIT(int n_) {
		n = n_; node.resize(n, UNITY_SUM);
	}
	//0-indexed
	void add(int a, Abel w) {
		for (int i = a; i < n; i |= i + 1)node[i] += w;
	}
	//[0,a)
	Abel sum(int a) {
		Abel ret = UNITY_SUM;
		for (int i = a - 1; i >= 0; i = (i&(i + 1)) - 1)ret += node[i];
		return ret;
	}
	//[a,b)
	Abel sum(int a, int b) {
		return sum(b) - sum(a);
	}
    //debug
    void print() {
        for(int i = 0; i < n; ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

void solve() {
	string s; cin >> s;
    int n = (int)s.size();
    vector<int> alp[30];
    rep(i, n) {
        alp[s[i] - 'a'].push_back(i);
    }
    int cnt = 0;
    rep(i, 26) {
        if((int)alp[i].size() % 2 == 1) cnt ++;
    }
    if(cnt >= 2) {
        cout << -1 << endl;
        return;
    }
    vector<int> num(n, 0);
    set<int> se[26];
    vector<int> cot(26, 0);
    int co = 0;
    rep(i, n) {
        int c = s[i] - 'a';
        int s = (int)alp[c].size();
        cot[c] ++;
        if(cot[c] <= s / 2) {
            num[i] = co;
            se[c].insert(co);
            ++co;
        } else if(s % 2 == 1 && (s + 1) / 2 == cot[c]) {
            num[i] = n / 2;
            // se[c].insert(n / 2);
        } else {
            num[i] = n - 1 - *(se[c].rbegin());
            se[c].erase(*se[c].rbegin());
        }
    }
    //num の転倒数を求めればok
    BIT<int> bnum(n);
    int ans = 0;
    rep(i, n) {
        ans += (i - bnum.sum(num[i]));
        bnum.add(num[i], 1);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 8340
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

int num(int n)
{
	int ng = n + 1;
	int ok = 1;
	while (abs(ng - ok) > 1)
	{
		ll m = (ll)((ng + ok) / 2);
		if (n > m*(m - 1) / 2)
		{
			ok = m;
		}
		else
		{
			ng = m;
		}
	}
	return ok;
}

int main()
{
	int N;
	cin >> N;
	while (N != 0)
	{
		int n = num(N);
		cout << n << endl;
		N -= n;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int sum = 0;
		for(int i = 1;i  <= N;i++){
			int x = i;
			int sub = 0;

			while(x >= 10){
				int valLen = String.valueOf( x ).length();    // けたが返される

				sub += x / (int)Math.pow(10, valLen-1);

				x -= (x / (int)Math.pow(10, valLen-1))* Math.pow(10, valLen-1);
			}
			sub += x;

			if(sub >= A && sub <= B){		
				sum += i;

			}
		}
		
		System.out.println(sum);

	}
}



Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  a, b, c, d, e, K;
  
  cin >> a >> b >> c >> d >> e >> K;
  
    if(e - a <= K ){
      cout << "Yay!" <<endl;
        } 
    else{
      cout << ":(" <<endl;
    }
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
 
void solve(){
    string s;
    cin>>s;
    if(s == "Sunny") print("Cloudy");
    else if(s == "Cloudy") print("Rainy");
    else if(s == "Rainy") print("Sunny");
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   /* #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    /*#ifndef ONLINE_JUDGE
        end_routine();
    #endif*/
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    // 次の文字への変換は, z -> a 以外常に悪くなる
    // 各文字で 'z'-c 回使って 'a' にするか, 何もしないかの二択
    // 先頭から'a'に変えられればかえる, できなければスルーする
    // 余ったら最後の文字で使えばよい

    string S;
    cin >> S;
    int K;
    cin >> K;

    REP0 (i, S.length())
    {
        if (S[i] == 'a')
            continue;

        int cost_i = 'z' - S[i] + 1;
        if (cost_i <= K)
        {
            K -= cost_i;
            S[i] = 'a';
        }
    }

    if (K > 0)
    {
        int n = S.back() - 'a';
        n += K;
        n %= 26;
        S.back() = char(n + 'a');
    }

    cout << S << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

using namespace std;

int main(void)
{
    char S[4], T[4];
    cin >> S;
    cin >> T;

    int count = 0;

    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
        {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
def f(exponent):
	#reurns how many times a prime raised to exponent can be used
	step = 1
	cumul = 0
	count = 0
	while( cumul <= exponent):
		cumul += step
		count +=1
		step +=1
	return count - (1 if cumul > exponent else 0)

def answer(n):
	if n == 1: return 0
	res = 0
	on = n
	p = True
	for d in range(2, int(on ** 0.5) + 2):
		if n % d == 0:
			p = False
			e = 0
			while(n%d == 0): 
				e +=1
				n/=d
			res+= f(e)
	if n > 1: res += 1
	return res

print answer(int(raw_input()))

Measured memory_bytes: 85952
#include<stdio.h>
int main(){
  unsigned int n;
  int y,m,d;
  while(scanf("%d %d %d",&y,&m,&d)!=EOF){
    n=y*10000+m*100+d;
    if(n<18680908){
      printf("pre-meiji\n");
      continue;
    }
    if     (n<19120730)printf("meiji %d", y-1867);
    else if(n<19261225)printf("taisho %d",y-1911);
    else if(n<19890108)printf("showa %d", y-1925);
    else               printf("heisei %d",y-1988);
    printf(" %d %d\n",m,d);
  }
  return 0;
}

Measured memory_bytes: 608
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = list(map(int, input()))
    n = len(s)
    ans = 0
    m = 1<<(n-1)
    for b in range(m):
        a = s[0]
        m = 0
        for i in range(n-1):
            if b&(1<<i):
                a *= 10
                a += s[i+1]
            else:
                m += a
                a = s[i+1]
        ans += a+m
    print(ans)
    return

#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#G
def G():

    return

#H
def H():

    return

#I
def I_():

    return

#J
def J():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 40048
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define PairV vector<pair<int , int> >
#define F first
#define S second
#define Vector1  vector<int>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
#define PI 3.14
#define Rad2Deg  57.29578
#define INF 1000000000000

using namespace std;

int MD(pair<int,int> a,pair<int,int> b){//ManhattanDisRance
    return abs(a.first-b.first) + abs(a.second-b.second);
}
int MOD(int a,int b){
    return abs(a%b);
}
template <typename T1,typename T2> bool Comp (pair<T1,T2> a,pair<T1,T2> b){
    if(a.first!=b.first){
        return a.first<b.first;//first昇順
    }
    if(a.second!=b.second){
        return a.second > b.second;
    }else{
        return  true;
    }
}
signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    incin(n);
    vector<pair<pair<string,int > ,int> > p(n);
    
    for(int i=0;i<n;i++){
        cin >> p.at(i).first.first >> p.at(i).first.second;
        p[i].first.second = -p[i].first.second;
        p.at(i).second = i+1;
    }
    sort(all(p));
    for(int i=0;i<n;i++){
        cout<<p[i].second<<endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    vector<int> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

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

    int ans = 0;

    for (int i = 0; i < K; ++i)
        ans += xs[i];

    cout << ans << '\n';

    return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((a != b && b != c && c != a) || a == b && b == c)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <cmath>

using namespace std;

struct zahyou{
    double x, y;
};

void print_zahyou(zahyou z){
    printf("%.8lf %.8lf\n",z.x,z.y);
}

void koch(int d,zahyou p1,zahyou p2){
    zahyou s, u, t;
    if(d==0) return;
    s.x=(2*p1.x+1*p2.x)/3;
    s.y=(2*p1.y+1*p2.y)/3;
    t.x=(1*p1.x+2*p2.x)/3;
    t.y=(1*p1.y+2*p2.y)/3;
    u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
    u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;
    koch(d-1,p1,s);
    print_zahyou(s);
    koch(d-1,s,u);
    print_zahyou(u);
    koch(d-1,u,t);
    print_zahyou(t);
    koch(d-1,t,p2);
}

int main(void){
    int n;
    zahyou p1,p2;
    p1.x=0.0;p1.y=0.0;
    p2.x=100.0;p2.y=0.0;
    cin >> n;
    printf("0.00000000 0.00000000\n");
    koch(n,p1,p2);
    print_zahyou(p2);
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll a,b;char c;cin>>a>>c>>b;
  if(c=='+'){
    P(a+b);
  }else{
    P(a-b);
  }
  return 0;
}


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

using namespace std;


int main(){
  int n,ans;
  cin >> n;
  vector<int> P(n);
  for(int i=0; i < n; i++){
   cin >> P[i];
  }
  ans = 0;
  int curmin = 1e9;
  for(int i = 0; i < n; i++){
    if(curmin > P[i]) ans++;
    curmin = min(curmin,P[i]);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n, m, d;
    cin >> n >> m >> d;

    double ans = 1.*(n-d)*(m-1)/n/n;
    if(d > 0) ans *= 2;
    cout << decimal << ans << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k, x, d;
  d = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x > k - x){
      d += 2 * (k - x);
    }
    else {
      d += 2 * x;
    }
   }
  cout << d << endl;
}

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

long long A[100000];

int main(void){
    // Your code here!
    int K;
    cin >> K;
    for(int i = 0; i < K; i++){
        cin >> A[i];
    }
    
    if(A[K - 1] != 2){
        cout << -1 << endl;
        return 0;
    }
    long long max_a = 3;
    long long min_a = 2;
    for(int i = K - 2; i >= 0; i--){
        if(A[i] > max_a){
            cout << -1 << endl;
            return 0;
        } else {
            long long new_max_a = (max_a / A[i]) * A[i] + (A[i] - 1);
            long long new_min_a = min_a;
            if(min_a % A[i] != 0){
                new_min_a = (min_a / A[i] + 1) * A[i];
            }
            if(new_max_a < min_a || new_min_a > max_a){
                cout << - 1 << endl;
                return 0;
            }
            max_a = new_max_a;
            min_a = new_min_a;
        }
    }
    cout << min_a << " " << max_a << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from math import gcd,ceil,floor,factorial,pi
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

import math
r = int(input())
ans = 2*pi*r
print(ans)

Measured memory_bytes: 68476
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(vtype,var,n) vtype var((uint)n);loop(i,0,n)cin>>var[i];
#define range(container) container.begin(),container.end()
#define loop(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<out<<endl;

const ull INF = (ull)(-1LL);

int main(void){
	init(ull, a);
	init(ull, b);

	uint n = 1;
	uint c = 0;
	a--;
	while (n < b){
		n += a;
		c++;
	}

	outl(c);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
#define ll long long
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<endl;
#define trace(a) cout<<#a<<": "<<a<< endl;

int a[N];
vector<int> v[22];
int main() {
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	int i,j,k,l,m,n,t;
	cin >> n;
	for(i = 1;i <= n;i++) {
		cin >> a[i];
	}
	for(i = 0;i < 21;i++) {
		v[i].push_back(0);
		v[i].push_back(0);
	}
	ll ans = 0;
	for(i = 1;i <= n;i++) {
		int max_l = 1;
		for(j = 0;j < 21;j++) {
			if((a[i]>>j)&1) {
				v[j].push_back(i);
			}
		}
		for(j = 0;j < 21;j++) {
			max_l = max(v[j][v[j].size()-2] + 1, max_l);
		}
		ans += (i - max_l + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9128
if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))

    a = sorted(a, reverse=True)

    total = sum(a)

    if a[m - 1] < total / (4 * m):
        print("No")
    else:
        print('Yes')

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
const int MAX_N = 100000;
ll N, M, A[MAX_N];
ll dp[MAX_N + 1];

void solve() {
    long long res = 0;
    unordered_map<ll, ll> mp;

    for (int i = 0; i < N; ++i) {
        dp[i + 1] = (dp[i] + A[i]) % M;
        mp[dp[i + 1]]++;
    }

    for (auto val: mp) {
        res += val.second * (val.second - 1) / 2;
        if (val.first == 0) {
            res += val.second;
        }
    }

    printf("%lld\n", res);
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; ++i) cin >> A[i];
    solve();
    return 0;
}

Measured memory_bytes: 4876
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
A = LIST()

A.sort(reverse=1)
total = sum(A)
a = A[M-1]
if a < total / (4*M):
    No()
else:
    Yes()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <sstream>

using namespace std;

void failed() {
  cout << "NA" << endl;
}

int main() {
  
  int Q1, B, C1, C2, Q2;
  
  while(cin >> Q1) {
    
    if(Q1 == 0) break;
    
    cin >> B >> C1 >> C2 >> Q2;
    
    assert(Q2 >= 0);
    
    /*
    if(B/C1 == 0) {
      failed(); continue;
    }
    */
    
    int AizuCh = min(B/C1, Q2);
    if(AizuCh <= 0) { failed(); continue; }
    int NCh = 0;
    for(;;) {
      
      NCh = (B - AizuCh*C1)/C2;
      
      /*
      if(B - (NCh+1)*C2 - AizuCh*C1 >= 0) {
        NCh = (B - AizuCh*C1)/C2;
      }
      */
      if(AizuCh + NCh >= Q1) {
        cout << AizuCh << ' ' << NCh << endl; break;
      }
      /*
      else if(B - (NCh+1)*C2 - (AizuCh-1)*C1 >= 0) {
        NCh ++, AizuCh --;
      }
      */
      else AizuCh --;
      
      if(AizuCh <= 0) { failed(); break; }
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007

bool vis[200005];
vector<int> vec[2000005], v1;
int child[2000005];
int parent[2000005];
int div1[100005];
int min_indx[900005];
int count1 = 0;
int height = 0;
int max_indx[200005];
void dfs(int node)
{

    vis[node] = 1;
    // cout << node << "\n";
    min_indx[count1] = node;
    max_indx[node] = min(max_indx[node], count1);
    count1++;

    //  count1++;
    child[node] = height++;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            min_indx[count1] = node;
            max_indx[node] = min(max_indx[node], count1);
            count1++;
        }
    }
    height--;
}

int MAXN = 200005;
int LOGMAXN = (int)log2(200005) + 1;
int M[200005][60];
void process2(int A[], int N)
{
    int i, j;

    //initialize M for the intervals with length 1
    for (i = 0; i < N; i++)
        M[i][0] = i;
    //compute values from smaller to bigger intervals
    for (j = 1; 1 << j <= N; j++)
        for (i = 0; i + (1 << j) - 1 < N; i++)
            if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]])
                M[i][j] = M[i][j - 1];
            else
                M[i][j] = M[i + (1 << (j - 1))][j - 1];
}
//int parent[200005];
vector<int> vec1;
//bool vis[200005];
//int hei[200005];
int lev[200005];
int dis[200005];
bool cmp(pair<int, int> &a,
         pair<int, int> &b)
{
    return a.second < b.second;
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    //  int t;
    int n, m;
    cin >> n;
    if (n > 999)
    {
        cout << "ABD"
             << "\n";
    }
    else
    {
        cout << "ABC"
             << "\n";
    }

    return 0;
}


Measured memory_bytes: 50492
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
	int n, W;
	cin >> n >> W;
	int w[n],v[n];
	REP(i,n){
		cin >> w[i] >> v[i];
	}
	vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0));
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= W; j++){
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if(j - w[i] < 0) continue;
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
		}
	}
	cout << dp[n][W] << endl;
	return 0;
}

Measured memory_bytes: 80256
// Igorjan94, template version from 13 October 2017. C++17 version, modified 18 march 2020 (writeln<tuple>, whole->all) {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <iomanip>

using namespace std;

#define FOR(i, m, n) for (int i = m; i <  (int) (n); ++i)
#define ROF(i, m, n) for (int i = m; i >= (int) (n); --i)
#define forn(i, n)   for (int i = 0; i < (int) (n); ++i)
#define  fori1(n)    for (int i = 1; i < (int) (n); ++i)
#define  forj1(n)    for (int j = 1; j < (int) (n); ++j)
#define   fori(n)    for (int i = 0; i < (int) (n); ++i)
#define   forj(n)    for (int j = 0; j < (int) (n); ++j)
#define     SZ(a)    int(size(a))

typedef  pair<int, int>   pii;
typedef   vector<int>     vi;
typedef    long long      ll;

#define pb push_back
#define all(a) begin(a), end(a)
#define ints(a...) int a; readln(a)

//Igorjan
//}}}

void run()
{
    string s;
    cin >> s;
    cout << (s[0] == '7' || s[1] == '7' || s[2] == '7' ? "Yes" : "No") << endl;
}

//{{{
int main()
{
    ios_base::sync_with_stdio(false);
    run();
    cerr << fixed << setprecision(0) << "Execution time = " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3212
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n, w;
        cin >> n >> w;
        ll minval = INF;
        vector<pair<ll,ll>> v(n);
        for(i = 0; i < n; i++){
            cin >> v[i].ff >> v[i].ss;
            minval = min(minval , v[i].ff);
        }
        vector<ll> wt[4];
        for(i = 0; i < n; i++){
            if(v[i].ff == minval){
                wt[0].pb(v[i].ss);
            }
            else if(v[i].ff == minval + 1){
                wt[1].pb(v[i].ss);
            }
            else if(v[i].ff == minval + 2){
                wt[2].pb(v[i].ss);
            }
            else{
                wt[3].pb(v[i].ss);
            }
        }
        for(i = 0; i < 4; i++){
            wt[i].pb(0);
            sort(wt[i].rbegin(), wt[i].rend());
        }
        ll w1, w2, w3;
        vector<ll> pref[4];
        for(i = 0; i < 4; i++){
            pref[i].pb(0);
            for(j = 0; j < wt[i].size(); j++){
                pref[i].pb(pref[i].back() + wt[i][j]);
            }
        }
        ll ans = 0;
        for(w1 = 0; w1 <= wt[0].size(); w1++){
            for(w2 = 0; w2 <= wt[1].size(); w2++){
                for(w3 = 0; w3 <= wt[2].size(); w3++){
                    ll total = pref[0][w1] + pref[1][w2] + pref[2][w3];
                    ll weight = w1 * minval + w2 * (minval + 1) + w3 * (minval + 2); 
                    ll lo = 0, hi = wt[3].size();
                    while(lo <= hi){
                        ll mid = (lo + hi) / 2;
                        if(weight + (minval + 3) * mid <= w){
                            ans = max(ans, total + pref[3][mid]);
                            lo = mid + 1;         
                        }
                        else{
                            hi = mid - 1;
                        }
                    }
                }
            }
        }
        cout << ans;
    }
    return 0;
}

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

struct {
  int id;
  int num_c;
  int *list_c;
  int parent;
  int depth;
  int flag;
} typedef Tree;

int main(){
  Tree *t;
  int n, id, num_c, p, i, j;

  scanf("%d", &n);
  t = (Tree *)malloc(sizeof(Tree) * n);
  if(t == NULL){
    printf("error!\n");
    exit(-1);
  }
  for(i = 0; i < n; i++){
    scanf("%d %d", &id, &num_c);
    t[id].id = id;
    t[id].num_c = num_c;
    if(num_c != 0){
      t[id].list_c = (int *)malloc(sizeof(int) * num_c);
      if( t[id].list_c == NULL){
	printf("error!\n");
	free(t);
	exit(-1);
      }
      for(j = 0; j < num_c; j++) scanf("%d", &t[id].list_c[j]); 
    }
  }
  
  for(i = 0; i < n; i++){
    t[i].parent = -1;
    t[i].depth = 0;
    t[i].flag = 0;
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < t[i].num_c; j++){
      if( i == 0) t[ t[i].list_c[j] ].flag = 1; 
      t[ t[i].list_c[j] ].parent = t[i].id;  
      t[ t[i].list_c[j] ].depth += 1; 

      p = t[i].parent;
      while(p != -1){
	t[ t[i].list_c[j] ].depth += 1; 
	p = t[p].parent;
      }
      
    }
  }
  
  for(i = 0; i < n; i++){
    if(t[i].flag == 1) t[i].depth += t[ t[i].parent ].depth;
  }

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", t[i].id, t[i].parent, t[i].depth);
    if(t[i].parent == -1) printf("root, [");
    else if(t[i].num_c != 0) printf("internal node, [");
    else printf("leaf, [");
    if(t[i].num_c != 0){
      for(j = 0; j < t[i].num_c - 1; j++) printf("%d, ", t[i].list_c[j]);
      printf("%d]\n", t[i].list_c[j]);
    }
    else printf("]\n");
  }

  return 0;
}

Measured memory_bytes: 4208
import copy
from functools import lru_cache
import numpy as np
from numba import njit

#@njit
# @njit('(i8[::1],)', cache=True)
# def func(A):
#     N = len(A)
#     B = np.zeros_like(A)
#     for i in range(N):
#         l = max(0, i - A[i])
#         r = min(i + A[i], N-1)
#         B[l] += 1
#         if r+1 < N:
#             B[r+1] -= 1

#     B = np.cumsum(B)
#     return B

def resolve():
    N, K = map(int, input().split())
    A = np.array(list(map(int, input().split())))

    # N = 2 * 10**5
    # K = 2 * 10**5
    # A = np.array([0] *  N)

    @njit
    def func(A):
        #N = len(A)
        B = np.zeros_like(A)
        for i in range(N):
            l = max(0, i - A[i])
            r = min(i + A[i], N-1)
            B[l] += 1
            if r+1 < N:
                B[r+1] -= 1

        B = np.cumsum(B)
        return B

    for k in range(K):
        #print(k)
        A = func(A)
        if k >= 50:
            break

    print(" ".join(map(str, A)))

if __name__ == "__main__":
    resolve()

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

/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

const int mxN = 100010;
vector<int> tree[mxN];
int st[mxN],en[mxN],H[mxN],C,sz[mxN];

void dfs(int v = 0,int p = -1) {
	st[v] = C++;
	sz[v] = 1;
	for(auto u : tree[v]) if(u != p) H[u] = H[v] + 1, dfs(u,v), sz[v] += sz[u];
	en[v] = C;
}

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

	int N,u,v;
	cin>>N;
	for(int i = 1;i < N;i++) {
		cin>>u>>v;
		u--,v--;
		tree[u].push_back(v);
		tree[v].push_back(u);
	}
	dfs();
	vector<pair<int,int> > vec;
	for(int i = 0;i < N;i++) {
		if(st[i] <= st[N-1] && en[i] >= en[N-1]) {
			vec.push_back({H[i],i});
		}
	}
	sort(vec.begin(),vec.end());
	int sec = sz[vec[(vec.size()+1)/2].second];
	if(sec >= N - sec) {
		cout<<"Snuke\n";
	} else {
		cout<<"Fennec\n";
	}
	return 0;
}


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

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

  vector<vector<int>> C(10, vector<int>(10, 0));
  rep1(i, N) {
    int right = i % 10;
    int left = to_string(i).at(0) - '0';
    C.at(left).at(right)++;
  }

  int ans = 0;

  rep(i, 10) rep(j, 10) ans += C.at(i).at(j) * C.at(j).at(i);

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

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

int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> ti(n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> ti[i];
        if(i != 0){
            if(ti[i]- ti[i-1] >= t) ans += t;
            else ans += ti[i]-ti[i-1]; 
        }
    }
    ans += t;
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int N;

	cin >> N ;

	bool n = false;

	for (int a = 0; a <= N; ++a)
	{
		for (int b = 0; b <= N; ++b)
		{

			int total = 4 * a + 7 * b;

			if (total == N)
			{ 
				cout << "Yes";
				n = true;
				return 0;
			}

		}
	}

	if(n==false) cout << "No";
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

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


int H, W;
int N;
int A[101*101];
int field[101][101];

int main(){

    cin >> H >> W;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];

    int pos = 0;
    for(int y = 0; y < H; y++){
        for(int j = 0; j < W; j++){
            int x = 0;
            if(y % 2 == 0) x = j;
            else x = W - 1 - j;
            field[y][x] = pos + 1;
            A[pos]--;
            if(A[pos] == 0) pos++;
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cout << field[i][j] << " ";
        }
        cout << endl;
    }
    

    return 0;
}


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

// {
#define debug(var)  do{ std::cout << #var << " : "; view(var); }while(0)
using ll = long long;
using ld = long double;
inline int num (const std::string& S, int idx) noexcept { return S.at(idx) - '0'; }
inline int ctoi(char c) noexcept { return c - '0'; }
inline bool isNumber(char c) noexcept { return ('0'<c && c<'9'? true : false); }
inline int safeCtoi(char c) { if(isNumber(c)) { return ctoi(c); } else { throw 1; } }
inline char itoc(int i) noexcept { return i + '0'; }
inline unsigned int bitMask(int i) noexcept { return (1 << i); }
inline bool isTrue(unsigned int bit, int i) noexcept { return bit & bitMask(i); }
inline bool isEven(int num) noexcept { return !num%2; }
inline bool isOdd(int num) noexcept { return num%2; }
template<typename T> inline short sgn(T num) noexcept { return (num==0? 0 : (num>0? 1 : -1) ); }
template<typename T> inline bool isZero(T num) noexcept { return (num==0? true : false); }
template<typename T> inline bool isPositive(T num) noexcept { return (num>0? true : false); }
template<typename T> inline bool isNegative(T num) noexcept { return (num<0? true : false); }
template<typename T> void view(T e) noexcept { cout << e; }
template<typename T> void view(std::vector<T> v) noexcept { for(const auto& e : v) cout << e << " "; }
template<typename T> void view(std::vector<std::vector<T>> vv) noexcept { for(const auto& v : vv) view(v); }
//}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	if( 360%x == 0 ){
		cout << 360/x << endl;
	}else{
		cout << (360/x) * (360 / (360%x)) << endl;
	}
	return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
// const int MOD = 1000000007;

signed main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll N; cin >>N;

    ll neg_c = 0;
    ll abs_min = LLONG_MAX;
    ll abs_sum = 0;

    ll A;
    rep(i, N) {
        cin >> A;
        ll abs_A = abs(A);
        chmin(abs_min, abs_A);
        abs_sum += abs_A;
        if (A < 0) {
            neg_c++;
        }
    }

    cout << (neg_c % 2 ? abs_sum - 2 * abs_min : abs_sum) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[100000],b[100000],c[100000];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n;i++)
		cin>>c[i];
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	long long ans=0;
	for(int i=0;i<n;i++)
		ans+=(long long)(lower_bound(a,a+n,b[i])-a)*(c+n-upper_bound(c,c+n,b[i]));
	cout<<ans<<endl;
}


Measured memory_bytes: 1408