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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

const ll mod = 1000000007;

int n, m, q;
ll f[1 << 19];
int msk[21];
int asn[21];
int u;

bool leg(int x, int s) {
	return (s & msk[x]) == asn[x];
}

int lowbit(int x) { return x & -x; }

int main() {
	cin >> n >> m >> q;
	if (n == 1) {
		cout << 1 % mod << endl;
		return 0;
	}
	
	--n;
	u = 1 << n;
	
	for (int i = 0; i < q; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		msk[a] |= 1 << b - 1;
		asn[a] |= c << b - 1;
	}
	
	
	f[0] = 1;
	for (int i = 1; i <= m; ++i) {
		for (int k = 0; k < n; ++k)
			for (int j = 0; j < u; ++j) if (~j >> k & 1)
				(f[j + (1 << k) - lowbit(j & ~((1 << k) - 1))] += f[j]) %= mod;
		for (int j = 0; j < u; ++j) if (!leg(i, j))
			f[j] = 0;
	}
	
	ll ans = 0;
	for (int i = 0; i < u; ++i)
		ans += f[i];
	
	cout << ans % mod << endl;
	
	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int mod=1e9+7;
const int N = 1e5+5;

int a1,a[105],n,ans1,ans2,a2;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>n;
  for(int i = 1;i <= n;i++){
    cin>>a[i];
    a1 += a[i];
  }
  a1 = a1/n;
  a2 = a1+1;  
  for(int i = 1;i <= n;i++){
    ans1 += pow(a1-a[i],2);
    ans2 += pow(a2-a[i],2);
  }
  cout<<min(ans1,ans2)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
	int i, n;
	scanf("%d", &n);
	int arr[n];
	for (i = 0; i < n; i++) {
		scanf("%d", &arr[n - i - 1]);
	}
	for (i = 0; i < n; i++) {
		i && printf(" ");
		printf("%d", arr[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String line = sc.nextLine();
			String answer = "";
			int length = line.length();
			for (int i = 0; i < length; i++) {
				char ch = line.charAt(i);
				if(Character.isLowerCase(ch)){
					answer += Character.toUpperCase(ch);
				}else{
					answer += Character.toLowerCase(ch);
				}
			}
			System.out.println(answer);
		}	
	}
	
}


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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 2e5+5;
int a[N], f[N];
ll n, k;
bool valid(ll ans){
	ll cur_k = 0;
	lp(i, n)
		cur_k += max((max(((ll)a[i]) * f[i] - ans, 0ll) + f[i] - 1) / f[i], 0ll);
	return (cur_k <= k);
}

int main()
{
	ll ans, b = 0, l = 1e12+12;
	init();
	cin >> n >> k;
	lp(i, n)
		cin >> a[i];
	lp(i, n)
		cin >> f[i];
	sort(a, a+n);
	sort(f, f+n, greater<int>());
	while(b < l){
		ans = (b + l) / 2;
		if(valid(ans))
			l = ans;
		else
			b = ans+1;
	}
	cout << b;
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n, k := io.ScanInt(), io.ScanInt()
	snackSunukeMap := map[int]bool{}
	for i := 1; i <= n; i++ {
		snackSunukeMap[i] = false
	}
	for i := 0; i < k; i++ {
		d := io.ScanInt()
		for _, n := range io.ScanInts(d) {
			snackSunukeMap[n] = true
		}
	}
	var count int
	for _, v := range snackSunukeMap {
		if !v {
			count++
		}
	}
	fmt.Println(count)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}



Measured memory_bytes: 2300
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI2(A,B);
    GI2(C,D);
    print(max(0,min(B,D)-max(A,C)));
    return 0;
}

Measured memory_bytes: 256
//
// Created by yutaro_nishikawa on 2020/07/27.
//
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> R[i];
    }

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; ++i) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}



Measured memory_bytes: 3824
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    string S;
    int K;

    cin >> K >> S;

    if (S.size () <= K) {
        cout << S << endl;
    } else {
        string s = S.substr(0, K);
        cout << s << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define INF 1000000

int a[MAX_N];
int op[MAX_N];

int ctoi(char c) {

  switch(c) {
  case '0' : return 0;
  case '1' : return 1;
  case '2' : return 2;
  case '3' : return 3;
  case '4' : return 4;
  case '5' : return 5;
  case '6' : return 6;
  case '7' : return 7;
  case '8' : return 8;    
  case '9' : return 9;
  default : return -1;
  }

}

int ctoi_2(char c) {
  return int(c - '0');
}


bool dfs(int sum, int depth, int N, int target) {

  // 自分のdepthは、受け取ったdepthに+1.
  int mydepth = depth+1;

  // ---------------------
  // 最深到達での終了条件
  
  if (mydepth == N) return false;

  if (sum + a[mydepth] == target && mydepth == N-1) {
    op[mydepth-1] = 1;
    return true;
  }

  if (sum - a[mydepth] == target && mydepth == N-1) {
    op[mydepth-1] = -1;
    return true;
  }

  // ---------------------
  // 終了しない場合は次のレイヤへ潜る
  
  // 自分のところで加算の場合
  if ( dfs(sum + a[mydepth], mydepth, N, target) ) {
    op[mydepth-1] = 1;
    return true;
  }

  // 自分のところで減算の場合
  if ( dfs(sum - a[mydepth], mydepth, N, target) ) {
    op[mydepth-1] = -1;
    return true;
  }

  // 終了もせず、下からtrueがかえらない場合は、
  // この下には可能性なしとしてfalseを返す.
  
  return false;

}

int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;

  int N = 4;

  for (int i = 0; i < N; i++) {
    a[i] = ctoi( S[i] );
    //a[i] = ctoi_2( S[i] );
  }

  fill(op, op + (N-1), 0);
  
  /*
  for (int i = 0; i < N; i++) {
    cout << a[i] << endl;
  }
  */
  
  // ---------------------
  // 

  // 深さ優先探索
  dfs(a[0], 0, N, 7);

  cout << a[0];
  for (int i = 1; i < N; i++) {
    if (op[i-1] == 1) cout << "+";
    else cout << "-";
    cout << a[i];
  }
  
  cout << "=7" << endl;
  
  return 0;
  
}


Measured memory_bytes: 2304
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int x,y,z;
  cin >> x >> y >> z;
  
  
  cout << z << " " << x << " " << y << endl;
    

}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define INT_MAXI 2147483647
#define INT_MINI -2147483648
#define REV(a) reverse(a.begin(),a.end())

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//cout<<"input"<<endl;freopen("input.txt","r",stdin);
	//cout<<"output"<<endl;freopen("output.txt","w",stdout);
	string s;
	cin>>s;
	int sum = 0;
	int rain = 0;
	for(int i=0;i<3;i++){
		if(s[i]=='R'){
			rain+=1;
			sum = max(rain,sum);
		}
		else
			rain = 0;
	}
	cout<<sum<<endl;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n;
    cin >> n;
    vint b(n - 1);
    rep(i, n - 1) cin >> b[i];

    vint a(n);
    rep(i, n) {
        if (i == 0) {
            a[i] = b[i];
            continue;
        }
        if (i == n - 1) {
            a[i] = b[i - 1];
            continue;
        }
        a[i] = min(b[i - 1], b[i]);
    }
    cout << accumulate(ALL(a), 0) << endl;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  string n;
  cin>>n;
  if(n=="RSR"){
    cout<<1;
  }
  else{
    ll a=0;
    rep(i,3){
      if(n[i]=='R'){
        a++;
      }
    }
    cout<<a;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll d = c - a - b;
  if (d > 0 && 4 * a * b < d * d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int i;
		int n = scanner.nextInt();
		for (i = 0; i < n; i++) {
			double x1 =  scanner.nextDouble();
			double y1 =  scanner.nextDouble();
			double x2 =  scanner.nextDouble();
			double y2 =  scanner.nextDouble();
			double x3 =  scanner.nextDouble();
			double y3 =  scanner.nextDouble();

			double X12 = x1 - x2;
			double Y12 = y1 - y2;
			double X32 = x3 - x2;
			double Y32 = y3 - y2;

			double px = (Y32*(X12*(x1+x2)+Y12*(y1+y2))-Y12*(X32*(x3+x2)+Y32*(y3+y2)))/(2*X12*Y32-2*Y12*X32);
	        double py = (-X32*(X12*(x1+x2)+Y12*(y1+y2))+X12*(X32*(x3+x2)+Y32*(y3+y2)))/(2*X12*Y32-2*Y12*X32);
			double r = Math.sqrt(Math.pow(x1 - px, 2) + Math.pow(y1 - py, 2) );

			System.out.printf("%.3f %.3f %.3f\n", px, py, r);

		}
		scanner.close();
	}

}



Measured memory_bytes: 28848
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s;
	cin >> s;
	
	int n = (int)s.size();
	int ans = 0;
	for(int i = 0; i < n / 2; ++i) {
		if( s[i] != s[n - i - 1] ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define SZ(c) int(c.size())
#define pb push_back
#define loop(i,start,n)  for(int i=start;i<n;i++)
#define rloop(i,start,n)  for(int i=start;i>n;i--)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
const ll inf = 2e9+3;

void solve(){
    int tc=1 ;
    //cin >> tc;
    while(tc--) {
        ll n, res = 0; cin >> n;
        loop(i,1,n+1){
            ll x;
            cin >> x ;
            if((i&1) && (x&1)) res++;
        }
        cout << res ;
    }
}

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

Measured memory_bytes: 3576
#include <iostream>
using namespace std;
int main(){
string a,b,c,k;

cin >> a >> b >> c >> k;
int a_num = std::stoi(a);
 int b_num = std::stoi(b);
  int c_num = std::stoi(c);
  int k_num = std::stoi(k);
  
  if (a_num > k_num) {
    cout << k_num << endl;
  }
  else if (a_num + b_num >= k_num){
    cout << a_num << endl;
  }
else {
  cout << a_num - (k_num - (a_num+b_num)) << endl;
}

 }

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	if(s=="zyxwvutsrqponmlkjihgfedcba")
	{
		cout<<-1<<endl;
		return 0;
	}
	s+='a';
	for(int i=s.size()-1;i>=0;i--)
	{
		if(i!=s.size()-1)
		{
			s[i]++;
		}
		while(s[i]<='z')
		{
			bool ok=true;
			int cnt[30];
			memset(cnt,0,sizeof(cnt));
			for(int j=0;j<=i;j++)
			{
				cnt[s[j]-'a']++;
				if(cnt[s[j]-'a']==2)
				{
					ok=false;
				}
			}
			if(ok)
			{
				for(int j=0;j<=i;j++)
				{
					cout<<s[j];
				}
				cout<<endl;
				return 0;
			}
			s[i]++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i).sort

neg_num = 0
pos_num = 0
a_arr.each do |a|
  if a < 0 then
    neg_num += 1
  else
    pos_num += 1
  end
end

puts_arr = []
(n-1).times do
  if a_arr.length == 2 then
    puts_arr << "#{a_arr[1]} #{a_arr[0]}"
    puts a_arr[1] - a_arr[0]
    break
  end
  if neg_num > pos_num then
    x = a_arr.pop
    y = a_arr.shift
    puts_arr << "#{x} #{y}"
    a_arr.push(x - y)
  else
    x = a_arr.shift
    y = a_arr.pop
    puts_arr << "#{x} #{y}"
    a_arr.unshift(x - y)
  end
  if x < 0 then
    neg_num -= 1
  else
    pos_num -= 1
  end
  if y < 0 then
    neg_num -= 1
  else
    pos_num -= 1
  end
  if x - y < 0 then
    neg_num += 1
  else
    pos_num += 1
  end
end


puts_arr.each do |str|
  puts str
end





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

int main() {
    int n;
    cin >> n;
    
    int p = 0;
    vector<int> ans;
    for (int i = 1; i <= n; i++) {
        p += i;
        ans.emplace_back(i);
        if (n < p) break;
    }
    
    for (const auto &e : ans) {
        if (e != p - n) cout << e << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 384
/**
 * C - *3 or /2
 * https://atcoder.jp/contests/abc100/tasks/abc100_c
 * 
 * 解法
 * ポイント
 * an全ての要素が奇数になれば終了
 **/
#include<iostream>
#include<vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> an(N);
    for(int i=0; i<N; i++) cin >> an[i];

    int ans = 0;
    for(auto ai:an) {
        // O(10^4)
        int tmp_ai = ai;
        int count = 0;
        while(tmp_ai%2==0) {
            tmp_ai = tmp_ai/2;
            count++;
        }
        // cout << "ai:" << ai << ", count:" << count << endl;
        ans += count;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
abc = list(map(int,input().split()))
lis=[abc]
ans=0
def ch(x):
  for i in x:
    if i%2==1:
      return -1
  return 1
def sw(x):
  ret=[]
  ret.append(x[2]/2+x[1]/2)
  ret.append(x[0]/2+x[2]/2)
  ret.append(x[0]/2+x[1]/2)
  return ret
def check(a,l):
  for x in l:
    if a==x:
      return 1
  return 0
while True:
  if ch(abc)==-1:
    break
  abc=sw(abc)
  if check(abc,lis):
    ans=-1
    break
  lis.append(abc)
  ans+=1
  
print(ans)
  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
using namespace std;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(c-a) <= d || (abs(b-a) <= d && abs(c-b) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

//素因数分解
vector<P> prime_factorize(ll N){
  vector<P> res;
  for (ll a = 2; a * a <= N; ++a){
    if (N % a != 0) continue;
    ll ex = 0; //指数
    while (N % a == 0){
      ++ex;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main(){
  int N, D; cin >> N >> D;
  vector<vector<int>> x(N, vector<int>(D));
  rep(i, N) rep(j, D) cin >> x[i][j];

  int ans = 0;
  for (int i = 0; i < N; ++i){
    for (int j = i + 1; j < N; ++j){
      int dist = 0;
      for (int d = 0; d < D; ++d){
        dist += (x[i][d] - x[j][d]) * (x[i][d] - x[j][d]);
      }
      vector<P> prime = prime_factorize(dist);
      bool flag = true;
      rep(k, (int)prime.size()){
        if (prime[k].second % 2 != 0) flag = false;
      }
      if (flag) ans++;
    }
  }
  cout << ans << endl;
}


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

#define int long long

int32_t main()
{
    int n;
    cin>>n;
    
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    unordered_map<int,int> m;
    
    int ans=0;
    for(int i=0;i<n;i++)
    {
        ans=ans+m[i-a[i]];
        m[i+a[i]]++;
    }
    cout<<ans;
}
          

Measured memory_bytes: 20104
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine());
        String S = scanner.nextLine();

        // 注目したリーダーの
        // 左側に存在する'W'のの数 + 右側に存在する'E'
        // が向く方向を変える人数
        int[] sum_e = new int[N];
        int[] sum_w = new int[N];

        // 左側に存在する合計
        int num_e = 0;
        int num_w = 0;

        for (int n = 0; n < N; n++) {
            sum_e[n] = num_e;
            sum_w[n] = num_w;

            if (S.charAt(n) == 'E') {
                num_e++;
            }
            if (S.charAt(n) == 'W') {
                num_w++;
            }
        }

        int min_num = N;
        for (int n = 0; n < N; n++) {
            int num = sum_w[n] + num_e - sum_e[n];
            if (S.charAt(n) == 'E') {
                num--;
            }

            if (num < min_num) {
                min_num = num;
            }
        }
        
        System.out.println(min_num);
    }
}


Measured memory_bytes: 30684
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {

        static void Main()
        {
            IO io = new IO();

            //ここから
            int[] len = io.ReadLineToIntArray();

            Console.Write(len[0]*len[1]/2);
            Console.ReadKey();
        }
    }

    //IOを担う関数群
    public class IO
    {
        //stringの入力
        public string ReadLineToString()
        {
            return Console.ReadLine();
        }

        //intの入力
        public int ReadLineToInt()
        {
            return int.Parse(Console.ReadLine());
        }

        //空白区切りの複数の文字列の入力をstring[]にして返す
        public string[] ReadLineToStringArray()
        {
            return Console.ReadLine().Split(' ').ToArray();
        }


        //空白区切りの複数の整数の入力をint[]にして返す
        public int[] ReadLineToIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        //空白区切りの複数の文字列の入力をList<string>で受け取る
        public List<string> ReadLineToStringList()
        {
            return Console.ReadLine().Split(' ').ToList();
        }

        //空白区切りの複数の整数の入力をList<int>で受け取る
        public List<int> ReadLineToIntList()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        }

    }

}


Measured memory_bytes: 13396
from collections import deque
H, W = map(int, input().split())
edges = '#' * (W + 2)
field = [edges]
BK = 0
for _ in range(H):
    row = input()
    field.append('#' + row + '#')
    BK += row.count('#')
field.append(edges)
que = deque([(1, 1, 1)])  # x, y, cnt
enq, deq = que.append, que.popleft
visited = [[0] * (W + 2) for _ in [0] * (H + 2)]
visited[1][1] = 1
dxy = [(0, 1), (0, -1), (1, 0), (-1, 0)]
while que:
    x, y, cnt = deq()
    for dx, dy in dxy:
        nx, ny = x + dx, y + dy
        if not visited[ny][nx] and field[ny][nx] == '.':
            if (nx, ny) == (W, H):
                res = cnt + 1
                print(H * W - BK - res)
                exit()
            else:
                enq((nx, ny, cnt + 1))
                visited[ny][nx] = 1
print(-1)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)

int main()
{
  //input
  inputInt2(K,X);
  
  //main
  fSE(i,X-(K-1),X+(K-1)) cout << i << " ";
  
  // 出力
  return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]

"""
counter = 0
B = [[0] * W] * H
ans = []


def dfs(x, y, counter):
    if B[x][y] == 1 or A[x][y] % 2 == 0:
        pass
    else:
        B[x][y] = 1
        for dx in range(-1, 2):
            for dy in range(-1, 2):
                if abs(dx) + abs(dy) == 1:
                    nx = x + dx
                    ny = y + dy
                    if 0 <= nx <= H-1 and 0 <= ny <= W-1:
                        if B[nx][ny] == 0 and A[nx][ny] % 2 == 1:
                            counter += 1
                            dfs(nx, ny, counter)
"""
ans = []
for i in range(H-1):
    for j in range(W):
        if A[i][j] % 2 == 1:
            ans.append([i+1, j+1, i+2, j+1])
            A[i+1][j] += 1
        else:
            pass


for j in range(W):
    if A[H-1][j] % 2 == 1:
        if j != W-1:
            ans.append([H, j + 1, H, j + 2])
            A[H - 1][j + 1] += 1
        else:
            pass


print(len(ans))
for i, j, i2, j2 in ans:
    print(i, j, i2, j2)

Measured memory_bytes: 30236
N,X,Y = map(int,input().split())
ans = [0]*N
for i in range(1,N+1):
  for j in range(i,N+1):
    y = min(abs(i-X)+abs(j-Y)+1,abs(i-Y)+abs(j-X)+1)
    x = min(j-i,y)
    ans[x]+=1

for k in range(1,N):
  print(ans[k])

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

int main() {
    int n, ans = 0;
    int a, b;
    cin >> n >> a >> b;
    for (int i = 1; i < n+1; i++) {
        string str = to_string(i);
        int sum_digit = 0;
        for (int j = 0; j < str.size(); j++) {
            sum_digit += str.at(j) - '0';
        }
        if (a <= sum_digit && sum_digit <= b) {
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, A[200005];
int main(){
    scanf("%d", &N);
    ll ss = 0;
    for(int i = 1; i <= N; i++){
        scanf("%d", A + i);
        ss += 1LL * A[i];
    }
    ll s = 0;
    ll ans = 1e18;
    for(int i = 1; i < N; i++){
        s += A[i];
        ll s2 = ss - s;
        ans = min(ans, abs(s2 - s));
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main () {
	stack<char> sc;
	int lim, m = 0, ds = 0, i = 0, k = 0, SS = 0;
	int s[10000];
	int rs[10000];
	char c;
	while(cin >> c) {
		sc.push(c);
		if (m == 0) {
			if (c == '\\')
				m++;
		}
		else {
			if (c == '/')
				m--;
			else if (c == '\\')
				m++;
		}
		ds = ds + m;
		if ((ds != 0) && (m == 0)) {
			s[i++] = ds;
			ds = 0;
			lim = sc.size();
			for(int j = 0; j < lim; j++)
				sc.pop();
		}
	}
	m = 0;
	ds = 0;
	lim = sc.size();
	for (int j = 0; j < lim; j++) {
		c = sc.top();
		sc.pop();
		if (m == 0) {
			if (c == '/')
				m++;
		}
		else {
			if (c == '\\')
				m--;
			else if (c == '/')
				m++;
		}
		ds = ds + m;
		if ((ds != 0) && (m == 0)) {
			rs[k++] = ds;
			ds = 0;
		}
	}
	for (int j = 0; j < i; j++)
		SS = SS + s[j];
	for (int j = 0; j < k; j++)
		SS = SS + rs[j];
	cout << SS << endl;
	cout << i + k;
	for (int j = 0; j < i; j++)
		cout << ' ' << s[j];
	for (int j = k - 1; j >= 0; j--)
		cout << ' ' << rs[j];
	cout << endl;
	return 0;
}

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;

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

  string ans;
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  if (s < t) {
    ans = "Yes";
  } else {
    ans = "No";
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <sstream>

using namespace std;

int main() {
  string str;
  while(getline(cin, str)) {
    stack<double> S;
    stringstream sin(str);
    string temp;
    while(sin >> temp) {
      bool flag = false;
      if(temp.length() == 1) {
	flag = true;
	switch(temp[0]) {
	  double a, b;
	case '+':
	  a = S.top();S.pop();
	  b = S.top();S.pop();
	  S.push(b+a);
	  break;
	case '-':
	  a = S.top();S.pop();
	  b = S.top();S.pop();
	  S.push(b-a);
	  break;
	case '*':
	  a = S.top();S.pop();
	  b = S.top();S.pop();
	  S.push(b*a);
	  break;
	case '/':
	  a = S.top();S.pop();
	  b = S.top();S.pop();
	  S.push(b/a);
	  break;
	default:
	  flag = false;
	}
      }
      if(!flag) {
	stringstream s1(temp);
	double d;
	s1 >> d;
	S.push(d);
      }
    }
    printf("%.6f\n", S.top());
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//	freopen("output.txt", "w", stdout);
int main ()
{
    int k,a,b,i,j;
    cin>>k>>a>>b;
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            break;
        }
    }
    if(i>b)
        cout<<"NG"<<endl;
    return 0;
}



Measured memory_bytes: 3624
#include <string>
#include <stack>
#include <iostream>
#include <cstdlib>
using namespace std;
int a, b;
string word;
stack<int> S;

int main() {
	while (cin >> word) { // ??\????????????????????????????????? 
		if (word == "+") {
			// ??°???2???pop???????????????push??????
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a + b);
		}
		else if (word == "-") {
			// ??°???2???pop???????????????push??????
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b - a);
		}
		else if (word == "*") {
			// ??°???2???pop???????????????push?????? 
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a * b);
		}
		else {
			// word?????°????????????push??????
			S.push(atoi(word.c_str()));
		} 
	}
	cout << S.top() << endl;
	// S?????????????´??????¨???????????? 
}

Measured memory_bytes: 3216
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,a,b; cin >> n >> a >> b;
    cout << min(n*a,b) << endl; return 0;
}


Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int cm=1000, cs, price[100];
void stockBuySell(int n) 
{ 
    // Prices must be given for at least two days 
    if (n == 1) 
        return; 
  
    // Traverse through given price array 
    int i = 0; 
    while (i < n - 1) { 
  
        // Find Local Minima 
        // Note that the limit is (n-2) as we are 
        // comparing present element to the next element 
        while ((i < n - 1) && (price[i + 1] <= price[i])) 
            i++; 
  
        // If we reached the end, break 
        // as no further solution possible 
        if (i == n - 1) 
            break; 
  
        // Store the index of minima 
        int buy = i++; 
        while ((i < n) && (price[i] >= price[i - 1])) 
            i++; 
  
        // Store the index of maxima 
        int sell = i - 1; 
  
             cs+=(cm/price[buy]);
             cm%=price[buy];
             cm+=(cs*price[sell]);
             cs=0;
    } 
} 
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>price[i];
    stockBuySell(n);
    cout<<cm;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

int main() {
  ll a,b,c,k;

  cin >> a >> b >> c >> k;

  ll ans = 0;
  if(a>=k){
    ans = k;
  }else if(a+b >=k){
    ans = a;
  }
  else{
    ans = a - (k - a - b);
  }
  ANS(ans);

  return 0;
}


Measured memory_bytes: 3636
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  vll a(n), b(n);
  for(ll i = 0; i < n; i++) cin >> a[i];
  for(ll j = 0; j < n; j++) cin >> b[j];
  ll xx = 0;
  for(ll i = 0; i < n; i++) {
    if(a[i] > b[i]) xx+=a[i]-b[i];
  }
  cout << xx << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;
static const long long MAX = 200005;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint ans;

int main(void) {
  int N;
  cin >> N;
  vector<ll> C(N);
  rep(i, 0, N) cin >> C[i];
  sort(all(C));
  
   rep (i, 0, N) {
     ll j = i, k = N-i-1;
     ans += mint(C[i])*mint(k+2)*mint(2).pow(N+j+k-1);
   
   }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4812
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  ll N;
  cin >> N;
  map<string,ll> ans;
  for (size_t i = 0; i < N; i++)
  {
    string s;
    cin >> s;
    ans[s]++;
  }
  cout << "AC x " << ans["AC"] << endl;
  cout << "WA x " << ans["WA"] << endl;
  cout << "TLE x " << ans["TLE"] << endl;
  cout << "RE x " << ans["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n, m, sum=0, i, input;
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> input;
		sum += input;
	}
	if(sum > n) cout << "-1" << endl;
	else cout << n-sum << endl;
	return 0;
}

Measured memory_bytes: 3572
from collections import deque
h,w = list(map(int,input().split()))
s = []
for i in range(h):
    sh = list(input())
    s.append(sh)
ki = [[] for i in range(h*w)]
def ichi(a,b):
    return a + b*h
for a in range(h):
    for b in range(w):
        if s[a][b] == ".":
            if  a+1 < h and s[a+1][b] == "." :
                ki[ichi(a+1,b)].append(ichi(a,b))
                ki[ichi(a,b)].append(ichi(a+1,b))
            if  a-1 >= 0 and s[a-1][b] == ".":
                ki[ichi(a-1,b)].append(ichi(a,b))
                ki[ichi(a,b)].append(ichi(a-1,b))
            if b-1 >= 0 and s[a][b-1] == ".":
                ki[ichi(a,b-1)].append(ichi(a,b))
                ki[ichi(a,b)].append(ichi(a,b-1))
            if b+1 < w and s[a][b+1] == "." :
                ki[ichi(a,b+1)].append(ichi(a,b))
                ki[ichi(a,b)].append(ichi(a,b+1))
        else:
            pass
for i in range(w*h):
    ki[i] = list(set(ki[i]))
ans = [0]
for i in range(w*h):
    ikeru = deque([i])
    sumi = []
    kaisuu = [-1]*(w*h)
    kaisuu[i] = 0
    while ikeru:
        j = ikeru.popleft()
        sumi.append(j)
        for k in range(len(ki[j])):
            if ki[j][k] in sumi:
                pass
            else:
                if ki[j][k] not in ikeru:
                    ikeru.append(ki[j][k])
                if kaisuu[ki[j][k]] > kaisuu[j] + 1:
                    kaisuu[ki[j][k]] = kaisuu[j] + 1
                elif kaisuu[ki[j][k]] == -1:
                    kaisuu[ki[j][k]] = kaisuu[j] + 1 
#        print(i,kaisuu,ikeru)
    ans.append(max(kaisuu))
#print(ans)
print(max(ans))        

Measured memory_bytes: 45148
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

bool v[1000];

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

  int x, n;
  cin >> x >> n;
  int a;
  for (int i = 0; i < n; i++){
    cin >> a;
    v[a] = 1;
  }
  int ans;
  int min_ = 100000;
  for (int i = 0; i <= 101; i++)
    if (!v[i] and abs(i - x) < min_)
      min_ = abs(i - x), ans = i;

  cout << ans << endl;

  
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
// make pair, tuple
// __gcd(int, int)
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }

int main(){
    int n;cin >> n;
    int currMin = INT_MAX;
    int ans = 0;
    for(int i = 0;i < n;i++){
        int t;cin >> t;
        if(t <= currMin){
            ans++;
            currMin = t;
        }
    }
    cout << ans;
}

Measured memory_bytes: 384
S=input()
T=input()
ng = 0
ds = {}
dt = {}
for i in range(len(S)):
    if S[i] in ds:
        if ds[S[i]] != T[i]:
            ng = 1
            break;
    else:
        ds[S[i]] = T[i]
    if T[i] in dt:
        if dt[T[i]] != S[i]:
            ng = 1
            break;
    else:
        dt[T[i]] = S[i]

if ng == 0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3632
use std::io::stdin;

fn main() {
    let mut s = String::new();

    stdin().read_line(&mut s).ok();
    let _n: i32 = s.trim().parse().ok().unwrap();
    s.clear();

    stdin().read_line(&mut s).ok();
    let mut nums: Vec<i32> = s
        .trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect();

    nums.sort();

    // let sum_i: i32 = nums.iter().step_by(2).into_iter().sum::<i32>();
    let sum_i: i32 = nums
        .iter()
        .enumerate()
        .filter(|&(i, _x)| i % 2 == 0)
        .into_iter()
        .map(|(_i, x)| x)
        .sum::<i32>();
    let diff: i32 = (nums.iter().sum::<i32>() - sum_i * 2).abs();

    println!("{}", diff)
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
class ilds1_5_b{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[] num = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    int ans = mergeSort(num,0,n);
    Console.WriteLine(string.Join(" ",num));
    Console.WriteLine(ans);
  }
  public static int mergeSort(int[] n, int left, int right){
    int ret = 0;
    if(left+1 < right){
      int mid = (left+right)/2;
      ret = mergeSort(n,left,mid) + mergeSort(n,mid,right);
      ret += merge(n,left,mid,right);
    }
    return ret;
  }
  public static int merge(int[] n, int l, int m, int r){
    //Console.WriteLine("Merge{0} ~ {1}",l,r);
    int n1 = m-l;
    int n2 = r-m;
    int[] left_a = new int[n1+2];
    int[] right_a = new int[n2+2];
    for(int i=0; i<n1; i++){
      left_a[i] = n[l+i];
    }
    for(int i=0; i<n2; i++){
      right_a[i] = n[m+i];
    }
    int ret = 0;
    left_a[n1] = right_a[n2] = Int32.MaxValue;
    int x=0, y=0;
    for(int k=l; k<r; k++,ret++){
      if(left_a[x] <= right_a[y]){
        n[k] = left_a[x];
        x++;
      }
      else{
        n[k] = right_a[y];
        y++;
      }
    }
    return ret;
  }
}



Measured memory_bytes: 86760
#include <math.h>
#include <stdio.h>

int main() {
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	double theta = c*3.14159265/180.0;
	printf("%lf\n%lf\n%lf\n",a*b*sin(theta)/2,a+b+sqrt(a*a+b*b-2*a*b*cos(theta)),b*sin(theta));
	return 0;
}

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

int main() {
	int w, a, b;
	cin >> w >> a >> b;

	if (w+a < b){
		cout << b-(w+a);
	}else if (b+w < a) {
		cout << a-(b+w);
	}else {
		cout << 0;
	}

	return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q. r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<str, ll>> vpsl;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n; cin >> n;
  vs s(n); vll p(n); rep(i, n) cin >> s[i] >> p[i];
  vtsl ans(n); rep(i, n) ans[i] = make_tuple(s[i], 100 - p[i], i + 1);
  sort(all(ans));
  rep(i, n)
  {
    fin(get<2>(ans[i]));
  }
  return;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=(1LL<<63) - 600;
const ll mod=1e9+7 ;

int main(){
  int N; string S; cin >> N >> S; int cnt=0;
  rep(i, N-2){
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') cnt++;
  }
  cout << cnt << endl;    
}

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

using ll = long long;
using ull = unsigned long long;

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

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

    cout << a * b << "\n";

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#define nINF -2147483648
using namespace std;
int p10(int x)
{
	int t=1;
	for (int i=1;i<=x;i++) t*=10;
	return t; 
}

bool a[1000000];
int s[1000000];
int main()
{
	int k,t=0;
	for (int i=2;i<=p10(3);i++)
	{
		k=2;
		while (i*k<p10(6))
		{
			a[k*i]=true;
			k++;
		}
	}
	for (int i=2;i<=p10(6);i++)
	{
		if (!a[i]) t++;
		s[i]=t;
	}
	while (cin>>k) cout<<s[k]<<endl;
	return 0;
}

Measured memory_bytes: 7872
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int main(){

  int n, a;
  cin >> n >> a;

  if(n%500<=a){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256