akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 1e5 + 5;

int n, k, a, b, v, p, reqparity[2][maxn];
pii mi[2][maxn], ma[2][maxn];
vector<int> adj[maxn];

void combine(int x, int v)
{
    int takev = (mi[0][v].second == x);
    if(takev)
        assert(mi[1][v].second != x);
    if(mi[takev][v].first - 1 > mi[0][x].first)
    {
        mi[1][x] = mi[0][x];
        mi[0][x] = {mi[takev][v].first - 1, v};
    }
    else if(mi[takev][v].first - 1 > mi[1][x].first)
        mi[1][x] = {mi[takev][v].first - 1, v};

    if(ma[takev][v].first + 1 < ma[0][x].first)
    {
        ma[1][x] = ma[0][x];
        ma[0][x] = {ma[takev][v].first + 1, v};
    }
    else if(ma[takev][v].first + 1 < ma[1][x].first)
        ma[1][x] = {ma[takev][v].first + 1, v};
}

void up(int x, int p)
{
    for(auto v : adj[x])
        if(v != p)
        {
            up(v, x);
            combine(x, v);
            for(int j = 0; j < 2; j++)
                reqparity[j][x] |= reqparity[j ^ 1][v];
        }
}

void down(int x, int p)
{
    if(p != -1)
    {
        combine(x, p);
        for(int j = 0; j < 2; j++)
            reqparity[j][x] |= reqparity[j ^ 1][p];
    }
    for(auto v : adj[x])
        if(v != p)
            down(v, x);
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 2; j++)
        {
            reqparity[j][i] = 0;
            mi[j][i] = {-2e9, i};
            ma[j][i] = {2e9, i};
        }
    }
    for(int i = 0; i < n - 1; i++)
    {
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    cin >> k;
    for(int i = 0; i < k; i++)
    {
        cin >> v >> p;
        v--;
        reqparity[p & 1][v] = 1;
        mi[0][v] = {p, v};
        ma[0][v] = {p, v};
    }
    up(0, -1);
    down(0, -1);
    int bad = 0;
    for(int i = 0; i < n; i++)
        if((reqparity[0][i] && reqparity[1][i]) || mi[0][i].first > ma[0][i].first)
            bad = 1;
    if(bad)
        cout << "No\n";
    else
    {
        cout << "Yes\n";
        for(int i = 0; i < n; i++)
            cout << mi[0][i].first << "\n";
    }
    return 0;
}

Measured memory_bytes: 23108
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main() {
    lli A,B,C;
    cin >> A>>B;
    NeOut(A*B);
    NeOut(" ");
    Out(2*(A+B));
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
/*ll power(ll a,ll b,ll p)
{
	ll res=1;
	a%=p;
	while(b>0)
	{
		if(b&1)
		res=res*a%p;
		a=a*a%p;
		b>>=1;
	}
	return(res);
}*/
/*void dfs(ll x)
{
	vis[x]=true;
	for(ll i=0;i<v[x].size();i++)
	{
		if(vis[v[x][i]]==false)
		dfs(v[x][i]);
	}
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
	ll l=0,r=n-1;
	while(l<=r)
	{
		ll mid=l+(r-l)/2;
		if(arr[mid]==s)
		return(mid);
		if(arr[mid]<s)
		l=mid+1;
		else
		r=mid-1;
	}
	return(-1);
}*/
 
void solve()
{
	ll n,m;
	cin>>n>>m;
	ll arr[n];
	ll s=0,cnt=0;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		s+=arr[i];
	}
	double c=(s*1.0)/(4.0*m);
	for(ll i=0;i<n;i++)
	{
		if(arr[i]>=c)
		cnt++;
	}
	if(cnt>=m)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}
 
int main()
{
	IOS
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
    return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	auto culc=[&](int i){
		string now=to_string(i);
		return Pi((int)now[0]-'0',(int)now.back()-'0');
	};
	map<Pi,int> cnt;
	FOR(i,1,n+1){
		cnt[culc(i)]++;
	}
	ll ans=0;
	FOR(i,1,n+1){
		Pi now=culc(i);
		ans+=cnt[Pi(now.se,now.fi)];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
 
class Program
{
    static void Main()
    {
        var DN =ReadLine().Split().Select(int.Parse).ToArray();
        var D =DN[0];
        var N =DN[1];
        if(D==0&&N!=100)WriteLine(N);
        else if(D==0&&N==100)WriteLine(101);
        else if(D==1&&N!=100)WriteLine(D*N*100);
        else if (D==1&&N==100)WriteLine(10100);
        else if(N!=100)WriteLine(N*10000);
        else WriteLine(1010000);
    }
}

Measured memory_bytes: 13268
N = int(input())
s = input().strip()


def check(a, b):
    v = [0]*N
    v[0] = a
    v[1] = b
    for i in range(1, N-1):
        if s[i] == 'o':
            if v[i]:
                v[i+1] = v[i-1]
            else:
                v[i+1] = not v[i-1]
        else:
            if v[i]:
                v[i+1] = not v[i-1]
            else:
                v[i+1] = v[i-1]

    ok = True
    for i in range(N):
        same = v[(i-1) % N] == v[(i+1) % N]
        if s[i] == 'o':
            if v[i] != same:
                ok = False
        else:
            if v[i] == same:
                ok = False

    return v if ok else None


p = [
    [True, True],
    [False, False],
    [True, False],
    [False, True]
]
ans = "-1"
for a, b in p:
    l = check(a, b)
    if l != None:
        ans = "".join(["S" if v else "W" for v in l])
        break
print(ans)


Measured memory_bytes: 55904
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{

    int n;
    cin >> n;
    int tmp = n;
    int fx = 0;
    while (tmp != 0)
    {
        fx += tmp % 10;
        tmp /= 10;
    }
    if (n % fx == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    int d = n % 10;
    if(d == 2 || d == 4 || d == 5 || d == 7 || d == 9){
        cout << "hon";
    }else if(d == 0 || d == 1 || d == 6 || d == 8){
        cout << "pon";
    }else{
        cout << "bon";
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 3656
# include <cstdio>
# include <iostream>
# define R register int

using namespace std;

const int mod=1e9+7;
int n,m;

int fac (int x)
{
	int s=1;
	for (R i=1;i<=x;++i) s=1LL*s*i%mod;
	return s;
}

int main()
{
	scanf("%d%d",&n,&m);
	if(n<m) swap(n,m);
	if(n==m)
		printf("%lld\n",2LL*fac(n)*fac(m)%mod);
	else if(n==m+1)
		printf("%lld\n",1LL*fac(n)*fac(m)%mod);
	else puts("0");
	return 0;	
} 

Measured memory_bytes: 256
from sys import stdin

n = stdin.readline().rstrip().split()
h = [int(x) for x in stdin.readline().rstrip().split()]

sum = 0

for k in range(len(h)):
    if k == 0:
        sum += 1
        continue

    for l in range(k):
        if h[k] < h[l]:
            break
    else:
        sum += 1

print(sum)


Measured memory_bytes: 3060
def search_near(X, N, nums):
    for n in range(1,N+2):
        if n % 2 ==0:
            diff = n//2 *(-1)
        else:
            diff = n//2
        target = X+diff
        if target in nums:
            pass
        else:
            print(target)
            break

X, N = map(int, input().split(" "))
if N ==0:
    print(X)
else:
    nums = [i for i in map(int, input().split(" "))]
    search_near(X,N,nums)

Measured memory_bytes: 9028
n = int(input())
l = list(map(int,input().split()))
l.sort()
l.reverse()
squ = 0
rec = []
count = 0
tmp = 0
for i in l:
  if i == tmp:
    count += 1
    if count == 2:
      rec.append(tmp)
    elif count == 4:
      squ = max([squ,tmp])
  else:
    tmp = i
    count = 1
if len(rec)<2:
  print(squ*squ)
else:
  print(max([squ*squ,rec[0]*rec[1]]))

Measured memory_bytes: 14252
#include <iostream>


using namespace std;


int main()
{
   int i, h, m, s;     
   cin >> i;
   h = i / 3600;
   m = i / 60 - h * 60;
   s = i % 60;
  
   cout << h << ":" << m << ":"<< s << endl;
   
   return 0;
}








Measured memory_bytes: 3088
// Devarshi

#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

int main(){

sync
/*
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif*/

int n,t;
cin>>n>>t;

int ans=INT_MAX;
while(n--){
	int a,b;
	cin>>a>>b;
	if(b<=t){
		ans=min(ans,a);
	}
}
if(ans==INT_MAX) cout<<"TLE";
else cout<<ans;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x[100010];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=1;i<=n;i++)
            scanf("%lld",&x[i]);
        sort(x+1,x+n+1);
        int flag=0;
        int k=n;
        ll ans1=0,ans2=0;
        while(k>=2)
        {
            if(x[k]==x[k-1])
            {
                if(flag==0)
                {
                    flag=1;
                    ans1=x[k];
                    k-=2;
                }
               else  if(flag==1)
                {
                    flag=2;
                    ans2=x[k];
                    break;
                }
            }
            else
            {
                k--;
            }

        }
        //cout<<ans1<<" "<<ans2<<endl;
        if(flag==2) printf("%lld\n",ans1*ans2);
        else printf("0\n");
    }





}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        int LMax = 0;
        int RMin = N;

        for (int i = 0; i < M; i++) {
            int L = sc.nextInt();
            int R = sc.nextInt();
            LMax = L >= LMax ? L : LMax;
            RMin = R <= RMin ? R : RMin;
        }
        sc.close();

        if (LMax > RMin) {
            System.out.println(0);
        } else {
            System.out.println(RMin - LMax + 1);
        }

    }
}


Measured memory_bytes: 63264
function main(lines) {
    const input = lines.split('\n')

        let result = ''
    for(let i=0; i<input.length; i++){
        const arrayNum = input[i].split(' ').map(Number)
        const H = arrayNum[0]
        const W = arrayNum[1]
        const odd = Array(W+1).join('#.').slice(0,W) + '\n'
        const even = Array(W+1).join('.#').slice(0,W) + '\n'

        for(let i=1; i<H+1; i++){
            result += (i%2 === 0 ? even : odd)
        }

        if(H === 0 && W === 0) break;
        result += '\n'
    }
    console.log(result.trim() + '\n')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 16124
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let a: u32 = iter.to();
    let b: u32 = iter.to();
    let x: u32 = iter.to();

    let v = a * a * b;
    if v / 2 < x {
        let af = (a * a * a) as f64;
        let vf = (2 * (v - x)) as f64;
        let angle = (vf / af).atan();
        println!("{}", angle.to_degrees());
    } else {
        let af = (a * b * b) as f64;
        let vf = (2 * x) as f64;
        let angle = (af / vf).atan();
        println!("{}", angle.to_degrees());
    }
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
   int i=1;
   int h=1;
   int n;
   int x;
   scanf("%d",&n);
   do{
      if(h==1){
         x=i;
         if(x%3==0){
            printf(" %d",i);
            h=3;
         }
         else{
            h=2;
         }
      }
      else if(h==2){
         if(x%10==3){
            printf(" %d",i);
            h=3;
         }
         else{
            x/=10;
            if(x){
               h=2;
            }
            else{
               h=3;
            }
         }
      }
      else if(h==3){
         if(++i<=n){
            h=1;
         }
         else{
            printf("\n");
            h=0;
         }
      }
   }while(h!=0);
   return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n,m;
    cin >> n;
    map<int,int> d;
    map<int,int> t;
    REP(i,n){
        int p;
        cin >> p;
        d[p]++;
    }
    cin >> m;
    REP(i,m){
        int p;
        cin >> p;
        t[p]++;
    }
    bool flag = true;
    
    for(const auto& i:t){
        if(t[i.first]>d[i.first]){
            flag = false;
            break;
        }
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}    

Measured memory_bytes: 18944
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        s: chars
    }

    let mut pre = s[0];
    let mut cnt = 0u64;
    for i in 1..s.len() {
        if pre != s[i] {
            cnt += 1;
            pre = s[i];
        }
    }
    println!("{}", cnt);
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int ok[404][404];
int A[101010],B[101010],nex[101010][2];
int last[404];
int alive[404];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(y,N) FOR(x,N) ok[y][x]=(y!=x);
	FOR(x,N) last[x]=-1;
	FOR(i,M) {
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
		nex[i][0]=last[A[i]];
		nex[i][1]=last[B[i]];
		last[A[i]]=i;
		last[B[i]]=i;
		ok[A[i]][B[i]]=ok[B[i]][A[i]]=1;
	}
	
	FOR(y,N) FOR(x,y) if(ok[y][x]) {
		ZERO(alive);
		alive[x]=alive[y]=1;
		set<int> S;
		S.insert(last[x]);
		S.insert(last[y]);
		ok[y][x]=0;
		while(S.size()) {
			i=*S.rbegin();
			if(i==-1) {
				ok[y][x]=1;
				break;
			}
			S.erase(i);
			if(alive[A[i]]&&alive[B[i]]) break;
			alive[A[i]]=alive[B[i]]=1;
			S.insert(nex[i][0]);
			S.insert(nex[i][1]);
		}
	}
	
	
	int ret=0;
	FOR(y,N) FOR(x,y) ret+=ok[y][x];
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int n, mmax, mmin=1000, a;
int main(){
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> a; // cin read as 2,3,5,7(missing 9). why? check line 5?
        if (i==0){
            mmin = a;
        }
        if (a>mmax){
            mmax = a;
        } else if (a<mmin){
            mmin = a;
        }
    }
    cout << mmax - mmin;
}

Measured memory_bytes: 256
#B
N=int(input())
S=input()

alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ans=""
for i in range(len(S)):
    for j in range(26):
        if alpha[j]==S[i]:
            index=(j+N)%26
            ans+=alpha[index]
            break
print(ans)

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

using namespace std;
int n,A[100005];
int dp1[100005],dp2[100005],dp[100005];
int main()
{
    int ans=0,t=0x7f7f7f7f7f;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    dp1[0]=dp2[0]=1;
    for(int i=1;i<n;i++)
    {
        int r1,r2;
        if(A[i]<A[i-1])
        {
            dp1[i]=min(dp1[i-1]+1,dp2[i-1]+1);
            dp2[i]=min(dp2[i-1],dp1[i-1]+1);
        }
        else if(A[i]>A[i-1])
        {
            dp1[i]=min(dp1[i-1],dp2[i-1]+1);
            dp2[i]=min(dp2[i-1]+1,dp1[i-1]+1);
        }
        else
        {
            dp1[i]=dp1[i-1];
            dp2[i]=dp2[i-1];
        }
    }

    cout << min(dp2[n-1],dp1[n-1]) << endl;
    return 0;
}


Measured memory_bytes: 1408
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    ans = 0
    for v in c.values():
        ans += v*(v-1)//2
    for k in range(N):
        if 2 <= c[A[k]]:
            print(ans - (c[A[k]] - 1))
        else:
            print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 89676
M,D=map(int,input().split())#標準入力を行う

count = 0
for m in range(1,M+1):
  for d in range(1,D+1):
    d_1=d%10
    d_10=int(d/10)
    #print(m, d_10, d_1)
    if(d_1 >= 2 and d_10 >= 2 and d_1*d_10 == m):
      count+=1

print(count)

Measured memory_bytes: 2940
/*input
16 4 3
ooxxoxoxxxoxoxxo
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
vi v[N];
lld deg[N];
void solve()
{
	lld n,k,c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	vi v;
	rep(i,0,s.size()){
		if(s[i]=='o'){
			v.pb(i);
		}
	}	
	lld cnt2[n+2],cnt[n+2];
	rep(i,0,n+2){
		cnt[i]=0;
		cnt2[i]=0;
	}
	rep(i,0,s.size()){
		if(s[i]=='o'){
			cnt[i]=1;
			cnt2[i]=1;
		}
	}
	rep(i,1,n){
		if(i-c-1>=0)
			cnt[i]+=cnt[i-c-1];
		cnt[i]=max(cnt[i],cnt[i-1]);
	}
	rrep(i,n-1,0){
		if(i+c+1<=n){
			cnt2[i]+=cnt2[i+c+1];
		}
		cnt2[i]=max(cnt2[i],cnt2[i+1]);
	}
	// rep(i,0,n){
	// 	cout << cnt[i] << ' ';
	// }
	// cout << endl;
	// rep(i,0,n){
	// 	cout << cnt2[i] << ' ';
	// }
	// cout << endl;
	set <lld> s2;
	for(auto i:v){
		lld t=i;
		lld t2=0;
		lld t3=0;
		if(i-1>=0){
			t2=cnt[i-1];
		}
		if(i+1<=n){
			t3=cnt2[i+1];
		}
		// cout << t2 << ' ' << t3 << endl; 
		if(t2+t3==k-1){
			s2.insert(i);
		}
	}
	for(auto i:s2){
		cout << i+1 << endl;
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 18184
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

int get_group(int v){
    if(v == 2) return 3;
    if(v == 4 || v == 6 || v == 9 || v == 11) return 2;
    return 1;
}

signed main() {
    Fast();

    int a, b, c;
    cin >>  a >> b >> c;

    cout << (c >= a && c <= b ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 256
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 998244353
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=-10000000000,t=0,q=0,x,y=100000000000;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
	}
	l=a[0];
	for(i=1;i<n;i++)
	{
		l=l^a[i];
	}
	for(i=0;i<n;i++)
	{
		k=l^a[i];
		cout<<k<<" ";
	}
}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	string s,t; cin >> s >> t;
	int N = s.size();
	ll i=0;
	VV<int> c2is(26);
	rep(i,N+N){
		c2is[s[i%N]-'a'].pb(i);
	}
	for(char c_: t){
		int c = c_ - 'a';
		if(c2is[c].empty()){
			cout << -1 << endl;
			return 0;
		}
		int dist = *lower_bound(all(c2is[c]),i%N) - i%N;
		i += dist+1;
	}
	cout << i << endl;
}


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

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;

  int ans=0,ove;
  if(x>=y){
    ove=y;
    if(a<c*2) ans+=(x-y)*a;
    else ans+=(x-y)*c*2;
  }
  else{
    ove=x;
    if(b<c*2) ans+=(y-x)*b;
    else ans+=(y-x)*c*2;
  }

  if(c*2<a+b) ans+=ove*c*2;
  else ans+=ove*(a+b);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int main(){
    int n, tmp;
    cin >> n;
    vector<pair<int, int>> a(n);
    rep(i, n){
        cin >> tmp;
        a[i] = make_pair(tmp, i + 1);
    }

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

    rep(j, n){
        cout << a[j].second << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    cout<<fixed<<setprecision(20);
    int n,k;
    cin>>n>>k;

    long double ans = 0;

    for ( int i = 1 ; i <= n ; i++ )
    {
        int x = i;
        double c = 1.0/n;

        while( x < k )
        {
            x *= 2;
            c /= 2;
        }

        ans += c;
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import cmath

cmp_s = cmath.rect(1/3, 0)
cmp_u = cmath.rect(3**(-1/2), cmath.pi / 6)
cmp_t = cmath.rect(2/3, 0)


def koch_curve(p1: complex, p2: complex, n):
    if n != 0:
        cmp = p2 - p1
        s, u, t = [p1 + cmp * c for c in (cmp_s, cmp_u, cmp_t)]
        koch_curve(p1, s, n-1)
        print('{0:8f} {1:8f}'.format(s.real, s.imag))
        koch_curve(s, u, n-1)
        print('{0:8f} {1:8f}'.format(u.real, u.imag))
        koch_curve(u, t, n-1)
        print('{0:8f} {1:8f}'.format(t.real, t.imag))
        koch_curve(t, p2, n-1)


def main():
    n = int(input())
    print('{0:8f} {1:8f}'.format(.0, .0))
    koch_curve(complex(.0, .0), complex(100.0, .0), n)
    print('{0:8f} {1:8f}'.format(100.0, .0))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5824
#pragma GCC optimize(2)
#pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include<cstring>
#include <stack>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include <string>
#define itn int
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
const int maxn = 100 + 6;
const int maxa = 1e5 + 7;
typedef long long ll;
const ll mod = 1000 * 1000 * 1000 + 7;
using namespace std;
ll t, n, m, T;
vector<ll>ans;
ll ten[maxn];
void gen(ll st,ll len) {
	ll next = max(1LL, st -1);
	auto l = lower_bound(ans.begin(), ans.end(),1LL* (next) * ten[len - 2])-ans.begin();
	next = min(10LL, st + 2);
	auto r = lower_bound(ans.begin(), ans.end(), 1LL*(next) * ten[len - 2])-ans.begin();

	if (st == 1) {
		ans.push_back(st * ten[len - 1]);

		for (ll i = 1; i < len - 1; i++) {
			auto l = lower_bound(ans.begin(), ans.end(), 1LL*ten[i - 1]) - ans.begin();
			auto r = lower_bound(ans.begin(), ans.end(), 2LL*ten[i - 1]) - ans.begin();
			for (ll it = l; it != r; it++) {
				ans.push_back(st * ten[len - 1] + ans[it]);
			}
		}
	}
	
	for (ll it = l; it != r; it++) {
		ans.push_back(st * ten[len - 1] + ans[it]);
	}
}
int main()
{
#ifdef _DEBUG
	freopen("D:\\input.txt", "r", stdin);
	//	freopen("E:\\output.txt", "w", stdout);
#endif
	ll i, j;
	std::ios::sync_with_stdio(false); cin.tie(0);	cout.tie(0);
	ten[0] = 1;
	for (ll i = 1; i < maxn; i++) {
		ten[i] = ten[i-1] * 10;
	}
	for (ll i = 0; i < 10; i++) {
		ans.push_back(i);
	}
	ll len = 2;
	while (ans.size() < maxa) {
		for (ll i = 1; i < 10; i++) {
			gen(i, len);
		}
		len++;
	}
	ll k;
	while (cin >> k) {
		cout << ans[k]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=1e5+100;
int dp[N],h[N];



int main(){
    int n;
    cin >> n;
    for (int i=0 ; i<n ; i++){
        cin >> h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for (int i=2 ; i<n ; i++){
        dp[i]=min( ( dp[i-1]+abs(h[i]-h[i-1]) ), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1];

}







Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i < n; i++)
#define per(i,a,n) for (int i=n-1; i >= a; i--)
#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 pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
using namespace std;
int64 power(int64 a, int64 b){
	if(b == 0) return 1;
	int64 ret = power(a, b/2);
	ret *= ret;
	ret %= MOD;
	if(b % 2)ret *= a;
	return ret % MOD;
}
  
int main(){
    int64 N; cin >> N; 
    int64 a = power(10,N);
    int64 b = 2*power(9,N);
    int64 c = power(8,N);
    cout << (((a-b) % MOD + MOD) + c) % MOD;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[2])
    {
     cout<<"No"<<endl;
    }
    else{
       cout<<"Yes"<<endl;
    }


    return 0;


}


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

ll extgcd(ll a, ll b, ll &x, ll &y){
    if (b == 0){
        x = 1;
        y = 0;
        return a;
    }
    ll g = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return g;
}

bool isprime(ll x){
    if (x == 1) return false;
    if (x == 2) return true;
    if (x % 2 == 0) return false;
    ll s = sqrt(x);
    for(ll y = 3; y <= s; y += 2){
        if (x % y == 0) return false;
    }
    return true;
}

ll divisor(ll g){
    ll ans = 1;
    ll s = sqrt(g);

    if (g % 2 == 0){
        ans++;
        while(g % 2 == 0) g /= 2;
    }
    for(ll y = 3; y <= s; y += 2){
        if (g % y == 0){
            ans++;
            while(g % y == 0) g /= y;
        }
    }
    if(g>1) ans++;
    return ans;
}

int main(){
    ll a, b, ans;
    cin >> a >> b;
    ll gcd, x, y;
    gcd = extgcd(a, b, x, y);
    ans = divisor(gcd);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
X,K,D = map(int,input().split())
x = abs(X)
if x > K*D:
    print(x-K*D)
else:
    n = x // D
    p = K - n
    if p % 2 == 0:
        print(x-D*n)
    else:
        print(abs(x-D*(n+1)))
        


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

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

    deque<int> d;

    rep(i, N)
    {
        int p = lower_bound(ALL(d), A[i]) - d.begin();
        int s = d.size();
        if (p == 0)
        {
            d.push_front(A[i]);
        }
        else
        {
            d[p - 1] = A[i];
        }
    }

    OP(d.size())

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n,m,a,b, k, sum = 0, d, w, h;
	long long dp[200005] = {}, memo[200005] = {};
	string str,str2;
	cin >> str;
	if (str.length() == 2) {
		cout << str;
	}
	else {
		cout << str[2] << str[1] << str[0];
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

long long dp[500500];
int x[500500];

int a[500500];
int N;
int D;

void fillAll(){
	x[0] = D;
	for(int i = 0; i < N; ++i){
		int tmp = x[i] - a[i];
		if(tmp < 0) tmp = -tmp;
		x[i + 1] = min(x[i], tmp);
	}
	dp[N] = 1;
	dp[N - 1] = (a[N - 1] == 1 ? 2 : 1);
	for(int i = N - 2; i >= 0; --i){
		if(a[i] < dp[i + 1] * 2) dp[i] = dp[i + 1] + a[i];
		else dp[i] = dp[i + 1];
	}
}

inline bool query(int id){
	return x[id] >= dp[id + 1];
}

void input(){
	scanf("%d%d", &N, &D);
	for(int i = 0; i < N; ++i){
		scanf("%d", a + i);
	}
}

int main(){
	input();
	fillAll();
	int Q;
	scanf("%d", &Q);
	for(int q = 0; q < Q; ++q){
		int id;
		scanf("%d", &id);
		id--;
		bool flg = query(id);
		if(flg) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 9728
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	while(cin>>N) {
		VI A(N);
		REP(i, N) cin>>A[i];
		ll ans=accumulate(ALL(A),0LL)-N;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,k,d,e; cin>>n>>k; vector<int> vis(n+1,0);
        for(int i=1;i<=k;i++){
                cin>>d;
                for(int j=1;j<=d;j++){
                        cin>>e; vis[e]=1;
                }
        }
        int cnt=0;
        for(int i=1;i<=n;i++) if(!vis[i]) cnt++;
        cout<<cnt<<endl;
}



Measured memory_bytes: 3620
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	ints := []int{a, b, c}
	sort.Ints(ints)
	fmt.Println(ints[2]*10 + ints[1] + ints[0])
}


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

int main() {
	int ma = -1, mi = 101;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s.substr(i, 1) == "C") {
			mi = min(mi, i);
		} else if (s.substr(i, 1) == "F") {
			ma = max(ma, i);
		}
	}
	if (ma != -1 && mi != 101) {
		if (mi < ma) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "No" << endl;
	}

	return 0;

}



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

int main() {
  ll n;
  cin >> n;
  string march = "MARCH";
  vector<ll> cnt(5);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < 5; j++) {
      if (s[0] == march[j]) {
        cnt[j]++;
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
multiset<int, greater<int>> a;
int64_t n,m,b,k;
int main()
{
cin>>n>>m;
while(n--)cin>>k,a.insert(k);
while(m--)a.insert((*a.begin())/2),a.erase(a.begin());
for(auto c:a)b+=c;
cout<<b;
}

Measured memory_bytes: 4992