akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;//998244353;
ll const inf = 3e6+1;

void solve()
{

    string s; cin >> s;
    ll n = s.size();
    ll ans = 0;
    f(i,0,n){
        ans += s[i]-'0';
    }
    if(ans%9==0)
        cout << "Yes\n";
    else
        cout << "No\n";
}
int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
        
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
    return 0;
}

Measured memory_bytes: 3788
import java.util.Scanner;
  
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int m,i,h;
          
        while(true){
            String c = stdIn.next();
            if(c.equals("-"))
                break;
              
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        }
    }
}


Measured memory_bytes: 26560
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T &a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T &a, T b) {
	a = std::min(a, b);
}

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)
			return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)
		return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i;
		res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)
		return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod ;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int> engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

signed main() {
	int n;
	set<int> st;
	st.insert(0);
	cin>>n;
	rep(i,n)
	{
		int a;
		cin >> a;
		if (st.find(a - 1) != st.end()) {
			auto it = st.find(a - 1);
			st.erase(it);
			st.insert(a);
		}
	}
	if(*st.begin()==0)cout<<-1<<endl;
	else {
		int p=*--st.end();
		cout<<n-p<<endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

static inline void MainTask() {
  uint32_t N;
  cin >> N;

  cout << N * N * N << endl;
}

int main() {
  MainTask();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VLL ru(n+1);
    REP(i,0,n) ru[i+1] = ru[i] + a[i];
    LL ans = 1LL << 60;
    REP(i,1,n-2) {
        LL lsum = ru[i+1], rsum = ru[n] - ru[i+1];
        auto lit = lower_bound(all(ru), lsum/2);
        auto rit = lower_bound(all(ru), lsum + rsum / 2);
        int li = distance(ru.begin(), lit);
        int ri = distance(ru.begin(), rit);
        VVLL c(4);
        REP(j,0,2) {
            c[j*2].push_back(ru[li]);
            c[j*2].push_back(ru[i+1] - ru[li]);
            c[j].push_back(ru[ri] - ru[i+1]);
            c[j].push_back(ru[n] - ru[ri]);

            c[j*2+1].push_back(ru[li-1]);
            c[j*2+1].push_back(ru[i+1] - ru[li-1]);
            c[j+2].push_back(ru[ri-1] - ru[i+1]);
            c[j+2].push_back(ru[n] - ru[ri-1]);
        }
        REP(j,0,4) {
            LL diff = *max_element(all(c[j])) - *min_element(all(c[j]));
            ans = min(ans, diff);
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3328
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <algorithm>
#include <vector>
#include <cmath>
#include <iostream>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

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;

//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#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,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#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()

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

// PRE: a > b
ll GCD(ll a, ll b)
{
	while (a%b > 0)
	{
		ll r = a % b;
		a = b;
		b = r;
	}
	return b;
}

void PrimeFactors(ll n, vector<pair<ll, ll>>& pf)
{
	for (ll p = 2; p*p <= n; ++p)
	{
		if (n%p != 0) { continue; }

		pair<ll, ll> el;
		ll c = 0;

		while (n % p == 0)
		{
			++c;
			n /= p;
		}

		pf.push_back(make_pair(p, c));
	}

	if (n > 1) { pf.push_back(make_pair(n, 1)); }
}


int main()
{
	ll A, B;

	cin >> A >> B;

	ll gcd = GCD(max(A, B), min(A, B));

	vector<pair<ll,ll>> pf;
	pf.reserve(10000);

	PrimeFactors(gcd, pf);

	cout << pf.size()+1 << endl;

	return 0;
}

/**
	Reference:
	http://drken1215.hatenablog.com/
*/


Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n1,n2,m;cin>>n1>>n2>>m;
	vi a(n1),b(n2);
	rep(i,0,n1) cin>>a[i];
	rep(i,0,n2) cin>>b[i];
	ll ans=*min_element(a.begin(), a.end()) +*min_element(b.begin(), b.end());
	rep(i,0,m)
	{
		ll x,y,c;cin>>x>>y>>c;
		ans=min(a[x-1]+b[y-1]-c,ans);
	}
	cout<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	in := nextInt
	type Point struct {
		x, y int
	}

	n := in()
	pb := make([]Point, n)
	for i := range pb {
		pb[i].x = in()
		pb[i].y = in()
	}

	m := make(map[Point]int)
	for _, a := range pb {
		for _, b := range pb {
			if a == b {
				continue
			}

			x := a.x - b.x
			y := a.y - b.y
			m[Point{x, y}]++
		}
	}

	max := 0
	for _, v := range m {
		if max < v {
			max = v
		}
	}

	ans := n - max

	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

Measured memory_bytes: 896
N, M, X = map(int, input().split())

import numpy as np
import itertools
from collections import defaultdict

l   = list(range(N))
c   = 0
d   = defaultdict(list)
for i in range(1, N+1):
    for j in itertools.combinations(l, i):
        d[c] = list(j)
        c    += 1

Y = np.zeros((N, M+1), dtype=int)

for i in range(N):
    Y[i] = [int(j) for j in input().split()]

res = []
for i in range(c):
    j   = Y[d[i]].sum(0)
    if np.sum(np.r_[j[1:]] >= X) == M:
        res.append(j[0])

if len(res) > 0:
    print(min(res))
else:
    print(-1)


Measured memory_bytes: 30008
#!/usr/bin/env python3
import sys
N = int(input())
A = list(map(int,input().split()))

def comb(n):
    if n > 1:
        return n * (n-1) // 2
    else:
        return 0

dict = {}

for i in range(N):
    if A[i] in dict.keys():
        dict[A[i]] = dict[A[i]] + 1
    else:
        dict[A[i]] = 1

combs = {}

for k in dict:
    combs[k] = comb(dict[k])


total = sum(combs.values())

for i in range(N):
    diff = combs[A[i]] - comb(dict[A[i]]-1)
    print(total - diff)



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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h,w,n;
	cin>>h>>w>>n;
	vector<int> a(h+1,w);
	for(int i=0,x,y;i<n;i++){
		cin>>x>>y;
		x--;y--;
		a[x]=min(a[x],y);
	}
	a[h]=0;
	int rb=0;
	for(int i=1;i<=h;i++){
		if(rb>=a[i]){
			cout<<i<<endl;
			return 0;
		}
		else if(rb+1!=a[i])
			rb++;
	}
}


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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}



signed main(){
    int x ; cin >> x ;
    string ans = "" ;
    while( x ){
        x-- ;
        int f = (x % 26)  ;
        ans = char('a' + f ) + ans ;
        x /= 26 ;
    }
    cout << ans ;
    return 0 ;   
}          

Measured memory_bytes: 3580
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N,max=-1,mmax=-1;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (max < A[i]) {
			mmax = max;
			max = A[i];
		}
		else if (mmax <= A[i]) {
			mmax = A[i];
		}
	}
	for (int i = 0; i < N; i++)
	{
		if (A[i] == max)cout << mmax;
		else cout << max;
		cout << endl;
	}
}


Measured memory_bytes: 2432
import java.util.Arrays;
import java.util.Scanner;



public class Main{


	public static void main(String[] args){

		Scanner scan=new Scanner(System.in);

		int n=scan.nextInt();
		int m=scan.nextInt();

		int[][] matrix_nm=new int[n][m];
		int[] matrix_m1=new int[m];
		int[] matrix_n1=new int[n];
		Arrays.fill(matrix_n1, 0);

		for(int i=0;i<n;i++){
		  for(int j=0;j<m;j++){
			matrix_nm[i][j]=scan.nextInt();
		  }
		}

		for(int j=0;j<m;j++){
			matrix_m1[j]=scan.nextInt();
		}

		for(int j=0;j<n;j++){
		  for(int i=0;i<m;i++){
			matrix_n1[j]+=matrix_nm[j][i]*matrix_m1[i];
		  }System.out.println(matrix_n1[j]);
		}

		scan.close();
	}

}

Measured memory_bytes: 40460
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	map<ll,ll> m;
	for(int i= 0; i<n; i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	ll l=0,r=0;
	for(auto it:m)
	{
		ll y = it.first;
		ll h = it.second;
		if(h>=4)
		{
			l = y;r = y;
		}
		else if(h>=2)
		{
			if(r<l)
				r = y;
			else
				l = y;
		}
	}
	cout<<l*r<<endl;
	return 0;
}

Measured memory_bytes: 6912
cin = open(0).read().strip().split('\n')
n = int(cin[0])
g = [list(map(lambda x: int(x)-1, a.split(' ')[2:])) for a in cin[1:]]

first_order = [-1] * n
last_order = [-1] * n
ptr = 1

def dfs(g, seen, idx):
    global first_order, first_order, ptr

    first_order[idx] = ptr
    ptr += 1

    seen[idx] = True
    for i in g[idx]:
        # idxから行ける各頂点について
        if seen[i]: continue
        dfs(g, seen, i)

    last_order[idx] = ptr
    ptr += 1

seen = [False] * n
dfs(g, seen, 0)

# 孤立している頂点対策
for i in range(n):
    if not seen[i]:
        ans = dfs(g, seen, i)

# 出力
for idx, (f, l) in enumerate(zip(first_order, last_order)):
    print(idx+1, f, l)


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

const int mod = 1000000007;
const int P = 3232323;

long long h[500010], power[500010];
char buf[500010];
int bad1[500010], bad2[500010];

string read(){scanf("%s", buf); return buf;}

long long get_h(int l, int r){return (h[r] - h[l - 1] * power[r - l + 1] % mod + mod) % mod;}

int main(){
	string s = read(); s = " " + s;
	int n = s.length() - 1;
	power[0] = 1;
	for (int i = 1; i <= n; i++){
		power[i] = power[i - 1] * P % mod;
		h[i] = (h[i - 1] * P % mod + s[i] - 'a' + 1) % mod;
	}
	int minpd;
	for (int i = 1; i <= n; i++){
		if (n % i) continue;
		if (get_h(1, n - i) == get_h(1 + i, n)){
			minpd = i;
			break;
		}
	}
	if (minpd == n){
		printf("1\n1\n");
		return 0;
	}
	if (minpd == 1){
		printf("%d\n1\n", n);
		return 0;
	}
	for (int i = 1; i <= n; i++){
		long long a = get_h(1, i);
		for (int j = 2 * i; j <= n; j += i){
			if (get_h(j - i + 1, j) != a) break;
			bad1[j] = 1;
		}
	}
	for (int i = 1; i <= n; i++){
		long long a = get_h(n - i + 1, n);
		for (int j = n - 2 * i + 1; j >= 1; j -= i){
			if (get_h(j, j + i - 1) != a) break;
			bad2[j] = 1;
		}
	}
	int ans = 0;
	for (int i = 2; i <= n; i++){
		if (!bad1[i - 1] && !bad2[i]) ans++;
	}
	printf("2\n%d\n", ans);
	return 0;
}


Measured memory_bytes: 12948
N=int(input())
T,A = map(int,input().split())
H=list(map(float,input().split()))
tm=0
tem=0
TEM = []
TM = []
for h in H:
    tm=T-h*0.006
    TM.append(tm)
for tm in TM:
    tem=abs(tm-A)
    TEM.append(tem)
num = TEM.index(min(TEM))
print(num+1)

Measured memory_bytes: 3064
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
void solve(){
    cout<<setprecision(12);
    cout<<fixed;
    ll n=0,m=0;
    cin>>n>>m;
    ll t=m;
    ll c=0,s=0;
    ll ar[n]={0};
    for(ll i=0;i<n;++i){
        cin>>ar[i];
        s+=ar[i];
    }
    sort(ar,ar+n,greater<ll>());
    double req=(double)s/(4*m);
   // deb(req)
   // ll selected=0;
    for(ll i=0;i<n;++i){
        if(ar[i]>=req)
            ++c;
        else
            break;
    }
    if(c>=m) cout<<"Yes"; else cout<<"No";
}
int main()
{
    fastio;
//    ll t=0;
//    cin>>t;
//    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
"use strict";

function Main(input) {
  let num = input.trim().split("\n")[0];
  let row = input.trim().split("\n")[1].split(' ').map(x => x - 0);
  let ans = 0;
  let min = Infinity;
  for(let i = 0; i < num; i++) {
    if(row[i] < min){
      ans++;
      min = row[i];
    };
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22352
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> vvec; 

int dfs(int cur,int t,vvec& g,vvec& cap,vec& vis){
    if(cur==t) return 1;
    vis[cur] = 1;
    for(int x=0;x<(int) g[cur].size();x++) if(g[cur][x]){
        //訪問済み、流れているなら進まない
        if(vis[x] || !cap[cur][x]) continue;
        if(dfs(x,t,g,cap,vis)){
            cap[x][cur]++;
            cap[cur][x]--;
            return 1;
        }
    }
    return 0;
}

int max_flow(int s,int t,vvec& g,vvec& cap,int cnt=100000){
    int n = g.size();
    vec vis(n);
    int flow = 0;
    while(cnt--){
        for(int i=0;i<n;i++) vis[i] = 0;
        if(dfs(s,t,g,cap,vis)) flow++;
        else break;
    }
    return flow;
}

int main(){
    int N,M,Q;
    cin >> N >> M >> Q;
    vvec g(N,vec(N,0)),cap(N,vec(N,0));
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a][b] = g[b][a] = 1;
        cap[a][b] = cap[b][a] = 1;
    }
    int ans = max_flow(0,N-1,g,cap);
    for(int i=0;i<Q;i++){
        int m,a,b;
        cin >> m >> a >> b;
        a--; b--;
        if(m==1){
            g[a][b] = g[b][a] = 1;
            cap[a][b] = cap[b][a] = 1;
        }else{
            if(cap[a][b]!=1){
                if(cap[a][b]==0) swap(a,b);
                if(!max_flow(b,a,g,cap,1)){
                    max_flow(b,0,g,cap,1);
                    max_flow(N-1,a,g,cap,1);
                    ans--;
                }
            }
            cap[a][b] = cap[b][a] = 0;
            g[a][b] = g[b][a] = 0;
        }
        ans += max_flow(0,N-1,g,cap);
        cout << ans << endl;
    }
}


Measured memory_bytes: 4996
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <iostream>
using namespace std;
typedef long long LL;
const int Maxn = 1e5 + 6;
const int inf = 1000000000;
const LL Inf = 1LL<<60;
int main ()
{
	int n;
	int a,b,c;
	scanf("%d%d",&a,&b);
	if (a%2 == 1 && b%2 == 1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n;
    ll a[100010];
    cin >> n;
    rep(i, n){
        cin >> a[i];
    }

    ll asum[100010];
    asum[0] = 0;
    rep(i, n){
       asum[i+1] = asum[i] + a[i]; 
    }

    ll sum = 0;
    ll res = 0;
    int flg = 1;
    reps(i, 1, n){
        if(flg == 1){
            if(asum[i] + sum >= 0){
                res += abs(asum[i] + sum) + 1;
                sum += -abs(asum[i] + sum) - 1;
            }
            flg = -1;
        }else if(flg == -1){
            if(asum[i] + sum <= 0){
                res += abs(asum[i] + sum) + 1;
                sum += abs(asum[i] + sum) + 1;
            }
            flg = 1;
        }
    }

    sum = 0;
    ll res2 = 0;
    flg = -1;
    reps(i, 1, n){
        if(flg == 1){
            if(asum[i] + sum >= 0){
                res2 += abs(asum[i] + sum) + 1;
                sum += -abs(asum[i] + sum) - 1;
            }
            flg = -1;
        }else if(flg == -1){
            if(asum[i] + sum <= 0){
                res2 += abs(asum[i] + sum) + 1;
                sum += abs(asum[i] + sum) + 1;
            }
            flg = 1;
        }
    }

    //adeb(asum, n);

    cout << min(res, res2) << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cout << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int a[200100][26];

int main(){
  ins(S,T);
  int N = sz(S);
  rep(i ,2 * N + 1) rep(j , 26) a[i][j] = -1;

  repr(i,2 * N){
    rep(j , 26){
     if(j == S[ (i + 1) % N] - 'a') a[i][j] = i + 1;
     else  a[i][j] = a[i + 1][j];
    }
  }

  //rep(i,sz(S) * 2) trca(a[i] , 26);

  ll ans = 0;
  rep(i , sz(T)) {
    if(i == 0 && S[0] == T[0]) ans = 0;
    else if(a[ans % N][T[i] - 'a'] == -1) die(-1);
    else ans += ( a[ans % N][T[i] - 'a'] - ans % N);
  }
  out(ans + 1);

}

Measured memory_bytes: 20944
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm> 
#include<cstring>
using namespace std;
typedef long long ll;
const ll maxn = 1e6 + 10;
int main()
{
	int n,ans=0;
	char ch[55];
	cin>>n;
	for(int i = 1;i <= n; i++) 
		cin>>ch[i];
	for(int i = 1;i <= n;)
	{
		if(ch[i] == 'A'&& ch[i+1] == 'B'&&ch[i+2] == 'C'){
			i+=3;
			ans++;
		}
		else
			i++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _007_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] hw = ReadInts();
            int cnt = 0;
            for(int i = 0; i < hw[0]; i++)
            {
                string s = Read();
                for(int j = 0; j < hw[1]; j++)
                {
                    if (s[j] == '#') cnt++;
                }
            }
            Console.WriteLine(cnt == (hw[0] + hw[1] - 1)
                ? "Possible" : "Impossible");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    N=int(input())
    S=input()
    ret = S.count('R')*S.count('G')*S.count('B')
    for i in range(N):
        for j in range(i+1,N):
            k = j + (j-i)
            if k>=N:
                break
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                ret-=1

    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main(){
    int n; cin >> n;
    vector<ll> A(n);
    vector<ll> X(n);
    REP(i, n){
        cin >> A[i];
        X[i] = A[i];
    }

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

    if ( n == 2 ){
        REP(i, n){
            if( X[i] == A[0] ) cout << A[1] << endl;
            else cout << A[0] << endl;
        }

        return 0;
    } else {

        ll res = 0;
        ll x = A[n/2-1], y = A[n/2];
        REP(i, n){
            if ( X[i]<=x ) res = y;
            else res = x;
            cout << res << endl;
        }
    
        return 0;
    }
}


Measured memory_bytes: 5376
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define all(v)   v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>v;
typedef vector<ll>vi;
typedef map<ll,ll>m;
typedef map<char,ll>mc;
typedef set<ll>st;
typedef set<char>sc;

int main()
{
    speed;
    ll a,b,i;
    string s;
    cin>>a>>s;
    b = s.size();
    for(i=0;i<min(a,b);i++)
    {
        cout<<s[i];
    }
    if(s.size()>a)
        cout<<"...";
    cout<<endl;


}


Measured memory_bytes: 3644
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    a,b,x = map(int,input().split())
    l = (a + x - 1) // x
    r = (b + x - 1) // x
    ans = r - l
    if b%x==0:
        ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38384
#include "bits/stdc++.h"
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int INF = 1001001001;
vector<int> to[100005];

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

    int n, m;
    cin >> n >> m;
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);

    dist[0] = 0;
    q.push(0);

    while(!q.empty()) {
        int v = q.front();
        q.pop();
        for (int u : to[v]) {
            if (dist[u] != INF)
                continue ;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << '\n';
    REP(i, n) {
        if (i == 0)
            continue ;
        int ans = pre[i];
        ++ans;
        cout << ans << '\n';
    }
    return 0;
}

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




int main() {
	std::ios_base::sync_with_stdio(false);
  	
  	string s;
  	cin >> s;
  
  	long long int c[2020] = {0};
  	long long ans = 0;
  	long long int temp[2020];

  	for (int i = 0; i < s.length(); ++i) {
    	int x = s[i] - '0';
    	for (int j = 0; j < 2020; ++j) temp[j] = 0;
      	for (int j = 0; j < 2020; ++j) {
        	temp[(10*j + x) % 2019] += c[j];
        }
      	temp[x]++;
      	
      	for (int j = 0; j < 2020; ++j) c[j] = temp[j];
      	ans += c[0];
      
    	//cout << i << " " << x << "  " << ans << endl;
    }
  
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3464
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = a[::-1]
ans = 0
for i in range(1,min(n+1, k+1)):
    for j in range(i+1):
        m = i - j
        l = a[:m] + b[:j]
        ml = sorted([i for i in l if i < 0])
        pl = [i for i in l if i >= 0]
        ml = ml[min(k-i, len(ml)):]
        if ml:
            minus = sum(ml)
        else:
            minus = 0
        if pl:
            plus = sum(pl)
        else:
            plus = 0
        ans = max(ans, minus + plus)        
print(ans)

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

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  
  int price = x*a + y*b;
  for(int i = 0; i <= max(x,y) * 2; i++) {
    if(price > (i * c + max(0,(x-i/2)) * a + max(0,(y-i/2)) * b))
      price = i * c + max(0,(x-i/2)) * a + max(0,(y-i/2)) * b;
  }
  cout << price << endl;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector< vector<int> > B(2*K,vector<int>(2*K,0)), W = B;
  int x, y;
  char c;
  for(int i = 0; i < N; ++i){
    cin >> x >> y >> c;
    if(c == 'W') ++W[x%(2*K)][y%(2*K)];
    else ++B[x%(2*K)][y%(2*K)];
  }

  for(int i = 0; i < 2*K; ++i){
    for(int j = 1; j < 2*K; ++j){
      B[i][j] += B[i][j-1];
      W[i][j] += W[i][j-1];
    }
  }
  for(int i = 1; i < 2*K; ++i){
    for(int j = 0; j < 2*K; ++j){
      B[i][j] += B[i-1][j];
      W[i][j] += W[i-1][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < K; ++i){
    for(int j = 0; j < K; ++j){
      int t = 0;
      t += W[i][j];
      t += W[i+K][j+K] - W[i][j+K] - W[i+K][j] + W[i][j];
      t += W[2*K-1][2*K-1] - W[i+K][2*K-1] - W[2*K-1][j+K] + W[i+K][j+K];
      t += W[2*K-1][j] - W[i+K][j];
      t += W[i][2*K-1] - W[i][j+K];

      t += B[i+K][2*K-1] - B[i][2*K-1] - B[i+K][j+K] + B[i][j+K];
      t += B[2*K-1][j+K] - B[2*K-1][j] - B[i+K][j+K] + B[i+K][j];
      t += B[i+K][j] + B[i][j+K] - 2*B[i][j];
      ans = max(ans,t);

      t = 0;
      t += B[i][j];
      t += B[i+K][j+K] - B[i][j+K] - B[i+K][j] + B[i][j];
      t += B[2*K-1][2*K-1] - B[i+K][2*K-1] - B[2*K-1][j+K] + B[i+K][j+K];
      t += B[2*K-1][j] - B[i+K][j];
      t += B[i][2*K-1] - B[i][j+K];

      t += W[i+K][2*K-1] - W[i][2*K-1] - W[i+K][j+K] + W[i][j+K];
      t += W[2*K-1][j+K] - W[2*K-1][j] - W[i+K][j+K] + W[i+K][j];
      t += W[i+K][j] + W[i][j+K] - 2*W[i][j];
      ans = max(ans,t);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31616
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long k = sc.nextLong();
    long[] num = new long[100001];
    long sum = 0;
    for(int i = 0; i<n; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      num[a] += (long)b;
    }
    for(int i = 0; i<100001; i++) {
      sum += num[i];
      if(sum >= k) {
        System.out.println(i);
        return;
      }
    }
  }
}


Measured memory_bytes: 65172
#include <iostream>
#define int long long
using namespace std;

int p10[10];

int solve(int x, int y, int n) {
	int ret = 0;
	
	for (int i = 1; i <= n; i++) {
		int f = i;
		while (f >= 10) f /= 10;
		if (f == x && i % 10 == y) ret++;
	}
	
	return ret;
}

signed main() {
	int n;
	cin >> n;
	
	p10[0] = 1;
	for (int i = 1; i < 10; i++) p10[i] = p10[i - 1] * 10;
	
	int ans = 0;
	
	for (int x = 1; x <= 9; x++) {
		for (int y = 1; y <= 9; y++) {
			//a = x..y
			int cntA = solve(x, y, n);
			
			//b = y..x
			int cntB = solve(y, x, n);
			
			ans += cntA * cntB;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define BLACK 1
#define WHITE 2
#define MAXW 2001
int main(){
  int n,i,j,k;
  int A[100][100];
  int B[100];
  int weight=0;
  int minw=0,mi,mj;
  scanf("%d",&n);
  for(i=0;i<n;i++)B[i]=WHITE;
  for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",&A[i][j]);
  B[0]=BLACK;
  while(1){
    minw=MAXW;
    for(i=0;i<n;i++)if(B[i]==BLACK){
	for(j=0;j<n;j++)if(A[i][j]!=-1){
	    if(B[j]!=BLACK){
	      if(A[i][j]<minw){
		mj=j;
		mi=i;
		minw=A[i][j];
	      }
	    }
	  }

      }
    
    weight+=minw;
    B[mj]=BLACK;
    for(i=0;i<n;i++)if(B[i]==WHITE)break;
    if(i==n)break;
    
  }
  printf("%d\n",weight);
  
  return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <iomanip>
#include <cassert>
#include <complex>
#include <functional>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
string s;
ll dfs(int i,ll cur,ll sum,const string &s)
{
	if (i==s.size()) return sum;
	int d=s[i]-'0';
	ll res=0;
	if (i+1!=s.size())
		res+=dfs(i+1,cur*10+d,sum,s);
	res+=dfs(i+1,0,sum+cur*10+d,s);
	return res;
}
int main()
{
	cin>>s;
	ll ans=dfs(0,0,0,s);
	cout<<ans;
	//system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")


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

	string s, t;
	cin >> s >> t;
	int n = s.length(), m = t.length(), ans = n * 2, i, j, k, ct;

	for (i = 0; i + m <= n; i++) {
		ct = 0;
		for (j = 0; j < m; j++) {
			if (s[j + i] != t[j]) ct++;
		}
		ans = min(ans, ct);
	}
	cout << ans << "\n";


	return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

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

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<int> ans(n, 0);
  for(int x=1; x<=100; x++) {
    for(int y=1; y<=100; y++) {
      for(int z=1; z<=100; z++) {
        int r = x*x + y*y + z*z + x*y + y*z + z*x;
        if(r <= n){
          ans[r - 1]++;
        }
      }
    }
  }

  for(int i=0; i<n; i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int A[100000];
int c[3];
int main(){
  int i;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=0;i<N;i++){
    if(A[i]%4==0){
      c[2]++;
    }
    else if(A[i]%2==0){
      c[1]++;
    }
    else{
      c[0]++;
    }
  }
  if(c[1]){
    c[0]++;
  }
  if(c[0] <= c[2]+1){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, A[1d5];
// int c[3];
// {
//   int i;
// 
//   rd(N,A(N));
//   rep(i,N) if[A[i]%4==0, c[2], A[i]%2==0, c[1], c[0]]++;
// 
//   if(c[1]) c[0]++;
//   
//   wt( if[c[0] <= c[2]+1, "Yes", "No"] );
// }


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] line = Stream.of(sc.nextLine().split("", 0)).mapToInt(Integer::parseInt).toArray();
		int let = 0;
		int min = Integer.MAX_VALUE;
		for (int i = 2; i < line.length; i++) {
			let = line[i-2] * 100 + line[i-1] * 10 + line[i] * 1;
			if (min > Math.abs(let - 753)) {
				min = Math.abs(let - 753);
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 36080
N=int(input())
a=list(map(int,input().split()))
count=0
for i in range(0,2801,400):
  for j in range(N):
    if i<=a[j]<=399+i:
      count+=1
      break
c=0
for i in range(N):
  if 3200<=a[i]:
    c+=1

if count!=0:
  print(count,count+c)
else:
  print(1,c)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int gcd(int bigger, int smaller){
    int mod = bigger % smaller;
    if(mod == 0){
        return smaller;
    }
    return gcd(smaller, mod);
}
int main(){
    ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    int x, y, d;
    cin >> x >> y;
    if(x > y){
        d = gcd(x, y);
    }else{
        d = gcd(y, x);
    }
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 1196
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  //startupcpp();
  ll i,N,x,ans=0;
  cin>>N;
  vec v;
  rep(i,N){
    cin>>x;
    if(x>N)ans++;
    else v.pb(x);
  }
  N=v.size();
  vsort(v);
  v.pb(0);
  //output(v);
  rep(i,N){
    x=1;
    while(v[i]==v[i+x])x++;
    if(v[i]>x)ans+=x;
    else ans+=x-v[i];
    i+=x-1;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);
int N;
string S;
int cnt[33];

signed main() {
    cin >> N >> S;
    for (int i = 0; i < N; i++)cnt[S[i] - 'a']++;
    int ans = 1;
    int mod = 1e9 + 7;
    for (int i = 0; i < 33; i++)(ans *= cnt[i] + 1) %= mod;
    cout << ans - 1 << endl;
}


Measured memory_bytes: 512