akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

template <typename Monoid>
struct SegmentTree
{
    using F = function<Monoid(Monoid, Monoid)>;

private:
    int n;
    vector<Monoid> node;
    Monoid E;
    F f;

public:
    SegmentTree(vector<Monoid> &v, Monoid e, const F func) : f(func), E(e)
    {
        int sz = v.size();
        n = 1;
        while (n < sz)
        {
            n *= 2;
        }
        node.resize(2 * n - 1, E);
        for (int i = 0; i < sz; i++)
        {
            node[i + n - 1] = v[i];
        }
        for (int i = n - 2; i >= 0; i--)
        {
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    void update(int i, Monoid val)
    {
        i += (n - 1);
        node[i] = val;
        while (i > 0)
        {
            i = (i - 1) / 2;
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    Monoid query(int a, int b, int i = 0, int l = 0, int r = -1)
    {
        if (r < 0)
        {
            r = n;
        }
        if (r <= a || b <= l)
        {
            return E;
        }
        if (a <= l && r <= b)
        {
            return node[i];
        }
        Monoid vl = query(a, b, 2 * i + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * i + 2, (l + r) / 2, r);
        return f(vl, vr);
    }

    Monoid operator[](const int &i) const
    {
        return node[i + n - 1];
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    SegmentTree<int> segmax(p, -INF, [](int a, int b) { return max(a, b); });
    SegmentTree<int> segmin(p, INF, [](int a, int b) { return min(a, b); });
    int ans = 0;
    vector<bool> isChange(n, false);
    int cnt = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (p[i] < p[i + 1])
        {
            cnt++;
        }
        else
        {
            cnt = 0;
        }
        if (cnt >= k - 1)
        {
            ans = 1;
            isChange[i - k + 2] = true;
        }
    }

    for (int i = 0; i < n - k + 1; i++)
    {
        if (isChange[i])
        {
            continue;
        }
        int bef = segmin.query(i, i + k);
        int aft = segmax.query(i + 1, i + k + 1);
        if (bef == p[i] && aft == p[i + k])
        {
            continue;
        }
        ans++;
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, M;
  cin >> N >> M;
  vector<tuple<int, int, int>> lrc;
  rep(i, M) {
    int l, r, c;
    cin >> l >> r >> c;
    lrc.emplace_back(l, r, c);
  }
  {
    vi32 imos(N);
    rep(i, M) {
      int l, r, c;
      tie(l, r, c) = lrc[i];
      imos[l]++;
      imos[r]--;
    }
    reps(i, N) imos[i] += imos[i - 1];
    bool ok = true;
    reps(i, N - 1) {
      if (imos[i] == 0) ok = false;
    }
    if (!ok) {
      cout << -1 << endl;
      return;
    }
  }
  vi64 dist(M);
  vector<vi32> adds(N);
  vector<vi32> rems(N);
  rep(i, M) {
    int l, r, c;
    tie(l, r, c) = lrc[i];
    l--, r--;
    adds[l].emplace_back(i);
    rems[r].emplace_back(i);
  }
  i64 ans = 0;
  set<pair<i64, int>> se;
  rep(i, N) {
    if (i != 0) {
      each(s, se) {
        ans = s.first;
        break;
      }
    }
    each(j, adds[i]) {
      int l, r, c;
      tie(l, r, c) = lrc[j];
      se.emplace(ans + c, j);
      dist[j] = ans + c;
    }
    each(j, rems[i]) {
      se.erase(make_pair(dist[j], j));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 13044
fn main() {
  let mut a = Vec::new();
  for _ in 0..5 {
    a.push(read_num());
  }

  let k = read_num();
  for i in 1..5 as usize {
    if a[i] - a[0] > k {
      println!(":(");
      return;
    }
  }
  println!("Yay!");
}

fn read_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_string()
}

fn read_num() -> i32 {
    read_line().parse().unwrap()
}

Measured memory_bytes: 4352
//minimum operations to reach y from x
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
int smod(string &s,int n)
{
	ll res=0;
    for (int i=0;i<s.length();i++) 
         res=(res*10+(int)s[i]-'0')%n; 
  
    return (int)res; 
}

void solve()
{
	int x;
	cin>>x;
	if(x%2==0 || x%5==0)
	{
		cout<<-1<<endl;
		return;
	}
	string s="7";
	ll cnt=1;
	ll ans=0;
	while(1)
	{
		ans=(ans*10+(int)s[s.size()-1]-'0')%x;
		if(ans%x==0)
		{
			cout<<cnt<<endl;
			break;
		}
		s+='7';
		cnt++;
	}
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int t;
	t=1;
	while(t--)
	solve();
}

Measured memory_bytes: 5284
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <random>

#define ll long long

using namespace std;

const int mod = 1e9 + 7;

int main() {
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    int h, w;
    scanf("%d %d", &h, &w);
    vector<vector<char>> a(h + 1, vector<char>(w + 1));
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            scanf(" %c", &a[i][j]);
    vector<vector<int>> cnt(h + 1, vector<int>(w + 1, 0));
    cnt[1][1] = 1;
    if (a[1][1] == '#' || a[h][w] == '#') {
        printf("0");
        return 0;
    }
    for (int j = 2; j <= w; j++) {
        if (a[1][j] != '#') {
            cnt[1][j] += (cnt[1][j - 1]) % mod;
        }
    }
    for (int i = 2; i <= h; i++) {
        if (a[i][1] != '#') {
            cnt[i][1] += (cnt[i - 1][1]) % mod;
        }
    }
    for (int i = 2; i <= h; i++) {
        for (int j = 2; j <= w; j++) {
            if (a[i][j] != '#') {
                cnt[i][j] = (cnt[i - 1][j] + cnt[i][j - 1]) % mod;
            }
        }
    }
    printf("%d", cnt[h][w] % mod);
    return 0;
}


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

set<int> S;
int n, k, a[210000];

int main() {
    scanf("%d%d", &n, &k);
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        if (i <= k) {
            S.insert(a[i]);
        } else {
            int Mi = *S.begin();
            S.erase(a[i - k]);
            S.insert(a[i]);
            int Ma = *S.rbegin();
            if (!(Mi == a[i - k] && Ma == a[i]))
                ans++;
        }
    }
    int now = 0, now2 = 0;
    for (int i = 1; i <= n; i++)
        if (a[i] >= a[i - 1]) {
            now++;
        } else {
            if (now >= k) now2++;
            now = 1;
        }
    if (now >= k) now2++;
    ans -= max(now2 - 1, 0);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
    using namespace std;
     
    #define fi first
    #define se second
    #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
    #define rep(i,n) repl(i,0,n)
    #define each(itr,v) for(auto itr:v)
    #define pb(s) push_back(s)
    #define mp(a,b) make_pair(a,b)
    #define all(x) (x).begin(),(x).end()
    #define dbg(x) cout<<#x"="<<x<<endl
    #define maxch(x,y) x=max(x,y)
    #define minch(x,y) x=min(x,y)
    #define uni(x) x.erase(unique(all(x)),x.end())
    #define exist(x,y) (find(all(x),y)!=x.end())
    #define bcnt(x) bitset<32>(x).count()
     
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int, int> P;
    typedef pair<P, int> PPI;
    typedef pair<ll, ll> PL;
    typedef pair<P, ll> PPL;
     
    #define INF INT_MAX/3
     
    #define MAX_N 1000
     
    int h,w;
    string s[10];
     
    int main(){
    	cin.sync_with_stdio(false);
    	cin>>h>>w;
    	rep(i,h)cin>>s[i];
    	int l=0,u=0;
    	bool ok=true;
    	rep(i,h)rep(j,w){
    		if(s[i][j]=='#'){
    			if(i<u||j<l)ok=false;
    			maxch(u,i);
    			maxch(l,j);
    		}
    	}
    	if(ok)cout<<"Possible"<<endl;
    	else cout<<"Impossible"<<endl;
    	return 0;
    }

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

class AOJ0007
{
    static void Main()
    {
        var debt = 100000d;
        for(var _ = int.Parse(Console.ReadLine()); _ > 0 ; _--)
        {
            debt = Math.Ceiling(debt * 1.05 / 1000) * 1000;
        }
        Console.WriteLine(debt);
    }
}

Measured memory_bytes: 5624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  map<int, int> map;
  rep(i, n) {
    int d; cin >> d;
    if (map.find(d) == map.end()) map.insert(make_pair(d, 1));
    else map[d]++;
  }
  int m; cin >> m;
  rep(i, m) {
    int t; cin >> t;
    if (map.find(t) == map.end()) map.insert(make_pair(t, -1));
    else map[t]--;
  }

  for (auto it = map.begin(); it != map.end(); it++) {
    if (it->second < 0) {
      NO();
      return;
    }
  }
  YES();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 9600
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll A, V, B, W, T;

signed main(){
	cin >> A >> V >> B >> W >> T;
	if(A == B){
		cout << "YES" << endl;
		return 0;
	}
	if(V <= W){
		cout << "NO" << endl;
		return 0;
	}
	if((abs(A-B)+abs(V-W)-1)/abs(V-W) <= T){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

string s;

signed main()
{
	IOS;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i%2) {
			if (s[i] == 'R') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (s[i] == 'L') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int i;
    int ans=0;
    for(i=0;i<s1.size();i++)
    {
        ans+=(s1[i]!=s2[i]);
    }
        cout<<ans<<endl;
}


Measured memory_bytes: 3912
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int i,j;
    for(i=1;i<10;i++){
        for(j=1;j<10;j++){
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    return 0;
}

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

int main() {
  int N, l, r, sum;
  sum = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
  	cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
  // ここにプログラムを追記
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string n;
	int i,boi=0;
	cin>>n;
	for (i=0;i<=n.size()-1;i++){
		boi=boi+n[i]-48;
	}
	if (boi%9==0){cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}


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

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

  if(n%k==0){
    cout << 0 << endl;
  } else{
    cout << 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = int(input())

# コーナーケース
if N == S:
    print(N + 1)
    exit()


# x進数
def encode_x_base(n, x):
    ret = []
    while n:
        ret.append(n % x)
        n //= x
    return ret[::-1]


# 桁和
def digit_sum(n):
    if isinstance(n, (int, str)):
        return sum([int(d) for d in str(n)])
    if isinstance(n, list):
        return sum([int(d) for d in n])


# Bが小さいとき
for b in range(2, int(N ** 0.5) + 1):
    encoded_N = encode_x_base(N, b)
    d_sum = digit_sum(encoded_N)
    if d_sum == S:
        print(b)
        exit()

# Bが大きいときはpを全探索
for p in range(int(N ** 0.5) + 1, 0, -1):
    b = (N - S) // p + 1
    if b < 2:
        continue
    encoded_N = encode_x_base(N, b)
    d_sum = digit_sum(encoded_N)
    if d_sum == S:
        print(b)
        break
else:
    print(-1)


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

l = []
for i in range(n):
    l.append(input().split())

judge = 1
#e = [int(i) for i in l[0]]
t = x = y = 0
for i in l:
    t = int(i[0]) - t
    x = abs(int(i[1]) - x)
    y = abs(int(i[2]) - y)
    d = x + y
    if (t < d):
        judge = 0
        break
    elif (t % 2 != d % 2):
        judge = 0
        break

if (judge == 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 32168
# C
ABCD = input()
A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]


for i in range(8):
    res = A
    if i in [0, 2, 4, 6]:
        res = res + '+' + B
    else:
        res = res + '-' + B
    if i in [0, 1, 4, 5]:
        res = res + '+' + C
    else:
        res = res + '-' + C
    if i in [0, 1, 2, 3]:
        res = res + '+' + D
    else:
        res = res + '-' + D
        
    if eval(res) == 7:
        print(res+'=7')
        break



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;

void solve() {
	cin >> N;
	cin >> S;
	int r = 0, s = 0;
	rep(i, 0, N) {
		if(S[i] == 'R') r++;
		else s++;
	}
	if(r > s) cout << "Yes\n";
	else cout << "No\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
def snake_toy(N: int, K: int, l: list)->int:
    return sum(sorted(l)[-K:])


if __name__ == "__main__":
    N, K = map(int, input().split())
    l = [int(s) for s in input().split()]
    ans = snake_toy(N, K, l)
    print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
void chmin(int &a,int b){if(a>b) a=b;}

int main()
{
    int R;
    cin>>R;
    if(R<1200)
    {
        cout<<"ABC"<<endl;
    }
    else if(R<2800)
    {
        cout<<"ARC"<<endl;
    }
    else cout<<"AGC"<<endl;

}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int ok=0,n,count;
  string s[200];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  for(int j=1;j<n;j++){
    string aa,bb;
    aa=s[j-1];
    bb=s[j];
    if(aa.back()!=bb[0])
      ok++;
  }
  for(int xx=0;xx<n;xx++){
    for(int yy=0;yy<n;yy++){
      if(s[xx]==s[yy])
        count++;
    }
  }
  if(count==n and ok==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = [0] + input().split()

for i in range(1,n+1):
    print(f'node {i}: key = {a[i]}, ',end ="")
    print(f'parent key = {a[i//2]}, 'if i>1 else "",end = "")
    print(f'left key = {a[2*i]}, 'if 2*i<=n else "",end = "")
    print(f'right key = {a[2*i + 1]}, ' if  2*i + 1<=n  else "")



Measured memory_bytes: 5684
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int n,m;
struct Node
{
	int a,b;
}a[100001];
bool cmp(const Node& t1,const Node& t2)
{
	return t1.a>t2.a;
}
priority_queue <int> q;
int f[100005];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].a,&a[i].b);
	}
	sort(a+1,a+n+1,cmp);
	int curr=n+1;
	f[m+1]=0;
//	for (int i=1;i<=n;i++) printf("!%d %d\n",a[i].a,a[i].b);
	for (int i=m;i>=1;i--)
	{
		while (curr>=2&&a[curr-1].a<=m-i+1)
		{
			curr--;
			q.push(a[curr].b);
		}
		//printf("%d %d %d\n",i,curr,t-1);
		//curr~t-1
		if (q.empty()) f[i]=f[i+1];
		else
		{
			f[i]=f[i+1]+q.top();
			q.pop();
		}
	}
	printf("%d",f[1]);
	return 0;
}

Measured memory_bytes: 2044
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n=I()
dp=[0]*(n+1)
dp[2]=1
for i in range(3,n+1):
    c=collections.Counter(prime_factorize(i-1))
    divnum=list(c.values())
    tmp=1
    for j in divnum:tmp*=j+1
    dp[i]=dp[i-1]+tmp
print(dp[n])


Measured memory_bytes: 78492
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
using namespace std;

signed main() {
	int a, c; char b;
	while (cin >> a >> b >> c,b!='?') {
		switch (b)
		{
		case '+':cout << a + c << endl; break;
		case '-':cout << a - c << endl; break;
		case '*':cout << a * c << endl; break;
		case '/':cout << a / c << endl; break;
		}
	}
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,Y; cin>>N>>Y;

    for(int i=0;i<=N;i++){
        for(int j=0;i+j<=N;j++){
            int k=N-(i+j);
            int sum=10000*i+5000*j+1000*k;
            if(sum==Y){
                cout<<i<<' '<<j<<' '<<k<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;

}


Measured memory_bytes: 256
s=int(input())
n=set()
a=s
for i in range(10**7):
    if a in n:
        break
    
    if a%2==0:
        n.add(a)
        a=a//2
    else:
        n.add(a)
        a=3*a+1
 
print(i+1)

Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    int n;
    string S;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        
        double xa,ya,ra,xb,yb,rb;
        
        scanf("%lf%lf%lf%lf%lf%lf",&xa,&ya,&ra,&xb,&yb,&rb);
        
        double dis = sqrt(pow(xa-xb,2)+pow(ya-yb,2));
        
        if(ra > rb){
            if(dis+rb < ra)
                puts("2");
            else if(dis-rb > ra)
                puts("0");
            else
                puts("1");
        }else{
            if(dis+ra < rb)
                puts("-2");
            else if(dis-ra > rb)
                puts("0");
            else
                puts("1");
        }
    }
    
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

bool solve (string S) {
    bool flag = true;
    for (int i = 0; i < S.length(); i++) {
        if (S.at(i) != S.at(S.length() - 1 - i)) flag = false;
    }
    for (int i = 0; i < (S.length() - 1) / 2; i++) {
        if (S.at(i) != S.at((S.length() - 1) / 2 - 1 - i)) flag = false;
    }
    for (int i = (S.length() + 3) / 2 - 1; i < S.length(); i++) {
        if (S.at(i) != S.at(S.length() + (S.length() + 3) / 2 - 2 - i)) flag = false;
    }
    return flag;
}

int main(){
  string S;
  cin >> S;
  cout << (solve(S) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 200000;
    int N, A[MAX_N + 1];
    ll B[MAX_N + 1];
    cin >> N;
    B[0] = 0;
    FOR(i, 1, N + 1, 1) {
        cin >> A[i];
        B[i] = B[i - 1] + A[i];
    }
    ll res = 2 * 100000000000000 + 1;
    int l = 1, r = 3;
    FOR(i, 2, N - 1, 1) {
        while (l < i && abs(2 * B[l] - B[i]) >= abs(2 * B[l + 1] - B[i])) {
            l++;
        }
        while (r < N &&
               abs(2 * B[r] - B[i] - B[N]) >= abs(2 * B[r + 1] - B[i] - B[N])) {
            r++;
        }
        ll P = B[l], Q = B[i] - B[l], R = B[r] - B[i], S = B[N] - B[r];
        ll _max = max({P, Q, R, S});
        ll _min = min({P, Q, R, S});
        amin(res, _max - _min);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

int a,b,c;
cin >> a >> b >> c;
if(b >= c){cout << b + c << endl;}
else{
  if(a + b >= c){cout << b + c << endl;}
  else{cout << a+b+b + 1 << endl;}
 }

return 0;
}


Measured memory_bytes: 256
def solve():
    N,C = map(int,input().split())
    x = [0 for i in range(N)]
    v = [0 for i in range(N)]
    for i in range(N):
        x[i],v[i] = map(int,input().split())

    sc = 0
    v11 = [0 for i in range(N)]
    v12 = [0 for i in range(N)]
    for i in range(N):
        sc += v[i]
        v11[i] = sc - x[i]
        v12[i] = sc - x[i] * 2
    for i in range(1,N):
        v11[i] = max(v11[i], v11[i-1])
        v12[i] = max(v12[i], v12[i-1])

    sc = 0
    v21 = [0 for i in range(N)]
    v22 = [0 for i in range(N)]
    for i in range(N-1,-1,-1):
        sc += v[i]
        v21[i] = sc - (C - x[i])
        v22[i] = sc - (C - x[i]) * 2
    for i in range(N-2,-1,-1):
        v21[i] = max(v21[i], v21[i+1])
        v22[i] = max(v22[i], v22[i+1])

    ans = 0
    for i in range(N):
        ans = max(ans, v11[i])
        ans = max(ans, v21[i])
    for i in range(N-1):
        ans = max(ans, v12[i]+v21[i+1])
        ans = max(ans, v11[i]+v22[i+1])

    return ans

print(solve())


Measured memory_bytes: 58400
# -*- coding: utf-8 -*-
 
s = str(input())

i = int(0)
d = int(1000)
x = int(0)

while i<len(s)-2:
    x=int(s[i:i+3])
    x = abs(x-753)
    if x < d:
        d=x
    i = i+1

print(d)

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int i, sum = 0;
    for (i = 0; i <= n; i++) {
        int k = i, c = 0;
        while (k > 0) {
            c += k % 10;
            k /= 10;
        }
        if (a <= c && c <= b)  
            sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int g=1,n,m,k,p;
vector<int> members(1,0);

void dfs(int x,vector<vector<int>> &friends,vector<vector<int>> &block,vector<int> &group){
    int cnt=1;
    stack<int> s;
    group[x]=g;
    s.push(x);
    while(!s.empty()){
        p=s.top();s.pop();
        for(int t:friends[p]){
            if(group[t]!=0)continue;
            group[t]=g;
            s.push(t);
            cnt++;
        }
    }
    members.pb(cnt);
    g++;
}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int x,y;
    cin>>n>>m>>k;
    vector<vector<int>> friends(n,vector<int>(0));
    vector<vector<int>> block(n,vector<int>(0));
    vector<int> visited(n,0);
    vector<int> group(n,0);
    for(int i=0;i<m;i++){
        cin>>x>>y;
        friends[x-1].pb(y-1);
        friends[y-1].pb(x-1);
    }
    for(int i=0;i<k;i++){
        cin>>x>>y;
        block[x-1].pb(y-1);
        block[y-1].pb(x-1);
    }
    for(int i=0;i<n;i++){
        if(group[i]==0)dfs(i,friends,block,group);
        int tmp=members[group[i]]-friends[i].size()-1;
        for(int x:block[i]){
            if(group[x]==group[i])tmp--;
        }
        if(i==n-1)cout<<tmp<<endl;
        else cout<<tmp<<" ";
    }
    
}


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

int main(void){
    while(1){
        ld n;
        cin >> n;
        if(!n) break;
        vector<ld> s(n);
        for(int i = 0; i < n; i++) cin >> s[i];
        ld sum = 0;
        for(auto x:s) sum += x;
        ld a = 0.0, ave = sum / n; 
        for(int i = 0; i < n; i++){
            ld t = s[i] - ave;
            a += (t * t);
        }
        cout << fixed << sqrt(a / n) << endl;
    }
    return 0;
}


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

int main(){
	int r;
	cin >> r;
	int ans = 3*r*r;
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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(){
  cout << fixed << setprecision(15);
  int ans = 0;
  //string ans = "No";

  int n; cin >> n;
  vector<pii> seats(n);
  rep(i, n){
    int l, r; cin >> l >> r;
    ans += (r - l + 1);
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<vector>

#define MOD 998244353
long long mod_div(long long a, long long b)
{
	if(a % b == 0)
	{
		return a / b;
	}
	long long index = MOD - 2, power = 1;
	while(index > 0)
	{
		if(index & 1)
		{
			power *= b;
			power %= MOD;
		}
		b *= b;
		b %= MOD;
		index >>= 1;
	}
	return a * power % MOD;
}

#define F_MAX 333333
long long combination(long long n, long long r)
{
	if(n < r || n < 0 || r < 0)
	{
		return -1;
	}
	static std::vector<long long>factorial_mod(F_MAX);
	if(factorial_mod[0] != 1)
	{
		factorial_mod[0] = 1;
		for(long long i = 1; i < F_MAX; i++)
		{
			factorial_mod[i] = (factorial_mod[i - 1] * i) % MOD;
		}
	}
	long long numerator = factorial_mod[n];
	long long denominator = (factorial_mod[r] * factorial_mod[n - r]) % MOD;
	return mod_div(numerator, denominator);
}

signed main()
{
	long long n, a, b, k;
	std::cin >> n >> a >> b >> k;
	std::vector<std::pair<long, long>>pairs;
	pairs.reserve(n);
	for(long long x = 0; x <= n; x++)
	{
		if((k - a * x) % b == 0)
		{
			long long y = (k - a * x) / b;
			if(0 <= y && y <= n)
			{
				pairs.push_back(std::make_pair(x, y));
			}
		}
	}
	long long ans = 0;
	for(auto i : pairs)
	{
		ans += combination(n, i.first) * combination(n, i.second) % MOD;
		ans %= MOD;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 7168
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(){
  int i,wlen,tlen,cnt=0;
  char W[10]={0};
  char T[1000]={0};
  scanf("%s",W);
  wlen=strlen(W);
  for(i=0;i<wlen;i++){
    if(isupper(W[i])){
      W[i]=tolower(W[i]);
    }
  }
  while(1){
    scanf("%s",T);
    if(strcmp(T,"END_OF_TEXT")==0)break;
    tlen=strlen(T);
    for(i=0;i<tlen;i++){
      if(isupper(T[i])){
        T[i]=tolower(T[i]);
      }
    }
    if(strcmp(W,T)==0){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  return 0;
}

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

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int x = 800 * n;
            int y = (n / 15) * 200;
            int ans = x - y;

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23252
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<numeric>

using ull = unsigned long long;
int main() {
	ull n, k;
	std::cin >> n >> k;

	std::vector<ull> v;
	v.resize(n);

	for (auto&e : v)
		std::cin >> e;

	std::sort(std::begin(v), std::end(v));

	ull min_ = 999999999;

	for (ull i{ k -1 }; i < n; i++) {
		min_ = std::min(min_, v[i] - v[i - (k-1) ] );
	}

	std::cout << min_ << "\n";
	return 0;
}

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

int main() {
  int n,m,c;
  cin >>n >>m >>c;
  
  vector<int>b(m);
  for(int i=0; i<m;i++){
    cin >>b[i];
  }
  
  int count=0,sum=0;
  for(int i=0; i<n; i++){
    vector<int>a(m);
    for(int j=0; j<m; j++){
      cin >>a[j];
    }    
    for(int k=0; k<m; k++){
      sum+=a[k]*b[k];
    }
    if(sum+c >0){
      count++;
    }
  sum = 0;
  }
  cout <<count <<endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int n, m, c;
  int a, b[20];
  int ans = 0;
  scanf("%d %d %d", &n, &m, &c);
  for (int i = 0; i < m; ++i)
  {
    scanf("%d", b + i);
  }
  for (int i = 0; i < n; ++i)
  {
    int test = 0;
    for (int j = 0; j < m; ++j)
    {
      scanf("%d", &a);
      test += a * b[j];
    }
    if (test + c > 0) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
	int n,weight;
    cin>>n>>weight;
    vector<vector<long long> > cell;   //cell for value
    cell.pb(vector<long long>(weight+1,0));
    int w,v;
    for(int i=1;i<=n;i++){
        cell.pb(vector<long long>(weight+1));
        cell[i][0]=0;
        cin>>w>>v;
        for(int j=1;j<=weight;j++){
            if(j-w<0){
                cell[i][j]=cell[i-1][j];
                //cout<<cell[i][j]<<'-'<<"\t";
                continue;
            }
            cell[i][j]=max(cell[i-1][j],v+cell[i-1][j-w]);
            //cout<<" ="<<cell[i][j]<<"+ \t";
        }
        //cell[i-1][j]<<"||"<<v+cell[i-1][j-w]
        //cout<<endl;
    }
    cout<<cell[n][weight];
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,i,x=0,count=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    while(1){
    for(i=0;i<n;i++){
        if(a[i]%2==0){
            a[i]/=2;
            x+=1;
        }else break;
    }
    if(x==n){
        count++;
    }
    if(x!=n){ break;}
    x=0;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n,m;
ll a,b,sum;
vector<pair<ll,ll> > v;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for (int i=0;i<n;++i)
	{
		cin>>a>>b;
		v.pb(mp(a,b));
	}
	sort(v.begin(),v.end());
	for (int i=0;i<n;++i)
	{
		if (m<v[i].second)
		{
			sum+=m*v[i].first;
			break;
		}
		sum+=v[i].first*v[i].second;
		m-=v[i].second;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 2548
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

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

  int ko = 0, bo = 0, sa = 0, mi = 0, ku = 0;
  int pa = as[0];
  bool pl = false;

  for (int i = 0; i < n - 1; i++) {
    if (as[i] == as[i + 1]) pl = true;
    else {
      if (as[i] > as[i + 1]) {
	if (pa < as[i]) {
	  if (pl) ko++;
	  else mi++;
	}
	else if (pa > as[i] && pl) sa++;
      }
      else {
	if (pa > as[i]) {
	  if (pl) bo++;
	  else ku++;
	}
	else if (pa < as[i] && pl) sa++;
      }
      pa = as[i];
      pl = false;
    }
  }

  printf("%d %d %d %d %d\n", ko, bo, sa, mi, ku);
  return 0;
}


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

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var xs = Console.ReadLine().Split()
            .Select(x => long.Parse(x))
            .ToArray();
        
        var xss = new []
        {
            xs,
            xs.Reverse().Select(x => -x).ToArray()
        };
        var score = new long[2][];
        var m = 2 * n;
        for (int i = 0; i < 2; ++i)
        {
            score[i] = new long[n + 1];
            score[i][0] = xss[i].Take(n).Sum();
            var dic = xss[i].Take(n)
                .GroupBy(x => x)
                .ToDictionary(x => x.Key, x => x.Count());
            var pbag = new SortedDictionary<long, int>(dic);
            for (int j = n; j < m; ++j)
            {
                if (pbag.ContainsKey(xss[i][j]))
                {
                    ++pbag[xss[i][j]];
                }
                else
                {
                    pbag[xss[i][j]] = 1;
                }

                var min = pbag.Keys.First();
                if (pbag[min] == 1)
                {
                    pbag.Remove(min);
                }
                else
                {
                    --pbag[min];
                }
                score[i][j - n + 1] = score[i][j - n] + xss[i][j] - min;
            }
        }
        Array.Reverse(score[1]);
        
        Console.WriteLine(Enumerable.Zip(score[0], score[1], (i, j) => i + j).Max());
    }
}


Measured memory_bytes: 63748
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1024)

func readLine() string {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func main() {
	b := readLine()
	if b == "A" {
		fmt.Println("T")
	} else if b == "C" {
		fmt.Println("G")
	} else if b == "G" {
		fmt.Println("C")
	} else if b == "T" {
		fmt.Println("A")
	}
}


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



int sc1(){int x; scanf("%d",&x); return x;}

long long sc2(){long long x;scanf("%lld",&x);return x;}



#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
#define  MAX              100007








int main()
{	
	
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n=Int;

    string s;
    cin>>s;
    int cnt1=0,cnt2=0;
    for(int i=0;s[i];i++)
    {
    	if(s[i]=='R') cnt1++;
    	else cnt2++;
    }
    
    cnt1>cnt2?puts("Yes"):puts("No");
    
    return 0;
}




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

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


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

#define ll long long
using namespace std;
#define BITS 61
void solve()
{
    int N;
    cin>>N;
    vector<ll> A(N);
    for(auto &a: A)
        cin>>a;
    string S;
    cin>>S;
    int ok = 1;
    vector<ll> B(BITS,0);
    for(int i=N-1; i>=0 && ok; --i)
    {
        if(S[i]=='0')
        {
            for(int j=0; j<BITS; ++j)
                if(A[i] & ((1ll)<<j))
                {
                    if(B[j]==0)
                    {
                        B[j] = A[i];
                        A[i] = 0;
                    }
                    else
                    {
                        A[i]^=B[j];
                    }
                }
        }
        else
        {
            for(int j=0; j<BITS; ++j)
                if(A[i] & ((1ll)<<j))
                    A[i]^=B[j];
            if(A[i]!=0)
                ok=0;
        }
        
    }
    cout<<(1^ok)<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int T;
    cin>>T;
    while(T--)
        solve();

		
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	char ch;
	cin >> ch;
	if(ch>='A' && ch<='Z'){
		cout<<"A";
	}
	else{
		cout<<"a";
	}


	return 0;
}

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

int main() {
    int n;
    cin >> n;
    double sum=0;
    int a;
    rep(i,n){
        cin >> a;
        sum +=1.0/a;
    }
    cout << 1/sum;

    return 0;
}


Measured memory_bytes: 256
m,k = map(int, input().split())

if( k >= 2**m):
    print(-1)
    exit()

if( (m==1) & (k==1) ):
    print(-1)
    exit()


n = 2**(m+1)
ans = [0] * n
if( k==0):
    for i in range(n):
        ans[i] = i//2
    print(' '.join([str(i) for i in ans ]))
    exit()

ans[0] = k
ind = 1
for i in range(n//2):
    if(i != k):
        ans[ind] = i
        ind += 1

ans[ind] = k
ind += 1

for i in range(n//2 -1, -1, -1):
    if(i != k):
        ans[ind] = i
        ind += 1


print(' '.join([str(i) for i in ans ]))

Measured memory_bytes: 71388
nums = map(int, input().split())
nums = sorted(nums)
A, B, C = nums

if A == B and B == C and A % 2 == 0:
    print(-1)
    exit()

count = 0
while True:
    if A % 2 != 0 or B % 2 != 0 or C % 2 != 0:
        print(count)
        exit()

    nA = (B + C) // 2
    nB = (A + C) // 2
    nC = (A + B) // 2
    count += 1
    A, B, C = nA, nB, nC

Measured memory_bytes: 38256
#include <iostream>
#include <stdio.h>

using namespace std;

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

int main()
{
	long long a, b, t;
	while (scanf("%lld%lld", &a, &b) != EOF)
	{
		if (a < b)
			t = gcd(b, a);
		else
			t = gcd(a, b);
		printf("%lld %lld\n", t, a * b / t);
	}
	return 0;
}

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

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


Measured memory_bytes: 3604
n = input()
for i in range(2 ** 3):
    op = ['+'] * 3
    for j in range(3):
        if i >> j & 1:
            op[j] = '-'
    f = [0] * 7
    f[::2] = n
    f[1::2] = op
    f = ''.join(f)
    if eval(f) == 7:
        print(''.join([f, '=7']))
        exit()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{

	int X,t;

	cin >> X >> t;

	cout << ((X-t > 0) ? X-t : 0) << endl;

	return 0;

}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long K = long.Parse(Console.ReadLine());
            long sum = 0;
            for (long i = 1; i <= K; i++)
                for (long j = 1; j <= K; j++)
                    for (long n = 1; n <= K; n++)
                        sum += Gcd(Gcd(i, j), n);
            Console.WriteLine(sum);
        }
        
　　　　//最小公倍数
        public static long Gcd(long a, long b)
        {
            if (a < b)
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


Measured memory_bytes: 27512