akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define mp make_pair
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcd(int a,int b){return a*b / gcd(a,b);}
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  string s,t;
  int a,b;
  string u;
  cin >> s >> t >> a >> b >> u;
  if(s == u){
    a--;
  }else{
    b--;
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

int main()
{
	IO;
	string s;
	cin>>s;
	if(s[2]==s[3]){
		if(s[4]==s[5]){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
 	return 0;
}







Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        StringTokenizer st;
        try {
            String line;
            line = br.readLine();
            st = new StringTokenizer(line);
            ArrayList<Integer> list = new ArrayList<>();
            for (int i = 0; i < 5 ; i++) {
                list.add(Integer.parseInt(st.nextToken()));
            }
            // 手抜き
            Collections.sort(list);
            Collections.reverse(list);
            for (Integer integer : list) {
                sb.append(integer).append(" ");
            }
            System.out.println(sb.toString().trim());

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	while(ll r=(a%b)){
		a = b;
		b = r;
	}
	return b;
}

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

	int K=in();
	ll S=0;
	REP(a,K){
		REP(b,K){
			REP(c,K){
				S += gcd(gcd(a+1,b+1),c+1);
			}
		}
	}
	out(S);
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>

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

using namespace std;

int main()
{
	char c;
	cin >> c;
	
	switch (c) {
	case 'A':cout << 'T'; break;
	case 'T':cout << 'A'; break;
	case 'C':cout << 'G'; break;
	case 'G':cout << 'C'; break;
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	k := sc.NextInt()

	ans := 0
	for i := 0; i < n; i++ {
		tmp := sc.NextInt()
		if tmp >= k {
			ans++
		}
	}

	fmt.Printf("%v\n", ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
using namespace std;
long long a[200010],ans = 0;
int main(){
    int i,n; cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a + n);
    long long num = n - 1;
    ans += a[n - 1]; num--;
    for(i=n - 2;i>=0;i--){
        ans += min(2LL,num)*a[i];
        num -= min(2LL,num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5196
/*  ex2_3
    Rikuta */

#include<stdio.h>

int main(void){

    int length,white,black,area;
    //マス目の一辺の数，白のマス数の入力
    scanf("%d",&length);
    scanf("%d",&white);
    //マスの数の計算
    area = length*length;
    //黒のマス数の計算
    black= area - white;
    //黒のマス数の出力
    printf("%d\n",black);

    return 0;
}


Measured memory_bytes: 128
N, K, Q = (int(i) for i in input().split())
A = [int(input()) for i in range(Q)]

import numpy as np
S = np.ones(N)*(K - Q)

for i in range(Q):
  x = A[i]
  S[x-1] += 1

for i in range(N):
  if S[i] <= 0:
    print('No')
  else:
    print('Yes')

Measured memory_bytes: 17884
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<memory.h>
#include<map>
#include<set>
#include<queue>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n;
int main()
{
	//freopen("B.out","w",stdout);
	cin>>n;
	if(n==3){cout<<2<<endl<<"1 3\n2 3\n";return 0;}
	if(n==4){cout<<4<<endl<<"1 2\n3 4\n1 3\n2 4\n";return 0;}
	if(n&1)
	{
		int t=n/2;
		cout<<t*4<<endl;
		rep(i,1,t-1)
		{
			cout<<i<<' '<<n-i-1<<endl;
			cout<<i+1<<' '<<n-i<<endl;
			cout<<i<<' '<<i+1<<endl;
			cout<<n-i-1<<' '<<n-i<<endl;
		}
		cout<<n<<' '<<1<<endl;
		cout<<n<<' '<<n-1<<endl;
		cout<<n<<' '<<t<<endl;
		cout<<n<<' '<<n-t<<endl;
	}else
	{
		int t=n/2;
		cout<<t*4<<endl;
		rep(i,1,t-1)
		{
			cout<<i<<' '<<n-i<<endl;
			cout<<i+1<<' '<<n-i+1<<endl;
			cout<<i<<' '<<i+1<<endl;
			cout<<n-i<<' '<<n-i+1<<endl;
		}
		cout<<t<<' '<<n<<endl;
		cout<<n-t+1<<' '<<1<<endl;
		cout<<t<<' '<<1<<endl;
		cout<<n-t+1<<' '<<n<<endl; 
	}
}


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

int main() {
    int n;
    bool ans = false;
    cin >> n;
    for (int i = 0; i < n/4+1; i++) {
        if ((n - 4*i) % 7 == 0) {
            ans += 1;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    ll N;
    cin >> N;
    cout << N + N*N + N*N*N << endl;
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N; cin >> N;
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 && i % 5) ans += i;
    }
    cout << ans << endl;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n,k;
    Scd2(n,k);

    int cycle[12] = {};
    cycle[k] += 5 * ((n - 2) / 11);
    n = (n - 2) % 11;
    Rep(i,n){
        Repe(j,6,1){
            cycle[(9*j+9+i*8+21+42)%11]++;
        }
    }

    printf ("%d\n", cycle[k]);

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main() {
    int n; string s;
    cin>>n>>s;
    
    int x=0;
    int ans=0;
    rep(i,n){
        if(s.at(i)=='I') x++;
        else x--;
        ans=max(ans,x);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @coding_abhi
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
int main(int argc, const char** argv) {
    int N,i,j;
    cin>>N;
    int H[N];
    rep(i,0,N)  cin>>H[i];
    int ans[N]={0};
    ans[0] = 0;
    ans[1] = abs(H[1] - H[0]);
    rep(j,2,N){
        ans[j] = min(ans[j-2]+ abs(H[j]-H[j-2]),ans[j-1]+ abs(H[j]-H[j-1]));
    }
    cout<<ans[N-1];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stack>

using namespace std;

int main() {
    string a;
    cin >> a;
    int strsize = 0;
    strsize = a.size() - 2;
    string num = std::to_string(strsize);
    cout << a[0] + num + a[strsize + 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, M;
    cin >> N >> M;
    ll L = 1, R = N;
    rep(i, 0, M){
        ll l, r;
        cin >> l >> r;
        L = max(l, L);
        R = min(r, R);
    }
    if(R >= L) cout << R-L+1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

bool letter[26][2];

int main()
{
	int l,total,answer;
	char str[105];
	scanf("%d%s",&l,&str);
	answer = 0;
	for (int i = 0; i < l; i++)
	{
		memset(letter,0,sizeof(letter));
		total = 0;
		for (int j = 0; j < i; j++)
		{
			letter[str[j] - 'a'][0] = 1;
		}
		for (int k = i; k < l; k++)
		{
			letter[str[k] - 'a'][1] = 1;
		}
		for (int m = 0; m < 26; m++)
		{
			total += (letter[m][0] & letter[m][1]);
		}
		answer = max(answer,total);
	}
	printf("%d\n",answer);
	return 0;
}


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

const int MAX_X = 100003;

int main()
{
    vector<int> min_factor(MAX_X + 1, 0);
    for (int64_t i = 2; i <= MAX_X; i++)
    {
        if (min_factor.at(i) > 0)
        {
            continue;
        }
        for (int64_t j = i * i; j <= MAX_X; j += i)
        {
            if (min_factor.at(j) > 0)
            {
                continue;
            }
            min_factor.at(j) = i;
        }
    }

    int X;
    cin >> X;
    for (int i = X; i <= MAX_X; i++)
    {
        if (min_factor.at(i) == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdint>
#include <vector>
#include <cmath>

class ModComb {
public:
  /**
   * \param p prime number
   * \param k max number for table
   */
  ModComb(uint64_t p, uint64_t k);

  uint64_t factorial(uint64_t n) const;
  uint64_t inverse(uint64_t n) const;
  uint64_t factorial_inverse(uint64_t n) const;

  uint64_t combination(uint64_t n, uint64_t k) const;

private:
  const uint64_t p_, k_;
  // table for n!
  std::vector<uint64_t> factorial_;
  // table for n^(-1)
  std::vector<uint64_t> inverse_;
  // table for (n!)^(-1)
  std::vector<uint64_t> factorial_inverse_;
};

ModComb::ModComb(uint64_t p, uint64_t k)
    : p_(p), k_(k)
{
  if(p < k) {
    throw std::runtime_error("p < k (must k <= p");
  }

  factorial_.resize(k_ + 1);
  inverse_.resize(k_ + 1);
  factorial_inverse_.resize(k_ + 1);

  factorial_[0] = factorial_[1] = 1;
  inverse_[0] = inverse_[1] = 1;
  factorial_inverse_[0] = factorial_inverse_[1] = 1;
  for(uint64_t i=2; i<=k_; i++) {
    factorial_[i] = (i * factorial_[i-1]) % p_;
    int64_t a = - (p_/i) * inverse_[p_ % i];
    while(a<0) {
      a += p_;
    }
    inverse_[i] = a % p_;
    factorial_inverse_[i] = (inverse_[i] * factorial_inverse_[i-1]) % p_;
  }
}

uint64_t ModComb::factorial(uint64_t n) const
{
  if(k_ < n) {
    throw std::runtime_error("too large n (must n <= k)");
  }
  return factorial_[n];
}

uint64_t ModComb::inverse(uint64_t n) const
{
  if(k_ < n) {
    throw std::runtime_error("too large n (must n <= k)");
  }
  return inverse_[n];
}

uint64_t ModComb::factorial_inverse(uint64_t n) const
{
  if(k_ < n) {
    throw std::runtime_error("too large n (must n <= k)");
  }
  return factorial_inverse_[n];
}

uint64_t ModComb::combination(uint64_t n, uint64_t k) const
{
  if(n < k) {
    throw std::runtime_error("error: n < k (must k < n)");
  }
  if(k_ < n) {
    throw std::runtime_error("too large n (must n < k_)"
                             " n = " + std::to_string(n) +
                             " k_ = " + std::to_string(k_));
  }

  return (((factorial_[n] * factorial_inverse_[n-k]) % p_) * factorial_inverse_[k]) % p_;
}


int main()
{
  uint64_t n, k;
  std::cin >> n >> k;

  constexpr uint64_t p = std::pow(10, 9) + 7;
  ModComb mc(p, n);
  if(n <= k) {
    k = n-1;
  }
  // std::cout << "k: " << k << std::endl;

  uint64_t ret = 0;
  for(uint64_t l=0; l<=k; l++) {
    // nstd::cout << "n=" << n << " l=" << l;
    uint64_t r = mc.combination(n, l) * mc.combination(n-1, n-1-l);
    // std::cout << " r=" << r << std::endl;
    ret += r;
    ret %= p;
  }

  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 8020
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    V = [True] * N
    H = [int(v) for v in input().split()]
    AB = [[int(v) - 1 for v in input().split()] for _ in range(M)]
    for a, b in AB:
        if V[a] or V[b]:
            if H[a] <= H[b]:
                V[a] = False
            if H[a] >= H[b]:
                V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

Measured memory_bytes: 30340
#include <stdio.h>

int main(void){

	int in[3]={0};
	
	int tmp=0;
	int i,j;
	scanf("%d %d %d",&(in[0]),&(in[1]),&(in[2]));
	
	for(i=0;i<2;i++){
		for(j=2;j>=i+1;j=j-1){
			if(in[j]<in[j-1]){
				tmp=in[j];
				in[j]=in[j-1];
				in[j-1]=tmp;
			}
		}
	}
	
	printf("%d",in[0]+in[1]);	
	
	return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    int cnt = 0;
    rep(0, 3) {
        if (s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#include<string.h>
#define inf 9000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	ll n,k;
	cin>>n>>k;
	ll p=(n*(n+1))/2;
	ll sum=0;
	repeat(i,k,n+2){
		ll o=(i*(i-1))/2;
		ll q=((n-i)*(n-i+1))/2;
		q=p-q;
		sum+=(q-o+1);
		sum%=mod;
	}
	cout1(sum);
}
int main(){
    int t=1;
	//scanf("%d",&t);
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdint>
#include <vector>
#include <utility>

using vec64 = std::vector<int64_t>;

int64_t solve(int n,const vec64 &as) {
  vec64 maxs(n+1);
  int64_t min=0,max=0;
  for ( int i=n; i>=0; i-- ) {
    auto e=as[i];
    min=(min+1)/2+e;
    maxs[i]=max+=e;
  }
  if ( min>1||max<1 ) {
    return -1;
  }
  int64_t t=1,ans=1;
  for ( int i=1; i<=n; i++ ) {
    ans += t = std::min((t-as[i-1])*2,maxs[i]);
  }
  return ans;
}

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

  vec64 as(n+1);
  for ( auto &e: as ) {
    std::cin >> e;
  }

  std::cout << solve(n,as) << std::endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll a[1000010];

void solve(){

    ll n,m;
    cin >> n >> m;
    ll sum = 0;
    rep(i,m){
        cin >> a[i];
        sum += a[i];
    }

    if(n>=sum) cout << n-sum << endl;
    else cout << -1 << endl;

}

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


Measured memory_bytes: 3680
n = int(input())
p = list(map(int, input().split()))

ans = 0

for i in range(1,n-1):
    if p[i-1] < p[i] and p[i] < p[i+1]:
        ans += 1
    elif p[i-1] > p[i] and p[i] > p[i+1]:
        ans += 1

print(ans)

Measured memory_bytes: 3060
import queue
n=int(input())
a=[int(input()) for _ in range(n)]
q=queue.Queue()
q.put(1)
ans=0
for i in range(n):
    b=q.get()
    if b==2:
        print(ans)
        exit()
    q.put(a[b-1])
    ans+=1
print(-1)

Measured memory_bytes: 8120
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;
const long MOD=1000000007;
long modinv(long a) {
    long  b = MOD, u = 1, v = 0;
    while (b) {
        long  t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

int main(void){
    vector<long> kaizyo(50000);
    kaizyo.at(0)=1;
    for(int i=1;i<5000;i++){
        kaizyo.at(i)=kaizyo.at(i-1)*i;
        kaizyo.at(i)%=MOD;
    }
    
    
    
    long N,K;
    cin>>N>>K;
    
    for(int i=1;i<=K;i++){
        long freeb=K-i;
        long freer=(N-K)-i+1;
        if(freer<0){
            cout<<0<<endl;
            continue;
        }
        long b=(kaizyo.at(freeb+i-1)*modinv(kaizyo.at(freeb))%MOD)*modinv(kaizyo.at(i-1));
        long r=(kaizyo.at(freer+i)*modinv(kaizyo.at(freer))%MOD)*modinv(kaizyo.at(i));
        
        cout<<((b%MOD)*(r%MOD))%MOD<<endl;
    }
    
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
const int N=107;
int n,k,A[N][N];
void eat() {
	For(i,1,n-1)
		For(j,i+1,n-1) {
			A[i][j]=1;
			if(!--k) return;
		}
}
int main() {
	scanf("%d%d",&n,&k);
	For(i,1,n-1) A[i][n]=1;
	k=(n-1)*(n-2)/2-k;
	if(k<0) {
		puts("-1");
		return 0;
	}
	if(k) eat();
	int m=0;
	For(i,1,n)
		For(j,i+1,n)
		if(A[i][j]) ++m;
	printf("%d\n",m);
	For(i,1,n)
		For(j,i+1,n)
		if(A[i][j]) printf("%d %d\n",i,j);
	return 0;
}

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

int A[100000], n;

int binary(int key){
    int left=0;
    int right=n;
    int mid;
    
    while(left < right){
        mid=(left+right)/2;
        if (A[mid] == key)return 1;
        if (key>A[mid])left=mid+1;
        else if (key < A[mid])right = mid;
        }
        return 0;
}

int main(){
    int i, q, key, sum=0;
    
    scanf("%d",&n);
    for(i=0; i<n; i++)scanf("%d",&A[i]);
    
    scanf("%d",&q);
    for(i=0; i<q; i++){
        scanf("%d",&key);
        if(binary(key))sum++;
    }
    printf("%d\n",sum);
    return 0;
}



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

using namespace std;

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    char turn = 'a';
    while (true) {
        switch (turn) {
            case 'a':
                if (sa == "a" or sa.empty()) {
                    cout << "A" << endl;
                    return 0;
                }
                turn = sa[0];
                sa = sa.substr(1);
                break;
            case 'b':
                if (sb == "b" or sb.empty()) {
                    cout << "B" << endl;
                    return 0;
                }
                turn = sb[0];
                sb = sb.substr(1);
                break;
            case 'c':
                if (sc == "c" or sc.empty()) {
                    cout << "C" << endl;
                    return 0;
                }
                turn = sc[0];
                sc = sc.substr(1);
                break;
            default:
                break;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll p, q, r;
    cin >> p >> q >> r;
    cout << (p + q + r - max({p, q, r}));
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

V,E=MI()
g=[[] for _ in range(V+1)]
for i in range(E):
    u,v,d=MI()
    g[u].append((v,d))
    g[v].append((u,d))

T=I()
order=[0]*T
accor=[0]*T
for i in range(T):
    n=I()
    accor[i]=accor[i-1]
    if n>0:
        oid,v=MI()
        order[i]=v
        accor[i]+=1

def rand_move():
    move=[]
    state=0 # on vertex
    cur=1
    
    st=min(T//2,bisect.bisect(accor,V//4))
    
    for t in range(st):
        print(-1)
    for t in range(st,T):
        if state==0:
            r=len(g[cur])
            dest,dist=g[cur][random.randint(0,r-1)]
            state=1
            move.append(dest)
            dist-=1
            if dist==0:
                state=0
                cur=dest
        else:
            move.append(dest)
            dist-=1
            if dist==0:
                state=0
                cur=dest
    return move

for i in range(1,V+1):
    show(i,g[i])
move=rand_move()
for i in move:
    print(i)


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

using namespace std;

int main()
{
	long long P, A[500000];

	int N, C, Q;

	scanf("%d", &N);

	scanf("%lld", &P);

	scanf("%d", &Q);

	long long zenbugaishoku = 0;

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &C);

		zenbugaishoku += C;

		A[i] = C - (Q - i) * P;
	}

	sort(A, A + N);

	long long Answer = zenbugaishoku;

	long long sum = zenbugaishoku;

	long long V = 2 * P;

	for (int i = 0; i < N; i++)
	{
		sum += V * i - A[i];

		Answer = max(sum, Answer);
	}

	printf("%lld\n", Answer);

	return 0;
}

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


using T = tuple<int, int, int>;// l,r,k
using P = pair<int, int>;// t, k
vector<P> in[200000];
vector<P> out[200000];
int cnt[200010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream ifs("in");
	std::cin.rdbuf(ifs.rdbuf());
#endif

	int N, K, Q;
	cin >> N >> K >> Q;
	for(int i = 0; i < Q; i++){
		int l, r, k;
		cin >> l >> r >> k;
		l--, r--;
		in[l].push_back({ i, k });
		out[r].push_back({ i, k });
	}
	int ans = 0, NG = 0;
	set<P> s;
	map<int, int> cm;
	cm[0] = K;
	for(int i = 0; i < N; i++){
		for(auto x : in[i]){
			s.insert(x);
			auto it = s.find(x);
			if(it != s.begin()){
				auto pre = prev(it);
				if(pre->second >= it->second) NG++;
				auto nxt = next(it);
				if(nxt != s.end()){
					if(pre->second >= nxt->second) NG--;
				}
			}
			{
				auto nxt = next(it);
				if(nxt != s.end()){
					if(it->second >= nxt->second) NG++;
				}
			}

			cm[cnt[x.second]]--;
			cnt[x.second]++;
			cm[cnt[x.second]]++;
		}

		if(NG == 0 && cm[1] == K && s.size() == K){
			ans++;
		}

		for(auto x : out[i]){
			auto it = s.find(x);
			if(it != s.begin()){
				auto pre = prev(it);
				if(pre->second >= it->second) NG--;
				auto nxt = next(it);
				if(nxt != s.end()){
					if(pre->second >= nxt->second) NG++;
				}
			}
			{
				auto nxt = next(it);
				if(nxt != s.end()){
					if(it->second >= nxt->second) NG--;
				}
			}

			s.erase(x);
			cm[cnt[x.second]]--;
			cnt[x.second]--;
			cm[cnt[x.second]]++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 27084
def main():
    h=int(input())
    c=0
    x=1
    for i in range(1,h+1):
        if h>1:
            h=h//2
            c+=x
            x*=2
        else:
            c+=x
            break
    print(c)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	ans += max(A, B);
	if (A >= B) {
		A--;
	}
	else {
		B--;
	}
	ans += max(A, B);
	cout << ans << endl;
}

Measured memory_bytes: 256
import bisect

A,B,Q=map(int,input().split())
S=[-10**18]+[int(input()) for _ in range(A)]+[10**18]
T=[-10**18]+[int(input()) for _ in range(B)]+[10**18]

for i in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(S,x), bisect.bisect_right(T,x)
    ans=float("inf")
    for s in [S[b-1], S[b]]:
        for t in [T[d-1], T[d]]:
            d1,d2=abs(s-x)+abs(t-s), abs(t-x)+abs(s-t)
            ans=min(ans,d1,d2)
    print(ans)

Measured memory_bytes: 14096
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <bitset>  
using namespace std;

//======================================================
#define for1(i,n)  for (int i = 0; i < (int)(n); ++i)
#define for2(i,n)  for (int i = 1; i <=(int)(n); ++i)
#define forr1(i,n)  for (int i = n - 1 ;i <= 0; --i)
#define forr2(i,n)  for (int i = n  ;i < 0; --i)
#define all(v)	   ((v).begin()), ((v).end())
#define allr(v)	   ((v).rbegin()), ((v).rend())
#define clr(v,d)   memset(v, d, sizeof(v))
#define ull        unsigned long long
#define MP(a,b)	   make_pair(a,b)
#define S          second
#define F          first
#define PI         3.14159265359
#define ll         long long
#define sz(v)	   v.size()
#define pb         push_back
#define pp         pop_back
#define bgn        begin
#define N          100000+5
#define	MOD        1e9+7
#define inf        1e18
//======================================================
int dx[] = { 0,  0, 1, -1 ,  1,  -1,  1,  -1 };
int dy[] = { 1, -1, 0,  0 , -1,   1,  1,  -1 };
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
	while (b--) ret = (ret * a);
	return ret;
}
//======================================================





int main()
{

	int n , k;
	cin >> n >> k;
	vector<int> v(n + 1);
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i];
	}
	vector<int> dp(n + 1 , 2147483647);

	dp[1] = 0;
	dp[2] = abs(v[2] - v[1]);
	for (int i1 = 3; i1 <=n; i1++)
	{

		for (int i2 = 1; i2 <=k; i2++)
		{
			int secIndex = i1 - i2;
			if (secIndex >= 1 && secIndex <= i1- 1)
			{
				dp[i1] = min(dp[secIndex] + abs(v[i1] - v[secIndex]), dp[i1]);

			}
		}
	}
	cout << dp[n];



}




Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int k, x;
    cin >> k >> x;
    REP(i, x-k+1, x+k) cout << i << (i < x+k-1 ? " " : "");
    cout << endl;
}

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

#define long long long int
using namespace std;


#ifdef JUDGE
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
using std::cin;
using std::cout;
#endif

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(6);


    int n, m;
    cin >> n >> m;
    int ans = 0;
    int outlet = 1;
    while (outlet < m) {
        --outlet;
        outlet += n;
        ++ans;
    }

    cout << ans;
    return 0;


}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N, i, x;
	scanf("%d", &N);
	for (i = 1;i <= N;i++)
	{
		x = i;
		if (x % 3 == 0)printf(" %d", i);
		else
		{
			for (;x&&x % 10 != 3;)
				x /= 10;
			if (x % 10 == 3)
				printf(" %d", i);
		}
	}

	puts("");

	return 0;
}


Measured memory_bytes: 2112
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

		String[] string_list = new String[N];
		for (int i = 0 ; i < N ; i++) {
			string_list[i] = scanner.next();
		}

		Arrays.sort(string_list, new Comparator<String>() {
			@Override
			public int compare(String o1, String o2) {
				String[] s = o1.split("");
				String[] t = o2.split("");
				int min_length = (s.length < t.length) ? s.length : t.length;

				for(int i = 0 ; i < min_length ; i++) {
					for(int j = 0 ; j <= i ; j++) {
						if (i == j && (s[i].compareTo(t[j]) < 0)) {
							return -1;
						}
						if (!s[j].equals(t[j])) {
							break;
						}
					}
				}

				for(int i = 0 ; i < min_length ; i++) {
					if (!s[i].equals(t[i])) {
						break;
					}
					if (i == min_length && (s.length < t.length)) {
						return -1;
					}
				}
				return 1;
			}
		});

		for (int i = 0 ; i < N ; i++) {
			System.out.print(string_list[i]);
		}
	}
}


Measured memory_bytes: 31008
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define lol long long
#define in(n,s) insert(n,s)//ノート参照
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int gcd(int x,int y){//最大公約数
  if(y>x) swap(x,y);
  int r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }
  return y;
}
int Lcm(int x,int y){//最小公倍数
  int t=x*y;
  return t/gcd(x,y);
}
priority_queue<int> i[300000];
bool ma[100],ma2[100];
lol a,b,c,d,g,h;
bool can(int n,int m){
  if(n<0) return false;
  if(m<0) return false;
  if(n>=a) return false;
  if(m>=b) return false;
  return true;
}
int dfs(int n,int m){
  if(n==g&&m==h) return true;
  //if(i[n][m]!=i[c][d]||!can(n,m)||ii[n][m]) return false;
  //ii[n][m]=true;
  return dfs(n+1,m)+dfs(n,m+1)+dfs(n-1,m)+dfs(n,m-1);
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long e=0,f=0,j=1;
  string w,p;
  cin >>a;
  if(a<112) cout <<"111\n";
  else{
    if(a<223) cout <<"222\n";
    else{
      if(a<334) cout <<"333\n";
      else{
	if(a<445) cout <<"444\n";
	else{
	  if(a<556) cout <<"555\n";
	  else{
	    if(a<667) cout <<"666\n";
	    else{
	      if(a<778) cout <<"777\n";
	      else{
		if(a<889) cout <<"888\n";
		else cout <<"999\n";
	      }
	    }
	  }
	}
      }
    }
  }
  return (0);
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    ll N;
    vector<ll> a;
    vector<ll> good;
    vector<ll> balls;
    cin >> N;
    a.resize(N);
    balls.resize(N, 0);
    for(ll i = 0;i < N;i++) cin >> a[i];
    for(ll i = N;i >= 1;i--) {
        ll count = 0;
        for(ll j = 1;j < N / i + 1;j++) {
            /*if(i * j <= N)*/ count += balls[i * j - 1];
        }
        if(count % 2 != a[i - 1]) {
            balls[i - 1] = 1;
            good.push_back(i);
        }
    }
    cout << good.size() << endl;
    for(auto &i: good) cout << i << ' ';
    return 0;
}


Measured memory_bytes: 4980
#include <cstring>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

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

	int** gresult = new int*[N + 1];
	for (int i = 1; i <= N; i++) {
		gresult[i] = new int[N + 1];
	}

	int numGame = N * (N - 1) / 2;
	for (int i = 0; i < numGame; i++) {
		int a, b, scoreA, scoreB;
		cin >> a >> b >> scoreA >> scoreB;

		if (scoreA == scoreB) {
			gresult[a][b] += 1;
			gresult[b][a] += 1;
		} else if (scoreA > scoreB) {
			gresult[a][b] += 3;
		} else if (scoreA < scoreB) {
			gresult[b][a] += 3;
		}
	}

	int* tScore = new int[N + 1];
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			tScore[i] += gresult[i][j];
		}
	}

	int* tRank = new int[N + 1];
	for (int i = 1; i <= N; i++) {
		tRank[i] = 1;
	}
	for (int i = 2; i <= N; i++) {
		for (int j = 1; j <= i - 1; j++) {
			if (tScore[i] > tScore[j]) tRank[j]++;
			if (tScore[i] < tScore[j]) tRank[i]++;
		}
	}

	for (int i = 1; i <= N; i++) {
		cout << tRank[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from math import sqrt
from math import gcd
a, b = map(int, input().split())
x = gcd(a, b)
print(len(set(prime_factorize(x)))+1)

Measured memory_bytes: 9116
const main = x => {
    s = x[0];
    // console.log(s.length);
    var i, ans=0, value;
    for(i=0; i<s.length-2; i++) {
        value = s.slice(i,i+3);
        // console.log(value);
        value = parseInt(value);
        // console.log(typeof value);
        // if (ans) {
        //     ans = Math.max(ans, value);
        // } else {
        //     ans = value;
        // }
        value = Math.abs(753-value);
        // console.log(value);
        ans = ans?Math.min(ans, value):value;
    }
    console.log(ans);
    
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7496
from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
t=[]
for i in range(int(input())):
  t.append(int(input()))
print(lcm(*t))

Measured memory_bytes: 5128
#include<iostream>
#include <bits/stdc++.h>
const int N = 1e6 + 7 ;
using namespace std;

int n,m;
int u,v;
int ans[N] = {0};
vector<int> s[N];

void bfs(){
	queue<int> q;
	q.push(1);
	ans[1] = 1;
	while(!q.empty()){
		int tmp = q.front();
		q.pop();
		for(auto w : s[tmp]){
			if(ans[w] == 0){
				ans[w] = tmp;
				q.push(w);
			}
		}
	}
}

int main(){
	cin >> n >> m;
	for(int i = 0; i< m; i++){
		cin >> u >> v;
		s[v].push_back(u);
		s[u].push_back(v);
	}
	bfs();
	for(int i = 1; i<=n; i++){
		if(ans[i] == 0){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes" << endl;
	for(int i = 2; i<= n; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 31584
#include <stdio.h>

int main()
{
  char S[100000],goal[10000];
  int num = 0;
  int zero_count = 0,one_count = 0;
  scanf("%s",S);

  for ( num; S[num] != '\0'; num++ );
  if ( num == '1' ) {
    printf("%d",0);
    return 0;
  }
  for ( int i = 0; i < num; i++ ) {
    if ( ( i % 2 == 0 && S[i] != '0' ) || ( i % 2 == 1 && S[i] != '1' ) )
      zero_count++;
    if ( ( i % 2 == 0 && S[i] != '1' ) || ( i % 2 == 1 && S[i] != '0' ) )
      one_count++;
  }
  if ( zero_count > one_count ) {
    printf("%d\n",one_count);
  } else {
    printf("%d\n",zero_count);
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  if(N==1) {
    cout << 1;
    return 0;
  }
  else if(N>1 && N<4) {
    cout << 2;
    return 0;
  }
  else if(N>3 && N<8) {
    cout << 4;
    return 0;
  }
  else if(N>7 && N<16) {
    cout << 8;
    return 0;
  }
  else if(N>15 && N<32) {
    cout << 16;
    return 0;
  }
  else if(N>31 && N<64) {
    cout << 32;
    return 0;
  }
  else {
    cout << 64;
    return 0;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    h = input_int()

    result = 0
    mon_cnt = 1
    while h != 0:
        result += mon_cnt
        mon_cnt *= 2
        h = (h // 2)

    return result


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


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

char HANTEI(int m, int f, int r){
    char S;
    int t = m + f;
    
    if(m == -1 || f == -1){
        S = 'F' ;
    }
    else if(80 <= t){
        S = 'A';
    }
    else if(65 <= t && t < 80 ){
        S = 'B';
    }
    else if(50 <= t && t < 65 ){
        S = 'C';
    }
    else if(30 <= t && t < 50 ){
        if(50 <= r){
             S = 'C';
        }
        else{
             S = 'D';
        }
    } 
    else if(t < 30 ){
        S = 'F';
    }   

    return S;
   

}



int main(){
    int m, f, r;
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1){
            break;
        }
        cout << HANTEI(m,f,r) << endl;
    }
    return 0;
    
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					System.out.printf("#");
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
	}
}



Measured memory_bytes: 62492
/*
  bit DP
    refer to http://d.hatena.ne.jp/iakasT/20091030/1256898765
*/

#include<cmath>
#include<cstdio>
#include<algorithm>

using namespace std;

int r[12],n;
double memo[1<<12][12];

double solve(int stat,int last)
{
	if(memo[stat][last]>1e-6)	return memo[stat][last];

	if(stat==0)	return memo[stat][last]=r[last];

	double wmin=10000;
	for(int i=0;i<n;i++){
		if((stat&(1<<i))==0)	continue;
		stat&=~(1<<i);
		wmin=min(wmin,2*sqrt(r[last]*r[i])+solve(stat,i));
		stat|=(1<<i);
	}
	return memo[stat][last]=wmin;
}

int main()
{
	int box;

	while(~scanf("%d ",&box)){
		for(n=1;;n++){
			scanf("%d",r+n-1);
			if(getchar()=='\n')	break;
		}

		for(int i=0;i<n;i++)
			for(int j=0;j<(1<<n);j++)
				memo[j][i]=0;

		double ans=10000;
		for(int i=0;i<n;i++){
			int stat=((1<<n)-1)&~(1<<i);
			ans=min(ans,r[i]+solve(stat,i));
		}
		puts(ans<=box?"OK":"NA");
	}

	return 0;
}

Measured memory_bytes: 1112