akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

constexpr int inf = (int)1e9;
constexpr double INF = 1e12, EPS = 1e-9;
constexpr int MX = 2010;
constexpr int mod = inf + 7;

int n, m, q, a[MX];
int L[MX][MX], R[MX][MX];
int memo[MX][MX];

int main() {
  int N, K;
  map<ll, ll> m;
  cin >> N >> K;

  rep(i,N) {
    int j;
    cin >> j;
    if (m[j]) {
      m[j] += 1;
    } else {
      m[j] = 1;
    }
  }

  int j{0};
  for (auto& pair : m) {
    a[j] = pair.second;
    ++j;
  }
  sort(a, a + j, greater<int>());

  int sum{0};
  rep(i,K) {
    sum += a[i];
  }

  cout << N - sum << endl;
}

Measured memory_bytes: 13568
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
arr = make_divisors(n)

ans = []
for i in arr:
    ans.append(max(len(str(i)),len(str(n // i))))
print(min(ans))

Measured memory_bytes: 3188
N, M = map(int, input().split())
progress = {}
# initialize
for i in range(N):
  progress[str(i+1)] = ["notCorrect",0]
correct = 0

for i in range(M):
  question, result = map(str, input().split())
  if (progress[question][0] == "notCorrect"):
    if (result == "WA"):
      progress[question][1] += 1
    else:
      progress[question][0] = "correct"
      correct += 1
  else:
    continue
penalty = 0
for i in range(N):
  if (progress[str(i+1)][0] == "correct"):
    penalty += progress[str(i+1)][1]
print(str(correct)+" "+str(penalty))

Measured memory_bytes: 101988
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"


void Main()
{
	ll result=0;
	string S;
	cin>>S;
	VI ten(SIZE(S),1);
	const int DIV=2019;
	FOR(i,1,SIZE(S)){
		ten[i]=10*ten[i-1];	//10の倍数？？
		ten[i]%=DIV;		//2019で割ったあまり
	}
	ll tmp=0;
	ll appear[DIV+1]={};//あまりの数？？
	appear[0]=1;
	FORD (i,SIZE(S)-1,0) {
		tmp+=ten[SIZE(S)-i-1]*(S[i]-'0');	//
		tmp%=DIV;							//
		result+=appear[tmp];				//2019で割り切れる数だけ加える？
		appear[tmp]++;						//
	}
	cout << result << "\n";
	return;
}

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


Measured memory_bytes: 5216
a=input()
b=int(len(a))
c=0
d=0
if b%2==0:
  for i in range(b//2):
    if a[2*i]=="1":
      c=c+1
    if a[2*i+1]=="0":
      c=c+1
  for i in range(b//2):
    if a[2*i]=="0":
      d=d+1
    if a[2*i+1]=="1":
      d=d+1
  if c>d:
    print(d)
  else:
    print(c)
if b%2==1:
  for i in range(b//2):
    if a[2*i]=="1":
      c=c+1
    if a[2*i+1]=="0":
      c=c+1
  if a[-1]=="1":
    c=c+1
  for i in range(b//2):
    if a[2*i]=="0":
      d=d+1
    if a[2*i+1]=="1":
      d=d+1
  if a[-1]=="0":
    d=d+1
  if c>d:
    print(d)
  else:
    print(c)

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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in = new Scanner(System.in);
		int a=in.nextInt();
		int b=in.nextInt();
		int ans=Math.max((a+b),Math.max(a-b,a*b));

		System.out.println(ans);
			
	}
}
	

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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector<int>
#define vvi         vector<vi>
#define pii         pair<int,int>
#define vii         vector<pii>
#define nl          '\n'
#define yy          "YES\n"
#define nn          "NO\n"
#define pb          emplace_back
#define mkpr        make_pair
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define mod         1000000007

signed main() {
        IO;
        int n;
        cin >> n;
        vi divs(n);
        for (int i = 1; i < n; i++) {
            for (int j = 1; j * i < n; j++) {
                divs[i * j]++;
            }
        }
        int ans = 0;
        for (int i = 1; i < n; i++) {
            ans += divs[i];
        }
        cout << ans;
}


Measured memory_bytes: 11044
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }

ll power(ll a, ll b){
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

int com(ll n,ll a){
    ll k=1;
    for(ll i=n;i>n-a;i--){
        k=k*i%MOD;
    }
    for(ll i=1;i<=a;i++){
        k=(k*power(i,MOD-2))%MOD;
    }
    return k;
}
int main(void){
    ll n,a,b;cin>>n>>a>>b;
    ll _2n=power(2,n);
    ll ans=(_2n+MOD+MOD-com(n,a)-com(n,b)-1)%MOD;
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
 
  int stack[100];
  char str[100];
  int top=0,i;
  int ch;
  for (i=0;i<100;i++){
    stack[i]=0;
  }
  while (scanf("%s",str)!=EOF){
    if (str[0]=='+'){
      stack[top-2]=stack[top-2]+stack[top-1];
      top=top-1;
    }else if(str[0]=='*'){
      stack[top-2]=stack[top-2]*stack[top-1];
      top=top-1;
    }else if(str[0]=='-'){
      stack[top-2]=stack[top-2]-stack[top-1];
      top=top-1;
    }else{
      stack[top]=atoi(str);
      top++;
    }
  }
  printf("%d\n",stack[top-1]);
  return 0;
}

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

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

    sort(p.begin(), p.begin()+N);

    int ans = 0;
    rep(i, N-1) ans += p[i];
    ans += p[N-1]/2;

    cout << ans << endl;
}

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

int main() {
	int a,b,t, ans=0;
	cin >> a>>b>>t;
	for (int i = 1; i <= t; i++) {
		if (i%a == 0) {
			ans += b;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

ll gcd(ll a, ll b) {
  if (b > a) {
    swap(a, b);
  }
  ll r = a%b;
  while (r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

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


signed main() {
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
    string s;
    cin>>s;
    int n=s.length();
    int i=n-2;
    int maxl = 0;
    while(i>0){
        string p = s.substr(0,i/2);
        string n = s.substr(i/2,i/2);
        //cout<<p<<" "<<n<<endl;
        if(p==n){
            maxl = i;
            break;
        }
        i -= 2;
    }
    cout<<maxl<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
const int biggg = 2000000000;
const long long bigggest = 1000000000000000000LL;
const double eps = .0000000001;

long long modpow(long long x, long long n) { 
  if (n == 0) return 1LL%mod; 
  long long u = modpow(x,n/2LL); 
 
  u = (long long)(u*u)%mod; 
  if (n%2LL == 1) u = (long long)(u*x)%mod; 
  return u;
}

int main ()
{
  prep();
  int n, k;
  cin >> n >> k;
  long long cnts[100001] = {0};
  for (int i=k; i>=1; i--){
      cnts[i] += modpow(k/i, n);
      cnts[i] = mymod(cnts[i]);
      for (int j=1; j<=sqrt(i); j++){
          if (i%j == 0 && j != i){
              cnts[j] -= cnts[i];
              if (j != i/j && i/j != i) cnts[i/j] -= cnts[i];
          }
      }
      
  }
  long long res = 0;
  for (int i=1; i<=k; i++){
      res += (cnts[i]*i)%mod;
      res %= mod;
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 4420
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

fn main() {
    let n: i64 = read();
    let k: String = read();
    let mut cnt = 0;
    for i in 0..n - 2 {
        if k[i as usize..i as usize + 3] == "ABC".to_string() {
            cnt += 1;
        };
    }
    println!("{}", cnt)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
    string s1,s2; cin>>s1>>s2;
    for(int i=0;i<(int)s1.length();i++){
        if(s1[i] != s2[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    inarr(n);in(k);
    for(int i=0;i<n;i++){
        in(temp);arr.push_back(temp);
    }
    ll dp[n+1];
    for(int i=0;i<=n;i++){
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i-j>=0){
                dp[i]=min(dp[i],dp[i-j]+(ll)fabs(arr[i]-arr[i-j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 4964
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

constexpr intmax_t MOD = 1e9+7;

int main() {
  size_t H, W, K;
  scanf("%zu %zu %zu", &H, &W, &K);

  std::vector<std::vector<intmax_t>> dp(H+1, std::vector<intmax_t>(W));
  dp[0][0] = 1;

  for (size_t i = 0; i < H; ++i) {
    for (size_t j = 0; j < W; ++j) {
      for (int k = 0; k < (1 << (W-1)); ++k) {
        if (k & (k >> 1)) continue;
        if (j+1 < W && k >> j & 1) {
          (dp[i+1][j+1] += dp[i][j]) %= MOD;
        } else if (j > 0 && k >> (j-1) & 1) {
          (dp[i+1][j-1] += dp[i][j]) %= MOD;
        } else {
          (dp[i+1][j] += dp[i][j]) %= MOD;
        }
      }
    }
  }
  printf("%jd\n", dp[H][K-1]);
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,k,q; scanf("%d%d%d",&n,&k,&q);
  int a[n];
  for(int i=0; i<n; i++) a[i]=k-q;
  for(int i=0; i<q; i++){
    int t; scanf("%d",&t); a[t-1]++;
  }
  for(int i=0; i<n; i++){
    if(a[i]>0) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

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

 int main() {
   string S;
   cin >> S;
   int l = S.length();
   vector<ll> increase(l + 1, 0), decrease(l + 1, 0);
   ll ans = 0;

   rep(i, 0, l) if(S.at(i) == '<') increase.at(i + 1) = increase.at(i) + 1;
   for(int i = l - 1; i >= 0; i--) if(S.at(i) == '>') decrease.at(i) = decrease.at(i + 1) + 1;

   rep(i, 0, l + 1) ans += max(increase.at(i), decrease.at(i));

   cout << ans << endl;
 }


Measured memory_bytes: 8708
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

signed main(){

    int N; cin >> N;
    vec A(N); readv(A);

    int odd = 0;
    REP(i, N) if(A[i] % 2== 1) odd++;
    int even = N - odd;
    even += odd / 2;
    odd %= 2;

    if((odd == 1 && even == 0) || odd == 0) cout << "YES";
    else cout << "NO"; 
    
    return 0;
}

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

int n;
int m;
int x;
int main(){
	cin >> n >> m >> x;
	if( (n == m && m != x) || (n == x && m != n) || (m == x && x != n)) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll A;
    ll B = 0;
    char c;
    cin >> A;
    cin >> c;
    B += (c-'0')*100;
    cin >> c;
    cin >> c;
    B += (c-'0')*10;
    cin >> c;
    B += (c-'0');



    cout << A*B/100 << "\n";

}

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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 20100;
int a[N];
int b[N];
int p[N];
int n;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	cin >> n;
	forn(i, n) {
		cin >> p[i];
		p[i]--;
	}
	forn(i, n) {
		a[i] = i;
	}
	forn(i, n) {
		b[p[i]] = i + N - a[p[i]];
	}
	int step = 0;
	forn(i, n) {
		a[i] += step;
		b[i] -= step;
		step += N;
	}
	int minn = 1e9;
	forn(i, n) {
		umn(minn, b[i]);
	}
	forn(i, n) {
		b[i] -= minn;
	}
	forn(i, n)
		printf("%d ", a[i] + 1);
	cout << endl;
	forn(i, n) 
		printf("%d ", b[i] + 1);
	
	return 0;
}


Measured memory_bytes: 1024
#n = gets.chomp.to_i
h,w = gets.chomp.split().map(&:to_i)

sharp = 0
grid = Array.new(h){Array.new(w, -1)}
q = []
h.times do |i|
  line = gets.chomp
  w.times do |j|
    if line[j] == '#'
      grid[i][j] = 0
      q.push [i,j, 0]
      sharp += 1
    end
  end
end
#p grid

cost = 0
num = 0
until sharp == h*w
  y,x = q[num]
  num += 1
  cost = grid[y][x] + 1
  if 0 < y && grid[y-1][x] == -1
    grid[y-1][x] = cost
    q.push [y-1, x]
  sharp += 1
  end
  if y < h-1 && grid[y+1][x] == -1
    grid[y+1][x] = cost
    q.push [y+1, x]
  sharp += 1
  end
  if 0 < x && grid[y][x-1] == -1
    grid[y][x-1] = cost
    q.push [y, x-1]
  sharp += 1
  end
  if x < w-1 && grid[y][x+1] == -1
    grid[y][x+1] = cost
    q.push [y, x+1]
  sharp += 1
  end
end

puts cost


Measured memory_bytes: 83580
#include <iostream>
#include <limits.h>
using namespace std;

int main(void){
	int n;
	int r;
	int max = INT_MIN;
	int min = INT_MAX;

	cin >> n;

	cin >> r;
	min = r;
	for(int i=1; i<n; i++){
		cin >> r;
		if(r - min > max){
			max = r - min; 
		}
		if(min > r) min = r;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define mp           make_pair
#define int          long long
#define uint         unsigned long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define vs           vector<string>
#define pi           pair<int,int>
#define di           deque<int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define noob         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    rep(i,0,n)
    {
        cin>>a[i];
        sum=(sum^a[i]);
    }
    rep(i,0,n)
    {
        cout<<(sum^a[i])<<" ";
    }

}

signed main()
{
        noob
        // #ifndef ONLINE_JUDGE
        //  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);
        //  #endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 5168
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<limits.h>
using namespace std;
int main(){
    string a,b,c;
    int aa,bb;
    cin>>a>>b>>aa>>bb>>c;
    if(a==c)
        cout<<aa-1<<" "<<bb<<endl;
    else
        cout<<aa<<" "<<bb-1<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <bitset>

using namespace std;

#define FSIO  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define DEBUG(a)   cout<<"DEBUG: "<<(a)<<endl;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define MP make_pair
#define X  first
#define Y  second
#define REP(i,st,ed)    for(int i=st;i<=ed;++i)
#define IREP(i,st,ed)   for(int i=st;i>=ed;--i)
#define TCASE(T)    cin>>T;while(T--)

const int MAXN = 5005;
const ll MOD = 1e9+7 ;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 1e9+7;
const double PI = acos(-1.0);
const double EPS = 1e-8;

int _;

using namespace std;

int cnt[105];
vector<int> res;

int main()
{
    //freopen("test.in","r+",stdin);
    //freopen("test.out","w+",stdout);
    FSIO;
    int N, M;
    while(cin>>N>>M)
    {
        memset(cnt,0,sizeof(cnt));
        REP(i,1,N)
        {
            int K;cin>>K;
            int tmp;
            REP(j,1,K)
            {
                cin>>tmp;
                cnt[tmp]++;
            }
        }
        res.clear();
        REP(i,1,M) if(cnt[i]==N)    res.pb(i);

        cout<<res.size()<<endl;
    }

    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int n;
    cin >> n;
    vector <ll> a(n, 0), sum(60, 0);
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (ll j = 0; j < 60; j++) {
            if (a[i] & (1LL << j)) sum[j]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < 60; i++) {
        ans += (1LL<<i)%mod * sum[i]%mod * (n-sum[i])%mod;
        ans %= mod;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2560
#include <stdio.h>
int main()
{
  int r;
  scanf("%d",&r);
  if(r<1200)
  {
    printf("ABC");
  }
  else if(r<2800)
  {
    printf("ARC");
  }
  else
  {
    printf("AGC");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long mod = 1000000007;
const long long MOD = 998244353;

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

	ll a, b, c;
	cin >> a >> b >> c;
	cout << b + min(a + b + 1, c) << "\n";

	return 0; 
}


Measured memory_bytes: 256
n = 10**6
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
                #エラトステネスの篩
prime=sorted(list(prime))
x=int(input())
for some in prime:
    if some>=x:
        print(some)
        break

Measured memory_bytes: 74336
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    cin >> n;
    vector<vector<int>> graph(n);
    for(int i = 0; i < n - 1; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    vector<int> dist(n);
    vector<int> c(n, 0);
    auto dfs = [&](auto&& self, int from = 0, int par = -1, int d = 0) -> int {
        dist[from] = d++;
        int S = 1;
        for(int to : graph[from]){
            if(to == par)   continue;
            S += self(self, to, from, d);
        }
        return c[from] = S;
    };
    dfs(dfs);
    vector<int> dist2(n);
    auto dfs2 = [&](auto&& self, int from, int par = -1, int d = 0) -> void{
        dist2[from] = d++;
        for(int to : graph[from]){
            if(to == par)   continue;
            self(self, to, from, d);
        }
        return;
    };
    dfs2(dfs2, n - 1);
    int v = 0;
    if(dist[n - 1] % 2 == 0){
        int d = dist[n - 1] / 2;
        for(int i = 0; i < n; ++i){
            if(dist[i] == d + 1 && dist2[i] == d - 1){
                v = i;
                break;
            }
        }
    }
    else{
        int d = dist[n - 1] / 2 + 1;
        for(int i = 0; i < n; ++i){
            if(dist[i] == d && dist2[i] == d - 1){
                v = i;
                break;
            }
        }
    }
    if(c[v] < n - c[v]) cout << "Fennec\n";
    else if(c[v] > n - c[v])    cout << "Snuke\n";
    else    cout << ((dist[n - 1] % 2) ? "Snuke\n" : "Fennec\n");
}

Measured memory_bytes: 17624
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Queue;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;



public class Main{
	
	static int posx;
	static int posy;
	static int type;
	static int diff;
	static int INF = Integer.MAX_VALUE;
	static int[][] d;
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 
	 int[] A=new int[N];
	 int min=100;
	 int max=-100;
	 
	 for(int i=0;i<N;i++) {
		 A[i]=sc.nextInt();
		 if(A[i]>max) {
			 max=A[i];
		 }
		 if(A[i]<min) {
			 min=A[i];
		 }
	 }
	 
	 
	 
	 long answermin=Long.MAX_VALUE;
	 
	 for(int i=-100;i<=100;i++) {
		 
		 long answer = 0;
		 
		 for(int j=0;j<N;j++) {
			 answer+=Math.pow((A[j]-i), 2);
		 }
		 if(answer<answermin) {
			 answermin=answer;
		 }
		 //System.out.println(answer);
		 
		 
	 }
	 
	 
	 
	 System.out.println(answermin);
	
	 
	 
	 
	 
 }
	


}

Measured memory_bytes: 23764
#include <stdio.h>
#include <string.h>

int main(void) {
    int n, i;
    char *strptr;
    char str[1002];

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

    for(i = 0; i < n; i++ ) {
        fgets(str, 1002, stdin);
        strptr = str;
        while( (strptr = strstr(strptr, "Hoshino")) != NULL ) {
            strptr += 6;
            *strptr = 'a';
        }
        printf("%s",str);
    }
    return 0;
}
    

Measured memory_bytes: 612
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;
typedef long long LL;

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

    for (int i = 0; i < s.size(); i++)
    {
        if (i % 2 == 0)
        {
            cout << s[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 512
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long p[210000];
long long q[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%lld%lld",p+i,q+i);
	}
	std::sort(p,p+a);
	std::sort(q,q+a);
	long long L=p[a/2]+p[a-a/2-1];
	long long R=q[a/2]+q[a-a/2-1];
	if(a%2==0){
		printf("%lld\n",R-L+1);
	}else{
		printf("%lld\n",(R-L)/2+1);
	}
}

Measured memory_bytes: 4812
D, G = map(int, input().split())
s = 0
Q = []
for i in range(D):
    p, c = map(int, input().split())
    s += p
    Q.append((i+1, p, c))
dp = [-10**18]*(s+1)

dp[0] = 0
for i, p, c in Q:
    for j in range(s, -1, -1):
        for k in range(1, p+1):
            if k == p:
                cc = 100*i*k + c
            else:
                cc = 100*i*k
            if j - k >= 0:
                dp[j] = max(dp[j], dp[j - k] + cc)
for i in range(1+s):
    if dp[i] >= G:
        print(i)
        break


Measured memory_bytes: 3188
#include <stdio.h>

#define BLOCK '#'
#define ARR_LIMIT 10000

typedef struct {
    int width;
    int height;
} Size;

void InputNumber(int* number, int limitLow, int limitHigh);
void Drawing(int x, int y, char block);

int main(void) {

    int i;
    int idx;
    Size sizes[ARR_LIMIT];

    for (idx = 0; idx < ARR_LIMIT; idx++) {
        int height;
        int width;
        Size size;

        InputNumber(&height, 0, 300);
        InputNumber(&width, 0, 300);

        if (width == 0 && height == 0) {
            break;
        }

        size = sizes[idx];
        size.width = width;
        size.height = height;
        sizes[idx] = size;
    }

    for (i = 0; i < idx; i++) {
        Size size = sizes[i];
        Drawing(size.width, size.height, BLOCK);
    }

    return 0;
}

void InputNumber(int* number, int limitLow, int limitHigh) {
    int x;
    do {
        scanf("%d", &x);
    } while (x < limitLow || x > limitHigh);
    *number = x;
}

void Drawing(int width, int height, char block) {
    int idW;
    int idH;

    for (idH = 0; idH < height; idH++) {
        for (idW = 0; idW < width; idW++) {
            printf("%c", block);
        }
        printf("\n");
    }
    printf("\n");
}



Measured memory_bytes: 2052
import Foundation

func solve(n: Int, aSizes: [Int], bSizes: [Int], cSizes: [Int]) -> Int {

    return bSizes
        .map {
            let lowerCases = corneredBounds(searchValue: $0, list: aSizes, policy: .lower).left + 1
            let upperCases = n - corneredBounds(searchValue: $0, list: cSizes, policy: .upper).right
            return lowerCases * upperCases
        }
        .reduce(0, +)
}

func corneredBounds(searchValue: Int, list: [Int], policy: Direction) -> (left: Int, right: Int) {

    var openedLeft = -1
    var openedRight = list.count

    while openedRight - openedLeft > 1 {

        let mid = (openedRight + openedLeft) / 2

        func midValueShouldBeInLeftSide() -> Bool {
            policy.midValueShouldBeInLeftSide(at: mid, on: list, with: searchValue)
        }

        if midValueShouldBeInLeftSide() {
            openedLeft = mid
        }
        else {
            openedRight = mid
        }
    }

    return (openedLeft, openedRight)
}

enum Direction {

    case lower
    case upper

    func midValueShouldBeInLeftSide(at index: Int, on list: [Int], with searchValue: Int) -> Bool {

        switch self {
            case .lower: return list[index] <  searchValue ? true : false
            case .upper: return list[index] <= searchValue ? true : false
        }
    }
}

let n = Int(readLine()!)!
var aSizes = readLine()!.split(separator: " ").compactMap{ Int($0) }
var bSizes = readLine()!.split(separator: " ").compactMap{ Int($0) }
var cSizes = readLine()!.split(separator: " ").compactMap{ Int($0) }

aSizes.sort()
bSizes.sort()
cSizes.sort()

let answer = solve(n: n, aSizes: aSizes, bSizes: bSizes, cSizes: cSizes)
print(answer)


Measured memory_bytes: 24232
N,M=map(int,input().split())
S=[]
G=[]
for i in range(M):
	x,y=map(int,input().split())
	if x==1:
		S.append(y)
	if y==N:
		G.append(x)
if S==[] or G==[]:
	print("IMPOSSIBLE")
	exit()
S=set(S)
G=set(G)
T=len(S)+len(G)
k=len(G)
S=list(S)
G=list(G)
for i in range(k):
	S.append(G[i])
U=len(set(S))
if T!=U:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	
	string str;
	cin >> str;
	int n = str.size();
		
	if(str[n-1] == '1' || str[0] == '0') {
		cout << -1 << endl;
		return 0;
	}
		
	for(int i = 0;i < n-1;i++){
		if(str[i] != str[n-i-2]){
			cout << -1 << endl;
			return 0;
		}
	}
	
	int cou = 2;
	int now = 1;
	
	for(int i = 0;i < n-1;i++){
		cout << now << ' ' << cou << endl;
		if(str[i] == '1'){
			now = cou;
		}
		cou++;
	}
	
	return 0;
}


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

using namespace std;

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

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    int ans = 0;
    for (int i = 0; i < K; ++i) {
        ans += A[i];
    }
    cout << ans << endl;

    return 0;
}

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

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>p(n);
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
		p.at(i)--;
	}
	vector<pair<int, int>>xy(m);
	for (int i = 0; i < m; i++) {
		cin >> xy.at(i).first >> xy.at(i).second;
		xy.at(i).first--;
		xy.at(i).second--;
	}
	sort(xy.begin(), xy.end());

	UnionFind tree(n);
	for (int i = 0; i < m; i++) tree.unite(xy.at(i).first, xy.at(i).second);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (tree.same(p.at(i), i))ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  //ABC096C - Grid Repainting2
  int H, W; cin >> H >> W;
  vector<vector<char> > s(H+2, vector<char>(W+2, '.'));
  REP(i, H){
    REP(j, W){
      char tmp; cin >> tmp;
      s[i+1][j+1] = tmp;
    }
  }

  bool flag = true;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      if(s[i][j] == '#'){
        if(s[i-1][j] == '.' && s[i+1][j] == '.' && s[i][j-1] == '.' && s[i][j+1] == '.'){
          flag = false;
          break;
        }
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef tuple<LL, LL, LL> TP;

int main() {
  int N, M; cin >> N >> M;
  vector<TP> tps(N);
  for (int i = 0; i < N; ++i) {
    LL x, y, z; cin >> x >> y >> z;
    tps[i] = {x, y, z};
  }

  LL vmax = 0;
  vector<TP> p = {{1, 1, 1}, {1, 1, -1}, {1, -1, 1}, {1, -1, -1},
                  {-1, 1, 1}, {-1, 1, -1}, {-1, -1, 1}, {-1, -1, -1}};
  for (auto [px, py, pz] : p) {
    vector<LL> v; v.reserve(N);
    for (auto [x, y, z] : tps) {
      v.push_back(px*x + py*y + pz*z);
    }
    sort(v.rbegin(),v.rend());
    LL sum = 0;
    for (int i = 0; i < M; ++i) {
      sum += v[i];
    }
    vmax = max(vmax, sum);
  }
  cout << vmax << endl;
}


Measured memory_bytes: 3584
void main(){
	string[] val = inln!string();
	bool a = (val[0]=="H")?true:false;
	bool b = (val[1]=="H")?true:false;
	writeln(( (a^b)==false)?'H':'D');

}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2652
#include <bits/stdc++.h>
using namespace std;
#define pll pair<int,int>
#define pLL pair<int,long long>
const int mx=1e5+5;
bool vis[mx];
vector<pLL> _count;
vector<pll> v[mx];

void dfs(int node, long long sum){
    if(vis[node]) return;
    vis[node]=true;
    _count.push_back({node,sum});
    for(auto i:v[node])
        dfs(i.first, sum+i.second);

}

int main(){

    int i,total;
    scanf("%d",&total);
    for(i=1;i<total;i++){
        int m,n,w;
        scanf("%d%d%d",&m,&n,&w);
        v[m].push_back({n,w});
        v[n].push_back({m,w});
    }

    dfs(1,0);
    sort(_count.begin(),_count.end());
    for(i=0;i<total;i++)
        if(_count[i].second&1) printf("1\n");
        else printf("0\n");
        //cout<<_count[i].first<<" "<<_count[i].second<<"\n";
    return 0;
}


Measured memory_bytes: 10100
#include<bits/stdc++.h>
#define ll long long
#define f first
#define  s second
#define pii pair<int,int>
#define pll pair<ll,l>
#define ull unsigned ll
#define mp make_pair
#define pb push_back

using namespace std;


int main(){
	
	int n;cin>>n;
	string s;cin>>s;
	int cnt1,cnt2;
	cnt1=cnt2=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R')cnt1++;
		else cnt2++;
	}
	int cnt3=0,cnt4=0;
	for(int i=0;i<cnt1;i++){
		if(s[i]=='W')cnt3++;
	}
	for(int i=n-cnt2+1;i<n;i++){
		if(s[i]=='R')cnt4++;
	}
	cout<<max(cnt3,cnt4);
	return 0;
}


Measured memory_bytes: 3720
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    h, w, k = map(int, input().split())
    field = [[] for i in range(h)]
    for i in range(h):
        field[i] = [int(s) for s in input()]
    import numpy as np
    field = np.array(field, dtype=int)
    inf = 10 **4
    ans = inf
    for i in range(2**(h-1)):
        prev = 0
        damy = []
        tmp_ans = format(i, 'b').count('1')
        for j in range(h-1):
            if (i >> j)&1:
                damy.append(field[prev:j+1].sum(axis=0))
                prev = j+1
        damy.append(field[prev:].sum(axis=0))
        damy = np.array(damy,dtype=int).T
        if (damy > k).any():
            continue

        prev = 0
        cnt_w = np.zeros(tmp_ans+1, dtype=int)
        for l in range(w):
            cnt_w += damy[l]
            if (cnt_w > k).any():
                cnt_w = damy[l]
                tmp_ans += 1
            
        ans = min(ans, tmp_ans)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 27356