akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

class Test {
	static void Main(string[] args) {
      var inputs = System.Console.ReadLine()
    	.Split(' ')
    	.Select(s => int.Parse(s))
    	.ToArray();
      int N = inputs[0];
      int[] A = System.Console.ReadLine()
    	.Split(' ')
    	.Select(s => int.Parse(s))
    	.ToArray();
      Array.Sort(A);
      Array.Reverse(A);
      Int64 cnt = 0;
      for(int i = 1; i < N; i++){
        cnt = cnt + A[(int)i/2];
      }
      Console.WriteLine(cnt);
	}
}

Measured memory_bytes: 44512
#include<iostream>
using namespace std; 
          
int main(){
        int h, m, s;
        cin >> s;
        h = s /3600; s %= 3600;
        m = s / 60; s %= 60;
             
        cout << h << ":" << m << ":" << s <<endl;

        return 0;
}   

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		String s = fs.next();
		String t = fs.next();
		int cnt = 0;

		for (int i = 0; i < s.length(); i++){
			if (s.charAt(i) != t.charAt(i)) cnt++;
		}

		System.out.println(cnt);
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}


}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(y==0)return x;
    return gcd(y,x%y);
}
ll LCM(ll a, ll b){
    return a/gcd(a,b)*b;
}

int main(void)
{
    int n;
    cin>>n;
    vector<int> v(n),c(n);
    int v_sum=0,c_sum=0;
    rep(i,0,n){ cin>>v[i]; v_sum+=v[i];}
    rep(i,0,n){ cin>>c[i]; c_sum+=c[i];}

    int ans=0;
    rep(i,0,n){
        if(v[i]-c[i]>0)ans+=v[i]-c[i];
    }
    cout<<ans<<endl;
     
    return 0;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
typedef vector<ll> vll;
typedef vector<int> vi;
const ll N = 1e6 + 10;
const int M = 1e9 + 7;
const double eps = 1e-9;

int main() {
    char ch;
    cin >> ch;
    if (isupper(ch))
        cout << "A" << endl;
    else cout << "a" << endl;
}



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

#define lugan "LP"
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define endl '\n'
#define _io ios_base::sync_with_stdio(0);   cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5+7;
const int oo = 1e9+7;

inline void initf()
{
    freopen(lugan".inp", "r", stdin);
    freopen(lugan".out", "w", stdout);
}

int n, m, deg[N], dp[N];
vector<int> g[N];

int main()
{
    _io
    cin >> n >> m;
    int u, v;
    while (m--)
    {
        cin >> u >> v;
        g[u].pb(v);
        deg[v]++;
    }
    queue<int> q;
    for (int i=1; i<=n; i++)
        if (deg[i] == 0)
            q.push(i);
    while (!q.empty())
    {
        u = q.front();
        q.pop();
        for (int v : g[u])
        {
            deg[v]--;
            if (deg[v] == 0)
            {
                q.push(v);
                dp[v] = max(dp[v], dp[u] + 1);
                dp[0] = max(dp[0], dp[v]);
            }
        }
    }
    cout << dp[0];
    return 0;
}



Measured memory_bytes: 6528
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    int X, Y, Z;
    if (scanf("%d%d%d", &X, &Y, &Z) < 3) return 0;

    int ans = 0;
    for (int i = 1; i < 100000; i++)
    {
        // i * Y + (i - 1) * Z + 2 * Z > X
        if (i * Y + (i + 1) * Z > X) break;
        ans = i;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Restaurant implements Comparable<Restaurant> {
  String city;
  int point;
  int i;
  public Restaurant(String city, int point, int i) {
    this.city = city;
    this.point = point;
    this.i = i;
  }

  public int compareTo(Restaurant other) {
    int ans = city.compareTo(other.city);
    if (ans != 0) return ans;
    return Integer.compare(other.point, point);
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      List<Restaurant> list = new ArrayList<Restaurant>();
      int n = sc.nextInt();
      for (int i = 1; i <= n; i++) {
        String city = sc.next();
        int point = sc.nextInt();
        list.add(new Restaurant(city, point, i));
      }
      Collections.sort(list);
      for (Restaurant restaulant: list) {
        System.out.println(restaulant.i);
      }
    } finally {
      sc.close();
    }
  }
}


Measured memory_bytes: 36112
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mmax=1000009;

int main(void){
    int h,w;
    cin>>h>>w;
    int C[10][10];
    rep(i,10) rep(j,10) cin>>C[i][j];
    rep(k,10) rep(i,10) rep(j,10){
        C[i][j]=min(C[i][j],C[i][k]+C[k][j]);
    }
    /*rep(i,10){
        rep(j,10){
            cout<<C[i][j]<<" ";
        }
        cout<<endl;
    }*/
    int count[10];
    rep(i,10) count[i]=0;
    rep(i,h) rep(j,w){
        int a;
        cin>>a;
        if(a==-1) continue;
        count[a]++;
    }
    long long ans=0;
    rep(i,10){
        if(i==1) continue;
        ans+=count[i]*C[i][1];
        //cout<<i<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define EM 1000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
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; }

int main(){
    LL N;
    cin >> N;
    LL ans = N*(N-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, p;
    int bowl, id, score[51];
    while (cin >> n >> p) {
        if (!n && !p) { break; }
        bowl = p; id = 0;
        fill(score, score+51, 0);
        while (true) {
            if (bowl > 0) {
                bowl--;
                score[id]++;
                if (score[id] == p) {
                    cout << id << endl;
                    break;
                }
            }
            else {
                bowl += score[id];
                score[id] = 0;
            }
            id++;
            id %= n;
        }
    }
    return 0;
}


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

typedef long long ll;
#define loop(i,n) for(int i=0;i<n;++i)
#define mem(x,y) memset(x,y,sizeof(x))
#define PI   3.1415926
#define INF  0x3f3f3f3f//(1061109567)
int main()
{
	int n,k,s;
	cin >>n>>k>> s;
	int q;
	if(s!=1e9) q=s+1;
	else q=s-1;
	if(n>k)
	{
		loop(i,k)
		{
			cout << s << " "; 
		}
		for(int j=0;j<n-k;j++)
		{
			if(j!=n-k-1) cout << q << " ";
			else cout << q;
		}
	}
	else
	{
		for(int j=0;j<k;j++)
		{
			if(j==k-1) cout << s;
			else cout << s << " "; 
		}
	}
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string s; cin >> s;
  int K; cin >> K; map<string, int> m;
  for(int i = 0; i < s.size(); ++i) {
    string t = char_to_string(s[i]); m[t]++;
    for(int k = i + 1; k < s.size(); ++k) {
      t += s[k];
      m[t]++;
      if(t.size() == K) break;
    }
  }
  vector<string> ans;
  for(auto x : m) {
    ans.push_back(x.first);
  }
  sort(all(ans));
  cout << ans[K - 1] << endl;
}


Measured memory_bytes: 5076
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BAroundSquare {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int i = 1;
            while (i * i <= n) {
                i++;
            }
            out.println(i * i - 2 * i + 1);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  char c;
  bool isFour = false;
  REP(i,n) {
    cin >> c;
    if (c == 'Y') isFour = true;
  }
  COUT(isFour ? "Four" : "Three");
  return 0;
}


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

struct activity
{
	int a, b, c;
};

int solve(vector<activity> ar, int n)
{
	int dp[n + 1][3];
	dp[1][0] = ar[1].a;
	dp[1][1] = ar[1].b;
	dp[1][2] = ar[1].c;

	for (int i = 2; i <= n; i++)
	{
		dp[i][0] = ar[i].a + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = ar[i].b + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = ar[i].c + max(dp[i - 1][0], dp[i - 1][1]);
	}

	//bottom up implementation
	int ans = max(dp[n][0], max(dp[n][1], dp[n][2]));

	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	vector<activity> arr(n + 1);
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i].a;
		cin >> arr[i].b;
		cin >> arr[i].c;
	}
	cout << solve(arr, n);
}

Measured memory_bytes: 6628
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    long double ans = 1e8;
    vector<pair<long double, long double>> p(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> p[i].first >> p[i].second;
    }
    auto score = [&](long double x, long double y) {
        long double res = 0;
        for (size_t i = 0; i < N; i++)
        {
            chmax(res, sqrt((p[i].first - x) * (p[i].first - x) + (p[i].second - y) * (p[i].second - y)));
        }
        return res;
    };
    long double ansx = 0, ansy = 0;
    long double left = 0, right = 1000;
    int num = 1e3;
    for (size_t i = 0; i < num; i++)
    {
        long double c1 = (left * 2 + right) / 3, c2 = (left + right * 2) / 3;
        long double l2 = 0, r2 = 1000;
        for (size_t i = 0; i < num; i++)
        {
            long double d1 = (l2 * 2 + r2) / 3, d2 = (l2 + r2 * 2) / 3;
            if (score(c1,d1 ) > score(c1,d2))
            {
                l2 = d1;
            }
            else
            {
                r2 = d2;
            }
        }
        long double ls = score(c1,l2);
        long double l3 = 0, r3 = 1000;
        for (size_t i = 0; i < num; i++)
        {
            long double d1 = (l3 * 2 + r3) / 3, d2 = (l3 + r3 * 2) / 3;
            if (score(c2,d1 ) > score(c2,d2))
            {
                l3 = d1;
            }
            else
            {
                r3 = d2;
            }
        }
        long double rs = score(c2,l3);
        chmin(ans,ls);
        chmin(ans,rs);
        if (ls > rs)
        {
            left = c1;
        }
        else
        {
            right = c2;
        }
    }
    

    cout << setprecision(20) << ans;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
import itertools

def main():
    n = int(sys.stdin.readline())
    ss = [sys.stdin.readline().strip() for _ in range(n)]

    ss.sort()
    votes = [(-sum(1 for _ in g), k) for k, g in itertools.groupby(ss)]
    votes.sort()

    for v, k in votes:
        if v != votes[0][0]:
            break
        print(k)

if __name__ == '__main__':
    main()

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

using namespace std;

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

void solve() {
	//~ freopen("lca.out", "w", stdout);
	//~ freopen("lca.in", "r", stdin);
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr);
	
	string s, t;
	cin >> s >> t;
	
	int n = s.size();
	int m = t.size();
	
	vector<vector<piii>> dp(n + 1, vector<piii>(m + 1, {0, {0, 0}}));
		
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j]) {
				if (dp[i][j].first + 1 > dp[i + 1][j + 1].first)
						dp[i + 1][j + 1] = {dp[i][j].first + 1, {i, j}};
			}
			dp[i + 1][j] = max(dp[i + 1][j], make_pair(dp[i][j].first, make_pair(i, j)));
			dp[i][j + 1] = max(dp[i][j + 1], make_pair(dp[i][j].first, make_pair(i, j)));
		}
	}
	piii max_ = {0, {0, 0}};
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++)
			max_ = max(max_, make_pair(dp[i][j].first, make_pair(i, j)));
			
	if (max_.first == 0) 
		return;
			
	vector<char> ans;
	int i = max_.second.first;
	int j = max_.second.second;
	while (i > 0 && j > 0) {
		pii prev = dp[i][j].second;
		if (prev.first == i - 1 && prev.second == j - 1) {
			ans.push_back(t[j - 1]);
		}
		i = prev.first;
		j = prev.second;
	}
	for (int k = ans.size() - 1; k >= 0; k--) {
		cout << ans[k];
	}
}

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




Measured memory_bytes: 105984
x = input()
space_index1 = x.index(' ')

n = int(x[0:space_index1])
m = int(x[space_index1+1:])

x = input()
tmp_space_idx = 0
Ajs = x.split(' ')

sum_ = 0
for aj in Ajs:
  sum_ += int(aj)

if sum_ <= n:
  print(n - sum_)
else:
  print(-1)

Measured memory_bytes: 9588
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

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

int ma() {
    bool cnt[8];
    REP(i, 8) cnt[i] = false;
    int free = 0;
    REP(i, N) {
        if (a[i] <= 399) cnt[0] = true;
        else if (a[i] <= 799) cnt[1] = true;
        else if (a[i] <= 1199) cnt[2] = true;
        else if (a[i] <= 1599) cnt[3] = true;
        else if (a[i] <= 1999) cnt[4] = true;
        else if (a[i] <= 2399) cnt[5] = true;
        else if (a[i] <= 2799) cnt[6] = true;
        else if (a[i] <= 3199) cnt[7] = true;
        else free++;
    }
    int res = 0;
    REP(i, 8) res += cnt[i];
    return res + free;
}
int mi() {
    bool cnt[8];
    REP(i, 8) cnt[i] = false;
    bool free = false;
    REP(i, N) {
        if (a[i] <= 399) cnt[0] = true;
        else if (a[i] <= 799) cnt[1] = true;
        else if (a[i] <= 1199) cnt[2] = true;
        else if (a[i] <= 1599) cnt[3] = true;
        else if (a[i] <= 1999) cnt[4] = true;
        else if (a[i] <= 2399) cnt[5] = true;
        else if (a[i] <= 2799) cnt[6] = true;
        else if (a[i] <= 3199) cnt[7] = true;
        else free = true;
    }
    int res = 0;
    REP(i, 8) res += cnt[i];
    if (res == 0 && free) ++res;
    return res;
}

int main(void) {
    cin >> N;
    REP(i, N) {
        cin >> a[i];
    }
    cout << mi() << " " << ma() << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int car[11],i=0,n;
	while(1){
		if(scanf("%d",&n)==EOF)break;
		if(n){
			car[i]=n;
			i++;
		}else{
			i--;
			printf("%d\n",car[i]);
			
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){
  ll n;
  cin>>n;
  vector<ll> l(n);
  rep(i,n) cin>>l[i];

  sort(begin(l),end(l));
  ll ans=0;
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){

      ll two=l[i]+l[j];
      auto itr=lower_bound(begin(l),end(l),two);
      ll num=distance(begin(l)+j,itr)-1;
      if(n>0) ans+=num;
    }
  }
  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


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

using namespace std;

typedef long long ll;

const ll MAX = 100010;

int main() {
    int n;
    cin >> n;
    vector<int> cnt(MAX);
    ll  sum = 0;
    int temp;
    for (int i = 0 ; i < n; i++) {
        cin >> temp;
        cnt[temp]++;
        sum += temp;
    }

    int q;
    cin >> q;
    int b,c;
    for (int i =0 ; i < q; i++) {
        cin >> b >> c;
        sum += (c - b) * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
bool visited[100005]={false};
int dp[100005]={0};
void dfs(int u){
  visited[u]=true;
  for(auto v: g[u]){
    if(!visited[v])
      dfs(v);
    dp[u]=max(dp[u],dp[v]+1);
  }
}
int main() {
  int n,m;
  cin>>n>>m;
  for(int u,v,i=0;i<m;i++){
    cin>>u>>v;
    g[u].push_back(v);
  }
  for(int i=1;i<=n;i++){
    if(!visited[i])
      dfs(i);
  }
  int ans=0;
  for(int i=1;i<=n;i++)
    ans=max(ans,dp[i]);
  cout<<ans<<endl;

}

Measured memory_bytes: 8192
from collections import Counter


class UnionFind:

    def __init__(self, n: int) -> None:
        self.parent = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, i: int) -> None:
        if self.parent[i] == i:
            return i
        else:
            return self.find(self.parent[i])

    def unite(self, i: int, j: int) -> None:
        root_i = self.find(i)
        root_j = self.find(j)
        if root_i == root_j:
            return
        if self.rank[root_i] < self.rank[root_j]:
            self.parent[root_i] = root_j
        else:
            self.parent[root_j] = root_i
            if self.rank[root_i] == self.rank[root_j]:
                self.rank[root_i] += 1

                
N, K, L = map(int, input().split())

uf1 = UnionFind(N)
for _ in range(K):
    i, j = map(int, input().split())
    uf1.unite(i - 1, j - 1)

uf2 = UnionFind(N)
for _ in range(L):
    i, j = map(int, input().split())
    uf2.unite(i - 1, j - 1)

set_id_pairs = [(uf1.find(i), uf2.find(i)) for i in range(N)]
counter = Counter(set_id_pairs)
counts = [counter[set_id_pairs[i]] for i in range(N)]
print(' '.join(str(c) for c in counts))

Measured memory_bytes: 72332
package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var wr *bufio.Writer = bufio.NewWriter(os.Stdout)

func nextInt() int {
	sc.Scan()
	val, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return val
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
    N := nextInt()
	cnt := 0
	resid := 0
	for i := 0; i < N; i++ {
		a := nextInt()
		if resid > 0 && a > 0 {
			cnt += 1
			a -= 1
		}
		cnt += a / 2
		resid = a % 2
	}
	fmt.Fprintln(wr, cnt)
	wr.Flush()
}


Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6+8;
const int sz = 1e5+5;
void f_io(){
    IOS;
}
int32_t main(){
    f_io();
    int t = 1;
    //cin>>t;
    while(t--){
        int n;cin>>n;
        string s; cin>>s;
        int fans = 0;
        n = 0;
        for(auto k : s){
            if(k == 'I') n++;
            else n--;
            fans = max(fans,n);
        }
        cout<<fans<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vector<pair<ll,ll>> factorize(ll n) {
    vector<pair<ll,ll>> ans;
    for (ll i = 2; i*i <= n; ++i) {
        if (n%i) continue;
        ans.emplace_back(i,0);
        while (n%i == 0) {
            n /= i;
            ans.back().second++;
        }
    }
    if (n != 1) ans.emplace_back(n,1);
    return ans;
}

int main() {
    ll n, p;
    cin >> n >> p;
    auto g = factorize(p);
    ll ans = 1;
    for (auto x : g) {
        ans *= pow(x.fi, (x.se / n));
    }
    cout << ans << endl;
    return 0;
}

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

const int N=1e6+30;
typedef long long ll;
int n,arr[200];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>arr[i];
    ll mn=INT_MAX;
    for(int i=1;i<=100;i++){
        ll ans=0;
        for(int j=0;j<n;j++){
            ll tmp=(arr[j]-i);
            ans+=tmp*tmp;
        }
        mn=min(mn,ans);
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 256
S = input()
Slist=[]
for i in range(4):
    Slist.append(S[i])
Slist.sort()

if Slist[0] == Slist[1] and Slist[2] == Slist[3] and Slist[0]!=Slist[2]:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

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

{
    int a,b,x,y;
    double c;
    
    scanf("%d %d", &a, &b);
    
    x = a / b;
    y = a % b;
    c = a * 1.0 / b * 1.0;
    printf("%d %d %f\n", x,y,c);
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<ll, ll>;

int main(){
    int n; 
    cin >> n;
    vector<ll> xs, ys;
    rep(i,n){
        ll a, b; cin >> a >> b;
        ll x = a - b;
        ll y = a + b;
        xs.push_back(x);
        ys.push_back(y);
    }
    sort(ALL(xs));
    sort(ALL(ys));
    ll ans =  *xs.rbegin() - *xs.begin();
    ans = max(ans, *ys.rbegin() - *ys.begin());
    cout << ans << endl;
}

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

const int MAX_N = 10;
const int MAX_M = 10;

int N, M;
int k[MAX_M];
int s[MAX_M][MAX_N];
int p[MAX_M];
int A[MAX_N];
int ans;

void check() {
    int cnt = 0;
    for (int i = 0; i < M; ++i) {
        int sum = 0;
        for (int j = 0; j < k[i]; ++j) {
            sum += A[s[i][j]];
        }
        if (sum % 2 == p[i]) {
            ++cnt;
        }
    }
    if (cnt == M) {
        ++ans;
    }
}

void dfs(int i) {
    if (i == N) {
        check();
    }
    else {
        for (int j = 0; j <= 1; ++j) {
            A[i] = j;
            dfs(i + 1);
        }
    }
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        cin >> k[i];
        for (int j = 0; j < k[i]; ++j) {
            cin >> s[i][j];
            --s[i][j];
        }
    }
    for (int i = 0; i < M; ++i) {
        cin >> p[i];
    }
    dfs(0);
    cout << ans;
}

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


int main() {
	int N = 0, Q = 0;
	ll K = 0;
	bool check = true;
	cin >> N;
	cin >> K;
	cin >> Q;
	vector<int>ans(Q);
	for (int i = 0; i < Q; i++) {
		cin >> ans.at(i);
	}

	vector<int>point(N, K-Q);
	
	int count = 0;
	for (int i = 0; i < Q; i++) {
		point.at(ans.at(i) - 1) += 1;
		
	}
	
	
	for (int i = 0; i < N; i++) {
		if (point.at(i) > 0) {
			cout << "Yes" << endl;
		}
		else{
		cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>

int dp[101][10001]; // i????????§?????????j??????????????§???v
int N, W;

int v[10000];
int w[10000];


using namespace std;

int serch(int i,int cw) {
	if (i >= N) return 0; 
	if (dp[i][cw] != -1) return dp[i][cw];
	if (cw + w[i] > W) return dp[i][cw] = serch(i + 1,cw);
	return dp[i][cw] = max(serch(i+1,cw + w[i]) + v[i],serch(i + 1,cw));
}


int main() {

	for (int i = 0; i < 100; i++) {
		for(int j = 0; j < 10000; j++) {
			dp[i][j] = -1;
		}
	}

	cin >> N >> W;

	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
	}

	cout << serch(0,0) << endl;

	return 0;
}

Measured memory_bytes: 5084
use std::io::*;

fn main() {
    let stdin = std::io::stdin();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut s = String::new();
    let _n: usize = reader.read_line(&mut s).unwrap();
    let mut s = String::new();
    reader.read_line(&mut s).unwrap();
    let a: Vec<String> = s.split_whitespace().map(|x| x.to_string()).collect();

    let mut a1 = vec![];
    let mut a2 = vec![];

    let div = if a.len() % 2 == 0 {
        0
    } else {
        1
    };

    for (i, e) in a.iter().enumerate() {
        if i % 2 == div {
            a2.push(e);
        } else {
            a1.push(e);
        }
    }
    a1.reverse();

    let mut ans = String::new();

    for e in a1 {
        ans += &format!("{} ", e);
    }
    for e in a2 {
        ans += &format!("{} ", e);
    }
    ans.pop();
    println!("{}", ans);
}


Measured memory_bytes: 21824
#include <bits/stdc++.h>
#define ll long long
#define int ll
#define endl '\n'
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)
using namespace std;
 
int32_t main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int a;
	cin >> a;
	cout << ((a%2==0)?(a/2):((a+1)/2)) << endl;;
	return 0;
}

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

using namespace std;

int main()
{
    long long int n;
    cin>>n;
    long long int broj=n;
    long long int stepen=0;
    while(broj>1)
    {
        broj=broj/2;
        stepen++;
    }
    long long int sum=1;
    long long int power=1;
    for(int i=1;i<=stepen;i++)
    {
        power=power*2;
        sum=sum+power;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;

    if(13 <= A) {
        cout << B;
    }
    else if(6 <= A && A <= 12) {
        cout << B / 2;
    }
    else {
        cout << 0;
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
# inputb = input().split()

a = int(inputa[0])
b = int(inputa[1])
c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

print(int(float(a)*float(b)/2))

Measured memory_bytes: 38384
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	
	string s;
	 sc(s);
	 if(s[2]==s[3] and s[4]==s[5])prY;
	 else prN;
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int succ[2000], pred[2000];

void kill(int n){
    succ[pred[n]] = succ[n];
    pred[succ[n]] = pred[n];
}

int main(){
    int n,m;
    while(cin>>n>>m, n){
        rep(i,n){
            succ[i] = (i+1)%n;
            pred[i] = (i-1+n)%n;
        }
        int cur = 0;
        rep(i,n){
            rep(i,m) cur = succ[cur];
            kill(cur);
            // cout << " " << cur << endl;
        }
        if(cur==0) cur=n;
        cout << cur << endl;
    }
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int x,w,ans=0;
    string s;
    cin>>x;
    ans+=(x/500)*1000;
    x%=500;
    ans+=(x/5)*5;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace TestApp2
{
    class Program
    {
        static void Main()
        {
            var str = Console.ReadLine();
            var mat = new Regex("^A?KIHA?BA?RA?$");
            Console.WriteLine(mat.IsMatch(str) ? "YES" : "NO");
            Console.ReadLine();
        } 
    }

}

Measured memory_bytes: 16204
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

typedef long long ll;
// #define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int a, b, c; cin >> a >> b >> c;
  if((a < c and c < b) or (a > c and c > b)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
#define pp pair<int,int>
#define ppn pair<pp,int>
#define F first
#define S second
#define N 1000005
#define mod 1000000007


using namespace std;


string longDivision(string number, int divisor)
{

    string ans;


    int idx = 0;
    int temp = number[idx] - '0';
    while (temp < divisor){
        temp = temp * 10 + (number[++idx] - '0');


    while (number.size() > idx) {
        // Store result in answer i.e. temp / divisor
        ans += (temp / divisor) + '0';

        // Take next digit of number
        temp = (temp % divisor) * 10 + number[++idx] - '0';
    }
    }

    if (ans.length() == 0)
        return "0";

    // else return ans
    return ans;
}


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

    int n;
    string s;
    cin>>n>>s;
    int i=0, j=n-1, c=0;
    while(i<j){
        if(s[i]=='W'&&s[j]=='R'){
            s[i]='R';
           s[j]='W';
            c++;
            i++;
            j--;
            continue;
        }
        if(s[i]=='R'&&s[j]=='W'){
            i++;
            j--;
            continue;
        }
        if(s[i]=='R'){
            i++;
            continue;
        }
        if(s[j]=='W'){
            j--;
            continue;
        }

        //cout<<i<<" "<<j<<endl;

    }
    //cout<<s<<endl;
    int k=0;
    for(int i=n-1; i>=0; i--){
        if(s[i]=='R'&&s[i-1]=='W'){
            c+=k;
            k=0;
        }
        if(s[i]=='W')k++;
    }
    cout<<c<<endl;

}


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  int N;
  cin >> N;
  for (int i = 0; i <= N / 4; i++) {
    for (int j = 0; j <= N / 7; j++) {
      if (i * 4 + j * 7 == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import math
K = int(input())

res = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    gcd1 = math.gcd(i, j)
    for k in range(1, K+1):
      if gcd1 == 1:
        res += 1
      else:
        res += math.gcd(gcd1, k)
print(res)

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




int main() {
	ll n,i,j,k,l,m,t;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++)cin>>a[i];
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	for(i=2;i<n;i++)
	{
	    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

struct bus {
	int mini = 0, tot = 0;	
};

int n, c, k, ar[N];
vector<bus> v;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> c >> k;
	for(int i = 1; i <= n; i++)
		cin >> ar[i];
	sort(ar + 1, ar + n + 1);
	v.pb({ar[1], 1});
	for(int i = 2; i <= n; i++) {
		if(ar[i] - v.back().mini <= k && v.back().tot <= c - 1)
			v.back().tot++;
		else {
			bus t = {ar[i], 1};
			v.pb(t);
		}
	}
	cout << v.size();
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                \
  \   
  ios::sync_with_stdio(false); \
  cin.tie(0);
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define debug(...)
#endif
#define trace(c, x) for (auto& x : c)

int main() {
  FAST_IO
  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
  return 0;
}

Measured memory_bytes: 3648
N = int(input())
A = list(map(int,input().split()))
ans = [None for k in range(N)]
x = sum(A)
y = 0
for n in range((N-1)//2):
	y += A[2*n]
ans[N-1] = x-y*2
ans[0] = A[N-1]*2 -ans[N-1]
for n in range(N-1):
	ans[n+1] = A[n]*2 - ans[n]
for a in ans:
	print(a, end=" ")

Measured memory_bytes: 14092