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

using namespace std;

/*helpfull*/
using vl  = vector<long long>;
using vpl = vector<pair<long long, long long>>;
using vs = vector<string>;
using pl  = pair<long long, long long>;
using ll  = long long int;
using vb  = vector<bool>;


struct hash_pair {
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const
	{
		auto hash1 = hash<T1> {}(p.first);
		auto hash2 = hash<T2> {}(p.second);
		return hash1 ^ hash2;
	}
};
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

// shortcut macros
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp              make_pair
#define fi              first
#define se              second
// #define mt              make_tuple
#define pb              push_back
#define all(x)          (x).begin(), (x).end()
#define ini(a, v)       memset(a, v, sizeof(a))
#define rep(i, a, n)    for(ll i=a ; i<n ; ++i)
#define For(i, n)       rep(i, 0, n)
#define sz(x)           (int((x).size()))
#define ump(x,y)        unordered_map<x,y>
#define umpr(x,y,z)     unordered_map<x,y,z>
void printcase(ll &x) {
	cout << "Case #" << x << ": ";
}
void read(vector<ll>&v, ll &n) {
	For(i, n)
	cin >> v[i];
}
void read(ll &x) {
	cin >> x;
}
void read(string &s) {
	cin >> s;
}
void read(int &x) {
	cin >> x;
}
void read(ll a[], ll &n) {
	For(i, n)
	cin >> a[i];
}
void print() {
	cout << endl;
}
void write(vector<ll>&v, ll &n) {
	For(i, n)
	cout << v[i] << " ";
	cout << endl;
}
void write(vector<ll>&v) {
	ll n = v.size();
	For(i, n)
	cout << v[i] << " ";
	cout << endl;
}
void write(ll x) {
	cout << x << endl;
}
void write(string &s) {
	cout << s << endl;
}
void write(int &x) {
	cout << x << endl;
}
void write(ll a[], ll &n) {
	For(i, n)
	cout << a[i] << " ";
	cout << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	IOS;
	ll n;
	cin >> n;
	string s;
	cin >> s;
	For(i, n)
	if (s[i] == 'W')
		s[i] = '1';
	else
		s[i] = '0';
	vl m(3, 0);
	m[0] = count(all(s), '0');
	m[1] = count(all(s), '1');
	ll c = 0;
	for (int i = m[0]; i < n; i++) {
		if (s[i] == '0')
			++c;
	}
	m[2] = c;
	cout << *min_element(all(m)) << endl;
	return 0;
}




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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    token = lines[0].split()
    n = int(token[0])
    a = int(token[1])
    b = int(token[2])

    return (n, a, b)


def solve(n, a, b):

    return min(n*a, b)




def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3316
n = int(input())
ans = 0
dic1 = {}
for _ in range(n):
    s = list(input())
    key = ""
    dic = {}
    for i in s:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
    for k in sorted(dic.keys()):
        key += "{}{}".format(k, dic[k])

    if key in dic1:
        dic1[key] += 1
    else:
        dic1[key] = 1

for v in dic1.values():
    ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 18456
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    int ans = min(a * n, b);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	string s;
	
	cin>>s;
	
	int size = s.size(), b = 0, ans = 0;
	
	for(int i = 0; i < size; i++){
		if(s[i] == 'W'){
			ans += i-b;
			b++;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))

ruiseki = [[0]*20 for i in range(n+1)]

for i in range(n):
    for j in range(20):
        ruiseki[i+1][j] = ruiseki[i][j] + a[i] % 2
        a[i] = a[i] >> 1

s = 0
t = 1
ans = 0
while s < n + 1:
    while t < n + 1: 
        flag = False
        for i in range(20):
            if ruiseki[t][i] - ruiseki[s][i] > 1:
                flag = True
        if flag:
            break
        t += 1
    ans += (t - s - 1)
    s += 1
print(ans)

Measured memory_bytes: 123852
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    int n, y;
    cin >> n >> y;
    for(int i=0;i<=n;++i) {
        for(int j=0;j<=n-i;++j) {
            int k = n - i - j;
            if(i * 10000 + j * 5000 + k * 1000 == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 3580
main(c,t){double*p=t,v,atof();for(;t=c&2&&printf("%f\n",v),~scanf("%s%c",&t,&c);)v=t<48?*--p=t&1?t&2?t&4?*p/v:*p+v:*p-v:*p*v:(*++p=atof(&t));}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
 int A,B,C;
  cin>>A>>B>>C;
  if(A==5&&B==5&&C==7){
  cout<<"YES"<<endl;
  }
else if(A==5&&B==7&&C==5){
cout<<"YES"<<endl;
}
  else if(A==7&&B==5&&C==5){
  cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
s = input()
MMYY, YYMM = 0, 0
if 1 <= int(s[0:2]) <= 12:
    MMYY = 1
if 1 <= int(s[2:4]) <= 12:
    YYMM = 1
if MMYY and YYMM:
    ans = 'AMBIGUOUS'
elif MMYY:
    ans = 'MMYY'
elif YYMM:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)

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

int main() {
	
	//解説PDFを見ました(迫真)
	//速度の様子うかがい

	int N;
	string S;
	cin >> N >> S;

	map<string, int> GODmae, GODato;

	rep(i, 1 << N) {
		string blue;
		string red;
		string blue2;
		string red2;
		rep(ii, N) {
			if (i >> ii & 1) {
				blue += S[ii];
				blue2 += S[2 * N - ii - 1];
			}
			else {
				red += S[ii];
				red2 += S[2 * N - ii - 1];
			}
		}
		GODmae[blue + "," + red]++;
		GODato[blue2 + "," + red2]++;
	}

	long long kotae = 0;
	for (auto itr : GODmae) {
		kotae += 1ll * itr.second * GODato[itr.first];
	}
	cout << kotae << "\n";
	Would you please return 0;

}

Measured memory_bytes: 83584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007, MAX=200005;

ll inv[MAX],fac[MAX],finv[MAX];
 
ll rui(ll a, ll b){
    ll ans=1;
    while (b > 0) {
        if(b & 1) ans = ans * a % mod;
        a = a * a % mod ;
        b /= 2;
    }
    return ans;
}
 
 
 
ll comb(ll a, ll b) {
    ll ans = 1 ;
    for(ll i = a; i > a - b; i--) {
        ans = ans * i % mod;
    }
    for(ll i = 1; i <= b; i++) {
        ans = (ans * rui(i, mod-2)) % mod;
    }
    return ans;
}

int main() {

    int n, a, b;

    cin >> n >> a >> b;
    
    cout << (mod + mod + rui(2, n) - comb(n, a) - comb(n, b) - 1) % mod << endl;

}

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

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    rep(i, N) cin >> s.at(i);
    int M;
    cin >> M;
    vector<string> t(M);
    rep(i, M) cin >> t.at(i);

    int maxScore = 0;
    rep (i, N) {
        int score = 0;
        rep(j, N) {
            if (s.at(i) == s.at(j)) {
                score++;
            }
        }
        rep(j, M) {
            if (s.at(i) == t.at(j)) {
                score--;
            }
        }
        maxScore = max(maxScore, score);
    }

    cout << maxScore << endl;

    return 0;
}


Measured memory_bytes: 3596
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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

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

ll K,N;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>N;
 ll  sum = 0;


  for(ll i = 1 ; i<=N ; i++){
    for(ll j = 1 ; j<=N ; j++){
      for(ll k = 1 ; k<=N ; k++)
        sum += gcd(i , gcd(j,k));
    }
  }


cout<<sum<<'\n';


   

}



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

  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  vi b(n-1);
  rep(i,n-1) cin >> b[i];
  vi a(n,INF);
  rep(i,n-1) {
    a[i] = min(a[i],b[i]);
    a[i+1] = min(a[i+1],b[i]);
  }

  int ans = 0;
  rep(i,n) ans += a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var input = input.split("\n");
    var  N = Int(input[0]);
    for(var i=1;i<=N;i++){
    	var side = input[i].split(" ");
    	for(var j =0;j<3;j++){
    		side[j]=Int(side[j]);
    	}
    	side.sort(descendingOrder);
    	if(side[0]*side[0]==side[1]*side[1]+side[2]*side[2]){
    		console.log("YES");
    	}else{
    		console.log("NO");
    	}
    }
}
//??°????????????????????¢??°??¨(??????)
function ascendingOrder(val1,val2){
    return val1 - val2;
}
//??°????????????????????¢??°??¨(??????)
function descendingOrder(val1,val2){
    return val2 - val1;
}
//??°??????
function Int(str){
    return parseInt(str, 10);
}
//????????????
function Str(num){
    return num.toString(10);
}


//???????????°??¨
function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

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

Measured memory_bytes: 17716
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>

int main() {
   int N, T;
   std::cin >> N >> T;
   int c[N], t[N];
   int ans = 10000;
   for (int i = 0; i < N; i++) {
      std::cin >> c[i] >> t[i];
      if (t[i] <= T && c[i] < ans) ans = c[i];
   }
   if (ans == 10000) std::cout << "TLE" << std::endl;
   else std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

bool can_make(const std::vector<long long int>& current_durability, const int power, const long long int lower_limit) {
	long long int right = current_durability.size();
	for (auto i = 0; i < current_durability.size(); ++i) {
		if (current_durability[i] < lower_limit) {
			if (current_durability[i] + power < lower_limit) return false;
			if (right <= i && current_durability[i] + power - (i - right) * (i - right) < lower_limit) return false;
			auto diff = power + current_durability[i] - lower_limit;
			right = std::min(right, i + static_cast<long long int>(std::sqrt(diff)));
		}
	}
	return true;
}
struct Shield {
	int power, position;
};
int main() {
	while (true) {
		int n, m; std::cin >> n >> m; if (n == 0) return 0;
		std::vector<long long int> units(n, 0);
		std::vector<Shield> shields(m - 1);
		for (auto& shield : shields) std::cin >> shield.power >> shield.position;
		for (const auto& shield : shields) {
			auto range = static_cast<int>(std::sqrt(shield.power));
			units[std::max(0, shield.position - range)] += -2;
			if (shield.position + range < units.size()) units[shield.position + range] += 2;
		}
		for (auto i = 1; i < units.size(); ++i) units[i] += units[i - 1];
		//for (auto u : units) std::cout << u << ' ';
		//std::cout << std::endl;
		for (const auto& shield : shields) {
			auto range = static_cast<int>(std::sqrt(shield.power));
			if (shield.position - range >= 0) units[shield.position - range] += range * 2 + 1;
			else units[0] += shield.position * 2 + 1;
			if (shield.position + range < units.size()) units[shield.position + range] += range * 2 - 1;
		}
		for (auto i = 1; i < units.size(); ++i) units[i] += units[i - 1];
		//for (auto u : units) std::cout << u << ' ';
		//std::cout << std::endl;
		for (const auto& shield : shields) {
			auto range = static_cast<int>(std::sqrt(shield.power));
			units[std::max(0, shield.position - range - 1)] += shield.power - std::min(static_cast<long long int>(range) * range, static_cast<long long int>(shield.position) * shield.position);
			if (shield.position + range < units.size()) units[shield.position + range] += -shield.power + static_cast<long long int>(range * range);
		}
		for (auto i = 1; i < units.size(); ++i) units[i] += units[i - 1];
		//for (auto u : units) std::cout << u << ' ';
		//std::cout << std::endl;
		int last_shield; std::cin >> last_shield;
		auto min = *std::min_element(units.begin(), units.end());
		auto max = min + last_shield + 1;
		while (min < max) {
			auto mid = (min + max) / 2;
			if (can_make(units, last_shield, mid)) min = mid + 1;
			else max = mid;
		}
		std::cout << max - 1 << std::endl;
	}
}



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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
vector<pint> G[110000];
bool c[110000];
void dfs(int idx, int par, bool color) {
    c[idx] = color;
    rep(i, G[idx].size()) {
        pint nxt = G[idx][i];
        if (nxt.first == par) { continue; }
        if (nxt.second & 1) { dfs(nxt.first, idx, !color); }
        else { dfs(nxt.first, idx, color); }
    }
}
signed main() {
    cin >> N;
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    dfs(0, -1, 0);
    rep(i, N) { cout << c[i] << endl; }

}


Measured memory_bytes: 11392
#include <iostream>
 
using namespace std;
 
int main(){
    int n;
    cin >> n;
    for (int i = 3; i <= n; i++) {
        if (i%3==0) cout << ' ' << i;
        else
        {
            int x = i;
            while (x) {
                if (x%10 == 3) {
                    cout << ' ' << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}


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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(), v.end()
const int MOD = 1e9+7;

int main(){
    FasterIO;

    int n;

    while(cin>>n){
        int data[n];

        for(int i=0; i<n; i++)
            cin>>data[i];

        int XOR = 0;

        for(int i=0; i<n; i++){
            XOR^=data[i];
        }

        cout<<(!XOR ? "Yes" : "No")<<endl;
    }

    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define lli long long int

using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif

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

    string s1, s2;
    int flag=0;
    cin >> s1 >> s2;
    if(s1.length() >= s2.length())
    {
        cout << "No\n";
    } 
    else
    {
        for(int i=0;i<s1.length();i++)
        {
            if(s1[i] == s2[i])
            {
                continue;
            }
            else
            {
                flag++;
            }
            
        }

        if(flag != 0)
        {
            cout << "No\n";
        }
        else
        {
            cout << "Yes\n";
        }
        
    }
    
}

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

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    string s;
    cin >> s;
    s = '0' + s;
    int N = s.size();
    vector<int> A(N), S(N+1);
    for(int i=0; i<N; i++){
        A[i] = s[i] - '0';
        S[i+1] = S[i] + A[i];
    }

    static int64_t dp[1001001][2];
    for(int i=0; i<=N; i++) for(int j=0; j<2; j++) dp[i][j] = 1e18;
    dp[0][0] = 0;
    for(int i=0; i<N; i++){
        chmin(dp[i+1][0], dp[i][0] + A[i]);
        chmin(dp[i+1][1], dp[i][0] + A[i] + 1);
        chmin(dp[i+1][0], dp[i][1] + 10-A[i]);
        chmin(dp[i+1][1], dp[i][1] + 10-A[i]-1);
    }
    int64_t ans = dp[N][0];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 24752
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int N = scan.nextInt();
	int[] A_ = new int[N+2];
	int[] B_ = new int[N+1];
	int[] M_ = new int[N];
	
	A_[0] = A_[N+1] = 0;

	for(int i = 1; i < N+1; i++){
	    A_[i] = scan.nextInt();
	}

	//N個すべてのスポットを回った場合の金額
	int sum = 0;
	for(int i = 0; i < N+1; i++){
	    sum += Math.abs(A_[i+1]-A_[i]);
	}

	//i個の場合についてsumから差分を引いていく
	for(int i = 1; i < N+1; i++){
	    M_[i-1] = (Math.abs(A_[i+1]-A_[i])+Math.abs(A_[i]-A_[i-1]))
		-(Math.abs(A_[i+1]-A_[i-1]));
	    System.out.println(sum-M_[i-1]);
	}
    }
}


Measured memory_bytes: 66444
import java.util.*;
 
public class Main{
    static int[][] islandMap = new int[12][12];//島の地図を数字のまま取込
    static boolean[][] checkMap = new boolean[12][12];//チェック用地図
    static int count;//島を数える

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
             
        while(scanner.hasNext()){
            for(int i=0; i<12; i++){
                String line = scanner.next();
                for(int j=0; j<12; j++){
                    islandMap[i][j] = Integer.parseInt(line.substring(j, j+1));
                    //チェック用地図には島をfalse、海はtrue。
                    //探索後の島はtrueに変えて海に沈める。
                    if(islandMap[i][j] == 1){
                        checkMap[i][j] = false;
                    }else if(islandMap[i][j] == 0){
                        checkMap[i][j] = true;
                    }
//使っていない：    Deque<String> deque = new ArrayDeque<>();
//検証用
//System.out.print(islandMap[i][j]);
//System.out.print(checkMap[i][j] + " ");                    
                }
//System.out.println("");
            }
            for(int k = 0;k <12;k++){
                for(int l = 0; l<12; l++){
                    if(islandMap[k][l]==1 && !checkMap[k][l]) {
                        checkIsland(k,l);
                    }
                }
            }
            System.out.println(count);
            count = 0;
        }
    }
    static void checkIsland(int x, int y) {
        finished(x,y);
        count++;
//検証用
//System.out.print("カウントしました");             
    }
 
    static void finished(int x, int y) {
        checkMap[x][y] = true;
//検証用
//System.out.print("checkMap[" + x + "][" + y + "]を");     
//System.out.print("trueに変えました");     

        if(x + 1 < 12 && islandMap[x+1][y]==1 && !checkMap[x+1][y]) {
//検証用
//System.out.print("checkMap[" + x + "][" + y + "]の");     
//System.out.print("下に来きました");
            finished(x+1,y);

        }
        if(y + 1 < 12 && islandMap[x][y+1]==1 && !checkMap[x][y+1]) {
//検証用
//System.out.print("checkMap[" + x + "][" + y + "]の");     
//System.out.print("右に来ました");
            finished(x,y+1);

        }        
        if(y - 1 >= 0 && islandMap[x][y-1]==1 && !checkMap[x][y-1]) {
//System.out.print("checkMap[" + x + "][" + y + "]の");     
//System.out.print("左に来ました");
            finished(x,y-1);

        }
        if(x - 1 >= 0 && islandMap[x-1][y]==1 && !checkMap[x-1][y]) {
//System.out.print("checkMap[" + x + "][" + y + "]の");     
//System.out.print("上に来ました");
            finished(x-1,y);

        }           
    }
}



Measured memory_bytes: 26040
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>

#define div 1000000000+7

typedef long long ll;

using namespace std;

void solve() {
    string s;
    int x[30];

    for(int i = 0; i < 30; i++){
        x[i] = 0;
    }
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        x[s[i] - 'a']++;
        if(x[s[i] - 'a'] > 1){
            cout << "no" << endl;
            return ;
        }
    }
    cout << "yes" << endl;

}

int main() {
    solve();
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int long long  a , b , n ; 
  cin >> a >> b >> n ;
  int long long  i = min(b-1,n) ;
  int long long  ans  = floor(a*i/b) - a*floor(i/b) ;
                
  
  cout << ans ;

}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << "a < b" << endl;
  } else if (a > b) {
    cout << "a > b" << endl;
  } else {
    cout << "a == b" << endl;
  }
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int maxn=2e5+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

priority_queue<ll> q1,q2,q3;

priority_queue<ll,vector<ll>, greater<ll> > q4; 

ll tmp[maxn];
int main(){
	int x,y,a,b,c;
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(int i=1;i<=a;i++){
		ll xx;
		scanf("%lld",&xx);
		q1.push(xx);
	}
	for(int i=1;i<=b;i++){
		ll xx;
		scanf("%lld",&xx);
		q2.push(xx);
	}
	for(int i=1;i<=c;i++){
		ll xx;
		scanf("%lld",&xx);
		q3.push(xx);
	}
	for(int i=1;i<=x;i++){
		q4.push(q1.top());
		q1.pop();
	}
	for(int i=1;i<=y;i++){
		q4.push(q2.top());
		q2.pop();
	}
	ll ans=0;
	while(!q3.empty()){
		if(q4.top()<q3.top()){
			ans+=q3.top();
			q4.pop();q3.pop();
		}
		else break;
	}
	while(!q4.empty()){
		ans+=q4.top();q4.pop();
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4724
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

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

    string W[7] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
    int w;
    for (w = 0; w < 7; ++w) {
        if (W[w] == S) break;
    }
    cout << 7 - w ;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 

fn main() {
    input!{
    	n: usize,
    	v: [i64; n],
    }
    let mut ans: i64 = 0;
    for i in 0..n {
    	for j in 0..n {
    		if i > j {
    			ans += v[i]*v[j];
    		}
    	}
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, m, v, t, l, r;
long long dp[5005][5005], a[5005], ans;
P b[205][5005];
int main(){
	scanf("%d%d", &n, &m);
	rep(i,n-1){
		scanf("%lld", a+i+1);
		a[i+1] += a[i];
	}
	rep(i,n) rep(j,m){
		scanf("%d", &v);
		b[j][i] = P(v,i);
	}
	rep(i,m){
		sort(b[i], b[i]+n, greater<P>());
		set<int> st;
		st.insert(-1); st.insert(n);
		rep(j,n){
			tie(v, t) = b[i][j];
			auto it = st.upper_bound(t);
			r = *it;
			l = *--it;
			dp[t][l+1] += v;
			dp[t][t+1] -= v;
			dp[r][l+1] -= v;
			dp[r][t+1] += v;
			st.insert(t);
		}
	}
	rep(i,n) rep(j,n) dp[i][j+1] += dp[i][j];
	rep(j,n) rep(i,n){
		dp[i+1][j] += dp[i][j];
		if(i >= j) ans = max(ans, dp[i][j]-a[i]+a[j]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 204032
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  vi seq = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  invar(int, K);
  
  fin(seq[K-1]);
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	string s; cin >> s;
	rep(i, s.size()){
		if(i == 4){
			cout << ' ';
		}
		cout << s[i];
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
s = list(input())
n = int(input())
head = []
tail = []

cnt = 0
for _ in range(n):
    li = list(input().split())
    if li[0] == '1':
        head, tail = tail, head
        cnt += 1
    else:
        if li[1] == '1':
            head.append(li[2])
        else:
            tail.append(li[2])

if cnt % 2 != 0:
    s = s[::-1]

ans = head[::-1] + s + tail
print(*ans , sep='')

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

using namespace std;

int init = 0;

bool sl = true;
vector<vector<int> > tree;
vector<long long> pesos;

vector<int> visto;
long long sol(int ver){

	visto[ver] = 1;

	long long count = 0;
	long long val = 0;
	vector<long long> vecVal;
	for(int i = 0; i < tree[ver].size(); i++){
		if(visto[tree[ver][i]] == 0){
			count++;
			long long v = sol(tree[ver][i]);
			vecVal.push_back(v);
			val += v;
		}
	}

	if(count == 1){

            if(val != pesos[ver]){
                     sl = false;
                     return 0;
            }else{
                  return val;
            }
     }else if(ver == init){


 		if(2*pesos[ver]-val != 0){
 		                   sl = false;
 		                   return 0;
 		           }else{
 		        	   int acomu = val;

 		        	   sort(vecVal.begin(), vecVal.end());
 						for(int i = vecVal.size()-1; i >= 0; i--){
 						//	cout << vecVal[i] << '\n';
 							if(vecVal[i] == val - pesos[ver]){
 								return 2*pesos[ver]-val;
 							}else if(vecVal[i] < val - pesos[ver] && acomu >= val - pesos[ver]){
 								return 2*pesos[ver]-val;
 							}else if(vecVal[i] > val && val - vecVal[i] >= val - pesos[ver]){
 								return 2*pesos[ver]-val;
 							}
 							acomu -= vecVal[i];
 						}
 		        	   	 sl = false;
 		        	   	 return 0;

 		           }
 	}else if(count == 0){
           return pesos[ver];
     }else{

           if(2*pesos[ver]-val < 0 || pesos[ver] > val){
                   sl = false;
                   return 0;
           }else{

	        	   if(val - pesos[ver] == 0) return 2*pesos[ver] - val;
	        	   sort(vecVal.begin(), vecVal.end());
		        	   int acomu = val;
		        	  // sort(vecVal.begin(), vecVal.end());
						for(int i = vecVal.size()-1; i >= 0; i--){

							if(vecVal[i] == val - pesos[ver]){
								return 2*pesos[ver]-val;
							}else if(vecVal[i] < val - pesos[ver] && acomu >= val - pesos[ver]){
								return 2*pesos[ver]-val;
							}else if(vecVal[i] > val - pesos[ver] && val - vecVal[i] >= val - pesos[ver]){
								return 2*pesos[ver]-val;
							}
							acomu -= vecVal[i];
						}
		        	   	 sl = false;
		        	   	 return 0;
           }
     }
}





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

    for(int i = 0; i < n; i++){
         vector<int> aux;
         tree.push_back(aux);
         long long auxa;
         cin >> auxa;
         pesos.push_back(auxa);
         visto.push_back(0);
    }

    for(int i = 0; i < n-1; i++){
            int a,b;
            cin >> a >> b;
            tree[a-1].push_back(b-1);
            tree[b-1].push_back(a-1);
    }
    init = 0;
    for(int i = 0; i < n; i++){
    	if(tree[i].size() != 1){
    		init = i;
    		break;
    	}
    }



    sol(init);

    if(sl) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 16304
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<unordered_map>

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

string a[510];

int main(){
  int H, W;
  cin >> H >> W;
  for(int i = 0; i < H; i++){
    cin >> a[i];
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(j == W - 1){
        cout << ".";
      }else if(a[i][j] == '#' || j == 0 || i % 2 == 0){
        cout << "#";
      }else{
        cout << ".";
      }
    }
    cout << endl;
  }
  cout << endl;

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(j == 0){
        cout << ".";
      }else if(a[i][j] == '#' || j == W - 1 || i % 2 == 1){
        cout << "#";
      }else{
        cout << ".";
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
// SeeAlso: https://atcoder.jp/contests/abc059/tasks/abc059_b

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

string a,b;

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

    if (a.size()>b.size()) {
        print("GREATER");
    } else if(b.size() > a.size()) {
        print("LESS");
    } else {
        if(a>b) {
            print("GREATER");
        } else if (b>a) {
            print("LESS");
        } else {
            print("EQUAL");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int w, h, n;
    cin>>w>>h>>n;
    int ws=0, hs=0;
    for(int i=0; i<n; i++){
        int x, y, a;
        cin>>x>>y>>a;
        if(a==1){
            if(x>ws) ws=x;
        }
        if(a==2){
            if(w>x) w=x;
        }
        if(a==3){
            if(hs<y) hs=y;
        }
        if(a==4){
            if(h>y) h=y;
        }
    }

    cout<<max(0, w-ws)*max(0, h-hs);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

void solve() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int> pref(n);
	vector<int> prof(n);
	int cnt_pos = 0;
	for (int i = 0; i < n; i++) {
		int k, l, r;
		cin >> k >> l >> r;
		k--;
		ans += r;
		l -= r;
		r = 0;
		pref[i] = k;
		prof[i] = l; 
		cnt_pos += (prof[i] >= 0);
	}
	vector<vector<int>> bpref(n);
	vector<vector<int>> bsuff(n);
	for (int i = 0; i < n; i++) {
		if (pref[i] == n - 1) {
			ans += prof[i];
			continue;
		}
		if (prof[i] >= 0) {
			bpref[pref[i]].push_back(i);
		} else {
			bsuff[pref[i] + 1].push_back(i);
		}
	}
	{
		set<pair<int, int>> s;
		for (int i = n - 1; i >= 0; i--) {
			for (auto j : bpref[i]) {
				s.insert({prof[j], j});
			}
			if (i < cnt_pos && !s.empty()) {
				ans += s.rbegin()->first;
				s.erase(--s.end());
			}
		}
	}
	{
		set<pair<int, int>> s;
		for (int i = 0; i < n; i++) {
			for (auto j : bsuff[i]) {
				s.insert({-prof[j], j});
			}
			if (i >= cnt_pos && !s.empty()) {
				s.erase(--s.end());
			}
		}
		for (auto t : s) {
			ans -= t.first;
		}
	}
	cout << ans << '\n';
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int q;
	cin >> q;
	while (q--) {
		solve();
	}
}


Measured memory_bytes: 25832
#include <stdio.h>

int main(void)
{
	int n, a[100], i;

	scanf("%d\n", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = n - 1; i >= 0 ; i--) {
		printf("%d", a[i]);
		if (i != 0) printf(" ");
	}
	printf("\n");
}



Measured memory_bytes: 2096
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


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

Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  Long c;
  cin >> c;
  c--;
  vector<Long> base(14);
  base[0] = 0;
  fore(i, 1, 14) base[i] = (base[i - 1] * 26 + 26);
  int p = upper_bound(all(base), c) - base.begin();
  p--;
  c -= base[p];
  vector<int> v(p + 1);
  fore(i, 0, p + 1) {
    v[i] = c % 26;
    c /= 26;
  }
  reverse(all(v));
  fore(i, 0, p + 1) cout << (char)(v[i] + 'a');
  cout << endl;

  return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy" << endl;
    else if (s == "Cloudy") cout << "Rainy" << endl;
    else if (s == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
n=int(input())
D={}
for i in range(n):
    s=input()
    if s in D:
        D[s]=D[s]+1
    else:
        D[s]=1
m=int(input())
for i in range(m):
    t=input()
    if t in D:
        D[t]=D[t]-1
Max=0
for i in D.values():
    Max=max(Max,i)
print(Max)
    


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);

	if (n == 1)
	{
		cout<<"YES"<<endl;
		return 0;
	}

	int cnt = 0;
	FOR (i, 0, n)
	{
		int x;
		scanf("%d", &x);
		if (x & 1) cnt ^= 1;
	}

	if (cnt) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
  }
  sort(h.begin(),h.end());
  int ans=1000000000;
  for(int i=0;i<N-K+1;i++){
    ans=min(ans,h.at(i+K-1)-h.at(i));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef vector<VB> VBB;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

int main() {
  ll x=0,y=0,z=0,k,n,m,h,w,ans=0,sum=0,Max=1,Min=1e9+1;
  string s,t;
  bool ok = false;
  ll a,b;
  cin >> a >> b;
  rep(i,100000){
    x = i * 0.08;
    y = i * 0.1;
    if(x == a && y == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i =0; i < N; i++) cin >> A[i];
	long long ans =1000000000000LL;
	for(int i =-100; i <= 100; i++) {
		long long akt =0;
		for(int j =0; j < N; j++) akt +=(i-A[j])*(i-A[j]);
		ans =min(ans,akt);}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


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

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

int main() {
  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  ll g = gcd(n, m);

  string a, b;
  for (int i = 0; i < n; i += n / g) a.push_back(s[i]);
  for (int i = 0; i < m; i += m / g) b.push_back(t[i]);

  cout << (a == b ? n * m / g : -1) << endl;
}


Measured memory_bytes: 512
N,A,B = list(map(int,input().split()))
mod = 10** 9+7
pattern_all = pow(2,N,mod)-1
def C(N,A,mod):
    high = N
    low =  A
    for i in range(1,A):
        high = high * (N-i) % mod
        low = low * (A-i) % mod
    return (high * pow(low,mod-2,mod))%mod
af_a = C(N,A,mod)
af_b = C(N,B,mod)
print((pattern_all-af_a-af_b)%mod)

Measured memory_bytes: 3064
n = int(input())
li = [int(_) for _ in input().rstrip().split()]

count = 0
for i in range(n-2):
    if (li[i] < li[i+1] and li[i+1] < li[i+2]) or (li[i] > li[i+1] and li[i+1] > li[i+2]):
        count += 1

print(count)

Measured memory_bytes: 3060
from collections import deque


def main():
    N, Q = map(int, input().split())
    edge = [[] for i in range(N)]
    ops = []
    ans = [0] * N
    
    for _ in range(N - 1):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)
    for _ in range(Q):
        ops.append(tuple(map(int, input().split())))
    
    for op in ops:
        node = op[0] - 1
        pnt = op[1]
        ans[node] += pnt
    
    stack = deque()
    stack.append((0, -1))
    
    while stack:
        st = stack.pop()
        node, parent = st[0], st[1]
        children = edge[node]
        for child in children:
            if child == parent:
                continue
            ans[child] += ans[node]
            stack.append((child, node))
    
    print(*ans)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll s = 0;
    cin >> n;
    vector<ll> a(n * 3);
    for (int i = 0; i < n * 3; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 3 * n - 2; i >= n; i -= 2) {
        s += a[i];
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 2560