akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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;

// 縦横
ll h, w; 

ll bfs(vector<string> &s, vvi &color, ll i, ll j, ll step){
    queue<pair<pair<ll, ll>, ll>> que;
    que.push(make_pair(make_pair(i, j), step));
    color[i][j] = 1;

    while(!que.empty()){
        auto p = que.front();
        que.pop();
        ll i = p.first.first;
        ll j = p.first.second;
        if(p.first.first == h-1 && p.first.second == w-1) return p.second;

        // 上下左右が壁でなく、かつ訪問済みでない場合次の訪問先として積む
        if(i != 0 && s[i-1][j] != '#' && color[i-1][j] == 0){
            que.push(make_pair(make_pair(i-1, j), p.second+1)); color[i-1][j] = 1; }
        if(i != h-1 && s[i+1][j] != '#' && color[i+1][j] == 0){
            que.push(make_pair(make_pair(i+1, j), p.second+1)); color[i+1][j] = 1; }
        if(j != 0 && s[i][j-1] != '#' && color[i][j-1] == 0){
            que.push(make_pair(make_pair(i, j-1), p.second+1)); color[i][j-1] = 1; }
        if(j != w-1 && s[i][j+1] != '#' && color[i][j+1] == 0){
            que.push(make_pair(make_pair(i, j+1), p.second+1)); color[i][j+1] = 1;}
    }
    return -1;
}

int main(){
    Init();
    cin >> h >> w;
    vector<string> s(h);
    vvi color(h, vi(w, 0));

    rep(i, h) cin >> s[i];

    // 元々の'#'マスの数を数える
    ll cntB = 0;
    rep(i, h) rep(j, w) if(s[i][j] == '#') cntB++;

    // 最短経路を計算
    ll step = bfs(s, color, 0, 0, 0);

    // 全体から最短経路（始点含む）を引き、かつ元々黒だった部分を覗いた部分が答え
    if(step != -1) cout << (h*w) - (step+1) - cntB << endl;
    else cout << step << endl;
}

Measured memory_bytes: 256
n = int(input())
pp = list(map(int, input().split()))
cnt = 0

for i in range(n-1):
  if pp[i] == i+1:
    pp[i], pp[i+1] = pp[i+1], pp[i]
    cnt += 1
    
if pp[-1] == n:
  cnt += 1
  
print(cnt)

Measured memory_bytes: 20576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
#define INF 1000000000000000000
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent,int mod)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
signed main()
{
	fast
	int n;
	cin>>n;
	vector<double>v(n+1);
	f(i,0,n) cin>>v[i];
	vector<vector<double>>dp(n+1,vector<double>(n+1));
	dp[0][0]=1;
	f(i,1,n+1)
	{
		f(j,0,i+1)
		{
			if(j==0) dp[i][j]=dp[i-1][j]*(1-v[i-1]);
			else dp[i][j]=(dp[i-1][j]*(1-v[i-1]))+(dp[i-1][j-1]*(v[i-1]));
		}
	}
	double ans=0;
	f(i,n/2+1,n+1) ans+=dp[n][i];
	printf("%.12f",ans); 
	return 0;
}


Measured memory_bytes: 73724
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
A = []
for i in range(N):
    A.append(_I())

max_v = max(A)
max_v_count = A.count(max_v)
if max_v_count >= 2:
    # どれをとっても最大は最大
    for a in A:
        print(max_v)
else:
    for a in A:
        if a == max_v:
            second_max_v = [_ for _ in A]
            second_max_v.remove(max_v)
            second_max_v = max(second_max_v)
            print(second_max_v)
        else:
            print(max_v)


Measured memory_bytes: 95064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		
		long sum = 0;
		for(int i = 0; i < m; i++)
		{
			sum += sc.nextLong();
		}
		
		if(sum > n)
			System.out.println(-1);
		else
			System.out.println(n-sum);
	}

}


Measured memory_bytes: 46532
/* ex3_2
   tamayama */

#include<stdio.h>

int main(void){
    int N;
    int Pencil;
    scanf("%d",&N);
    Pencil = N;
    if((Pencil-2)%10 == 0 || (Pencil-4)%10 == 0 || (Pencil-5)%10 == 0 || (Pencil-7)%10 == 0 || (Pencil-9)%10 == 0){
        printf("hon");
    }else if(Pencil%10 == 0 || (Pencil-1)%10 == 0 || (Pencil-6)%10 == 0 || (Pencil-8)%10 == 0){
        printf("pon");
    }else{
        printf("bon");
    }
    return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max(a - 2 * b, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = [int(i) for i in input().split()]
L = [0] + sorted(L)

from bisect import bisect_left

ans = 0
for i in range(1,N-1):
    for j in range(i+1,N):
        ans += (bisect_left(L,L[i]+L[j]))-j-1

#短い2本を固定して考える

print(ans)

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int X, N, P[105];
map <int, bool> mp;

int main(){
  cin >> X >> N;
  for (int i = 0; i < N; i++){
    cin >> P[i];
    mp[P[i]] = true;
  }

  for (int i = 0; i < 100; i++){
    int now = X - i;
    if (!mp[now]){
      cout << now << endl;
      break;
    }
    now = X + i;
    if (!mp[now]){
      cout << now << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a, b, fim=0;
		Scanner scanner = new Scanner(System.in);

		a = scanner.nextInt();
		b = scanner.nextInt();
		
		for(int i = 0; i < 2; i++) {
			if(a > b) {
				fim += a;
				a--;
			}else if(b > a) {
				fim += b;
				b--;
			}else if(b == a) {
				fim += a;
				a--;
			}
		}
		System.out.println(fim);
	}
}


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

int main(){
	int A1, B1, A2, B2;
	cin >> A1 >> B1;
	int ans = 0;
	if(A1 > B1){
		ans = A1;
		A2 = A1 - 1;
		B2 = B1;
	}
	else{
		ans = B1;
		B2 = B1 - 1;
		A2 = A1;
	}
	if(A2 > B2){
		ans = ans + A2;
	}
	else{
		ans = ans + B2;
	}
	cout << ans << endl;

}

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

using namespace std;

int main(void) {
    int w;
    string c;
    list<int> myList;
    list<int>::iterator it;
    cin >> w;
    for (int i = 0; i < w; i++) {
        cin >> c;
        if (c == "insert") {
            int x;
            cin >> x;
            myList.push_front(x);
        } else if (c == "delete") {
            int x;
            cin >> x;
            for (it = myList.begin(); it != myList.end(); it++) {
                if (*it == x) {
                    myList.erase(it);
                    break;
                }
            }
        } else if (c == "deleteLast") {
            myList.pop_back();
        } else if (c == "deleteFirst") {
            myList.pop_front();
        }
    }

    for (it = myList.begin(); it != myList.end(); it++) {
        if (it == myList.begin()) {
            cout << *it;
        }else{
            cout << ' ' << *it; 
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 34404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int[] x = new int[5];

		for(int i = 0; i < 5; i++) {
			x[i] = scan.nextInt();
			if (x[i] == 0) {
				System.out.println(i+1);
				break;
			}
		}
	}

}

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

int main(){
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];

    for(int i=0; i<=100; ++i){
        bool in=true;
        int y = x-i;
        for(auto k : p) if(k==y) in = false;
        if(in){
            cout << y << endl;
            return 0;
        }
        in=true;
        y = x+i;
        for(auto k : p) if(k==y) in = false;
        if(in){
            cout << y << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3628
import java.io.*;
import java.util.*;

public class Main {
	
	int[][] g;

	void submit() {
		int n = nextInt();
		g = new int[n][];
		int[] a = new int[3 * n - 3];
		int[] deg = new int[n];
		for (int i = 0; i < n - 1; i++) {
			a[3 * i] = nextInt();
			a[3 * i + 1] = nextInt();
			a[3 * i + 2] = nextInt();
			deg[a[3 * i]]++;
			deg[a[3 * i + 1]]++;
		}

		for (int i = 0; i < n; i++) {
			g[i] = new int[2 * deg[i]];
		}

		for (int i = 0; i < 3 * n - 3; i += 3) {
			int v = a[i];
			int u = a[i + 1];
			int lbl = a[i + 2];
			--deg[v];
			g[v][2 * deg[v]] = u;
			g[v][2 * deg[v] + 1] = lbl;
			--deg[u];
			g[u][2 * deg[u]] = v;
			g[u][2 * deg[u] + 1] = lbl;
		}
		
		dfs(0, -1);
		
		int groups = 0;
		groups += cnt[0];
		cnt[0] = 0;
		for (int i = 1; i < 16; i++) {
			groups += cnt[i] / 2;
			cnt[i] %= 2;
		}
		
		groups += go(cnt);
		out.println(n - 1 - groups);
	}
	
	int go(int[] arr) {
		int[] xor = new int[1 << 15];
		for (int i = 0; i < 15; i++) {
			xor[1 << i] = i + 1;
		}
		for (int i = 1; i < xor.length; i++) {
			int low = i & -i;
			xor[i] = xor[low] ^ xor[i ^ low];
		}
		
		int[] dp = new int[1 << 15];
		dp[0] = 0;
		for (int mask = 1; mask < 1 << 15; mask++) {
			for (int sub = mask; sub > 0; sub = (sub - 1) & mask) {
				dp[mask] = Math.max(dp[mask], dp[mask ^ sub] + (xor[sub] == 0 ? 1 : 0));
			}
		}
		
		int look = 0;
		for (int i = 0; i < 15; i++) {
			if (cnt[i + 1] > 0) {
				look |= 1 << i;
			}
		}
		return dp[look];
	}
	
	int[] cnt = new int[16];
	
	int dfs(int v, int p) {
		int up = 0;
		int allChild = 0;
		for (int i = 0; i < g[v].length; i += 2) {
			int u = g[v][i];
			int x = g[v][i + 1];
			if (u == p) {
				up = x;
			} else {
				allChild ^= dfs(u, v);
			}
		}
		if (p != -1) {
//			System.err.println(ret);
			cnt[up ^ allChild]++;
		}
		return up;
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 53932
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>

using namespace std;

struct E{int to,cost;};
vector<E> edges[100010];
long long dp[100010];
long long INF=1ll * 1000 * 1000 * 1000* 1000*1000;
typedef pair<int,int> P;
int main() {
  int N,Q,K;
  scanf("%d", &N);
  for(int i=0;i<N-1;++i) {
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);
    --a;--b;
    edges[a].push_back({b,c});
    edges[b].push_back({a,c});
  }
  scanf("%d%d",&Q,&K);
  --K;
  for(int i=0;i<N;++i) {
    dp[i]=INF;
  }
  dp[K]=0;
  priority_queue<P, vector<P>, greater<P> > PQ;
  PQ.push(P(0, K));
  while(!PQ.empty()) {
    P current = PQ.top();PQ.pop();
    if (dp[current.second] < current.first) continue;
    for (int j=0;j<edges[current.second].size();++j) {
      E e=edges[current.second][j];
      if (dp[e.to] > dp[current.second] + e.cost) {
        dp[e.to] = dp[current.second] + e.cost;
        PQ.push(P(dp[e.to], e.to));
      }
    }
  }
  for(int i=0;i<Q;++i) {
    int x,y;
    scanf("%d%d", &x, &y);
    --x;--y;
    printf("%lld\n", dp[x] + dp[y]);
  }
  return 0;
}


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

#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}

void solve() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a == b) {
    cout(c);
  } else if (b == c) {
    cout(a);
  } else {
    cout(b);
  }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A2 = []
for ai in A:
    if ai % 2 == 0:
        A2.append(ai)

ans = True
for ai in A2:
    if ai % 3 != 0 and ai % 5 != 0:
        ans = False


if ans:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){

  int X,Y;
  cin >> X >> Y;
  print(X + Y/2);

  return 0;
}


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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  vector<int> x(n);
  for(int i = 0;i < n;i++){
    cin >> x[i];
  }
  long long ret = 0;
  for(int i = 0;i < n-1;i++){
    ret += min((long long)(x[i+1]-x[i])*a,(long long)b);
  }
  cout << ret << endl;
}


Measured memory_bytes: 640
from itertools import permutations
import math

n = int(input())
p = [tuple(map(int, input().split())) for _ in range(n)]

ans = cnt = 0
for perm in permutations(range(n)):
    dist = 0
    for i in range(1, n):
        dist += math.sqrt((p[perm[i]][0] - p[perm[i - 1]][0])**2 +
                          (p[perm[i]][1] - p[perm[i - 1]][1])**2)

    # print(perm, dist)
    ans += dist
    cnt += 1

ans /= cnt
print(ans)


Measured memory_bytes: 40940
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    long long N, C;
    cin >> N >> C;
    vector<LLP> sushi(N);
    rep(i,N) cin >> sushi[i].first >> sushi[i].second;
    
    sort(sushi.begin(), sushi.end());

    vector<long long> clock(N, 0), antiClock(N, 0);
    vector<long long> clockMax(N, 0), antiClockMax(N, 0);

    clock[0] = sushi[0].second - sushi[0].first;
    clockMax[0] = max((long long)0, clock[0]);

    for (int i = 1; i < N; i++) {
        clock[i] = clock[i - 1] + sushi[i].second - (sushi[i].first - sushi[i - 1].first);
        clockMax[i] = max(clockMax[i - 1], clock[i]);
    }

    antiClock[N - 1] = sushi[N - 1].second - (C - sushi[N - 1].first);
    antiClockMax[N - 1] = max((long long)0, antiClock[N - 1]);
    for (int i = N - 2; i >= 0; i--) {
        antiClock[i] = antiClock[i + 1] + sushi[i].second - (sushi[i + 1].first - sushi[i].first);
        antiClockMax[i] = max(antiClockMax[i + 1], antiClock[i]);
    }

    long long ans = 0;
    for (int i = 0; i <= N - 2; i++) {
        ans = max(ans, clock[i] - sushi[i].first + antiClockMax[i + 1]);
    }
    ans = max(ans, clockMax[N - 1]);
    for (int i = N - 1; i > 0; i--) {
        ans = max(ans, antiClock[i] - (C - sushi[i].first) + clockMax[i - 1]);
    }
    ans = max(ans, antiClockMax[0]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7928
#include <string>
#include <string.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <functional>
#include <set>

using namespace std;

int n;
int m;
int a[50];
int b[50];
bool g[50][50];
int low[50];
int ord[50];
int order = 0;
int ans = 0;

void dfs(int cur,int par) {
	ord[cur] = order;
	low[cur] = order;
	++order;
	for (int i = 0; i < n; ++i) {
		if (!g[cur][i])
			continue;
		if (ord[i] != -1 && i != par) {
			low[cur] = min(low[cur], ord[i]);
		}
		else if (ord[i] == -1) {
			dfs(i, cur);
			low[cur] = min(low[cur], low[i]);
		}
	}

	if (cur != 0) {
		if (low[cur] > ord[par]) {
			++ans;
		}
	}

}


int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		--a[i];
		--b[i];
		g[a[i]][b[i]] = true;
		g[b[i]][a[i]] = true;
	}
	memset(ord, -1, sizeof(ord));
	dfs(0, -1);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int h = inpt[0];
        int w = inpt[1];

        for (int i = 0; i <= 9; i++) {
            inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

            for (int j = 0; j<inpt.Length; j++) {
                ConvDic[i, j] = inpt[j];
            }
        }

        int[] count = new int[10];

        for (int i = 0; i < h; i++) {
            inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            for (int j = 0; j < w; j++) {
                if(inpt[j] >= 0) {
                    count[inpt[j]]++;
                }
            }
        }

        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 10; k++) {
                    ConvDic[j, k] = Math.Min(ConvDic[j, k], ConvDic[j, i] + ConvDic[i, k]);
                }
            }
        }

        long ans = 0;
        for (int i = 0; i < count.Length; i++) {
            ans += ConvDic[i, 1] * count[i];
        }
        Console.WriteLine(ans);
    
    }

    private int[,] ConvDic = new int[10, 10];


    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



2 4
0 9 9 9 9 9 9 9 9 9
9 0 9 9 9 9 9 9 9 9
9 9 0 9 9 9 9 9 9 9
9 9 9 0 9 9 9 9 9 9
9 9 9 9 0 9 9 9 9 2
9 9 9 9 9 0 9 9 9 9
9 9 9 9 9 9 0 9 9 9
9 9 9 9 9 9 9 0 9 9
9 9 9 9 2 9 9 9 0 9
9 2 9 9 9 9 9 9 9 0
-1 -1 -1 -1
8 1 1 8


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 15444
function Main(input) {
    const lowerBound = (arr, n) => {
        let first = 0, last = arr.length - 1, middle;
        while (first <= last) {
            middle = Math.floor((first + last) / 2);
            if (arr[middle] < n) first = middle + 1;
            else last = middle - 1;
        }
        return first;
    }
    const upperBound = (arr, n) => {
        let first = 0, last = arr.length - 1, middle;
        while (first <= last) {
            middle = Math.floor((first + last) / 2);
            if (arr[middle] <= n) first = middle + 1;
            else last = middle - 1;
        }
        return first;
    }
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let H = parseInt(input[0][0], 10);
    let W = parseInt(input[0][1], 10);
    let M = parseInt(input[0][2], 10);
    let arr_hw = [];
    let arr_rowCount = Array.from({length: H}, () => []);
    let arr_colCount = Array.from({length: W}, () => []);

    for (let i = 0; i < M; i++){
        arr_hw.push(input[i + 1].map(e => parseInt(e, 10)));
        arr_rowCount[arr_hw[i][0] - 1].push(arr_hw[i][1] - 1);
        arr_colCount[arr_hw[i][1] - 1].push(arr_hw[i][0] - 1);
    }

    // console.log(arr_colCount);
    let MAXrow = 1;
    let tmpRowCandidate = [];
    for (let i = 0; i < H; i++){
        if (arr_rowCount[i].length === MAXrow) {
            tmpRowCandidate.push(i);
        }
        else if (arr_rowCount[i].length > MAXrow) {
            tmpRowCandidate = [i];
            MAXrow = arr_rowCount[i].length;
        }
    }
    let MAXcol = 1;
    let tmpColCandidate = [];
    for (let i = 0; i < W; i++){
        if (arr_colCount[i].length === MAXcol) {
            tmpColCandidate.push(i);
        }
        else if (arr_colCount[i].length > MAXcol) {
            tmpColCandidate = [i];
            MAXcol = arr_colCount[i].length;
        }
    }

    // console.log(tmpRowCandidate);
    // console.log(tmpColCandidate);

    let ans = MAXrow + MAXcol - 1;
    let count = 0;
    for (let hw of arr_hw){
        if (lowerBound(tmpRowCandidate, hw[0] - 1) !== upperBound(tmpRowCandidate, hw[0] - 1) || lowerBound(tmpColCandidate, hw[1] - 1) !== upperBound(tmpColCandidate, hw[1] - 1)){
            // console.log(hw);
            count ++;   
        }
    }
    // console.log(count);
    // console.log(MAXrow * tmpRowCandidate.length + MAXcol * tmpColCandidate.length - tmpRowCandidate.length * tmpColCandidate.length);
    if (count > (MAXrow * tmpRowCandidate.length + MAXcol * tmpColCandidate.length - tmpRowCandidate.length * tmpColCandidate.length)){
        ans ++;
    }

    console.log(ans);

}   

function DFS(tmpNode){
    for (let x of arr_v[tmpNode]){
        if (arr_time[x - 1][1] === 0) {
            arr_time[x - 1] = [x, time, 0];
            time ++;
            history.push(x);
            DFS(x - 1);
        } 
    }
    arr_time[tmpNode][2] = time;
    time ++;
    history.pop();
    return true;
}

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


Measured memory_bytes: 263372
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
//#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return (t*t)%mod;
    return (t*t*a)%mod;
}

//library end

signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    int q=n/(a+b),r=n%(a+b);
    int br=min(r,a);
    int ans=q*a+br;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <memory.h>
#include <algorithm>
using namespace std;


int	n,k, a[200001];
int	t[200001],tc=0;


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

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

	memset(t,0,sizeof(int)*(n+1));

	for(int i=0; i<n;i++)
	{
		t[a[i]]++;
	}

	int ans=0;

	sort(t,t+n+1);

	for(int i=0;i<k;i++)
	{
		ans+=t[n-i];
	}

	cout << (n-ans);

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

template<class T = ll>
struct Edge {
  int to;
  T cost;
  Edge() {}
  Edge(int to, T cost) : to(to), cost(cost) {}
  bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T = ll>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

  int V = (int)edges.size();
  const int INF = numeric_limits<T>::max();
  vector<T> dist(V, INF);
  dist[st] = 0;

  priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
  p_que.emplace(st, dist[st]);

  while (!p_que.empty()) {

    Edge<T> now(p_que.top().to, p_que.top().cost);
    p_que.pop();

    if (dist[now.to] < now.cost) continue;
    for (const Edge<T> &e : edges[now.to]) {
      T tmp_cost = now.cost + e.cost;
      if (dist[e.to] > tmp_cost) {
        dist[e.to] = tmp_cost;
        p_que.emplace(e.to, dist[e.to]);
      }
    }
  }

  return dist;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M,R;
  cin>>N>>M>>R;
  vector<int>r(R);
  vector<vector<Edge<int>>> edges(N);
  REP(i,R)cin>>r[i];
  REP(i,R)r[i]--;
  REP(i,M){
    int a,b,c;
    cin>>a>>b>>c;a--;b--;
    edges[a].emplace_back(b,c);
    edges[b].emplace_back(a,c);
  }

  vector<vector<int>> ans(R,vector<int>(R));

  REP(i,R){
    auto djk = Dijkstra<int>(edges,r[i]);
    REP(j,R){
      ans[i][j]=djk[r[j]];
    }
  }

  vector<int>tmp(R);
  REP(i,R)tmp[i]=i;

  int now=INF;

  do{
    int cnt=0;
    REP(i,R-1){
      cnt+=ans[tmp[i]][tmp[i+1]];
    }
    now=min(now,cnt);
  }while(next_permutation(ALL(tmp)));

  cout<<now<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  string s; cin >> s;
  bool ok = false;
  for (char c: s) if (c == '7') ok = true;
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    int k;
    cin>>k;
    
    for(int i=1;i<3;){
        if(a[i-1]<a[i]){
            i++;
            continue;
        }
        if(k==0){
            break;
        }
        a[i] = a[i]*2;
        k--;
    }
    for(int i=1;i<3;i++){
        if(a[i-1]>=a[i]){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes";
}


Measured memory_bytes: 3596
import numpy as np
import sys
import math

N = int(input())

A = input().split()
A = np.array(A, dtype=np.int64)

front = 0
base = 0
basesum = 0
for i in range(N):
    if front > A[i]:
        base = front - A[i]
        basesum = basesum + base
        front = A[i] + base
    else:
        base = 0
        front = A[i]

print(basesum)

Measured memory_bytes: 53004
/**
 * @param {String} raw_input 入力
 */
function Main(raw_input) {
	const [ rawS, rawT ] = raw_input.split("\n");
	
	const s = rawS.split('');
	const t = rawT.split('');

	let minCount = t.length;
	for (let i = 0; i <= s.length - t.length; i++) {

		let changed = 0;
		for (let n = 0; n < t.length; n++) {
			const tt = t[n];
			const ss = s[i + n];
			if(tt != ss)changed++;
		}
		if(changed < minCount) minCount = changed;
	}
	
	console.log(minCount);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

////////// ユーティリティ関数

/**
 * 文字列を数値配列
 * @param {String} str 文字列
 */
function toNumArray(str, delimitor = ' ') {
	return str.split(delimitor).map(s => parseInt(s, 10));
}

/**
 * 文字列をVigInt配列に変換する
 * @param {String} str 文字列
 */
function toBitIntArray(str, delimitor = ' ') {
	return str.split(delimitor).map(s => BigInt(s));
}

/**
 * 2次元配列を返す
 * @param {Array<String>} array 1次元の文字列配列
 * @param {String} delimitor デリミタ
 */
function toMatrix(array, delimitor = ' ') {
	const result = array.map(v => v.split(delimitor));
	return result;
}

/**
 * 合計を出す
 * @param {Array<Number>} n 数値配列
 */
function sum(n) {
	return n.reduce((a, b) => a + b);
}

Measured memory_bytes: 32284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,m,k,x,y,pre[200005][4],mp[128],erp[200005][4],px[5],py[5],dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
char s[200005],t[200005];
void fail(){puts("NO");exit(0);}
bool valid(int x,int y){
    return (x>=1 && x<=n) && (y>=1 && y<=m);
}
int main()
{
    scanf("%d%d%d%d%d%s%s",&n,&m,&k,&x,&y,s+1,t+1);
    mp['U']=0; mp['D']=1; mp['L']=2; mp['R']=3;
    rep(i,0,3) px[i] = x, py[i] = y;
    rep(i,1,k) rep(j,0,3){
        int jj = j ^ 1;
        if(mp[s[i]] == j){
            px[j] += dx[j];
            py[j] += dy[j];
            if(!valid(px[j],py[j])) fail();
        }
        if(mp[t[i]] == jj){
            if(valid(px[j] + dx[jj], py[j] + dy[jj])) {
                px[j] += dx[jj];
                py[j] += dy[jj];
            }
        }
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 2688
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            int size = cin.ReadInt;
            int[] list = cin.ReadIntArray(size);
            int a = 0;
            int b = 0;

            Array.Sort(list);
            Array.Reverse(list);
            for (int i = 0; i < list.Length; i++)
            {
                if (i % 2 == 0)
                    a += list[i];
                else
                    b += list[i];
            }

            Console.WriteLine(a-b);
        }


    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int turn = 0;
	while (A > 0 && C > 0) {
		if (turn == 0) {
			C -= B;
		}
		else {
			A -= D;
		}
		turn ^= 1;
	}
	cout << (C <= 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector <string> S(N);

	for (int i = 0; i < N; i++) {
		cin >> S.at(i);
	}

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

	vector <string> X(N);
	vector <int> Y(N);
	int j = 0;
	int MAX = 1;
	X.at(0) = S.at(0);
	Y.at(0) = 1;
	for (int i = 0; i < N - 1; i++) {
		if (S.at(i) == S.at(i + 1)) {
			Y.at(j)++;
			MAX = max(MAX, Y.at(j));
		}
		else {
			j++;
			Y.at(j)++;
			X.at(j) = S.at(i + 1);
		}
	}



	for (int i = 0; i < X.size() && Y.at(i) != 0; i++) {
		if (Y.at(i) == MAX) {
			cout << X.at(i) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 16640
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL a,b,c,N;
	cin >> N;
	for(a=1;a<=3500;++a){
		for(b=1;b<=3500;++b){
			LL R = N*a*b;
			LL Q = 4*a*b-N*b-N*a;
			if( Q > 0 && R%Q == 0){
				cout << a << " " << b << " ";
				cout << R/Q << endl;
				return;
			}
		}
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
N = int(input())
number_list = []
for i in map(int, input().split()):
    number_list += [i]

for i in range(N-1):
    for j in range(N):
        if i < j:
            if number_list[i] > number_list[j]:
                a = number_list[i]
                number_list[i] = number_list[j]
                number_list[j] = a

sum = 0
for i in range(N-1):
    sum+=number_list[i]

if sum > number_list[N-1]:
    print("Yes")
else:
    print("No")

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

typedef long long ll;

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

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

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

    rep(i, S.size()) {
        S[i] = 'A' + (S[i]-'A'+N)%26;
    }

    cout << S << endl;
}


Measured memory_bytes: 256
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let () =
  let x = read_int () in let t = read_int () in
  printf "%d\n" @@ max 0 (x-t)


Measured memory_bytes: 384
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

    int n, m;
    cin >> m >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> comp;
    int prev = -1;
    rep(i, n) {
        if(prev != a[i]) { comp.push_back(0); }
        prev = a[i];
        comp.back()++;
    }

    if(m > 2) {
        int ans = 0;
        for(int x : comp) {
            ans += x / 2;
        }
        cout << ans << '\n';
    } else {
        vector<int> t(n), s(n);
        rep(i, n) {
            t[i] = i % 2 + 1;
            s[i] = 3 - t[i];
        }
        int ans1 = 0, ans2 = 0;
        rep(i, n) {
            if(t[i] != a[i]) ++ans1;
            if(s[i] != a[i]) ++ans2;
        }
        cout << min(ans1, ans2) << '\n';
    }

}



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

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];
    if (c == 'B') {
      if (!ans.empty()) {
        ans.pop_back();
      }
    } else {
      ans.push_back(c);
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    vl x(n);
    rep(i,n) cin >> x[i];
    ll ans = 0;
    rep(i,1,n){
        ans += min(a*(x[i]-x[i-1]),b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
ansa=0
ansb=0
for i in range(x,n):
    if i in a:
        ansa+=1
for i in range(0,x):
    if i in a:
        ansb+=1
print(min(ansa,ansb))

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if(str[0] + str[1] < 10)
            {
                Console.WriteLine(str[0] + str[1]);
            }
            else
            {
                Console.WriteLine("error");
            }
        }
    }
}

Measured memory_bytes: 13140
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
d11 = b - a
d12 = c - a
d13 = d - a
d14 = e - a
d21 = c - b
d22 = d - b
d23 = e - b
d31 = d - c
d32 = e - c
d41 = e - d
if d11 <= k and d12 <= k and d13 <= k and d14 <= k and d21 <= k and d22 <= k and d23 <= k and d31 <= k and d32 <= k and d41 <= k:
  print('Yay!')
else:
  print(':(')

Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    x = S()
    ans = len(x)
    l = 0
    for xi in x:
        if xi == "T":
            if l:
                l -= 1
                ans -= 2
        else:
            l += 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 62192
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}


int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
P a[100000];
vector<P> vec;
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
		vec.push_back({ a[i].first + a[i].second,a[i].first - a[i].second });
	}
	sort(all(vec));
	int k = -INF;
	for (int i = 0; i < n; i++) {
		if (k <= vec[i].second) {
			ans++;
			k = vec[i].first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3444