akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n,x,d;
    cin>>n>>x>>d;
    if(d==0){
        if(x==0) cout<<1<<en;
        else cout<<n+1<<en;
        return;
    }

    map<ll,vec<P>> mp;
    if(d<0){
        d=-d;
        x=-x;
    }
    for(ll a=0;a<=n;++a){
        ll t=a*abs(x)%d;
        if(x<0) t=(d-t)%d;
        ll base=(a*x-t)/d;
        ll l = a*(a-1)/2;
        ll r = n*(n-1)/2 - (n-a)*(n-a-1)/2;
        mp[t].push_back(make_pair(l+base,r+base));
    }

    ll ans=0;
    for(auto i:mp){
        vec<P> lr=i.second;
        sort(all(lr));
        ll l=lr[0].first;
        ll r=lr[0].second;
        REP(j,lr.size()){
            if(lr[j].first<=r){
                chmax(r,lr[j].second);
            }else{
                ans+=r-l+1;
                l=lr[j].first;
                r=lr[j].second;
            }
        }
        ans+=r-l+1;
    }
    cout<<ans<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 22144
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**5+1)
def dfs(p):
  for edge in g[p]:
    if x[edge[0]] is not None:
      if x[edge[0]]-x[p]!=edge[1]:
        print('No')
        exit()
    else:
      x[edge[0]]=x[p]+edge[1]
      dfs(edge[0])
n,m=map(int,input().split())
g=[[] for i in range(n)]
for i in range(m):
  u,v,c=map(int,input().split())
  g[u-1].append((v-1,c))
  g[v-1].append((u-1,-c))
x=[None]*n
for i in range(n):
  if x[i]==None:
    x[i]=0
    dfs(i)
print('Yes')


Measured memory_bytes: 128912
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] B = new int[N-1];
		for(int i=0;i<N-1;i++) {
			B[i]=sc.nextInt();
		}
		sc.close();
		if(N==1) {
			System.out.println(2*B[0]);
		} else {
			int ans = 0;
			for(int i=0;i<=N-3;i++) {
				ans += Math.min(B[i], B[i+1]);
			}
			ans += B[0];
			ans += B[N-2];
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 36028
#!/usr/bin/env python3
import sys
from itertools import product
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    H,W,K = MAP()
    S = [input() for _ in range(H)]
    accum_s = [[0]*W for _ in range(H)]

    for i in range(H):
        for j in range(W):
            if j == 0:
                accum_s[i][j] = int(S[i][j])
            else:
                accum_s[i][j] = accum_s[i][j-1]+int(S[i][j])

    answer = 10**9
    for p in product([0,1],repeat=H-1):
        one_index = [i for i in range(H-1) if p[i] == 1]
        one_index.append(H-1)
        score = 0
        prev_j = -1
        outflag = False

        for j in range(W):
            if outflag:
                break
            prev_i = 0
            for slice_index in one_index:
                group_count = 0
                
                while prev_i <= slice_index:
                    if prev_j == -1:
                        group_count += accum_s[prev_i][j]
                    else:
                        group_count += accum_s[prev_i][j] - accum_s[prev_i][prev_j]

                    prev_i += 1
                
                if group_count > K:
                    if prev_j == j-1:
                        outflag = True
                    score += 1
                    prev_j = j-1
                    break
        else:
            if answer > score+len(one_index)-1:
                answer = score+len(one_index)-1
    
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42076
#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;
}

bool dp[5005][5005];
bool dp2[5005][5005];

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    dp[0][0] = true;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        for(int j = 0; j < k; ++j){
            if(!dp[i][j])   continue;
            dp[i + 1][j] = true;
            if(j + a[i] < k)    dp[i + 1][j + a[i]] = true;
        }
        // for(int j = 0; j < k; ++j){
        //     cerr << dp[i + 1][j] << ' ';
        // } cerr << endl;
    }

    dp2[n][0] = true;
    for(int i = n - 1; i >= 0; --i){
        for(int j = 0; j < k; ++j){
            if(!dp2[i + 1][j])  continue;
            dp2[i][j] = true;
            if(j + a[i] < k)    dp2[i][j + a[i]] = true;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(a[i] >= k){
            ++ans;
            continue;
        }
        vector<int> S(k + 1);
        S[0] = 0;
        for(int j = 0; j < k; ++j)  S[j + 1] = S[j] + dp[i][j];
        // for(int j = 0; j < k; ++j)  cerr << dp[i][j] << ' ';
        // cerr << ' ';
        // for(int j = 0; j <= k; ++j) cerr << S[j] << ' ';
        // cerr << endl;
        bool ok = false;
        for(int j = 0; j < k; ++j){
            if(!dp2[i + 1][j])  continue;
            int L = max(0, k - j - a[i]);
            int R = max(0, k - j);
            // cerr << "L:" << L << ",R:" << R << endl;
            if(S[R] - S[L] > 0){
                ok = true;
                break;
            }
        }
        if(ok)  ++ans;
        // cerr << "i:" << i << ' ';
        // cerr << "ans:" << ans << endl;
    }
    ans = n - ans;
    cout << ans << endl;
}

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

using ll_t = long long;

int main() {
  ll_t n;
  std::cin >> n;
  int sqrt = std::sqrt(n + 0.5);
  ll_t ans = 0;
  for (int i = sqrt; i > 0; --i) {
    if (n % i == 0) {
      ans = n / i + i - 2;
      break;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }
    
}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }
        
        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}

fn main(){
    let r: i32 = read_as_vec()[0];

    println!("{}", 3*r*r);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int n;
	cin >> n;

	loop(i,1,n)
	{
		for(int j = i; j < n; j += i)
		{
			A[j]++;
		}
	}

	int ans = 0;

	loop(i,1,n+1)ans += A[i];

	cout << ans;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 11456
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main(void){
   long N,X;
   cin>>N>>X;
   long num1[N];
   for(int i=0;i<N;i++){
       cin>>num1[i];
   }
   long num2[N];
   for(int i=0;i<N;i++){
       int a=num1[i]-X;
       num2[i]=std::abs(a);
   }
   long min=num2[0];
   for(int i=1;i<N;i++){
       if(num2[i]<min) min=num2[i];
   }
   long check=0;
   long max=0;
  
    for(int i=1;i<=min;i++){
        if(min%i==0){  check=0;
               for(int j=0;j<N;j++){
                   if(num2[j]%(min/i)==0) check++;
               }
               if(check==N){ max=min/i; break;}
           }
       }
    cout<<max; 
   return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string str;
	string r = "yuiophjklnm";
	bool rflag = false;

	while (true) {
		cin >> str;
		if (str == "#")break;
		int ans = 0;
		rflag = false;
		if (r.find(str[0]) != string::npos) rflag = true;

		for (int i = 1; i < str.length(); i++) {
			//cout << rflag << endl;
			if (r.find(str[i]) != string::npos) {
				if (rflag == false) {
					ans++;
					rflag = true;
				}
			}
			else {
				if (rflag == true) {
					ans++;
					rflag = false;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

const int INF = 100000000;

const int tetra_size = 185;
int tetra[tetra_size];
int tri[tetra_size];
void settetra(){
	tetra[0] = 0;
	tri[0] = 0;
	for(int i = 1; i < tetra_size; i++){
		tri[i] = tri[i-1] + i;
		tetra[i] = tetra[i-1] + tri[i];
	}
}

int dp[1000001];
int dpodd[1000001];
void setdp(){
	fill(dp, dp+1000001, INF);
	dp[0] = 0;
	fill(dpodd, dpodd+1000001, INF);
	dpodd[0] = 0;
	for(int i = tetra_size ; i >= 1; i--){
		for(int j = 0; j + tetra[i] < 1000001; j++ ){
			if(dp[j] == INF) continue;
			dp[j+tetra[i]] = min(dp[j]+1, dp[j+tetra[i]]);
			if(tetra[i]%2 == 1) dpodd[j+tetra[i]] = min(dpodd[j]+1, dpodd[j+tetra[i]]);
		}
	}
}

int main(){
	settetra();
	setdp();
	int n;
	while(cin >> n, n){
		//cout << tetra[n]  << endl;
		cout << dp[n] << ' ' <<  dpodd[n]  << endl;
	}

	return 0;
}

Measured memory_bytes: 8972
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int r,g,b,n;
	cin >>r>>g>>b>>n;
	int ans=0;
	for(int a1=0;a1<1+(n/r);a1++){
		for(int a2=0;a2<1+(n-a1*r)/g;a2++){
			if(n-a1*r-a2*g >=0){
				if ((n - a1 * r - a2 * g)%b==0){
					ans++;
				}
			}	
		}
	}
	cout <<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int main() {
    // source
    int n;
    cin >> n;
    ll ans;
    if (n % 2 == 0) {
        ans = n;
    } else {
        ans = 2 * n;
    }
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    
    if(a >= b) cout << "delicious" << endl;
    else{
        if(b - a <= x) cout << "safe" << endl;
        else cout << "dangerous" << endl; 
    }


    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;
	std::vector<int64_t> a(N);
	for (int64_t i = 0; i < N; i++) {
		std::cin >> a[i];
	}

	int64_t ans;
	for (int64_t i = 0; i < N; i++) {
		while (true)
		{
			if (a[i] % 2 == 0) {
				ans++;
				a[i] /= 2;
			} else {
				break;
			}
		}	
	}
	std::cout << ans << std::endl;
}

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


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 200 * 1000 + 13;

int n;
int a[N], b[N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n)
		scanf("%d", &a[i]);
	forn(i, n)
		scanf("%d", &b[i]);
	return true;
}

void solve() {
	set<pt, greater<pt>> mx;
	forn(i, n) mx.insert(mp(b[i], i));
	
	li cnt = 0;
	while (!mx.empty()){
		int i = mx.begin()->y;
		mx.erase(mx.begin());
		if (b[i] == a[i])
			continue;
		if (b[i] < a[i]){
			puts("-1");
			return;
		}
		int sum = b[(i - 1 + n) % n] + b[(i + 1) % n];
		int req = a[i];
		if (b[(i - 1 + n) % n] > a[(i - 1 + n) % n])
			req = max(req, b[(i - 1 + n) % n]);
		if (b[(i + 1) % n] > a[(i + 1) % n])
			req = max(req, b[(i + 1) % n]);
		if (req > b[i]){
			puts("-1");
			return;
		}
		int cur = (b[i] - req + sum - 1) / sum;
		if (cur == 0){
			puts("-1");
			return;
		}
		cnt += cur;
		b[i] -= sum * cur;
		mx.insert(mp(b[i], i));
	}
	
	printf("%lld\n", cnt);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ( A + B > C + D) {
    cout << "Left" << endl;
  }
  else if ( A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
// atcoder/abc136/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b, c;
  while (cin >> a >> b >> c) {
    cout << max(0, c - (a - b)) << endl;
  }

  return 0;
}


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

int main(){
   int A = 0;
   int retu;
   cin >> retu;
   vector<int> a;
   a={100000,10000,1000,100,10,1};
   for(int i=0;i<6;i++){
      int b = retu / a.at(i);
      if(b == 1){
         A++;
      }
      retu = retu - b * a.at(i);
   }
   cout << A<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int N;
  cin>>N;
  vector <int> A(N),B(N);
  int ans=0;
  for (int i=0;i<N;i++) cin>>A[i];
  for (int i=0;i<N;i++) cin>>B[i];
  for (int i=0;i<N;i++){
    int tmp=0;
    for(int j=0;j<=i;j++){
      tmp+=A[j];
    }
    for(int j=i;j<N;j++){
      tmp+=B[j];
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 10;
int p[maxN];
int get(int a) {
  if (a == p[a]) return a;
  return p[a] = get(p[a]);
}
bool unite(int a, int b) {
  a = get(a);
  b = get(b);
  if (a == b) return false;
  if (rand() & 1) swap(a, b);
  p[a] = b;
  return true;
}
vector < int > by[maxN];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
   	int cnt;
    cin >> cnt;
    for (int j = 0; j < cnt; j++) {
    	int x;
      	cin >> x;
      	by[x].emplace_back(i);
    }
  }
  for (int i = 1; i <= n; i++) p[i] = i;
  int r = 0;
  for (int i = 1; i <= m; i++) {
   	 for (int c = 0; c + 1 < by[i].size(); c++) {
     	r += unite(by[i][c], by[i][c + 1]);
     }
  }
  cout << ((r == (n - 1)) ? "YES" : "NO");
}

Measured memory_bytes: 7932
X, Y = map(int, input().split())
m = [300000, 200000, 100000]
ans = 0
if X <= 3:
    ans += m[X - 1]
if Y <= 3:
    ans += m[Y - 1]
if X == 1 and Y == 1:
    ans += 400000
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll n;
    cin >> n;
    if(n < 1000){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int A, B, M;
    cin>>A>>B>>M;
    vector<int> a(A), b(B);
    int r, ma,mb;
    ma = mb = 1e6;
    for (auto& i : a) cin >> i, ma=min(ma,i);
    for (auto& i : b) cin >> i, mb=min(mb,i);
    r = ma + mb;
    for (int i = 0; i < M; ++i) {
        int x,y,c;
        cin>>x>>y>>c;
        r = min(r, a[x-1]+b[y-1]-c);
    }
    cout << r;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
//map<key,value>

int main(){
  int n,ans=0;
  cin >> n;
  vector<long long>a(n);
  map<long long,long long>mp;
  for(int i=0;i<n;i++){
    cin >> a[i];mp[a[i]]++;
  }
  map<long long,bool>flag;
  for(int i=0;i<n;i++){
    if(flag[a[i]]==false){
        if(mp[a[i]]%2==1)
            ans++;
        flag[a[i]] = true;
    }
  }
  cout << ans;
}


Measured memory_bytes: 13568
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> curr_max(4, 0), v(4, 0);

    while (n --) {
        vector<int> new_max(4, 0);

        for (int i = 1; i < 4; i ++) {
            cin >> v[i];
            for (int j = 1; j < 4; j += 1) {
                if (i != j)
                    new_max[i] = max(new_max[i], v[i] + curr_max[j]);
            }
        }
        curr_max = new_max;
    }
    cout << max(max(curr_max[1], curr_max[2]), curr_max[3]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

const int MAXN = 100010;

inline int sgn(int x) { return !x ? 0 : ( x > 0 ? 1 : -1 ); }

int n, a[MAXN], ans, type;

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d", &n );
	for( int i = 1 ; i <= n ; i++ ) scanf( "%d", &a[ i ] );
	for( int i = 2 ; i <= n ; i++ )
	{
		if( a[ i ] == a[ i - 1 ] ) continue;
		if( sgn( a[ i ] - a[ i - 1 ] ) == type ) ans++, type = 0;
		else if( !type ) type = -sgn( a[ i ] - a[ i - 1 ] );
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 640
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys

sys.setrecursionlimit(1000000)

S1 = raw_input()
S2 = raw_input()

m = {}

for i in range(len(S1)):
    lst = [0 for j in range(26)]
    for j in range(i, len(S1)):
        lst[(ord(S1[j]) - ord('a'))] += 1
        m[hash(tuple(lst))] = j - i + 1

ans = 0

for i in range(len(S2)):
    lst = [0 for j in range(26)]
    for j in range(i, len(S2)):
        lst[(ord(S2[j]) - ord('a'))] += 1
        t = hash(tuple(lst))
        if t in m:
            ans = max(ans, m[t])

print ans


Measured memory_bytes: 852248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int p[105];
int num[105];
int main()
{
    int x,n;
    cin>>x>>n;
    for(int i=1; i<=n; i++)
        cin>>p[i];
    if(n==0)                                  //n=0时
        cout<<x<<endl;
    else
    {
        sort(p+1,p+1+n);
        memset(num,0,sizeof(num));
        for(int i=1; i<=n; i++)             //将所有出现过的数标记
            num[p[i]]=1;
        if(num[x]==0)
            cout<<x<<endl;
        else
        {
            int ans1=-1,ans2=102;
            for(int i=x-1; i>=0; i--) //优先向下找，下限0
                if(num[i]==0)
                {
                    ans1=i;
                    break;
                }
            for(int i=x+1; i<=101; i++)   //向上找,封顶101
                if(num[i]==0)
                {
                    ans2=i;
                    break;
                }
            if(x-ans1>ans2-x)
                cout<<ans2<<endl;
            else if(x-ans1<ans2-x)
                cout<<ans1<<endl;
            else if(x-ans1==ans2-x)
                cout<<ans1<<endl;
        }
    }
}

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

#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair


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

    ll n;
    cin>>n;
    ll arr[n-1],i;
    for(i=0;i<n-1;i++){
        cin>>arr[i];
    }
    ll val[n],ans=0;
    val[0]=arr[0];
    ans+=val[0];
    for(i=0;i<n-1;i++){
        if(i<n-1)
        val[i+1]=min(arr[i],arr[i+1]);
        else
        val[i+1]=arr[i];
    ans+=val[i+1];
    }
    cout<<ans;

    return 0;  
}

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


using namespace std;
#define CIN ios_base::sync_with_stdio(0)
#define mx 200007
#define i64 long long

i64 arr[mx],tree[3*mx],lazy[3*mx];

void BuildTree(i64 node, i64 b, i64 e)
{
    if(b==e)
    {
        tree[node]=arr[b];
        return;
    }

    i64 mid=(b+e)/2;
    i64 left=2*node,right=2*node+1;

    BuildTree(left,b,mid);
    BuildTree(right, mid+1 , e);

    tree[node]=max(tree[left],tree[right]);
}

i64 query(i64 node, i64 b, i64 e, i64 l, i64 r)
{
	if(b>r || b>e || e<l)
	{
		return INT_MIN; //return 0 as sum;
	}

	if(lazy[node]!=0)
	{
		tree[node]+=(e-b+1)*lazy[node];

		if(b!=e)
		{
			lazy[node*2]+=lazy[node];
			lazy[node*2+1]+=lazy[node];
		}
		lazy[node]=0;
	}

	if(b>=l && e<=r)
	{
		return tree[node];
	}

	i64 mid=(b+e)/2,left=node*2,right=node*2+1;
	i64 lft=query(left, b, mid, l, r);
	i64 rgt=query(right, mid+1, e, l, r);

	return max(lft,rgt);

}




void updateRange(i64 node, i64 b, i64 e, i64 l, i64 r, i64 value)
{
	if(lazy[node]!=0)
	{
		tree[node]+=(e-b+1)*lazy[node];

		if(b!=e)
		{
			lazy[node*2]+=lazy[node];
			lazy[node*2+1]+=lazy[node];
		}
		lazy[node]=0;
	}



	if(b>e || b>r || e<l)
	{
		//start > end or start > r or end < l ....out of range
		return;
	}

	if(b>=l && e<=r)
	{
		//fully cover range [l....r]
		tree[node]+= (e-b+1)*value;

		if(b!=e)
		{
			// not a leaf
			lazy[node*2]+=value;
			lazy[node*2+1]+=value;
		}
		return; //why ? dud

	}

	i64 mid = (b+e)/2,left=node*2,right=node*2+1;

	updateRange(left, b, mid, l, r, value);
	updateRange(right, mid+1, e, l, r, value);

	tree[node]=max(tree[left],tree[right]);

}




int main()
{
	CIN;
	i64 t,qu,q,p,a;
	i64 val;
	int n;
	cin >> n;
	for(int i=1 ; i<=n ; i++) cin >> arr[i];

	BuildTree(1,1,n);
    memset(lazy, 0, sizeof lazy);

    for(int i=1 ; i<=n ; i++){
        int idx=i;
        updateRange(1,1,n,idx,idx,-arr[idx]);

        i64 left = query(1,1,n,1,idx-1);
        i64 right = query(1,1,n,idx+1,n);
        i64 ans= max(left, right);
        cout << ans << endl;
        updateRange(1,1,n,idx,idx,arr[idx]);

    }
	return 0;
}


Measured memory_bytes: 12544
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<string> separate(const string& S){
	vector<string> res;
	int prev = 0, sum = 0;
	for(int i=0;i<S.size();i++){
		sum += (S[i] == 'a' ? 1 : -1);
		if(sum == 0){
			res.push_back(S.substr(prev, i - prev + 1));
			prev = i + 1;
		}
	}
	return res;
}

string solvePart(const string& S){
	string res = "";
	if(S[0] == 'a'){
		vector<int> dp(S.size()+1, 0);
		vector<int> posB;
		for(int i=0;i<S.size();i++){
			if(S[i] == 'b') posB.push_back(i);
		}
		int cntA = 0;
		for(int i=0;i<S.size();i++){
			dp[i+1] = max(dp[i], dp[i+1]);
			if(S[i] == 'a'){
				dp[posB[cntA]] = max(dp[posB[cntA]], dp[i]+1);
				++cntA;
			}
		}
		for(int i=0;i<dp.back();i++) res += "ab";
	} else {
		vector<int> order(S.size());
		int cnt[2] = {0, 0};
		for(int i=0;i<S.size();i++){
			order[i] = cnt[S[i]-'a'];
			cnt[S[i]-'a']++;
		}
		for(int i=S.size()/2-1;i>=0;i--){
			string tmp = "";
			for(int j=0;j<S.size();j++){
				if(order[j] >= i) tmp += S[j];
			}
			res = max(res, tmp);
		}
	}
	return res;
}

int main(){
	int N;
	while(cin >> N){
		string S; cin >> S;
		vector<string> vs = separate(S);
		for(auto& s : vs) s = solvePart(s);
		string res = "";
		for(int i=vs.size()-1;i>=0;i--){
			if(res < vs[i] + res) res = vs[i] + res;
		}
		cout << res << endl;
	}
}


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

#define mp make_pair
#define pb push_back

#define int int64_t

const int MOD = 1e9+7;
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    char a,b;
    cin>>a>>b;
    string la="",lb="";
    for(char i='0';i<a;i++) {
        la+=b;
    }   

    for(char i='0';i<b;i++)
        lb+=a;

    cout<<min(la,lb);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){

  ios::sync_with_stdio(false);
  int N, M;   cin >> N >> M;
  vector<int> A(N);
  vector<pair<int , int>> pairs(M);
  for(int i = 0 ; i < N ; i++)	cin >> A[i];
  for(int i = 0 ; i < M ; i++)	cin >> pairs[i].second >> pairs[i].first;

  sort(pairs.begin() , pairs.end());
  sort(A.begin() , A.end(), greater<int>() );
  int count = N - 1;
  bool endFlag = false;
  //pairの大きいほうから指す
  for(int i = M - 1 ; 0 <= i && !endFlag && 0 <= count ; i--){

    for(int j = 0 ; j < pairs[i].second && 0 <= count ; j++){

      if(pairs[i].first < A[count]){
		endFlag = true;
		break;
      }
      
	A[count] = pairs[i].first;
	count--;
    }

  }

  long long ans = 0;
  for(int i = 0 ; i < N ; i++)  ans += A[i];

  cout << ans << endl;


  return 0;
}

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

int main() {
    int N; cin >> N;
    int cnt = 0, ans = 0, tmp;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        if (i == 0) {
            tmp = x;
            continue;
        }
        if (tmp >= x) {
            cnt++;
            ans = max(ans, cnt);
        } else cnt = 0;
        tmp = x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;

#define rep(i,n) for(ll (i) = 0; (i) < (n); (i)++)

int main(void){
    string S;
    cin >> S;
    int pmt[3];

    for(int bit = 0;bit<(1<<3);bit++){
        int ans = S[0] - '0';
        rep(i,3){
            if (bit & (1<<i)){
                ans += S[i+1] - '0';
                pmt[i] = 1;
            }
            else {
                ans -= S[i+1] - '0';
                pmt[i] = 0;
            }
        }
        //cout << ans << endl;
        if (ans == 7) break;
    }

    rep(i,4){
        cout << S[i];
        if (i < 3){
            if(pmt[i]) cout << "+";
            else cout << "-";
        }
    }
    cout << "=7" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static int[] xs = {1, 0, -1, 0};
	public static int[] ys = {0, 1, 0, -1};
	public static int[][] w;
	public static boolean[][] bools;
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
    	int n = Integer.parseInt(sc.nextLine());
    	int[] p = new int[n*n];
    	w = new int[n+2][n+2];
    	bools = new boolean[n+2][n+2];
    	int roop = n+2 -(n+2)/2;
    	for(int i = 1; i < roop; i++) {
    		for(int j = i; j < roop; j++) {
    			w[i][j] = i;
    			w[i][n+1-j] = i;
    			w[n+1-i][j] = i;
    			w[n+1-i][n+1-j] = i;
    			w[j][i] = i;
    			w[j][n+1-i] = i;
    			w[n+1-j][i] = i;
    			w[n+1-j][n+1-i] = i;
    		}
    	}
    	for(int i = 0; i < n*n; i++) {
    		p[i] = sc.nextInt() - 1;
    	}
    	int sum = 0;
    	for(int i = 0; i < n*n ; i++) {
    		int x = p[i] % n + 1;
    		int y = p[i] / n + 1;
    		int k = w[x][y];
    		sum += k;
    		bools[x][y] = true;
    		update(x, y);
    	}
    	
    	System.out.println(sum - n*n);
    }
	
	private static void update(int x, int y){
		int z = w[x][y];
		if(!bools[x][y]) {
			z++;
		}
		for(int i = 0; i < 4; i++){
			int x2 = x + xs[i];
			int y2 = y + ys[i];
			if(w[x2][y2] > z) {
				w[x2][y2] = z;
				update(x2, y2);
			}
		}
	}
}

Measured memory_bytes: 60404
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<unordered_set>
#include<string.h>
#include<unordered_map>
#include<numeric>
#include <iomanip>
#include<string.h>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;

#define FOR(i,N) for(int i=0;i<N;i++)

ll mod=1e9+7;


int main() {
    int N,M,K;
    cin>>N>>M>>K;
    for(int i=0;i<=M;i++){
        for(int j=0;j<=N;j++){
            if(N*i+M*j-i*j*2==K){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int input() {
	int r;
	cin >> r;
	//scanf("%lld", &r);
	return r;
}
signed main() {
	string s; cin >> s;
	cout << (s[0] == '7' || s[1] == '7' || s[2] == '7' ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int x[5];
    for(int i = 0;i<5;i++){
      cin>>x[i];
      if(x[i] == 0){
        cout<<i+1;
        return 0;
      } 
    }
    return 0;
}

Measured memory_bytes: 3160
#include<iostream>
using namespace std;
int main(){
    int A[4] = {0};
    int Asum = 0;
    int B[4] = {0};
    int Bsum = 0;
    for(int i = 0;i < 4;i++){
        cin >> A[i];
        Asum+=A[i];
    }
    for(int i = 0;i < 4;i++){
        cin >> B[i];
        Bsum+=B[i];
    }
    if(Asum >= Bsum){
        cout << Asum << endl;
    }
    else if(Asum < Bsum){
        cout << Bsum << endl;
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    ll s; cin >> s;
    ll x2 = 1000000000;
    ll b = ceil((long double)s / (long double)x2);
    ll a = (x2 - s%x2)%x2;
    ll ans[] = {0, 0, x2, 1, a, b};
    rep(i, 6){
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int n;
    scanf("%d", &n);
    int t[13];
    rep(i, 13) t[i] = 0;
    ++t[0];
    rep(i, n){
        int d = 0;
        scanf("%d", &d);
        ++t[d];
    }
    vector<int> a, b;
    rep(i, 13){
        if(t[i] > 2){
            printf("%d\n", 0);
            return 0;
        }
        if(t[i] == 2){
            a.push_back(i);
            a.push_back(-i);
        }
        if(t[i] == 1) b.push_back(i);
    }
    int ans = 0;
    int s = 30;
    rep(i, a.size())For(j, i+1, a.size()) s = min(s, min(abs(a[i]-a[j]), 24-abs(a[i]-a[j])));
    rep(i, 1<<b.size()){
        int tmp = min(30, s);
        rep(j, b.size())if((i>>j)&1) b[j] *= -1;
        rep(j, b.size()){
            For(k, j+1, b.size()) tmp = min(tmp, min(abs(b[k]-b[j]), 24-abs(b[k]-b[j])));
            rep(k, a.size()) tmp = min(tmp, min(abs(a[k]-b[j]), 24-abs(a[k]-b[j])));
        }
        ans = max(ans, tmp);
        rep(j, b.size()) b[j] = abs(b[j]);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: usize = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let M: usize = sc.get();
    let mut adj = vec![Vec::new(); N];
    for _ in 0..M {
        let a: usize = sc.get::<usize>()-1;
        let b: usize = sc.get::<usize>()-1;
        adj[a].push(b);
        adj[b].push(a);
    }
    let mut q = VecDeque::new();
    q.push_front(0);
    let mut cost = vec![INF; N];
    cost[0] = 0;
    let mut prev = vec![0; N];
    while let Some(now) = q.pop_back() {
        for &n in &adj[now] {
            if cost[n] != INF {
                continue;
            }
            cost[n] = cost[now] + 1;
            prev[n] = now;
            q.push_front(n);
        }
    }
    println!("Yes");
    for i in 1..N {
        println!("{}", prev[i]+1);
    }
}


Measured memory_bytes: 12648
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main() {
    int i, j, n, max_a=0;
    long long int a[110];
    cin >> n;
    for(i=0; i<n; i++) cin >> a[i];
    
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            if(max_a < abs(a[i]-a[j])) {
                max_a = abs(a[i]-a[j]);
            }
        }
    }
    
    cout << max_a << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

vector<string> split(string s) {
  string t = "";
  rep(i,(int)s.size()) {
    t += s[i];
    if( !( i + 1 < (int)s.size() && isdigit(s[i]) && isdigit(s[i+1]) ) ) t += " ";

  }
  stringstream ss(t);
  vector<string> vec;
  while( ss >> t ) vec.push_back(t);
  return vec;
}

char check(vector<string> vs, vector<string> vt) {
  int n = min(vs.size(),vt.size());
  rep(i,n) {
    if( isdigit(vs[i][0]) && isdigit(vt[i][0]) ) {
      long long is = atoll(vs[i].c_str());
      long long it = atoll(vt[i].c_str());
      if( is != it ) return ( is < it ) ? '+' : '-';
    } else if( isdigit(vs[i][0]) || isdigit(vt[i][0]) ) {
      return isdigit(vs[i][0]) ? '+' : '-';
    } else {
      if( vs[i] != vt[i] ) return ( vs[i] < vt[i] ) ? '+' : '-';
    }
  }
  if( vs.size() <= vt.size() ) return '+';
  return '-';
}

int main() {
  int n;
  cin >> n;
  string s,t;
  cin >> s;
  vector<string> vs = split(s);
  rep(i,n) {
    cin >> t;
    cout << check(vs,split(t)) << endl;
  }
  return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N; 
    int ans = 0;
    REP(i, 0, N) {
        int a; cin >> a;
        if (i % 2 == 0 && a % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

int c[200200] = {};
void tasu(int suuji) {
	while (suuji < 200200) {
		c[suuji]++;
		suuji += suuji & -suuji;
	}
}
int kazoeru(int suuji) {
	int output = 0;
	while (suuji != 0) {
		output += c[suuji];
		suuji -= suuji & -suuji;
	}
	Would you please return output;
}
int main() {
	int N;
	int a[100000];
	cin >> N;
	rep(i, N) cin >> a[i];

	int l = 0, r = 1000000000;
	int b[100000];
	while (l != r) {
		int mid = (l + r + 1) / 2;
		rep(i, N) {
			if (a[i] >= mid) b[i] = 1;
			else b[i] = -1;
		}
		int atai = 100100;
		tasu(atai);
		long long goukei = 0;
		rep(i, N) {
			atai += b[i];
			goukei += kazoeru(atai);
			tasu(atai);
		}
		memset(c, 0, sizeof(c));
		if (goukei >= (1ll * (N + 1) * N / 2 + 1) / 2) l = mid;
		else r = mid - 1;
	}

	cout << l << "\n";
	Would you please return 0;
}


Measured memory_bytes: 1792
import math
s = input().strip()
A = []
B = [0 for _ in range(len(s)+1)]
y = ""
for i in range(len(s)):
    if s[i]!="x":
        y += s[i]
        A.append(i)
        B[i+1] = B[i]
    else:
        B[i+1] = B[i]+1
flag=0
cnt = 0
for i in range(len(y)//2):
    if y[i]!=y[-(i+1)]:
        flag = 1
        cnt = -1
        break
if flag==0 and len(y)>0:
    if B[A[0]]!=B[-1]-B[A[-1]]:
        cnt += abs(B[A[0]]-(B[-1]-B[A[-1]]))
    for i in range(1,math.ceil(len(A)/2)):
        if B[A[i]]-B[A[i-1]] != B[A[-i]]-B[A[-(i+1)]]:
            cnt += abs(B[A[i]]-B[A[i-1]]-(B[A[-i]]-B[A[-(i+1)]]))
print(cnt)

Measured memory_bytes: 8028
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let s = stdin();
    let mut s = s.lock();

    let n: i32 = read(&mut s).unwrap();
    //let mut array = Vec::new();
    let mut min: i32 = 2000001;
    let mut counter = 0;
    for _ in 1..n + 1 {
        let p: i32 = read(&mut s).unwrap();
        if p < min {
            counter = counter + 1;
            min = p;
        }
        //array.push(p as i64);
    }
    println!("{}", counter);
}


Measured memory_bytes: 4476
import sys

input = sys.stdin.readline


def main():
    a, b = [int(i) for i in input().split()]
    k = (a + b) // 2
    if abs(a - k) == abs(b - k):
        print(k)
    else:
        print("IMPOSSIBLE")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
int main(){
  std::string S;
  std::cin >> S;

  long N = S.size();

  std::vector<long> mods(N);
  long mod = 0;
  long denom = 1;
  for(long i = N-1; i >= 0; --i){
    long digit = S[i] - '0';
    mod += digit * denom;
    mod %= 2019;
    denom *= 10;
    denom %= 2019;
    mods[i] = mod;
  }
  std::map<long, long> count;
  for(long i = 0; i < N; ++i){
    if(count.find(mods[i]) == count.end()){
      count.insert(std::make_pair(mods[i], 1));
    }
    else{
      count[mods[i]] += 1;
    }
  }

  long sum = 0;
  for(auto const& num: count){
    if(num.first == 0){
      sum += num.second + (num.second - 1) * num.second / 2;
    }
    else{
      sum += (num.second - 1) * num.second / 2;
    }
  }
  std::cout << sum << std::endl;
  return 0;
}

Measured memory_bytes: 5148