akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=jp

int N;
int A[1000005];

static int bubble() {
    int cnt = 0;
    bool flag = true;
    for (int i = 0; flag; i++) {
        flag = false;

        for (int j = N-1; j >= i+1; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                cnt++;
                flag = true;
            }
        }
    }

    return cnt;

}

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];
    int c = bubble();
    arrdump(N, A);
    cout << c << "\n";
    return 0;
}



Measured memory_bytes: 3100
n, c = map(int, input().split())
X = []
V = []
right = []
rightleft = []
calsum = 0
for i in range(n):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
    calsum += v
    right.append(calsum-x)
    rightleft.append(calsum-2*x)

left = []
leftright = []
calsum = 0
for i in range(n):
    calsum += V[n-i-1]
    left.append(calsum - (c-X[n-i-1]))
    leftright.append(calsum - 2*(c-X[n-i-1]))

m = 0
M = 0
for i in range(0, n-1):
    m = max(m, left[i])
    M = max(M, m + rightleft[n-i-2])

mm = 0
MM = 0
for i in range(0, n-1):
    mm = max(mm, right[i])
    MM = max(MM, mm + leftright[n-i-2])

print(max(max(right), max(left), M, MM, 0))


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

#define NMAX 101

int v[NMAX][NMAX];

int main()
{
    ios_base::sync_with_stdio(false);
    // ifstream cin("code.in");
    int N, M, P;
    cin >> N >> M;
    cin >> P;
    int i = 1, j = 1, inc = 1;
    for (int color = 1; color <= P; color++) {
        int cnt;
        cin >> cnt;
        for (int k = 1; k <= cnt; k++) {
            v[i][j] = color;
            j += inc;
            if (j == M + 1) {
                j = M;
                inc = -1;
                i++;
            } else if (j == 0) {
                j = 1;
                inc = 1;
                i++;
            }
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            cout << v[i][j] << " ";
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n,W; cin >> n >> W;
    vector<int> w(n+1),v(n+1);
    for(int i = 1; i <= n; i++) cin >> w.at(i) >> v.at(i);
    vector<vector<ll>> dp(n+1,vector<ll>(W+1));
    rep(i,W+1) dp.at(0).at(i) = 0;

    for(int i = 1; i <= n; i++){
        rep(j,W+1){
            ll now;
            if(j - w.at(i) >= 0){
                now = max(dp.at(i-1).at(j - w.at(i)) + v.at(i),dp.at(i-1).at(j));
                dp.at(i).at(j) = now;
            }
            else dp.at(i).at(j) = dp.at(i-1).at(j);
        }
    }
    cout << dp.at(n).at(W) << endl;
    return 0;   
}


Measured memory_bytes: 80256
use std::collections::HashMap;
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_vec();
    let mut acc = HashMap::<i64, i64>::new();
    let mut ans = 0;
    for i in 0..n {
        let b = (i as i64 + 1) + a[i];
        let c = -a[i] + (i as i64 + 1);
        if let Some(x) = acc.get(&c) {
            ans += x;
        }
        if let Some(x) = acc.get_mut(&b) {
            *x += 1;
        } else {
            acc.insert(b, 1);
        }
    }
    //println!("{:?}", acc);
    //println!("{}", get_type(acc));
    println!("{}", ans);
}

fn get_type<T>(_: T) -> &'static str {
    std::any::type_name::<T>()
}


Measured memory_bytes: 12324
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
  cin>>n;
  int j,k,i;
  vector<pair<int,int>> v(n);
  for( i=0;i<n;i++)
  {
      cin>>j>>k;
      v[i]={j,k};
  }
  string ans="No";
  for(i=0;i<=n-3;i++)
  {
     if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second)
     {
         ans="Yes";
         break;
     }
  }
  cout<<ans;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

const int MAXN = 2000;
int N, K;
V<V<int>> dist(MAXN, V<int>(MAXN, -1));
V<V<int>> edge(MAXN);

void bfs(int s){
	queue<int> q;
	q.push(s);
	dist[s][s] = 0;
	while (!q.empty()) {
		int from = q.front();
		q.pop();
		for(auto to: edge[from]){
			if(dist[s][to]==-1){
				q.push(to);
				dist[s][to] = dist[s][from]+1;
			}
		}
	}
	return;
}

int main() {
	cin >> N >> K;
	REP(i,N-1){
		int A, B; 
		cin >> A >> B;
		A--; B--;
		edge[A].push_back(B);
		edge[B].push_back(A);
	}
	REP(i, N) bfs(i);
	if(K%2){
		//odd
		V<int> cnt((2 * (N - 1)),0);
		int idx = 0;
		REP(i, N){
			for(auto j:edge[i]){
				REP(k,N){
					int l = dist[i][k],r = dist[j][k];
					if (l > K / 2 && r > K / 2) cnt[idx]++;
				}
				idx++;
			}
		}
		cout << *min_element(ALL(cnt)) << endl;
	}
	else{
		//even
		V<int> cnt(N,0);
		REP(i, N) REP(j, N) if (dist[i][j] > K / 2)cnt[i]++;
		cout << *min_element(ALL(cnt)) << endl;
	}
	return 0;
}



Measured memory_bytes: 16128
import sys

def str_to_int(ch):
	if ch =='A':
		return 0
	if ch =='B':
		return 1
	if ch =='C':
		return 2
def int_to_str(ch):
	if ch ==0:
		return 'A'
	if ch ==1:
		return 'B'
	if ch ==2:
		return 'C'

N, A, B, C = list(map(int, input().split()))
ABC =[0, 0, 0]
ABC[0] = A
ABC[1] = B
ABC[2] = C

ops = []
for _ in range(N):
	l =list(map(str_to_int, list(input())))
	ops.append(l)

if sum(ABC) == 0:
	print("No")
	sys.exit(0)

ans = []
for idx, op in enumerate(ops):
	n0 = ABC[op[0]]
	n1 = ABC[op[1]]
	if n0 == 0 and n1 == 0:
		print("No")
		sys.exit(0)
	elif n1 == 0:
		inc = op[1]
		dec = op[0]
	elif n0 == 0:
		inc = op[0]
		dec = op[1]
	elif idx +1 < len(ops) and op[0] in ops[idx+1]:
		inc = op[0]
		dec = op[1]
	else:
		inc = op[1]
		dec = op[0]
	ans.append(inc)
	ABC[dec]-=1
	ABC[inc]+=1
print("Yes")
for i in map(int_to_str, ans):
	print(i)
sys.exit(0)



Measured memory_bytes: 21860
def extgcd(a, b):
  if b == 0:
    return 1
  else:
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
      x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
      k, l = l, k % l
    return x
def inved(x, m):
  return x % m
def gcd(x, y):
  while y != 0:
    x, y = y, x % y
  return x
def doubling(n, m, mod):
  y = 1
  base = n
  while m != 0:
    if m % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    m //= 2
  return y
def factorization(n):
  if n == 1:
    return {1: 1}
  else:
    D = {}
    base = n
    p = 2
    while n != 1:
      i = 0
      while n % p == 0:
        i += 1
        n //= p
      if i != 0:
        D[p] = i
      p += 1
      if p * p > base and n != 1:
        D[n] = 1
        break
    return D
def Torshent(n):
  dic = factorization(n)
  S = n
  for i in dic:
    S //= i
    S *= i - 1
  return S
def bin_digits(n):
  cnt = 0
  while n != 0:
    cnt += 1
    n //= 2
  return cnt
def Resque(a, mod):
  if mod == 1:
    return 1
  M = Torshent(mod)
  MM = gcd(M, mod)
  R = Resque(a, MM)
  k = doubling(a, R, mod)
  m, modmod = M // MM, mod // MM
  Tm = Torshent(modmod)
  invm = doubling(m, Tm-1, modmod)
  t = ((k - R) // MM) * invm
  R += t * M
  R %= (mod * M // MM)
  R += (mod * M // MM)
  return R

#---------------------------------------------------------------#

Q = int(input())
for i in range(Q):
  A, M = map(int, input().split())
  if M == 1:
    print(1)
  else:
    R = Resque(A, M)
    print(R)

Measured memory_bytes: 3316
import java.util.*;
import java.util.TreeMap;
import java.util.ArrayList;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        TreeMap<Integer, ArrayList<Integer>> map = new TreeMap<>();

        for(int i=0; i<M; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            if(map.get(b[i])==null){
                ArrayList<Integer> list = new ArrayList<>();
                list.add(a[i]);
                map.put(b[i], list);
            }
            else{
                ArrayList<Integer> list = map.get(b[i]);
                list.add(a[i]);
                map.put(b[i], list);
            }
        }
        boolean[] bridge = new boolean[N];
        int x = 0;
        int ans = 0;
        for(int key : map.keySet()){
            ArrayList<Integer> list = map.get(key);
            for(int i=0; i<list.size(); i++){
                if(list.get(i)>x && !bridge[key-1]){
                    x = key - 1;
                    ans += 1;
                    bridge[x] = true;
                }
            }
        }   
        System.out.println(ans);     
    }
}

Measured memory_bytes: 103388
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	string str;
	cin>>str;
	ll N=0;
	F0R(x,sz(str))
		N+=str[x]-'0';
	if(N%9==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3744
#include <bits/stdc++.h>
 
using namespace std;
 
#define LL long long 
#define ULL unsigned long long 
#define LD long double 
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int lc = 0;
	int nx = n;
	while(nx!=0) {
		lc++;
		nx/=10;
	}
	if(lc%2==0) {
		lc--;
		int w = 0;
		while(lc>0) {
			w+=pow(10, lc);
			w-=pow(10, lc-1);
			lc-=2;
		}
		cout<<w;
	}
	else {
		int poc = pow(10, lc-1);
		int w = (n+1) - poc;
		lc-=2;
		while(lc>0) {
			w+=pow(10, lc);
			w-=pow(10, lc-1);
			lc-=2;
		}
		cout<<w;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n;cin>>n;
  const int A=0;
  const int B=2;
  const int C=2;

  vector<vector<ll>>dp(n+1,vector<ll>(3,0));

  rep(i,n){
    ll a[3];
    rep(j,3)cin>>a[j];
    rep(j,3)rep(k,3){
      if(j==k)continue;
      chmax(dp[i+1][k],dp[i][j]+a[k]);
    }
  }
  cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 5760
def decsum(i):
  ans = 0
  while(i>0):
    ans+=i%10
    i//=10
  return ans

n,a,b = tuple(map(int,input().split()))

ans = 0
for i in range(1,n+1):
  t = decsum(i)
  if a<=t and t<=b:
    ans+=i
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    set<int> s;
    int q, x, y;
  	cin >> q;
    for (int i = 0; i < q; i++){
        cin >> y >> x;
        if (y == 0) {
            s.insert(x);
            cout << s.size() << endl;
        }
        else if (y == 1){
            auto t = s.find(x);
            if (t != s.end()) cout << 1 << endl;
            else cout << 0 << endl;
        }
      	else s.erase(x);
        
    }
	return 0;
}


Measured memory_bytes: 12464
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k =sc.nextInt();
        int k2 =k-1;
        int sum =k;


        for(int i =0;i<n-1;i++){
            sum *=k2;
        }
        System.out.println(sum);
    }
}






Measured memory_bytes: 22612
N = int(input())

if N == 0:
    print(0)
    exit()

ans = ""
while(N != 0):
    div = N // -2
    rem = N % -2
    if rem == -1:
        div += 1
        rem = 1
    N = div
    ans = str(rem) + ans
print(ans)
    




Measured memory_bytes: 2940
#include<stdio.h>

int N, M;
int V[100000];

int root(int x) {
  if(V[x] == -1) return x;
  else return V[x] = root(V[x]);
}

void merge(int a, int b) {
  a = root(a);
  b = root(b);
  if(a == b) return;
  V[a] = b;
}

int main() {
  int unique[100000] = {};
  scanf("%d%d", &N, &M);
  for(int i = 0;i < N;i++) V[i] = -1;
  for(int i = 0;i < M;i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--; b--;
    merge(a, b);
  }
  int ans = -1;
  for(int i = 0;i < N;i++) {
    if(unique[root(i)]++ == 0) ans++;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 2512
// (>"°w°)>"*'~-~
//CF_Handle: Nurseyit_00
#include <bits/stdc++.h>

#define fname ""

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(s) (int)s.size()
#define forn(i, fn, n) for(int i = (fn); i <= (n); ++i)
#define forev(i, n, fn) for(int i = (n); i >= (fn); --i)
#define all(s) (s).begin(),(s).end()
#define fast_stream cin.tie(0), ios_base::sync_with_stdio(0)
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int maxn = (int) 1e5 + 100;
const int mod = (int) 1e9 + 7;

int n;
string s, t;

bool check (int len) {
  string a, b;
  forn (i, n - len, n - 1)
    a += s[i];
  forn (i, 0, len - 1)
    b += t[i];
  return a == b;
}

int main () {
  #ifdef u310
    freopen (fname".in", "r", stdin);
    freopen (fname".out", "w", stdout);
  #endif
  fast_stream;
  cin >> n >> s >> t;
  forev (i, n, 1)
    if (check (i)) {
      cout << n + n - i;
      return 0;
    }
  cout << n + n;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

const int N = 2e3 + 7;
typedef pair<int, int> pii;
const int Mod = int(1e9) + 7;

struct TBIT {
    int t[N];
    TBIT() {fill(t, t + N, 0);}
    void Update(int x, int val) {for(; x > 0; x -= (x & -x)) t[x] += val;}
    int Get(int x) {int res = 0; for(x = max(x, 1); x < N; x += (x & -x)) res += t[x]; return res;}
} bit[2];

int n, color, p, cost0[N][N], cost1[N][N], f[N][N];
char c;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= 2 * n; ++i) {
        cin >> c >> p;
        color = (c == 'B')? 0: 1;
        if(color == 0) {
          for(int j = 0; j <= n; ++j) cost0[p][j] = bit[0].Get(p) + bit[1].Get(j + 1);
        } else {
          for(int j = 0; j <= n; ++j) cost1[j][p] = bit[0].Get(j + 1) + bit[1].Get(p);
        }
        bit[color].Update(p, 1);
    }
    f[0][0] = 0;
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= n; ++j) {
            if(i == 0 && j == 0) continue;
            f[i][j] = 1e9;
            if(i) f[i][j] = min(f[i - 1][j] + cost0[i][j], f[i][j]);
            if(j) f[i][j] = min(f[i][j], f[i][j - 1] + cost1[i][j]);
        }
    }
    cout << f[n][n];
}


Measured memory_bytes: 47488
#include <iostream>

using namespace std;

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r >= 0 && x+r <= w && y+r <= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
# (c) midandfeed
q = []
for i in range(4):
	b = []
	for j in range(3):
		a = [0 for x in range(10)]
		b.append(a)
	q.append(b)

t = int(input())
for _ in range(t):
	b, f, r, v = [int(x) for x in input().split()]
	q[b-1][f-1][r-1] += v

a = 0
for x in q:
	a += 1
	for y in x:
		for z in range(len(y)):
			print(" {}".format(y[z]), end='')
			if (z==(len(y))-1):
				print()
	if (a!=4):	
		print("#"*20)

Measured memory_bytes: 7744
# AtCoder Beginner Contest 159: B (2020/03/22)
S = str(input())
N = len(S)
x1 = int((N-1)/2)
flag = True
for i in range(x1):
    if S[i] != S[N-1-i]:
        flag = False
        break
if flag == True:
    y1 = int((x1+1)/2)
    for j in range(y1):
        if S[j] != S[x1-1-j]:
            flag = False
if flag == False:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
N = list(map(int,list(input())))

flag = True
for i in range(10):
    if N[0]==i and N[1]==i and N[2]==i:
        print("Yes")
        flag = False
        break
    elif N[3]==i and N[1]==i and N[2]==i:
        print("Yes")
        flag = False
        break

if flag:
    print("No")
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100005;
const ll inf=0x3f3f3f3ff;
bool vis[maxn];
ll dis[maxn],path[maxn];
typedef struct Node{
	ll to,val;
	Node(){};
	Node(ll a,ll b):to(a),val(b){};
}node;
vector<node>edge[maxn];

inline void add_edge(int a,int b,int c){
	edge[a].push_back(node(b,c));
	edge[b].push_back(node(a,c));
}

void dfs(int u,int fa){
	vis[u]=1;
	for(int i=0;i<edge[u].size();i++){
		node temp=edge[u][i];
		if(!vis[temp.to]){
			dis[temp.to]=dis[u]+temp.val;
			dfs(temp.to,u);
		}
	}
}

int main(int argc, char const *argv[])
{
	int n;
	while(cin>>n){
		ll a,b,c;
		for(int i=1;i<=n;i++){
			edge[i].clear();
		}
		for(int i=0;i<n-1;i++){
			scanf("%lld %lld %lld",&a,&b,&c);
			add_edge(a,b,c);
		}
		int q,k;
		scanf("%d %d",&q,&k);
		memset(vis,0,sizeof(vis));
		dis[k]=0;
		dfs(k,-1);
		for(int i=0;i<q;i++){
			scanf("%lld %lld",&a,&b);
			printf("%lld\n",dis[a]+dis[b]);
		}
	}
	return 0;
}

Measured memory_bytes: 14464
#include <stdio.h>

int main(void)
{
  char c;
  scanf("%c", &c);
  
  switch(c){
    case 'a':
    case 'i':
    case 'u':
    case 'e':
    case 'o':
      printf("vowel");
      break;
    default:
      printf("consonant");
  }
  
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    vector<int> b,c;
    for(int i = 0; i < n; i += 2) {
        b.push_back(a[i]);
    }
    for(int i = 1; i < n; i += 2) {
        c.push_back(a[i]);
    }
    vector<int> ans;
    if(n%2==0){
        reverse(c.begin(),c.end());
        for(int i = 0; i < c.size(); i++) {
            ans.push_back(c[i]);
        }
        for(int i = c.size(); i < n; i++) {
            ans.push_back(b[i-c.size()]);
        }
    }
    else{
        reverse(b.begin(),b.end());
        for(int i = 0; i < b.size(); i++) {
            ans.push_back(b[i]);
        }
        for(int i = b.size(); i < n; i++) {
            ans.push_back(c[i-b.size()]);
        }
    }
    for(int i = 0; i < n-1; i++) {
        cout << ans[i] << ' ' ;
    }
    cout << ans[n-1] << endl;


    return 0;
}

Measured memory_bytes: 5816
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	int cnt4mul = 0;
	int cnt2mul = 0;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		if( a[i] % 2 == 0 && a[i] % 4 != 0 ) cnt2mul++;
		if( a[i] % 4 == 0 ) cnt4mul++;
	}
	
	if( cnt2mul == 0 ) {
		if( cnt4mul + 1 >= n - cnt4mul ) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		if( cnt4mul >= n - cnt4mul - cnt2mul ) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int K = sc.nextInt();
        long ans = 0;
        for (int b=K+1;b<=N;b++) {
            ans = ans + N/b*Math.max((b-K), 0) + (long)Math.max(N-N/b*b-K+1, 0);
        }
        if (K==0) {
            ans = N*N;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include <iostream>

using namespace std;
int main(){
	int n,m,sum,count;
	for(int i=1;cin.eof()==false;i++){
		n = -1;
		cin >> n >> m;
		if (n == -1) break;
		sum = n + m;
		count = 0;
		while(sum!=0){
			sum /= 10;
			count++;
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 0
import queue

n, m = map(int, input().split())
ng_s = 10 ** 6

d = [[]] * (n+1)
s = [ng_s] * (n+1)
for i in range(1, n+1):
  d[i] = []

for _ in range(m):
  a, b = map(int, input().split())
  d[a].append(b)
  d[b].append(a)

#print(n, m)
#print(d)
#print(s)

q = queue.Queue()
q.put(1)
s[0] = 0
s[1] = 0

while not q.empty():
  c = q.get()
  to_list = d[c]
  for j in range(len(to_list)):
    to = to_list[j]
    if s[to] == ng_s and to != 1:
      s[to] = c
      q.put(to)
    
s2 = s[2:]

if min(s2) == ng_s:
  print('No')
else:
  print('Yes')
  for i in range(2, n+1):
    print(s[i])

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

const int N = 2e5 + 10, mod = 1e9 + 7;

int n, c[N], dp[N << 1], sz[N], in[N], out[N], t, pr[N << 1], p[N], prp[N << 1];
long long sub[N];
vector<int> adj[N], ord;

void pre(int u, int pa) {
    sz[u] = 1;
    ord.push_back(-u);
    in[u] = t++;
    p[u] = pa;
    for(int v : adj[u]) {
        if(v == pa) continue;
        pre(v, u);
        sz[u] += sz[v];
    }
    ord.push_back(u);
    out[u] = t++;
}

ll query(int u) {
    int v = p[u];
    ll res = sz[u] - (dp[prp[out[u]]] - dp[prp[in[u]]]);
    res = res * (res + 1) / 2;
    return res;
}

void dfs(int u, int pa) {
    for(int v : adj[u]) {
        if(v == pa) continue;
        sub[c[u]] += query(v);
        dfs(v, u);
    }
}


int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    //scanf("%d", &tc);
    while(tc--) {
        scanf("%d", &n);
        for(int i = 1; i <= n; i++) scanf("%d", &c[i]);
        for(int i = 0; i < n - 1; i++) {
            int u, v; scanf("%d%d", &u, &v);
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        pre(1, 1);
        vector<int> last(ord.size(), 0);
        for(int i = 0; i < ord.size(); i++) {
            int u = ord[i];
            if(u > 0) {
                dp[i] = dp[pr[in[u]]] + sz[u];
                pr[i] = last[c[u]];
                last[c[u]] = i;
            }
            else {
                u = -u;
                pr[i] = last[c[u]];
            }
            prp[i] = last[c[p[u]]];
        }
        dfs(1, 1);
        for(int i = 1; i <= n; i++) {
            if(c[1] == i) continue;
            ll res = n - dp[last[i]];
            res = res * (res + 1) / 2;
            sub[i] += res;
        }
        ll tot = 1ll * n * (n + 1) / 2;
        for(int i = 1; i <= n; i++) {
            printf("%lld\n", tot - sub[i]);
        }
    }    
    return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long
const int inf = 100100100100100;
const int mod = 1000000007;

vector<vector<pair<int,int>>> al(100000);
vector<int> dist(100000,inf * -1);
vector<bool> visited(100000,false);

bool bfs(int i,int d){
    
    if(visited[i] && d != dist[i]) return false;
    
    if(visited[i] && d == dist[i]) return true;

    visited[i] = true;
    dist[i] = d; 
    rep(j, 0, al[i].size()){
        if( ! bfs(al[i][j].first, d + al[i][j].second) ) return false;
    }
    
    return true;
}


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

    int n,m;
    cin >> n >> m;

    rep(i,0,m){
        int l,r,d;
        cin >> l >> r >> d;
        l--; r--;
        al[l].push_back(make_pair(r,d));
        al[r].push_back(make_pair(l,-1*d));
    }

    rep(i,0,n){
        if(!visited[i]){
            if( ! bfs(i,0) ){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 15616
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(input()):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
for i in sorted(map(int,t)):i=str(i);print(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]")


Measured memory_bytes: 52940
n=int(input())
f=[[int(i) for i in input().split()] for _ in range(n)]
p=[[int(i) for i in input().split()] for _ in range(n)]
ans=-10000000000000
All=[[] for _ in range(2**10)]
count=0
for bit in range(1<<10):
    pattarn = []
    for j in range(10):
        if (bit & (1<<j)):
            pattarn.append(j)
    All[count]=pattarn
    count+=1

for i in range(len(All)):
    All[i]=tuple(All[i])
All=sorted(list(set(All)),key=len)[1:]
for i in All:
    result=0
    for j in range(n):
        s=0
        for num in i:
            s+=f[j][num]
        res=p[j][s]
        result+=res
    ans=max(ans,result)
print(ans)

Measured memory_bytes: 42860
#include <iostream>
using namespace std;
typedef long long ll;
int ret[100];
int main() {
  ll N;
  cin >> N;
  int n = 0;
  ll r = 1;
  ll t = 1;
  while (N != 0) {
    if (N & t) {
      ret[n] = 1;
      N -= r;
    }
    r = r * (-2);
    t = t << 1;
    n++;
  }
  if (n == 0) n = 1;
  for (int i=n-1; i>=0; i--) {
    cout << ret[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    ll n;cin >> n;
    string s;cin >> s;
    ll l,r;
    while(true){
        ll lcnt=0,rcnt=0;
        bool x=false;
        rep(i,s.size()){
            if(s[i]=='(')lcnt++;
            else rcnt++;
            if(rcnt>lcnt){
                x=true;
                break;
            }
        }
        if(x){
            s='('+s;
            continue;
        }
        l=lcnt;r=rcnt;
        break;
    }
    rep(i,l-r){
        s+=')';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i;
  int N;
  int a, b, c;

  scanf("%d", &N);

  for (i = 0; i < N; i++) {
    scanf("%d %d %d", &a, &b, &c);
    a *= a;
    b *= b;
    c *= c;
    if(a == b + c || b == a + c || c == a + b) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}



Measured memory_bytes: 2040
/*----------------------------------------------------*
* लेखक --> अमित सिंह
* संस्थान --> राष्ट्रीय प्रौद्योगिकी संस्थान, कुरुक्षेत्र
*-----------------------------------------------------*/
   #include <bits/stdc++.h>
   using namespace std;
   #define ll long long
   #define w(t) int t; cin>>t; while(t--)
   #define fo(i,n) for(int i=0;i<n;i++)
   #define endl "\n" 
   #define MOD 1000000007
   void Tez(){
      ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
   }
   int main(){
      Tez();
      string s;
      cin>>s;
      if(s[s.length()-1]=='s'){
         cout<<s<<"es";
      }else{
         cout<<s<<"s";
      }
      return 0;
   }



Measured memory_bytes: 3640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long h = sc.nextLong();
    long[] a = new long[n];
    long[] b = new long[n];
    int k = 0;
    long ma = 0;
    long mb = Long.MAX_VALUE;
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
      b[i] = sc.nextLong();
      if(a[i] >= ma) {
        ma = a[i];
      }
    }
    ArrayList<Long> list = new ArrayList<Long>();
    for(int i = 0; i < n; i++) {
      if(b[i] > ma) list.add(b[i]);
    }
    Collections.sort(list);
    long ans = 0;
    int p = list.size() - 1;
    while(h > 0) {
      ans++;
      if(p >= 0) {
        h -= list.get(p);
        p--;
      } else {
        h -= ma;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 85524
'''
.append(要素) リストに要素を追加 
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul


data = [int(s) for s in stdin.readline().rstrip().split()]
data.sort()
if data[0] == data[1] and data[0] == data[2]:
    print('No')
elif data[0] != data[1] and data[2] != data[1] and data[0] != data[2]:
    print('No')
else:
    print('Yes')


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

int main()
{
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
  long long ab[2], cd[2], l[4];
  cin >> ab[0] >> ab[1] >> cd[0] >> cd[1];
  for(int i=0; i<4; i++){
    l[i] = ab[i/2] * cd[i%2];
  }
  long long maxnum = l[0];
  for(int i=1; i<4; i++){
    if(maxnum < l[i]) maxnum = l[i];
  }
  cout << maxnum << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
//#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define INF (int)1e15
#define MOD 1000000007
//#define N 12
#define sz 1000*1000

//int mp[110][110] = {0};

 int main(){

 string a,b;
 cin>>a>>b;

 int ans = INT_MAX;

   int n = a.length();
   int n2 = b.length();

  for(int i=0;i<=n-n2;i++){
    int cnt=0;
      for(int j=0;j<n2;j++){

       if(a[i+j] != b[j]){
            cnt++; }
      }
      ans = min(ans,cnt);
  }

  cout<<ans<<endl;

 return 0;
 }

Measured memory_bytes: 3632
# include <stdio.h>

int main(void){
	int i, n , max ,min, x, s;
	while(1){
	scanf("%d",&n);
	if (n == 0)
		break;
	else{
	x = 0;
	max = 0;
	min = 10000;
	for(i=0;i < n; i++){
		scanf("%d", &s);
		if(max < s){
			max = s;
		}
		if(min > s){
			min = s;
		}
		x += s;
		}
	printf("%d\n" ,(x - max - min)/(n - 2));
	}
	}
	
	return 0;
}


Measured memory_bytes: 2020
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

x, y = Is()
print(x+y//2)

Measured memory_bytes: 65260
fun next() = readLine()!!
        fun nextInt() = next().toInt()
        fun nextLong() = next().toLong()
        fun nextDouble() = next().toDouble()
        fun nextList() = next().split(" ")
        fun nextIntList() = next().split(" ").map{ it.toInt() }
        fun nextLongList() = next().split(" ").map{ it.toLong() }
        fun nextDoubleList() = next().split(" ").map{ it.toDouble() }
        fun nextListNull() = next().split("").filter { it != "" }.map{ it.toInt() }

        /* fun main(args: Array<String>){
          var a: MutableList<Int> = nextIntList().toMutableList()
          println("$a")
        } */

        // template
        /*
        A 500
        B 100
        C 50
        X 合計
         */

        // input
        /*
        30
        40
        50
        6000
         */

        // output
        /*
        213
         */

        fun main(args: Array<String>){
            val output = 0
            val n = nextInt()
            val remainder = 10000 - n

            println(remainder % 1000)
        }

Measured memory_bytes: 34436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	ll n, m;
 	cin >> n >> m;
 	ll c = 2*n + m;
 	
 	if(c/4 > n){
 		cout << c/4 << endl;
 	} else {
 		cout << min(n, m/2) << endl;
 	}
 	return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--){solve();}
#define test2()            int x;cin >> x;for(int i=1;i<=x;i++){cout << "Case #" << i << " : ";solve();}
#define watch(x)           cout << (#x) << " is " << (x) << endl
using namespace std;


/* Mathematical Functions */
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);

const int inf = (int)1e17;
const int N = (int)3e5+5;

int32_t main(){

	
	FASTIO;
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k <= a){
		cout << k << endl;
	}
	else if(k <= a+b){
		cout << a << endl;
	}
	else{
		cout << a-(k-(a+b)) << endl;
	}
    return 0;

}
int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}
 
int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}
 
int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}
 
bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}

Measured memory_bytes: 3704
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    println!("{}",if a[0]==a[2]{"Yes"}else{"No"})
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h,w;
    cin>>h>>w;
    string a[h];
    vector<int>x[h];
    vector<int>y[w];

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

    for (int i = 0; i < h; ++i) {
        x[i].push_back(-1);
        x[i].push_back(w);
    }

    for (int i = 0; i < w; ++i) {
        y[i].push_back(-1);
        y[i].push_back(h);
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(a[i][j]=='#')
            {
                x[i].push_back(j);
                y[j].push_back(i);
            }
        }
    }


    for (int i = 0; i < h; ++i) {
        sort(x[i].begin(),x[i].end());
    }

    for (int i = 0; i < w; ++i) {
        sort(y[i].begin(),y[i].end());
    }

    int dp1[h][w]={};
    int dp2[h][w]={};
    int l=0,r=0;

    for (int i = 0; i < h; ++i) {
        l=0;
        r=1;
        for (int j = 0; j < w; ++j) {
            if(a[i][j]=='.')
            {
                dp1[i][j]=x[i][r]-x[i][l]-1;
            }
            else
            {
                l++;
                r++;
            }
        }
    }

    for (int i = 0; i < w; ++i) {
        l=0;
        r=1;
        for (int j = 0; j < h; ++j) {
            if(a[j][i]=='.')
            {
                dp2[j][i]=y[i][r]-y[i][l]-1;
            }
            else
            {
                l++;
                r++;
            }
        }
    }

    int mx=0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(a[i][j]=='.')
            {
                mx=max(mx,dp1[i][j]+dp2[i][j]-1);
            }
        }
    }

    cout<<mx;
}

Measured memory_bytes: 69888
S = input()

def solve(s, n=0, tight=True, value=""):
	if n == len(s):
		while value and value[0] == "0":
			value = value[1:]
		if set("753") == set(value):
			#print(value)
			return 1
		return 0
	hi = int(s[n]) if tight else 9
	c = 0
	for i in range(hi + 1):
		if i in [7, 5, 3, 0]:
			c += solve(s, n + 1, tight and not(i < hi), value + str(i))
	return c

print(solve(S))


Measured memory_bytes: 3064