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

using namespace std;
using namespace atcoder;

const int max_n = 200222, mod = 998244353;

int mul(int x, int y) {
    return (1LL * x * y) % mod;
}

int power(int a, int b) {
    int res = 1 % mod;
    while (b) {
        if (b % 2) {
            res = mul(res, a);
        }
        b /= 2;
        a = mul(a, a);
    }
    return res;
}

int inv(int x) {
    return power(x, mod - 2);
}

int n, k, a[max_n];

int solve() {
    fenwick_tree<long long> t1(n), t2(n);
    const int rk = inv(k);
    const int r2 = inv(2);
    const int A = mul(k - 1, rk), B = mul(k - 2, rk);
    const int RA = inv(A);
    const int C = inv((B + mod - 1) % mod);
    const int D = (r2 + mul(rk, C)) % mod;
    const int E = (mod - mul(rk, C)) % mod;
    int ans = 0;
    for (int j = 0; j < n; ++j) {
        const int F = (mul(power(B, n - j - 1), D) + E) % mod;
        int sum = 0;
        if (j < k) {
            sum = t1.sum(0, a[j]) % mod;
            /*for (int i = 0; i < j; ++i) {
                sum += a[i] < a[j];
            }*/
        } else {
            /*for (int i = 0; i < j; ++i) {
                if (a[i] > a[j]) {
                    continue;
                }
                sum += power(RA, max(i, k - 1));
                sum %= mod;
            }*/
            sum = t2.sum(0, a[j]) % mod;
            sum = mul(sum, power(A, j));
        }
        ans += mul(F, sum);
        ans %= mod;
        t1.add(a[j], 1);
        t2.add(a[j], power(RA, max(j, k - 1)));
    }
    return ans;
}

int cinv() {
    fenwick_tree<long long> t(n);
    long long res = 0;
    for (int i = 0; i < n; ++i) {
        res += t.sum(a[i], n);
        t.add(a[i], 1);
    }
    return res % mod;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    if (0) {
        n = 200000;
        k = 100000;
        for (int i = 0; i < n; ++i) {
            a[i] = i;
        }
        random_shuffle(a, a + n);
    } else {
        scanf("%d%d", &n, &k);
        for (int i = 0; i < n; ++i) {
            scanf("%d", &a[i]);
            --a[i];
        }
    }
    int ans = cinv();
    ans += solve();
    ans %= mod;
    for (int i = 0; i < n; ++i) {
        a[i] = n - 1 - a[i];
    }
    ans += mod - solve();
    ans %= mod;

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


Measured memory_bytes: 7220
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main() {
    char s;
    cin >> s;

    if (isupper(s)) cout << 'A' << endl;
    else cout << 'a' << endl;
}

Measured memory_bytes: 3616
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		try (Scanner in = new Scanner(System.in)) {
			int N = Integer.parseInt(in.nextLine());
			String S = in.nextLine();

			int max = -1;
			for (int i = 1; i < N; i++) {
				String x = S.substring(0, i);
				String y = S.substring(i, N);

				int count = 0;
				HashSet<String> used = new HashSet<>();
				for (int j = 0; j < x.length(); j++) {
					String s = "" + x.charAt(j);
					if (!used.add(s)) {
						continue;
					}
					if (y.contains(s)) {
						count++;
					}
				}

				max = Math.max(max, count);

			}

			System.out.println(max);
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
 
 
bool check_kaibun(string S){
	int len = int(S.length());
 
	for(int i=0; i<len/2; i++){
		if(S[i]!=S[len-1-i]){
			return false;
		}
	}
	return true;
}
 
int main()
{
	string S, S1, S2;
	bool flag;
 
	cin >> S;
 
	S1 = S.substr(0, (S.length()-1)/2);
	S2 = S.substr((S.length()+3)/2-1);
 
	flag = (check_kaibun(S1) && check_kaibun(S2) && check_kaibun(S));
	cout << (flag ? "Yes" : "No");
	
 
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char a, b;
	scanf("%c %c", &a, &b);
	if(a == 'H'){
		if(b == 'H'){
			printf("H\n");
		}else{
			printf("D\n");
		}
	}else{
		if(b == 'H'){
			printf("D\n");
		}else{
			printf("H\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n, t;
  cin >> n >> t;
  int Min = INF;
  rep(i, n)
  {
    int ci, ti;
    cin >> ci >> ti;
    if (ti > t)
      continue;
    Min = min(Min, ci);
  }
  if(Min != INF)
  cout << Min << endl;
  else 
  cout << "TLE" << endl;
  return 0;
}


Measured memory_bytes: 256
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]
INF = 10**9
def dfs(cur,a,b,c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a,b,c) > 0 else INF
  ret0 = dfs(cur + 1,a,b,c)
  ret1 = dfs(cur + 1,a + L[cur],b,c) + 10
  ret2 = dfs(cur + 1,a,b + L[cur],c) + 10
  ret3 = dfs(cur + 1,a,b,c + L[cur]) + 10
  return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
n = int(input())
h = list(map(int, input().split()))
ans = True
left = 0
for i in h:
    if left > i:
        ans = False
        break
    elif left < i:
        left = i -1
    elif left == i:
        continue
if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14276
n = int(input())
hs = list(map(int, input().split()))

cnt = 0
max_cnt = 0
for i in range(1, n):
	if hs[i] <= hs[i - 1]:
		cnt += 1
	else:
		max_cnt = max(max_cnt, cnt)
		cnt = 0
print(max(max_cnt, cnt))

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

#----------
N,M,C = list(map(int, input().rstrip().split()))
B_list = list(map(int, input().rstrip().split()))
#----------

count=0
for n in range(N):
    A_list = list(map(int, input().rstrip().split()))
    
    sum=0
    for m in range(M):
        sum += A_list[m] * B_list[m]
    
    sum += C
    
    if sum > 0:
        count += 1
    
print(count)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

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

    cout << (N + 2 - 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
import static java.lang.Integer.parseInt;

public class Main {
    public static void main(String[] args) {
        String line = new java.util.Scanner ( System.in ).nextLine();
        String[] number = line.split(" ", 0);

        String answer = Compare(parseInt(number[0]),parseInt(number[1]));
        System.out.println(answer);
    }
    public static String Compare(int x,int y){
        if ( x < y ) { 
            return "a < b";
        }
        if ( x > y ) { 
            return "a > b";
        }
        if ( x == y ) { 
            return "a == b";
        }
        return null;
    }
}

Measured memory_bytes: 26008
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <cmath>
#include <vector>
#include <tuple>

using namespace std;
using ll = long long;

struct C1 {
    ll N_{};
    C1(ll N) : N_(N){}
    ll resolve() {
        ll count = 0;
        for(ll i=1; i <= N_; ++i) {
            if( (1 <= i && i < 10) ||
                    (100 <= i && i < 1000) ||
                    (10000 <= i && i < 100000) ) {
                ++count;
            }
        }
        return count;
    }
};

int main() {
    ll N;
    cin >> N ;
    C1 c{N};
    cout << c.resolve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rep(i,N) for(int i = 0;i < N;i++)
using namespace std;

int main(){
  
  int n,m,ans=0,x=3000;
  cin >> n >> m;

  int w[n+1],b[n+1],r[n+1];
  fill_n(w,n,0);
  fill_n(b,n,0);
  fill_n(r,n,0);
  char f[n][m];
  
  Rep(i,n){    // 入力
    Rep(j,m){
      cin >> f[i][j];
      if(f[i][j] == 'W') w[i]++;
      else if(f[i][j] == 'B') b[i]++;
      else if(f[i][j] == 'R') r[i]++;
    }
    w[i] = m-w[i];
    b[i] = m-b[i];
    r[i] = m-r[i];
  }

  
  for(int i = 0;i < n-2;i++){ // 白塗る数
    
    ans = 0;
    for(int j = 0;j <= i;j++) ans += w[j];
    
    for(int j = i+1;j < n-1;j++){ // 青塗る数
      ans += b[j];
      
      if(j == i+1){
	for(int k = j+1;k < n;k++){ // 赤塗る数
	  ans += r[k];
	}	
      }
      
      x = min(x,ans);
      ans -= r[j+1];

    }
    
  }

  cout << x << endl;
  return (0);
}

Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
	char code[32][20] = {
		"101","000000","000011","10010001","010001","000001","100101","10011010",
		"0101","0001","110","01001","10011011","010000","0111","10011000",
		"0110","00100","10011001","10011110","00101","111","10011111","1000",
		"00110","00111","10011100","10011101","000010","10010010","10010011","10010000"
	};
	int coden[256];
	char tmp[] = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for (int i = 0; i < 32; i++) {
		coden[tmp[i]] = i;
	}
	char str[200];
	int makedcode[3000];
	int count;

	while (gets(str) != NULL) {
		count = 0;
		for (int i = 0, slen = strlen(str); i < slen; i++) {
			for (int j = 0, clen = strlen(code[coden[str[i]]]); j < clen; j++) {
				makedcode[count++] = code[coden[str[i]]][j] - '0';
			}
		}
		for (int i = 0, j = 0, sum;; i++, j++) {
			if (j == 5) {
				if ('a' - 'a' <= sum && sum <= 'z' - 'a')
					cout << (char)(sum + 'A');
				else {
					char c;
					switch (sum) {
					case 26:
						c = ' '; break;
					case 27:
						c = '.'; break;
					case 28:
						c = ','; break;
					case 29:
						c = '-'; break;
					case 30:
						c = '\''; break;
					case 31:
						c = '?'; break;
					}
					cout << c;
				}
				if (i >= count)
					break;
				j = 0;
			}
			if (j == 0)
				sum = 0;
			if (i < count)
				sum = (sum << 1) + makedcode[i];
			else
				sum = sum << 1;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (110)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
T1 mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  T1 tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

bool isPrime(int n){
  if(n == 1) return false;
  rep(i, 2, min((int)(pow(n, 0.5) + 1), n)){
    if(n % i == 0) return false;
  }
  return true;
}

/////////////////////////////////////////////////////////

void Main() {
  ll N, x; cin >> N >> x;
  vector<ll> a(N);
  rep(i, 0, N) cin >> a[i];
  sort(all(a));
  ll res = 0;
  rep(i, 0, N){
    if(i == N - 1){
      if(x == a[i]){
        x -= a[i];
        res++;
      }
    }
    else if(x >= a[i]){
      x -= a[i];
      res++;
    }else{
      break;
    }
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>

typedef struct{
  char moji;
  int kazu;
}Card;

int partition(Card *,int,int,int);
void marge(Card *,int,int,int);
void mergesort(Card *,int,int,int);
void quicksort(Card *,int,int,int);
Card L[100000],R[100000];

int main()
{
  int n,i,N,stable=1;
  Card A[100000],B[100000];
  char S[10];
  
    scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf(" %c",&S);
      scanf("%d",&N);
      A[i].moji=B[i].moji=S[0];
      A[i].kazu=B[i].kazu=N;
    }
  mergesort(A,n,0,n);
  quicksort(B,n,0,n-1);
  for(i=0;i<n;i++)
    {
      if(A[i].moji!=B[i].moji)
	stable=0;
  }
  if(stable==1)
     printf("Stable\n");
      else printf("Not stable\n");
  for(i=0;i<n;i++)
    {
      printf("%c %d\n",B[i].moji,B[i].kazu);
    }
  return 0;
}

int partition(Card *A,int n,int p,int r)
{
  int i,j;
  Card x,a;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++)
    {
      if(A[j].kazu<=x.kazu)
	{
	  i++;
	  a=A[i];
	  A[i]=A[j];
	  A[j]=a;
	}
    }
	  a=A[i+1];
	  A[i+1]=A[r];
	  A[r]=a;
	  return i+1;
    }

void merge(Card *A,int left,int mid,int right)
{
  int i,j,k;
  int n=mid-left;
  int m=right-mid;
  for(i=0;i<n;i++)
    L[i]=A[left+i];
    for(i=0;i<m;i++)
      R[i]=A[mid+i];
    L[n].kazu=R[m].kazu=INT_MAX;
    i=0;
    j=0;
    for(k=left;k<right;k++)
      {
	if(L[i].kazu<=R[j].kazu)
	  {
	    A[k]=L[i++];
	  }
	else
	  {
	  A[k]=R[j++];
	  }
      }
}




void mergesort(Card *A,int n,int left,int right)
{
  int mid;
  if(left+1<right)
    {
      mid=(left+right)/2;
      mergesort(A,n,left,mid);
      mergesort(A,n,mid,right);
      merge(A,left,mid,right);
    }
}
    
void quicksort(Card *A,int n, int p,int r)
    {
      int q;
      if(p<r)
	{
	  q=partition(A,n,p,r);
	   quicksort(A,n,p,q-1);
	   quicksort(A,n,q+1,r);
	}
    }
  


  






Measured memory_bytes: 4040
obj = {}
("a".."z").each do |s|
  obj[s] = 0
end

while (ln = gets) do
  ln.downcase.gsub(/[^a-z]/, '').chars do |key|
    obj[key] += 1
  end
end

obj.each do |key, val|
  puts "#{key} : #{val}"
end

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

class MyClass
{
public:
	int a;
	int b;
	void set(int ini_a, int ini_b);
};

void MyClass::set(int ini_a, int ini_b)
{
	a = ini_a;
	b = ini_b;
}

int main()
{
	MyClass seisu;
	seisu.set(0, 0);
	
	cin >> seisu.a;
	cin >> seisu.b;
	
	if( seisu.a < seisu.b)
	{
		cout << "a < b" << endl;
	}else if( seisu.a > seisu.b){
		cout << "a > b" << endl;
	}else{
		cout << "a == b" << endl;
	}
	
}


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

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

  if (N == 1) {
    cout << K << endl;
  } else {
    long long ans = K;
    for (int i=2; i<=N; i++) {
      ans *= K - 1;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int dp[50];

int fib(int n){
  if(n==0||n==1)return dp[n]=1;
  if(dp[n]!=-1)return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}

int main()
{
  int n=0,i;
  for(i=0;i<50;i++) dp[i]=-1;
  
  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
// -----------------------------------------------------------------------------

const int N = 2E5 + 100;
const int M = 20;
int nxt[M][N], bak[M][N], ans[N];
int f[1 << M], g[1 << M];
LL x[N];
vector<LL> spans;

int main() {
    int n, v; cin >> n >> v;
    while (v) {
        spans.push_back(v);
        v /= 2;
    }
    spans.push_back(0);
    FOR (i, 1, n + 1) cin >> x[i];

    int m = spans.size();
    FOR (i, 0, m) {
        const auto& span = spans[i];
        FORD (j, n, 0) {
            if (j < n && x[j + 1] - x[j] <= span) {
                nxt[i][j] = nxt[i][j + 1];
            } else {
                nxt[i][j] = j;
            }
        }
        FOR (j, 1, n + 1) {
            if (j > 1 && x[j] - x[j - 1] <= span) {
                bak[i][j] = bak[i][j - 1];
            } else {
                bak[i][j] = j;
            }
            // dbg(i, span, j, nxt[i][j], bak[i][j]);
        }
    }

    fill(g, g + (1 << m), n + 1);
    FOR (u, 0, 1 << m) {
        if (u & 1) continue;
        dbg(u, f[u], g[u]);
        FOR (i, 1, m) {
            if ((u >> i) & 1) continue;
            int v = u | (1 << i);

            if (f[u] == n) f[v] = n;
            else f[v] = max(f[v], nxt[i][f[u] + 1]);
            if (g[u] == 1) g[v] = 1;
            else g[v] = min(g[v], bak[i][g[u] - 1]);
        }
    }

    FOR (u, 0, 1 << m) {
        if (u & 1) continue;
        int v = ((1 << m) - 2) ^ u;
        int st = f[u] + 1, ed = g[v] - 1;
        if (st > n || ed < 1) {
            fill(ans + 1, ans + n + 1, 1);
            break;
        }
        if (nxt[0][st] >= ed) {
            FOR (i, bak[0][st], nxt[0][st] + 1) {
                if (ans[i]) break;
                ans[i] = 1;
            }
        }
    }

    FOR (i, 1, n + 1) {
        puts(ans[i] ? "Possible" : "Impossible");
    }
}

Measured memory_bytes: 43392
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,a[200010],b[200010];
bool can[200010];
bool check(int x)
{
	for (int i=1;i<2*n;i++)
	{
		if (a[i]>=x)
		{
			b[i]=1;
		}
		else
		{
			b[i]=0;
		}
	}
	memset(can,false,sizeof(can));
	for (int i=2;i<2*n;i++)
	{
		if (b[i]==b[i-1])
		{
			can[i]=true;
		}
	}
	int i=n,j=n;
	while (i && j<2*n)
	{
		i--;
		j++;
		if (can[i+1])
		{
			return b[i];
		}
		if (can[j])
		{
			return b[j];
		}
	}
	return b[1];
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<2*n;i++)
	{
		scanf("%d",&a[i]);
	}
	int l=1,r=2*n-1,mid;
	while (l<=r)
	{
		mid=(l+r)>>1;
		if (check(mid))
		{
			l=mid+1;
		}
		else
		{
			r=mid-1;
		}
	}
	printf("%d\n",l-1);
    return 0;
}
//茶香溢满江南巷，执子之手花下行。

Measured memory_bytes: 2048
import collections

N = int(input())
A = [int(i) for i in input().split()]

con = collections.Counter(A).most_common()
ans = 0

for a, b in sorted(con, reverse= True):
    if b >= 4 and ans == 0:
        print(a**2)
        break
    elif b >= 2 and ans == 0:
        ans = a
    elif b >= 2:
        print(ans*a)
        break
else:
    print(0)

Measured memory_bytes: 21660
#include "bits/stdc++.h"
using namespace std;


class friends {
private:
	int n, m;

	int ans = 1;
	int depth = 0;

	vector<set<int>> adjacencyList;
	vector<bool> seeked;

public:
	friends(int _n, int _m) {
		n = _n;
		m = _m;

		adjacencyList.resize(n + 1);
		seeked.resize(n + 1);
		for (auto e : seeked) e = false;
	}

	void setAdjList(int a, int b);
	void search(int i = 1);
	void show();
	void solve();
};

void friends::setAdjList(int a, int b) {
	adjacencyList[a].insert(b);
	adjacencyList[b].insert(a);
}

void friends::search(int i) {
	for (auto e : adjacencyList[i]) {
		if (seeked[e] == true) continue;

		depth += 1;
		seeked[e] = true;
		search(e);
	}
}

void friends::show() {
	for (int i = 1; i <= n; i++) {
		cout << i << ":";
		for (auto e : adjacencyList[i]) {
			cout << " " << e;
		}
		cout << endl;
	}

	for (int i = 1; i <= n; i++) {
		if (seeked[i] == false) cout << "未探索" << endl;;
	}
}

void friends::solve() {
	search();
	ans = max(ans, depth);

	for (int i = 1; i <= n; i++) {
		if (seeked[i] == true) continue;

		depth = 0;
		search(i);

		ans = max(ans, depth);
	}

	cout << ans << endl;

	//show();
}

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

	friends friends(n, m);

	int a, b;
	for (int i = 1; i <= m; i++) {
		cin >> a >> b;
		friends.setAdjList(a, b);
	}

	friends.solve();
}

Measured memory_bytes: 40732
X = int(input())

import math

while True:
    be_prime = True
    
    for i in range(2, int(math.sqrt(X))+1):
        if X % i == 0: 
            be_prime = False
    
    if be_prime:
        print(X)
        exit(0)
    else:
        X += 1
        

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    int S;
    cin >> S;
    int T = S;
    if(S/100 >= 1 && S/100 <= 12 && S%100 >= 1 && S%100 <= 12){
        cout << "AMBIGUOUS" << endl;
    }
  
    if(S/100 < 1 || S/100 > 12){
        if(T%100 < 1 || T%100 > 12){
            cout << "NA" << endl;
        }
    }
  
    if(S/100 <= 0 || S/100 >= 13){
        if(T%100 >= 1 && T%100 <= 12){
            cout << "YYMM" << endl;
        }
    }
  
    if(S/100 >= 1 && S/100 <= 12){
        if(T%100 < 1 || T%100 > 12){
            cout << "MMYY" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int H,W;
    cin >> H >> W;
    int N;
    cin >> N;
    int ans[H][W];
    int h=0,w=0;
    for(int i=1;i<=N;i++){
        int a;
        cin >> a;
        while(a){
            if(h%2==0){
                ans[h][w]=i;
                if(w==W-1){
                    h++;
                    a--;
                    continue;
                }
                w++;
                a--;
            }
            if(h%2==1){
                ans[h][w]=i;
                if(w==0){
                    h++;
                    a--;
                    continue;
                }
                w--;
                a--;
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 764
s = str(input())
t = str(input())
lis = [0 for i in range(26)]
li = [0 for i in range(26)]
for i in range(len(s)):
  lis[ord(s[i])-ord("a")] += 1
  li[ord(t[i])-ord("a")] += 1
lis.sort()
li.sort()
for i in range(26):
  if lis[i] != li[i]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>

typedef long long LL;
using namespace std;

int main()
{
    int n; cin >> n;
    if(n % 10 == 0){
        cout << 10 << endl;
        return 0;
    }
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
//#define BUG
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <list>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define pf push_front
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)
#ifdef BUG
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << '\n';
}
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...);
}
#endif

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<LL> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 7;

int main() {
#ifdef LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    LL n, k; cin >> n >> k;
    vi a(n); for (LL& x : a) cin >> x;
    vi b(n); for (LL& x : b) cin >> x;
    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());
    LL r = 0;
    fore(i, 0, n) maxi(r, a[i] * b[i]);
    LL l = 0;
    while (l < r) {
        LL m = (l + r) >> 1;
        LL tmp = 0;
        fore(i, 0, n) tmp += max(0LL, a[i] - m / b[i]);
        if (tmp <= k) r = m;
        else l = m + 1;
    }
    cout << l << '\n';
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    string a;
    cin >> a;
    vector<ll> count(27, 0);
    ll ans = 1;
    REP(i, a.size()){
        const ll d = a.at(i) - 'a';
        ans += i - count.at(d);
        count.at(d)++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cout<<fixed;
//    cout<<setprecision(10);
    map<int,int>mp;
    int x;
    int mx=0;
    cin>>x;
    mp[x]++;
    mx=max(mx,mp[x]);
    cin>>x;
    mp[x]++;
    mx=max(mx,mp[x]);
    cin>>x;
    mp[x]++;
    mx=max(mx,mp[x]);
    if (mx==2)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int w,h,i,j,x[4000],y[4000],c,ny,nx,r,t;
  int X[]={0,1,0,-1};
  int Y[]={1,0,-1,0};
  char m[20][20];
  while(scanf("%d %d",&w,&h),w||h){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	scanf(" %c",&m[i][j]);
	if(m[i][j]=='@'){
	  y[0  ]=i;
	  x[t=0]=j;
	  m[i][j]='#';
	}
      }
    }
    for(r=c=1;r-t;t++){
      for(i=0;i<4;i++){
	nx=x[t]+X[i];
	ny=y[t]+Y[i];
	if(nx<0||w<=nx||ny<0||h<=ny)continue;
	if(m[ny][nx]=='#')continue;
	x[r]=nx;
	y[r++]=ny;
	m[ny][nx]='#';
	c++;
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>

int main (void)

{  int a,b;
scanf("%d %d",&a,&b);
if(a<b)  
{
	printf("a < b\n"); 
}  
	else if(a == b)
	{
		printf("a == b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
 return 0;
} 

Measured memory_bytes: 580
#include <stdio.h>
#define N 45
int A[N];

int fibonacci(int n){
  int i;
  for(i=0;i<=n;i++){
  if(i<2){
    A[i] = 1;
  }
  else
    A[i] = A[i-1] + A[i-2];
  } return A[n];

}
main(){
  int i,n,m;
  scanf("%d",&n);
  m = fibonacci(n);
  printf("%d\n", m);
  return 0;
}
  

Measured memory_bytes: 596
#include <cstdio>
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
  ll  X, A,  B,  a  , b;
   cin>>X;
  for (A = 0; 1; A++) {
    for (B = 0; B <= A; B++) {
      a = A* A* A * A* A;
      b = B * B * B * B * B;
      if (a - b == X) {
        printf("%d %d", A, B);
        return 0;
      }
      if (a + b== X) {
        printf("%d %d", A, -B);
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

long double Setup[20];

int main() {
  long double N, K; cin >> N >> K;

  for (int i = 0; i < 20; i++) {
    Setup[i] = pow(2, i);
  }

  long double ans = 0.0;
  long double prob = 1.0 / N;
  // cout << prob << endl;
  for (long double i = 1; i <= N; i++) {
    long double p = K / i;
    int x = lower_bound(Setup, Setup + 20, p) - Setup;
    // cout << "i is: " << i << " x is: " << x << " Setup[x] is :" << Setup[x] << endl;
    long double t = pow((long double)1/2, x);
    // cout << t << endl;
    ans += prob * t;
  }

  cout  << setprecision(15) << ans << endl;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int a[200][200];
int b[200];
signed main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < w; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < h; i++) {
		int ans = 0;
		for (int j = 0; j < w; j++) {
			a[i][j] *= b[j];
			ans += a[i][j];
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3236
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <stack>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;

int main(){
	int dx[4]={-1,0,1,0};
	int dy[4]={0,1,0,-1};
	char dc[4]={'U','R','D','L'};
	int h,w,n,f=1;
	int sx,sy;
	string s,t;
	cin>>h>>w>>n;
	cin>>sx>>sy;
	cin>>s>>t;
	FOR(d,0,2){
		if(d==1)d=3;
		int dr=d^2;
		/*
		int hp;
		if(d==0)hp=sx;
		if(d==1)hp=w+1-sy;
		if(d==2)hp=h+1-sx;
		if(d==3)hp=sy;
		//**/
		int l=1,r=w,rr=w;
		if(d==0){
			r=h;
			rr=h;
		}
		FORD(i,n,0){
			if(t[i]==dc[d]){
				r=min(rr,r+1);
			}else if(t[i]==dc[dr]){
				l=max(1,l-1);
			}
			if(s[i]==dc[d]){
				l=min(rr+1,l+1);
			}else if(s[i]==dc[dr]){
				r=max(0,r-1);
			}
			//if(d!=0)cerr<<l<<" "<<r<<endl;
			if(l>r){
				f=0;
				break;
			}
		}
		if(d==0){
			if(l>sx||r<sx)f=0;
		}else{
			if(l>sy||r<sy)f=0;
		}
	}

	if(f){
		cout<<"YES";
	}else{
		cout<<"NO";
	}
  return 0;
}


Measured memory_bytes: 776
#include<stdio.h>

int main(){
	int n,i;
	long long a[100011],b[100011],ans=0;
	scanf("%d",&n);
	for(i=0;i<n+1;i++)scanf("%lld",&a[i]);
	for(i=0;i<n;i++)scanf("%lld",&b[i]);
	for(i=0;i<n;i++){
		if(a[i]>b[i]){
			ans+=b[i];
		}else{
			ans+=a[i];
			b[i]-=a[i];
			if(a[i+1]>b[i]){
				ans+=b[i];
				a[i+1]-=b[i];
			}else {
				ans+=a[i+1];
				a[i+1]=0;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

int calc(ll x){
    if(x == 0)
        return 0;
    int cnt = 0;
    ll tmp = x;
    while(tmp > 0){
        if(tmp&1) cnt++;
        tmp >>= 1;
    }
    
    return calc(x % cnt) + 1;
}
int calc(string x, int cnt, int bit, vector<ll> &p2_plus, vector<ll> &p2_minus, ll base_plus, ll base_minus){
    ll now;
    if(x[bit] == '0'){
        cnt++;
        now = (base_plus + p2_plus[x.size()-1-bit]) % cnt;
    }
    else{
        cnt--;
        if(cnt == 0) return 0;
        now = (base_minus + (cnt-p2_minus[x.size()-1-bit])) % cnt;
    }

    return calc(now) + 1;
}


int main() {
    int n;
    cin >> n;
    string x;
    cin >> x;
    int popcount = count(x.begin(), x.end(), '1');


    vector<ll> p2_minus(n+1, 1);
    vector<ll> p2_plus(n+1, 1);
    IFOR(i, 1, n){
        p2_plus[i] = (p2_plus[i-1]*2) % (popcount+1);
        if(popcount >= 2)
            p2_minus[i] = (p2_minus[i-1]*2) % (popcount-1);
    }
    
    ll base_plus = 0;
    ll base_minus = 0;
    REP(i, x.size()){
        base_plus *= 2;
        base_minus *= 2;
        int toadd = x[i]-'0';
        base_plus = (base_plus+toadd) % (popcount+1);
        if(popcount>=2)
            base_minus = (base_minus+toadd) % (popcount-1);
    }

    REP(i, n){
        cout << calc(x, popcount, i, p2_plus, p2_minus, base_plus, base_minus) << endl;
    }

    return 0;
}

Measured memory_bytes: 6392
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll n,W;
    cin>>n>>W;
    ll w[n+5],v[n+5];
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    ll dp[n+5][sum+5],maxi=0;

    for(ll i=0;i<=n;i++)
        for(ll j=0;j<=sum;j++)
            dp[i][j]=1e18;
    for(ll i=0;i<=n;i++)
        dp[i][0]=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=sum;j++)
        {

            if(v[i]<=j)
                dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
            if(dp[i][j]<=W)
                maxi=max(maxi,j);
        }
    }
    cout << maxi << endl;


    return 0;
}


Measured memory_bytes: 81024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main{
    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();

	    int n = 0;

	    for (String line = br.readLine(); line != null; line = br.readLine()) {
		lines.add(line);
	    }

	    br.close();

	    for (Integer i = 0; i < lines.size(); i++) {
		if (i==0) {
		    n = Integer.parseInt(lines.get(i));
		} else {
		    String[] splits = lines.get(i).split(" ");
		    List<Long> numbers = new ArrayList<Long>();
		    for ( int j = 0; j < splits.length; j++ ) {
			numbers.add(j, Long.parseLong(splits[j]));
		    }

		    numbers.sort(Comparator.naturalOrder());
		    Long min = numbers.get(0);
		    numbers.sort(Comparator.reverseOrder());
		    Long max = numbers.get(0);

		    Long sum = 0L;
		    for (Long e : numbers) {
			sum += e;
		    }

		    System.out.println(String.format("%d %d %d", min, max, sum));
		}
	    }
	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
}

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

using namespace std;

struct SegmentTree
{
  const int INF = 1 << 30;

  vector< int > add;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    add.assign(2 * sz - 1, 0);
  }

  void update(int a, int b, int x, int k, int l, int r)
  {
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      add[k] += x;
      return;
    }
    update(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    update(a, b, x, 2 * k + 2, (l + r) >> 1, r);
  }

  void rangeadd(int a, int b, int x)
  {
    update(a, b, x, 0, 0, sz);
  }

  int query(int k)
  {
    k += sz - 1;
    int ret = add[k];
    while(k > 0) {
      k = (k - 1) >> 1;
      ret += add[k];
    }
    return (ret);
  }
};

int main()
{
  int N, Q;
  scanf("%d %d", &N, &Q);
  SegmentTree tree(N);
  while(Q--) {
    int t;
    scanf("%d", &t);
    if(t == 0) {
      int s, t, x;
      scanf("%d %d %d", &s, &t, &x);
      tree.rangeadd(--s, t, x);
    } else {
      int i;
      scanf("%d", &i);
      printf("%d\n", tree.query(--i));
    }
  }
}

Measured memory_bytes: 3840
input();a,b,c,d,r=list(map(int,input().split())),0,0,0,'NYoe s'
for i in a:
  if i%2!=0: b+=1
  elif i%4==0: c+=1
  else: d+=1
print([r[b<=c::2],r[b<=c+1::2]][d==0])

Measured memory_bytes: 20160
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
	class Program
	{
		static int In => int.Parse(Console.ReadLine());
		static int[] Ins => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		static void Out(bool b) => Console.WriteLine(b ? "Yes" : "No");

		static void Main(string[] args)
		{
			var n = In;
			var t = Ins;
			var v = Ins;
			int sum = 0;
			var li = new List<Func<double, double>>();
			li.Add(f(0, 0, 0));
			for (int i = 0; i < n; i++)
			{
				li.Add(f(sum, sum + t[i], v[i]));
				sum += t[i];
			}
			li.Add(f(sum, sum, 0));

			double ans = 0;
			for (double d = 0; d <= sum; d += 0.5)
			{
				ans += li.Select(f => f(d)).Min();
			}
			Console.WriteLine(ans / 2);
			//Console.ReadLine();
		}

		static Func<double, double> f(int a, int b, int m)
		{
			return x =>
			{
				if (x < a) return m + a - x;
				else if (b < x) return x + m - b;
				else return m;
			};
		}
	}
}

Measured memory_bytes: 17488
#include <stdio.h>

int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);

	if (c >= b) {
		printf("0\n");
	} else if (a >= d) {
		printf("0\n");
	} else if (c >= a && d >= b) {
		printf("%d\n", b - c);
	} else if (a >= c && b >= d) {
		printf("%d\n", d - a);
	} else if (c >= a && b >= d) {
		printf("%d\n", d - c);
	} else if (a >= c && d >= b) {
		printf("%d\n", b - a);
	}

	return 0;
}


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

using namespace std;

vector<int> adj[100005];
int dp[100005];
void dfs(int node, vector<bool> &vis) 
{ 
    vis[node] = true; 
  
    for (int i = 0; i < adj[node].size(); i++) { 
  
        if (!vis[adj[node][i]]) 
            dfs(adj[node][i],vis); 
  
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
    } 
} 

int main(){
	int n;
	int m;
	cin>>n;
	cin>>m;
	for(int i = 0 ; i <= n ; i++){
		dp[i] = 0;
	}
	for(int i = 0 ; i < m ; i++){
		int x , y;
		cin>>x>>y;
		adj[x].push_back(y);
	}
	vector<bool> vis(n+1 , false);
	
	for (int i = 1; i <= n; i++) { 
        if (!vis[i]) 
            dfs(i, vis); 
    } 
	
	int ans = 0;
	for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    }
    cout<<ans;
	return 0;
}

  
 


Measured memory_bytes: 8192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int[] arr = new int[n];
			long total = 0;
			for (int i = 0; i < n; i++) {
				arr[i] = in.nextInt();
				total += arr[i] - 1;
			}
			out.println(total);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
        string s;
        cin >> s;
        
        const int n = s.size();
        
        vector<int> a(n);
        REP(i, n) a[i] = s[i] - '0';
        reverse(a.begin(), a.end());

        auto dp = make_v(n + 1, 2, (int)1e8);
        dp[0][0] = 0;

        REP(i, n) {
                dp[i + 1][1] = min(dp[i][1] + (9 - a[i]), dp[i][0] + (10 - a[i]));
                dp[i + 1][0] = min(dp[i][1] + (a[i] + 1), dp[i][0] + a[i]);
        }

        cout << min(dp[n][0], dp[n][1] + 1) << endl;

        return 0;
}


Measured memory_bytes: 59780
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int p, q, r;

void solve()
{
    cout << min(p+q, min(q+r, r+p)) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> p >> q >> r;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,d,h,i,k,l,hiroshi,kenjiro;
	scanf("%d %d",&h,&i);
	scanf("%d %d",&k,&l);
	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	hiroshi=h*a+h/10*c+i*b+i/20*d;
	kenjiro=k*a+k/10*c+l*b+l/20*d;
	if(hiroshi==kenjiro){
	printf("even\n");
	}
	if(hiroshi>kenjiro){
	printf("hiroshi\n");
	}
	if(hiroshi<kenjiro){
	printf("kenjiro\n");
	}
	return 0;
}

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

int main() {
  string b;
  cin >> b;
  if(b=="A"){
    cout << "T" << endl;
  }else if(b=="C"){
    cout << "G" << endl;
  }else if(b=="G"){
    cout << "C" << endl;
  }else{
    cout << "A" << endl;
  }
}


Measured memory_bytes: 256