akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;

const int mod = 1000000007;

struct mint {
	ll x;
	mint(ll x = 0) : x((x%mod+mod)%mod) {}
	mint operator-() const {return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint &operator-=(const mint a)
	{
		if ((x += mod - a.x) >= mod)
			x -= mod;
		return *this;
	}
	mint &operator*=(const mint a)
	{
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const
	{
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const
	{
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const
	{
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const
	{
		if (!t)
			return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1)
			a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const
	{
		return pow(mod - 2);
	}
	mint &operator/=(const mint a)
	{
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const
	{
		mint res(*this);
		return res /= a;
	}
};

mint choose(int n, int a)
{
	mint x = 1, y = 1;
	rep(i, a)
	{
		x *= n - i;
		y *= i + 1;
	}
	return x / y;
}

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	mint ans = mint(2).pow(n);
	ans -= 1;
	ans -= choose(n, a);
	ans -= choose(n, b);
	cout << ans.x << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll x;
    cin >> x;
    REP(i, 1e4) {
        REP(j, 1e4) {
            ll a = i - 5e3, b = j - 5e3;
            if (a * a * a * a * a - b * b * b * b * b == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    int n; int m;
    cin >> n >> m;
    int a[1010];
    long long allVotes = 0;
    int res = 0;
    rep(i, n) {
        cin >> a[i];
        allVotes += a[i];
    }

    rep(i, n) {
        if (a[i]*4*m >= allVotes) {
            res++;
        }
    }
    if (res >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;

    }

    return 0;
}


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

int main()
{
    int n;
    cin >> n;

    vector<int> difficultyVec;
    for (int i = 0; i < n; ++i)
    {
        int input;
        cin >> input;
        difficultyVec.push_back(input);
    }

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

    cout << difficultyVec.at(n / 2) - difficultyVec.at(n / 2 - 1) << endl;
}

Measured memory_bytes: 892
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

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

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

string s;

bool solve()
{
	for(auto it: s) for(auto jt: s) if(it != jt) return 1;

	return 0;
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n >> m >> k)
    {
		ans = (n / (m + k)) * m;

		ans += min((n % (m + k)), m);

		cout << ans << "\n";
    }

}






Measured memory_bytes: 3644
import itertools
N = int(input())
A = [int(_) for _ in input().split()]


class SegmentTree():
    """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        e : 
            identity element of the monoid
        size : int
            limit for array size
    """

    def __init__(self, array, f, e, size):
        self.f = f
        self.e = e
        self.size = size
        self.n = n = len(array)
        self.dat = [e] * n + array + [e] * (2 * size - 2 * n)
        self.build()

    def build(self):
        dat, n, f = self.dat, self.n, self.f
        for i in range(n - 1, 0, -1):
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):
        """
        set value at position p (0-indexed)
        """
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = f(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):
        """
        result on interval [l, r) (0-indexed)
        """
        f, e, n, dat = self.f, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = f(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = f(res, dat[r])
            l >>= 1
            r >>= 1
        return res


e = 0
size = 2 * N + 2
f = lambda a, b: a + b
offset = N


def check(x):
    cumsum = list(itertools.accumulate([0] + [1 if a <= x else -1 for a in A]))
    # sum([l:r)) = cumsum[r] - cumsum[l] >= 0
    # ⇔ cumsum[l] <= cumsum[r]
    ST = SegmentTree([e] * size, f=f, e=e, size=size)
    count = 0
    for c in cumsum:
        c += offset
        count += ST.query(0, c + 1)
        ST.modify(c + 1, ST.query(c + 1, c + 2) + 1)
    return 2 * count > N * (N + 1) // 2


A_sorted = [0] + sorted(set(A)) + [10**10]
lb = 0
rb = len(A_sorted) - 1
# check(x) == Trueとなる最小のx
while rb - lb > 1:
    mid = (rb + lb) // 2
    if check(A_sorted[mid]):
        rb = mid
    else:
        lb = mid
print(A_sorted[rb])


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

typedef long long ll;
typedef unsigned long long ull;

struct node {
  vector<ll> next;
};

vector<ll> ans;
vector<struct node> tree;

void calc(ll i, vector<ll> nodes) {
  for (auto itr = nodes.begin(); itr != nodes.end(); ++itr) {
    ans[*itr] += ans[i];
    calc(*itr, tree[*itr].next);
  }
}

int main() {
  ll n, q;
  cin >> n >> q;

  for (ll i = 0; i < n; ++i) {
    struct node n;
    tree.push_back(n);
    ans.push_back(0);
  }
  for (ll i = 0; i < q; ++i) {
//    cnt.push_back(0);
  }

  for (ll i = 0; i < n-1; ++i) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    tree[a].next.push_back(b);
  }

  for (ll i = 0; i < q; ++i) {
    ll p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }

  calc(0, tree[0].next);

  for (ll i = 0; i < n-1; ++i) {
    cout << ans[i] << " ";
  }
  cout << ans[n-1] << endl;
    
  return 0;
}

Measured memory_bytes: 40492
def main():
    n, m, x, y = map(int, input().split())
    X = list(map(int, input().split()))
    Y = list(map(int, input().split()))

    mx, my = max(max(X), x), min(min(Y), y)
    if mx < my:
        print("No War")
    else:
        print("War")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
'use strict'

const main = (INPUT) => {
  const S = INPUT.split('\n')[0]
  let ans = 0
  for (let i = 0; i < S.length; i++) {
    if (S[i] == '1') ans++
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 29392
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    int a,b,c,x;
    cin >> a >> b >> c;
    if (a > b) {
        x = a;
        a = b;
        b = x;
    }
    if (a > c) {
        x = a;
        a = c;
        c = x;
    }
    if (b > c) {
        x = b;
        b = c;
        c = x;
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

ll ans, n,v[N], xo;

void solve(){
    scanf("%lld", &n);
    for(int i=0;i<n;i++){
        scanf("%lld",v+i);
        xo^=v[i];
    }
    for(int i=0;i<n;i++){
        printf("%lld ",xo^v[i]);
    }
    printf("\n");
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 5320
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        #print(n,h)
        if 4*n*h-N*h-N*n<=0:
            continue
        w=(N*n*h)/(4*n*h-N*h-N*n)
        if int(w)==w:
            print(h,n,int(w))
            exit()

Measured memory_bytes: 40796
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a - c) / (b + c);
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize
    }
    let mut can = false;
    let mut count = 0;
    for _ in 0..n {
        input! {
            d: usize,d2: usize
        }
        if d == d2 {
            count += 1;
            if count == 3 {
                can = true;
            }
        } else {
            count = 0;
        }
    }
    let mut res = if can { "Yes" } else { "No" };
    println!("{}", res);
}


Measured memory_bytes: 2148
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    string s;
    cin>>s;
    if(s=="RRR") cout<<"3"<<endl;
    else if(s=="SRR"||s=="RRS") cout<<"2"<<endl;
    else if(s=="SSS") cout<<"0"<<endl;
    else cout<<"1"<<endl;
}


Measured memory_bytes: 3132
#include <stdio.h>

int main(){
    int a,b,k,i,cont=0;

    scanf("%d",&k);

    scanf("%d %d",&a ,&b);

    int maior = (b/k)*k;

    if(a<=maior){
        printf("OK");
    }else {
        printf("NG");
    }




return 0;
}


Measured memory_bytes: 1728
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
const double INT_MAX = 2147483647;
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, x, n) for(int i = (int)(n) - 1 - (int)(x); i >= 0; i--)

void printv(vector<int> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << *it << ",";
    }
    cout << endl;
}

ull N,K;
vector<int> A(10e6);

int main(void){
    // Your code here!
    cin>>N>>K;
    REP(i,1,N+1){ cin>>A[i]; }
    vector<int> l;
    // めぐる街の軌跡
    l.emplace_back(1);
    // ループしているところの先端と終端
    ull idx1, idx2;
    rep(i,N){
        l.emplace_back(A[l[i]]);
        //今移動した街が過去にいた街に含まれているか確認する
        // rep(j,l.size()-1){
        //     if (l[j] == l.back()) {
        //         idx1 = j;
        //         idx2 = l.size() - 1;
        //         //printv(l);
        //         goto A;
        //     }
        // }
    }
    //printv(l);
    rep(i,N){
        if(l.back() == l[i]){
            idx1=i;
            idx2=l.size()-1;
        }
    }
//A:
    if (K<=idx1) cout << l[K]<< endl;
    else cout << l[idx1 + (K-idx1) % (idx2-idx1)]<<endl;
    //cout << idx1<<" "<<idx2;
}


Measured memory_bytes: 43368
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
import math as M
n,k=INPUT()
A=INPUT()
A.sort()
sum=0
for i in range(n-k):
    sum+=A[i]
print(sum)


Measured memory_bytes: 88396
package main

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

func main() {
	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	result := 0
	a := make([]int, N)
	bs := make([]int, N)
	for b := 0; b < 60; b++ {
		t := 0
		a[N-1] = (A[N-1] >> uint(b)) & 1
		bs[N-1] = a[N-1]
		for i := N - 2; i > -1; i-- {
			a[i] = (A[i] >> uint(b)) & 1
			bs[i] = bs[i+1] + a[i]
			if a[i] == 0 {
				t += bs[i+1]
			} else {
				t += (N - (i + 1)) - bs[i+1]
			}
		}
		t %= 1000000007
		B := (1 << uint(b)) % 1000000007
		result += (t * B) % 1000000007
		result %= 1000000007
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 12928
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>

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

#define INF 1000 * 1000

using namespace std;

int main() {
  int array[100001] = { 0 };

  int n;
  cin >> n;

  int a;

  rep(i, n) {
    cin >> a;
    array[a]++;
    if (array[a] > 2)
      array[a] -= 2;
  }

  int count1 = 0;
  int count2 = 0;

  rep(i, 100001) {
    if (array[i] == 1)
      count1++;
    else if (array[i] == 2)
      count2++;
  }

  if (count2 % 2 == 1)
    count2--;


  cout << count1 + count2 << endl;

  return 0;
}



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

main() {
  int cnt[11]{};
  for (int i = 0; i < 3; i++) {
    int num; cin >> num;
    cnt[num]++;
  }
  cout << ( (cnt[5] == 2 && cnt[7] == 1) ? "YES" : "NO" ) << endl;
}


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    bool judge = false;
    for (int i = 1; i <= 100; i++)
    {
        if ((A * i) % B == C)
        {
            judge = true;
            break;
        }
    }
    if (judge)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;



class Main{

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] input = br.readLine().split(" ");
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = Integer.parseInt(input[i]);
		}
		int[] color = new int[8];
		int count1 = 0;
		int count2 = 0;
		for(int i = 0;i < n;i++){
			if(1 <= a[i] && a[i] <= 399){
				color[0] = 1;
			}else if(400 <= a[i] && a[i] <= 799){
				color[1] = 1;
			}else if(800 <= a[i] && a[i] <= 1199){
				color[2] = 1;
			}else if(1200 <= a[i] && a[i] <= 1599){
				color[3] = 1;
			}else if(1600 <= a[i] && a[i] <= 1999){
				color[4] = 1;
			}else if(2000 <= a[i] && a[i] <= 2399){
				color[5] = 1;
			}else if(2400 <= a[i] && a[i] <= 2799){
				color[6] = 1;
			}else if(2800 <= a[i] && a[i] <= 3199){
				color[7] = 1;
			}else if(3200 <= a[i]){
				count2 += 1;
			}
		}
		for(int i = 0;i < 8;i++){
			if(color[i] != 0){
				count1 += 1;
				count2 += 1;
			}
		}
		if(count1 == 0){
			count1 += 1;
		}
		System.out.println(String.valueOf(count1) + " " + String.valueOf(count2));

	}

}

Measured memory_bytes: 20948
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i += 2) {
            sb.append(s.charAt(i));
        }
        String result = sb.toString();

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 25800
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define endl "\n"
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);
char diff(char a,char b){
    for(char x='a';x<='z';x++){
        if(x!=a && x!=b)return x;
    }
}
void solve() {
    int a,b;cin>>a>>b;
    string f;
    string s;
    map<int,char> mp;
    mp[1]='1';
    mp[2]='2';
    mp[3]='3';
    mp[4]='4';
    mp[5]='5';
    mp[6]='6';
    mp[7]='7';
    mp[8]='8';
    mp[9]='9';
    for(int i=1;i<=a;i++){
        s.push_back(mp[b]);
    }
    for(int i=1;i<=b;i++){
        f.push_back(mp[a]);
    }
    if(f<s){
        cout<<f;
    } else{
        cout<<s;
    }

}
int32_t main() {
    IOS;
    int test = 1;
    //cin >> test;
    while (test--) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int price;
    scanf("%d",&price);
    int four,seven,num[400],i=0;

    for(four=0;four<=25;four++){
        for(seven=0;seven<15;seven++){
            num[i] = four*4 + seven*7;
            if(num[i]==price){
                printf("Yes");
                exit(0);
            }
            i++;
        
        }
    }

    printf("No");

    return 0;
}

Measured memory_bytes: 128
n,c=gets.split.map(&:to_i)
d=[*1..c].map{gets.split.map(&:to_i)}
g=[*1..n].map{gets.split.map(&:to_i)}
a=eval ([[0]*c]*3).to_s
c.times{|q|
  n.times{|x|
    n.times{|y|
      a[(x+y)%3][q]+=d[g[y][x]-1][q]
    }
  }
}
p [*0...c].permutation(3).map{|x,y,z|a[0][x]+a[1][y]+a[2][z]}.min

Measured memory_bytes: 4720
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n,cnt=1,kake=0,tmp=0;
	ll ans = 0;
	cin >> n;
	REP(i, (int)sqrt(n)) {
		kake = (n - 1) / cnt;
		tmp = kake - i;
		if (1 <= tmp) {
			ans += tmp * 2 + 1;
		}
		else if (tmp == 0) {
			ans += tmp + 1;
		}
		cnt++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
using namespace std;
int x,y;
ll fac(int x){
	ll s=1;
	for (int i=1;i<=x;i++)
		s=s*i%mo;
	return s;
}
int main(){
	scanf("%d%d",&x,&y);
	if (x>y) swap(x,y);
	if (x==y) printf("%lld",fac(x)*fac(x)*2%mo);
	else if (x+1==y) printf("%lld",fac(x)*fac(y)%mo);
	else puts("0");
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    s.insert(4," ");
    cout << s << endl;
}


Measured memory_bytes: 3580
//control+option+n to run!
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define NEGFOR(i, a, b) for (ll i = (a); i > (b); i--)
#define vll vector<long long>
#define sll set<long long>
#define ld long double
#define inf 1000000000000000000;
#define mll multiset<long long>
#define nn << "\n"
#define F(i, b) for (ll i = 0; i < b; i++)
//10^8 operations per second
//greatest int is 2,147,483,647
//greates long long is 9.22337204e18

//ALL FUNCTIONS SHOULD BE LL!!!!
ll mod = (ll)(1e9+7);

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  vll v(n);
  vll prefix = {0};
  FOR(i, 0, n)
  {
    cin >> v[i];
    v[i] %= mod;
    prefix.pb((v[i]%mod + prefix[prefix.size()-1]%mod) % mod);
  }

  ll ans = 0;
  ll sum = prefix[n]%mod;
  FOR(i, 0, n)
  {
    ans += (v[i] * ((sum - prefix[i + 1]+mod*mod)%mod)) % mod;
    ans %= mod;
  }
  cout << ans;


  cout << "\n"; //GET RID OF THIS FOR THE ACTUAL PROGRAM!!!!
}


Measured memory_bytes: 6868
from operator import itemgetter

N = int(input())
ranking = []
for i in range(N):
  si, pi = input().split()
  ranking.append((si,int(pi)*(-1),i+1))

sorted_ranking = sorted(ranking, key = lambda x: (x[0],x[1]))
for i in range(N):
  print(sorted_ranking[i][2])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string S, Sc ="CODEFESTIVAL2016";
	cin >> S;
	int ans =0;
	for(int i =0; i < (int)S.length(); i++) if(S[i] != Sc[i]) ans++;
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n;
    
    scanf("%d", &n);
    
    for (int i=0; i<=n; i++) {
        for (int j=0; j<=n-i; j++) {
            if (n==i*4+j*7) {
                printf("Yes");
                return 0;
            }
        }
    }
    
    printf("No");
    
    return 0;
}


Measured memory_bytes: 1728
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

ll dp[100010];

int main(){
  itn n,k; cin >> n >> k;
  vector<pll> a(n);
  rep(i,n) cin >> a[i].se >> a[i].fi;
  rsort(a);
  ll ans=0;
  set<int> kind;
  vector<ll> pulllist;
  rep(i,k){
    if(kind.count(a[i].se)) pulllist.push_back(a[i].fi);
    ans+=a[i].fi;
    kind.insert(a[i].se);
  }
  ans+=kind.size()*kind.size();
  if(pulllist.size()==0){
    cout << ans << endl;
    return 0;
  }
  sortt(pulllist);
  vector<ll> spull(pulllist.size());
  spull[0]=pulllist[0];
  rep(i,pulllist.size()-1) spull[i+1]=spull[i]+pulllist[i+1];
  int ks0=kind.size();
  vector<ll> pushlist;
  for(int i=k;i<n;i++){
    if(!(kind.count(a[i].se))) pushlist.push_back(a[i].fi);
    kind.insert(a[i].se);
  }
  if(pushlist.size()==0){
    cout << ans << endl;
    return 0;
  }
  vector<ll> spush(pushlist.size());
  spush[0]=pushlist[0];
  rep(i,pushlist.size()-1) spush[i+1]=spush[i]+pushlist[i+1];
  ll ans0=ans;
  ans=ans0;
  rep(i,min(spull.size(),spush.size())){
    chmax(ans,ans0-ks0*ks0-spull[i]+spush[i]+(ks0+i+1)*(ks0+i+1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<< #x" " << x << endl;
#define ll long long
int main()
{
    //ios_base::sync_with_stdio(false);
    ll n;
    ll a;
    ll ans=0;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a,ans+=(a-1);
    cout<< ans<<endl;
    return 0;
}


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

int main() {
  int n, c = 0;
  cin >> n;
  for(int i = 0;i < n;i++) {
    int a;
    cin >> a;
    if(((i+1) * a) % 2 == 1) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 3636
x=gets.to_i
array=[0]
1.upto(1000) do |i|
  array.push(i**5)
  array.push((-i)**5)
end
array.sort!
a=0
b=0
array.repeated_combination(2) do |an,bn|
  if an-bn==x
    a=an
    b=bn
    break
  elsif bn-an==x
    a=bn
    b=an
    break
  end
end
aindex=array.index(a)-1000
bindex=array.index(b)-1000
puts [aindex,bindex].join(" ")


Measured memory_bytes: 14356
#include <stdio.h>
#include <stdlib.h>

struct asumisu {
	int X;
	int idx;
};

int mimorinn(const void* yukachi, const void* ayachi) {
	int mikisinn = ((const struct asumisu*)yukachi)->X, hayaminn = ((const struct asumisu*)ayachi)->X;
	return mikisinn < hayaminn ? -1 : mikisinn > hayaminn;
}

int N;
struct asumisu mizuhasu[271828];

int mareitaso[271828];

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &mizuhasu[i].X) != 1) return 1;
		mizuhasu[i].idx = i;
	}
	qsort(mizuhasu, N, sizeof(*mizuhasu), mimorinn);
	for (i = 0; i < N / 2; i++) {
		mareitaso[mizuhasu[i].idx] = mizuhasu[N / 2].X;
	}
	for (i = N / 2; i < N; i++) {
		mareitaso[mizuhasu[i].idx] = mizuhasu[N / 2 - 1].X;
	}
	for (i = 0; i < N; i++) {
		printf("%d\n", mareitaso[i]);
	}
	return 0;
}


Measured memory_bytes: 4472
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, M = [ int(x) for x in input().split() ]

nm = []
for _i in range(M):
    nm.append([ int(x) for x in input().split() ])

ans = [1,N]

for _nm in nm:
    if ans[0] < _nm[0]:
        ans[0] = _nm[0]
    if ans[1] > _nm[1]:
        ans[1] = _nm[1]

print(max(ans[1] - ans[0] + 1,0))



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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string s;
  cin >> s;
  int k = 0;
  REP(i,SZ(s))
	if(k == 0 && s[i] == 'C')
	  ++k;
	else if(k==1 && s[i] == 'F')
	  ++k;

  cout << (k==2?"Yes":"No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


ll ans[100001];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ,Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    
    ll now = 0 ;
    rep(i, S.size()){
        if(i == 0) ans[i] = 0;
        else{
            if(S[i] == 'C' && S[i-1] == 'A'){
                now ++;
            }
            ans[i] = now;
        }
    }
    
    /*
    rep(i, S.size()){
        cout << ans[i] ;
    }
    cout << endl;
     */
    vector<ll> a;

    rep(i, Q){
        ll l,r;
        cin >> l >> r;
        l--;
        r--;
        if(l == -1){
            a.pb(ans[r]);
        }else{
            a.pb(ans[r] - ans[l]);
        }
    }
    
    rep(i, a.size()){
        cout << a[i] << endl;
    }
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int S[n];
    for(int i=0; i<n; i++){
        cin >> S[i];
    }
    
    int q;
    cin >> q;
    int T[q];
    for(int j=0; j<q; j++){
        cin >> T[j];
    }
    
    int count = 0;
    for(int a=0; a<q; a++){
        int b=0;
        while(b<n){
            if(T[a] == S[b]){
                count++;
                break;
            } else {
                b++;
            }
        }
    }
    cout << count << endl;
    
    return 0;
}


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

int main(){

    string n;
    cin >> n;


    for( int i = 0; i < 3; i++ ){
        if( n[i] == '1' ) n[i] = '9';
        else n[i] = '1';
    }

    cout << n << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n,a,b; cin >> n >> a >> b;

  if(a>b) swap(a,b);

  if(a%2==0&&b%2==0){
    cout << (b-a)/2;
  }
  else if(a%2==1&&b%2==1){
    cout << (b-a)/2;
  }
  else{

    int dis1 = a - 1;
    int b1 = b - dis1;
    
    int moves1 = dis1;

    if(b1%2==0){
      b1--;
      moves1++;
    }

    moves1+=(b1-1)/2;

    int dis2 = n-b;
    int a1 = a + dis2;

    int moves2 = dis2;

    if(a1%2!=n%2){
      a1++;
      moves2++;
    }

    moves2+=(n-a1)/2;

    cout << min(moves1,moves2);

  }

  

  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc077/tasks/abc077_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string x, y;
    cin >> x >> y;
    reverse(ALL(y));
    if (x == y) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 256
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */



  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <string.h>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9;

const long long MOD = 1e9 + 7;

long long dp[15][500000];
int main(){
    ios_base::sync_with_stdio();
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    dp[0][0] = 1;
    for (int i = 0; i < s.size(); i++)
    {
        for (int P = 0; P < 13; P++)
        {
            if (s[i] == '?')
            {
                for (int x = 0; x < 10; x++)
                {
                    int kek = (10 * P + x) % 13;
                    dp[kek][i + 1] = (dp[kek][i + 1] + dp[P][i]) % MOD;
                }
            }
            else
            {
                int x = s[i] - '0';
                int kek = (10 * P + x) % 13;
                dp[kek][i + 1] = (dp[kek][i + 1] + dp[P][i]) % MOD;
            }
        }
    }
    cout << dp[5][s.size()];
    // for(int i=0;i<13;i++){
    //   for(int j=0;j<=s.length();j++)
    //     cout<<dp[i][j]<<" ";
    //   cout<<"\n";
    // }
return 0;
}


Measured memory_bytes: 38144
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll n, i;
	cin >> n;
	pair <ll, ll> p[n];
	fr(i,0,n)
		cin >> p[i].ss >> p[i].ff;
	sort(p, p+n);
	ll ct = 0;
	fr(i,0,n)
	{
		if(p[i].ff >= ct + p[i].ss)
			ct = ct + p[i].ss;
		else
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 3328
from sys import stdin
input=stdin.readline().rstrip()
input_list=list(input)
n=len(input_list)-1

for i in range(2**n):
    out=input_list[0]
    for j in range(n):
        if ((i >> j) & 1):
            out+="+"
        else:
            out+="-"
        out+=input_list[j+1]
    if eval(out)==7:
        print(out+"=7")
        break

Measured memory_bytes: 3064
def main():

    S, T = input().split()
    A, B = map(int, input().split())
    U = input()

    if U == S:
        return " ".join(map(str, [A-1, B]))
    else:
        return " ".join(map(str, [A, B-1]))

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
int n, u[2];
vector< vector<int> > edg;
vector<int> dst[3];
void f(int x, int v){
    for(int i=0;i<edg[v].size();i++){
        int w = edg[v][i];
        if(dst[x][w] != -1) continue;
        dst[x][w] = dst[x][v] + 1;
        f(x, w);
    }
}
void g(int x, int v){
    for(int i=0;i<edg[v].size();i++){
        int w = edg[v][i];
        if(w == x || dst[2][w] == -2) continue;
        dst[2][w] = -2;
        g(x, w);
    }
}
int main(void){
    cin >> n >> u[0] >> u[1];
    edg.assign(n, vector<int>());

    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edg[a].push_back(b);
        edg[b].push_back(a);
    }

    for(int i=0;i<2;i++){
        dst[i].assign(n, -1);
        dst[i][--u[i]] = 0;
        f(i, u[i]);
    }



    if(dst[0][0]%2 == dst[1][0]%2){
        int x = -1;
        for(int i=0;i<n;i++){
            if(dst[0][i] == dst[1][i]){
                if(x == -1) x = i;
                else if(dst[0][i] < dst[0][x]) x = i;
            }
        }
        dst[2].assign(n, -1);
        dst[2][u[1]] = -2;
        dst[2][x] = 0;
        g(x, u[1]);
        f(2, x);
        int mx = 0;
        for(int i=0;i<n;i++){
            if(dst[0][i] == dst[1][i]) continue;
            if(mx < dst[2][i]) mx = dst[2][i];
            //cout << i << " " << dst[2][i] << endl;
        }
        cout << dst[0][x] + mx - 1 << endl;
        //cout << x << " " << dst[0][x] << endl;

    }else{
        int ans = 0;
        for(int i=0;i<n;i++){
            int fu = dst[0][i];
            int fv = dst[1][i];
            if(fu < fv && ans < fv-1){
                ans = fv-1;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

int main()
{
  double L;
  cin >> L;
  double ans = (L / 3) * (L / 3) * (L / 3);
  printf("%.12f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, l, n, ans = 0;
  scanf("%lld%lld", &n, &k);
  ll a[n];
  vector<ll> sum;
  vector<bool> flg;
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < n; ++i) {
    ll now = 0;
    for(j = i; j < n; ++j) {
      now += a[j];
      sum.push_back(now);
      flg.push_back(true);
    }
  }
  for(i = 45; i >= 0; --i) {
    ll t = 1ll << i, cnt = 0;
    for(j = 0; j < sum.size(); ++j) if(flg[j] && (sum[j] & t)) ++cnt;
    if(cnt >= k) {
      ans += t;
      for(j = 0; j < sum.size(); ++j) if(!(sum[j] & t)) flg[j] = false;
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 6000
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
//#define endl '\n'
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;
const ll INFTY=1000000000000000000LL;
int n,m,ans=0;
int main(){
cin>>n>>m;
int k,s;
vector<vector<int> >G(m);

rep(i,m){
    cin>>k;
    rep(j,k){
        cin>>s;
        G[i].push_back(s);
    }
}
vector<int>p;
rep(i,m){
    cin>>s;
    p.push_back(s);
}
for(int bit=0;bit<(1<<n);bit++){
    bool flag=true;
    vector<int>on;
    for(int i=0;i<n;i++){//onになっている電球をリストアップ
        if(bit & (1<<i)){
            on.push_back(i+1);
        }
    }

    rep(i,m){
        int count=0;
        rep(j,G[i].size()){
            count+=(int)binary_search(ALL(on),G[i][j]);
        }
        if(count%2!=p[i]){
            flag=false;
            break;
    }
}
if(flag)ans++;
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
character(50)mihon(16)
character(50) S
mihon(1)="AKIHABARA"
mihon(2)="AKIHABAR"
mihon(3)="AKIHABRA"
mihon(4)="AKIHABR"
mihon(5)="AKIHBARA"
mihon(6)="AKIHBAR"
mihon(7)="AKIHBRA"
mihon(8)="AKIHBR"
mihon(9)="KIHABARA"
mihon(10)="KIHABAR"
mihon(11)="KIHABRA"
mihon(12)="KIHABR"
mihon(13)="KIHBARA"
mihon(14)="KIHBAR"
mihon(15)="KIHBRA"
mihon(16)="KIHBR"
read*,S
do i=1,16
  if(S==mihon(i))then
  print"(A)","YES"
  stop
  endif
end do
print"(A)","NO"
end

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

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    string S, O;
    cin >> S;
    
    REP(i, S.length()) {
        O += "x";
    }

    cout << O << endl;

    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pair<string, int>> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
	string x;
	cin >> x;
	int st;
	for (int i = 0; i < n; i++) {
		if (p[i].first == x) {
			st = i + 1;
			break;
		}
	}
	int ans = 0;
	for (; st < n; st++) {
		ans += p[st].second;
	}
	cout << ans;
	return 0;
}

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

using namespace std;

const int N = 2005;
int n, k, q, a[N], ans = 1e9+5, t[N], b[N], c[N];

void cal(int mn){
	int l = 1, r = 1;
	b[0] = 0;
	while(l <= n){
		c[0] = 0;
		while(a[l] < mn && l <= n)	l++;
		r = l;
		while(a[r] >= mn && r <= n)	r++;
		for(int i = l; i < r && i <= n; i++)
			c[++c[0]] = a[i];
		if(c[0] >= k){
			sort(c+1, c+c[0]+1);
			for(int i = 1; i <= c[0] - k + 1; i++)
				b[++b[0]] = c[i];
		}
		l = r;
	}
	sort(b+1, b+b[0]+1);
	if(b[0] >= q)	ans = min(ans, b[q] - b[1]);
}

int main(){
	scanf("%d%d%d", &n, &k, &q);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		t[i] = a[i];
	}
	sort(t+1, t+n+1);
	for(int i = 1; i <= n; i++)
		cal(t[i]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SP << " " <<
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long
int MOD = 2019;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int L, R;
  cin >> L >> R;
  if(R - L + 1 >= MOD) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> s;
  for(int i = L; i <= R; i++) {
    s.push_back(i % MOD);
  }
  int ans = 10000;
  for(int i = 0; i < s.size() - 1; i++) {
    for(int j = i + 1; j < s.size(); j++) {
      int tmp = (s[i] * s[j]) % MOD;
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    w = input()
    flag = True
    for i in range(ord('a'), ord('z')+1):
        if w.count(chr(i)) % 2:
            flag = False
            break
    print('Yes' if flag else 'No')

main()


Measured memory_bytes: 3064
from collections import deque
import numpy as np

H,W = map(int,input().split())
maze = [input() for _ in range(H)]

ans = 0
for x in range(H):
    for y in range(W):
        #壁からはスタートできない
        if maze[x][y] == "#":
            continue

        distance = [[-1]*W for _ in range(H)]
        distance[x][y] = 0
        #start位置
        stack = deque([[x,y]])

        while stack:
            h,w = stack.popleft()
            for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
                new_h, new_w = h+i, w+j
                if new_h < 0 or new_w < 0 or new_h >= H or new_w >= W:
                    continue
                elif maze[new_h][new_w] != "#" and distance[new_h][new_w] == -1:
                    distance[new_h][new_w] = distance[h][w]+1
                    stack.append([new_h, new_w])

        ans = max(ans, np.max(distance))

print(ans)

Measured memory_bytes: 27192
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

LL calc(LL a){
    LL tmp = a/4 * 4;
    LL ans = 0;
    for(LL b = tmp;b <= a;++b)ans ^= b;
    return ans;
}

int main(){
    LL A,B;cin >> A >> B;
    LL res = 0;
    if(A != 0)res = calc(B) ^ calc(A-1);
    else res = calc(B);
    cout << res << endl;
}


Measured memory_bytes: 256