akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
#define x first
#define y second
p a[300010],c;priority_queue<p,vector<p>,greater<p> >q;int main(){int n,r=0,i;cin>>n;for(i=0;i<n;i++)scanf("%d%d",&a[i].x,&a[i].y);sort(a,a+n);long long s=0;for(i=0;i<n;i++){s+=a[i].x,c.x=a[i].y,c.y=a[i].x;q.push(c);while(!q.empty()){if(s<=q.size()*q.top().x)break;s-=q.top().y,q.pop();}if(r<q.size())r=q.size();}cout<<r<<endl;return 0;}

Measured memory_bytes: 9356
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {


	lli a, b;
	cin >> a;
	b = a % 100;
	a /= 100;

	if (a > 12 || a == 0) {//YYMM
		if (b > 12 || b == 0) {
			cout << "NA" << endl;
		}
		else {
			cout << "YYMM" << endl;
		}
	}
	else if (b > 12 || b == 0) {//MMYY
		if (a > 12 || a == 0) {
			cout << "NA" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}

	}
	else{
		cout << "AMBIGUOUS" << endl;
	}




	return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
input = sys.stdin.readline

N = int(input())
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)
C = np.array(input().split(), dtype=np.int64)

A.sort()
B.sort()
C.sort()

# 各bに対して使えるaの個数
cnt_A = np.searchsorted(A,B,side='left')
# 各bに対して使えないcの個数
cnt_C = np.searchsorted(C,B,side='right')

answer = (cnt_A * (N - cnt_C)).sum()
print(answer)

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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;

    int *A = new int[N];
    for (int i=0;i<N; ++i) {
        cin >> A[i];
    }
    
    int Q;
    cin >> Q;
    
    //auto *S = new unsigned long int[Q];
    auto *B = new int[Q];
    auto *C = new int[Q];
    
    for (int qi=0;qi<Q;++qi) {
        cin >> B[qi] >> C[qi];
    }
        
    const int ND = 100001;
    int D[ND] = {0};

    long int S = 0;
    for (int ni=0;ni<N;++ni) {
        D[A[ni]]++;
        S += A[ni];
    }
    
    for (int qi=0;qi<Q;++qi) {
        S += D[B[qi]] * (C[qi] - B[qi]);
        D[C[qi]] += D[B[qi]];
        D[B[qi]] = 0;
        cout << S << endl;
    }
            
    return 0;
}


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

ll dfs(string s, ll ans){  
  ll q = ans;
  if(s.size() == 1)
    return ans + stoll(s);
  
  for(int i=1; i<s.size(); i++)
    q += dfs(s.substr(i), ans + stoll(s.substr(0,i)));
  
  q += stoll(s);  
  return q;
}

int main(){
  string s;
  cin >> s;
  
  ll ans = 0;
  
  cout << dfs(s, ans) << endl;
}
  

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

int main() {
  int a, b;
  for (int i=11;i<100;i++) {
    a = i / 10;
    b = i % 10;
    if (b != 0) {
      cout << a << "x" << b << "=" << a * b << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2928
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll h, n,a,b,d;

	std::cin >> h >> n;
	vector<pair<ll, ll>> p(n);
	vll dp(h + 1, 0);
	rep(i, 0, n) {
		std::cin >> a >> b;
		p[i] = make_pair(a, b);
	}

	repeq(i, 1, h) {
		ll min_tmp = 1e9;
		ll tmp;
		rep(j, 0, n) {
			if (i - p[j].first < 0) {
				tmp = dp[0] + p[j].second;
			}
			else {
				tmp = dp[i - p[j].first] + p[j].second;
			}
			min_tmp = min(min_tmp, tmp);
		}
		dp[i] = min_tmp;
	}
	
	outn(dp[h]);
	return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  cin >> n;
  vi h(n+2,0);
  rep(i,n){
    cin >> h.at(i+1);
  }
  int count = 0;
  int mini;
  int from;
  int reach;
  bool start;
  bool goal;
  bool allzero = false;
  while(!allzero){
    start = false;
    goal = false;
    mini = 1000;
    for(int i=1;i<=n;i++){
      if(!start && !goal){
        if(h.at(i) != 0 && h.at(i-1) == 0){
          from = i;
          start = true;
        }
      }
      if(start && !goal){
        if(h.at(i) != 0 && h.at(i+1) == 0){
          reach = i;
          goal = true;
        }
      }
      if(start && goal){
        mini = 1000;
        for(int j=from;j<=reach;j++){
          if(h.at(j) < mini) mini = h.at(j);
        }
        for(int j=from;j<=reach;j++){
          h.at(j) -= mini;
        }
        count += mini;
        start = false;
        goal = false;
      }
    }
    allzero = true;
    for(int i=1;i<=n;i++){
      if(h.at(i) != 0){
        allzero = false;
        break;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

int main(){
	ll n;cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	ll ans=INF;
	rep(x,200){
		ll num=0;
		rep(i,n){
			num+=(x-a[i])*(x-a[i]);
		}
		ans=min(ans,num);
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
#define mp make_pair
//manip
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always

bool dp[100001];
//石の個数がi個
//1 -> 勝てる
//0 -> 勝てない

//先手の人はk個石がある状態で勝てるか

int main() {
    int N, K; cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    
    for (int i = 1; i <= K; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i - a[j] < 0) continue; //index
            //遷移元が全て勝ちなら負け
            //なぜなら、自分がどうやっても相手が勝つ
            dp[i] |= (dp[i - a[j]] == 0);
        }
    }
    //outa(dp, K + 1);
    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
    
}

/*
 2 4
 1 2
 0 1 1 0 1
 
 最初k個石がある
 dp[k] = 1
 先手は1を選択
 
 後手
 dp[k - 1] = 0
 何を選択しても先手が1
 
 */


Measured memory_bytes: 384
n,x = gets.split.map(&:to_i)

$a,$q = [1],[1]
n.times{|i|
  $a << $a[i]*2+3
  $q << $q[i]*2+1
}

def f(n,x)
  if n==0
    return (x<=0)? 0 : 1
  elsif x <= 1+$a[n-1]
    return f(n-1,x-1)
  else
    return $q[n-1]+1+f(n-1,x-2-$a[n-1])
  end
end

p f(n,x)

Measured memory_bytes: 1788
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n + 2];
		for (int i = 1; i <= n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int[] b = new int[n + 2];
		for (int i = 1; i <= n + 1; i++) {
			b[i] = Math.abs(a[i] - a[i - 1]) + b[i - 1];
		}
		for (int i = 1; i <= n; i++) {
			int c = Math.abs(a[i - 1] - a[i + 1]);
			System.out.println(b[n + 1] - Math.abs(a[i + 1] - a[i]) - Math.abs(a[i] - a[i - 1]) + c);
		}
	}
}

Measured memory_bytes: 53548
#include<stdio.h>
  
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}


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

int main(){
 int a;
 int b;
cin >> a >>b;
if (a>b){
cout << "a > b"<<endl;
}
if (a==b){
cout << "a == b"<<endl;
}
if (a<b){
cout << "a < b"<<endl;
}
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll h[220000];
int main(){
    ll n,k,ans=0;
    cin>>n>>k;
    rep(i,0,n){cin>>h[i];}
    sort(h,h+n);
    rep(i,0,n-k)ans+=h[i];
    cout<<ans;
    
}

Measured memory_bytes: 1792
//be name khoda :)

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

#define sz(x) ((int)x.size())
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define pb emplace_back
#define IINF 0x3f3f3f3f //1061109567
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;

inline int in() {int x, y; y = scanf("%d", &x); return x;}

const int N = 1e6 + 123;

int a[N];

int f2(int n) {
	int sum = 0;
	while(n) {
		sum += n / 2;
		n /= 2;
	}
	return sum;
}

int c(int n, int k) {
	int o = f2(n) - f2(k) - f2(n - k);
	return o == 0;
}

void chap(int* a, int n) {
	int sum = 0;
	rep(i, n) {
		sum += a[i];
		cerr << a[i];
	}
	cerr << "-->" << sum;
	cerr << endl;
}

int main() {
	random_device rd; mt19937_64 eng(rd()); uniform_int_distribution<long long> distr; // distr(eng)
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n;
	bool one = false;
	string s;
	cin >> n >> s;
	rep(i, sz(s)) {
		a[i] = s[i] - '1';
		one |= s[i] == '2';
	}
	if(!one)
		rep(i, n)
			if(a[i] == 2)
				a[i] = 1;
	// chap(a, n);
	int sum = 0;
	rep(i, n) 
		sum = (sum + c(n - 1, i) * (a[i] == 1)) % 2;
	if(sum)
		cout << (one ? 1 : 2) << endl;
	else
		cout << sum << endl;
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 5276
package main

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

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	n := scanInt()
	works := make(works, n)
	for i := 0; i < n; i++ {
		w := &work{time: scanInt(), deadline: scanInt()}
		works[i] = w
	}

	// sort.Slice(works, func(i, j int) bool {
	// 	return works[i].deadline < works[j].deadline
	// })
	sort.Sort(works)

	elapsed := 0
	for _, v := range works {
		elapsed += v.time
		if elapsed > v.deadline {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

type work struct {
	time     int
	deadline int
}

type works []*work

func (w works) Len() int {
	return len(w)
}

func (w works) Swap(i, j int) {
	w[i], w[j] = w[j], w[i]
}

func (w works) Less(i, j int) bool {
	return w[i].deadline < w[j].deadline
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {

	if a < b {
		a, b = b, a
	}

	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}


Measured memory_bytes: 6528
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

    public static void main(String[] args) throws IOException {

        int a = 0;

        ArrayList<Integer> list = new ArrayList<>();

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        a = Integer.parseInt(br.readLine());

        String[] line = br.readLine().split(" ");
        for (int i = 0; i < a; i++) {
            list.add(Integer.parseInt(line[i]));
        }

        Collections.reverse(list);

        for (int x = 0; x < a; x++) {
            if (x == a - 1) {
                System.out.println(list.get(x));
            } else {
                System.out.printf("%d ", list.get(x));
            }
        }

    }

}

Measured memory_bytes: 24680
import sys
from io import StringIO
import unittest
from collections import deque
# import queue


def resolve():
    # ★get input
    h, w = map(int, input().split())

    # ★exec
    # BFSにて最短経路を求める
    # 準備
    distance = [[-1 for i in range(w)] for j in range(h)]
    que = deque()

    # スタート地点の情報を設定
    # 多点スタートの設定
    for i in range(h):
        line = list(input())
        for j in range(w):
            if line[j] == "#":
                que.append((i, j))
                distance[i][j] = 0

    # BFS開始
    while len(que) > 0:

        # now = que.get()
        now = que.popleft()

        # 上下左右のマスを確認
        for move_y, move_x in ((1, 0), (-1, 0), (0, 1), (0, -1)):

            # 盤の範囲外なら何もしない
            target = (now[0] + move_y, now[1] + move_x)
            if not (h > target[0] >= 0 and w > target[1] >= 0):
                continue

            # 距離が設定済みなら何もしない
            if not distance[target[0]][target[1]] == -1:
                continue

            # キューに追加
            # que.put(target)
            que.append(target)
            # 最短距離を設定
            distance[target[0]][target[1]] = distance[now[0]][now[1]] + 1

    # 距離が最大の点 = 答えになる。
    ans = 0
    for i in range(h):
        ans = max(ans, max(distance[i]))

    print(ans)



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 3
...
.#.
..."""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """6 6
..#..#
......
#..#..
......
.#....
....#."""
        output = """3"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 98904
#include <iostream>
using namespace std;
int main() {
  string S;
  cin >> S >> S;
  int x{}, m{};
  for (auto c : S) {
    x += c - 'D' ? 1 : -1;
    m = m < x ? x : m;
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c;
    int ans=0;
    scanf("%d %d %d",&a,&b,&c);
    for(a;a<=b;a++){
        if(c%a==0){
            ans+=1;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2104
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


S = input()
K = int(input())

pre = None
if K < 10:
    first_cnt = 0
    for s in S*K:
        if s == pre:
            first_cnt += 1
            pre = None
        else:
            pre = s
    print(first_cnt)
    exit()

pre = S[0]
first_cnt = 0

for s in S[1:]:
    if s == pre:
        first_cnt += 1
        pre = None
    else:
        pre = s

continuous_cnt = 0
for s in S:
    if s == pre:
        continuous_cnt += 1
        pre = None
    else:
        pre = s

continuous_cnt2 = 0
for s in S:
    if s == pre:
        continuous_cnt2 += 1
        pre = None
    else:
        pre = s

if continuous_cnt == continuous_cnt2:
    print(first_cnt+continuous_cnt*(K-1))
elif K % 2 == 1:
    print(first_cnt+(continuous_cnt+continuous_cnt2)*((K-1)//2))
else:
    print(first_cnt+continuous_cnt*((K-1)//2+1)+continuous_cnt2*((K-1)//2))
    # print(first_cnt, ((K-1)//2))


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
 
typedef struct node{
    int p;
    int left;
    int right;
} Node;
 
int searchHight(int);
 
Node *node;
 
int main(){
     
    int n,i,id,depth,tmpP,deg,nowNode,sibling;
 
    scanf("%d", &n);
 
    node = malloc(sizeof(Node)*n);
 
    for (i = 0; i < n; ++i){
        node[i].p = -1;
    }
 
    for (i = 0; i < n; ++i){
        scanf("%d",&id);
        scanf("%d%d",&node[id].left,&node[id].right);
        node[node[id].left].p = id;
        node[node[id].right].p = id;
    }
 
    nowNode = 0;
    while(1){
        if (node[nowNode].left != -1 && node[nowNode].right != -1)
        {
            break;
        } else if (node[nowNode].left == -1)
        {
            nowNode = node[nowNode].right;
        } else {
            nowNode = node[nowNode].left;
        }
    }
 
    //Search
    for (i = 0; i < n; ++i){
         
        //sibling
        tmpP = node[i].p;
        if (tmpP == -1) sibling = -1;
        else if(node[tmpP].left == i) sibling = node[tmpP].right;
        else sibling = node[tmpP].left;
 
        //depth
        depth = 0;
        while(tmpP != -1){
            tmpP = node[tmpP].p;
            depth++;
        }
 
        //degree
        deg = 0;
        if (node[i].left != -1) deg++;
        if (node[i].right != -1) deg++;
 
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
            ,i,node[i].p,sibling,deg,depth,searchHight(i));
 
        if(node[i].p == -1) printf("root\n");
        else if(node[i].left == -1 && node[i].right == -1) printf("leaf\n");
        else printf("internal node\n");
    }
 
    return 0;
}
 
int searchHight(int index){
    int hLeft = 0;
    int hRight = 0;
 
    if (node[index].left != -1){
        hLeft = searchHight(node[index].left) +1;
    }
    if (node[index].right != -1){
        hRight = searchHight(node[index].right) +1;
    }
    if (hLeft < hRight) return hRight;
    else return hLeft;
}

Measured memory_bytes: 612
N = gets.to_i
edges = Hash.new{|h,k| h[k] = []}
(N-1).times do
  a, b = gets.split.map(&:to_i)
  edges[a-1] << b-1
  edges[b-1] << a-1
end

#0,N-1をつなぐパスを見つける
stack = [0]
prev = Hash.new
visited = Array.new(N, false)
dist = Array.new(N, 0)
while from = stack.pop do
  visited[from] = true
  edges[from].each do |to|
    if !visited[to]
      stack << to
      dist[to] = dist[from] + 1
      prev[to] = from
    end
  end
end

path = [N-1]
cur = -1
l = 0
while cur != 0 do
  cur = path[l]
  path << prev[cur] if prev[cur]
  l += 1
end

visited = Array.new(N, false)

colors = Hash.new{|h,k| h[k] = []}
0.upto(l-1) do |i|
  if i < l-1 - (l-1)/2
    colors["w"] << path[i]
  else
    colors["b"] << path[i]
  end
  visited[path[i]] = true
end

colors["w"].each do |i|
  stack = [i]
  while from = stack.pop do
    edges[from].each do |j|
      if !visited[j]
        stack << j
        colors["w"] << j
        visited[j] = true
      end
    end
  end
end

colors["b"].each do |i|
  stack = [i]
  while from = stack.pop do
    edges[from].each do |j|
      if !visited[j]
        stack << j
        colors["b"] << j
        visited[j] = true
      end
    end
  end
end


if colors["b"].size > colors["w"].size
  puts "Fennec"
else
  puts "Snuke"
end


Measured memory_bytes: 26492
#include<bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
int main(){
 int n,m;
 long long k;
 cin >> n >> m >> k;
 vector<int>a(n);
 vector<int>b(m);
 long long t = 0;
 for(int i= 0;i<n;i++){
    cin >> a[i];
 }
for(int i= 0;i<m;i++){
   cin >> b[i];
   t+=b[i];
}
int ans = 0;
int j = m;
for(int i= 0;i<=n;i++){
   while (j>0&&t>k){
      --j;
      t-=b[j];
   }
   if(t>k) break;
   ans = max(ans,i+j);
   if(i==n) break;
   t +=a[i];
}
cout << ans << endl;
 return 0;
}

Measured memory_bytes: 4840
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

def foo(x):
    cnt = 0
    for i in range(n):
        cnt += (a[i]-1)//x
    return k>=cnt

n,k = inm()
a = inl()
mn = 0
mx = max(a)
while mn+1<mx:
    mid = (mn+mx)//2
    if foo(mid):
        mx = mid
    else:
        mn = mid
print(mx)


Measured memory_bytes: 93820
#include <stdio.h>
int main()
{
    int N, D, X;
    scanf("%d", &N);
    scanf("%d %d", &D, &X);

    int A[100];
    for (int i=0; i<N; i++) {
        scanf("%d", &A[i]);
    }

    int ans = 0;
    for (int i=0; i<N; i++) {
        int tmp = 0;
        for (int j=1; j<=D; j+=A[i]) tmp++;
        ans += tmp;
    }

    ans += X;

    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int diff(string &a, string &b)
{
    int ans=0;
    for (int i = 0; i <2*100000 ; ++i) {
        if(int(a[i])>=int ('a')&&int (a[i])<=int ('z')) { if (a[i] != b[i])ans++; }
        else
            break;
    }
    return ans;
}
int main() {
string a,b;
cin>>a>>b;
cout<<diff(a,b)<<endl;
}



Measured memory_bytes: 3880
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,x,y;
    cin>>i;
    x = i%100;
    y = i/100;
    if(x>=0 && y>=0)
    {
        if(y>=1&&y<=12)
        {
            if(x>=1&&x<=12)
                cout<<"AMBIGUOUS";
            if(x>12 || x==0)
                cout<<"MMYY";
        }
        if(y>12 || y==0)
        {
            if(x>=1&&x<=12)
                cout<<"YYMM";
            if(x>12 || x==0)
                cout<<"NA";
        }
    }
    else
        cout<<"NA";
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
n,*l=map(int,open(0).read().split())
c=l[::3];s=l[1::3];f=l[2::3]
def func(m):
	t=c[m]+s[m]
	for i in range(m+1,n-1):
		fi=f[i]
		t=max((t//fi+(t%fi!=0))*fi,s[i])+c[i]
	return t
for i in range(n-2):
	print(func(i))
print(c[-1]+s[-1],0,sep="\n")

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 233333, mo = 998244353;
char s[N]; int n;
set<string> Set;
string q[N];
void add(int &a, int b) {a=a+b<mo?a+b:a+b-mo;}
void solve() {
	string a; s[0]=':'; a=s; int f=0,r=1; q[f]=a; Set.insert(a);
	while (f!=r) {
		string a=q[f++];
	//	rep(i,1,n) printf("%d : %c\n",i,a[i]);
	//	cout<<a<<endl;
		rep(i,2,n) if (a[i]!=a[i-1]) {
			string b=a; int v=(a[i]-'a')+(a[i-1]-'a'); v=(v==1?2:(v==2?1:0));
			b[i]='a'+v; b[i-1]='a'+v; if (!Set.count(b)) {
				Set.insert(b); q[r++]=b;
			}
		}
	}
}
int f[N][3][3][2];
int main() {
	scanf("%s",s+1); n=strlen(s+1);
	if (n<=3) {solve(); printf("%d",Set.size()); return 0;}
	bool flag=1; rep(i,2,n) flag&=s[i]==s[i-1]; if (flag) {puts("1"); return 0;}
//	solve(); printf("%d",Set.size());
	int ans=1; rep(i,2,n) ans&=s[i]!=s[i-1];
	f[1][0][0][0]=f[1][1][1][0]=f[1][2][2][0]=1;
	rep(i,1,n-1) rep(j,0,2) rep(k,0,2) rep(l,0,1) {
		rep(u,0,2) add(f[i+1][(j+u)%3][u][l|(k==u)],f[i][j][k][l]);
	}
	int sum=0; rep(i,1,n) sum+=s[i]-'a'; sum%=3;
	rep(i,0,2) (ans+=f[n][sum][i][1])%=mo;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 16640
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var O, E string

func main() {
	sc.Split(bufio.ScanWords)

	O, E = nextStr(), nextStr()
	l := len(O) + len(E)

	buf := bufio.NewWriter(os.Stdout)
	for i := 0; i < l; i++ {
		if (i+1)%2 != 0 {
			buf.Write([]byte(fmt.Sprintf("%s", string(O[(i)/2]))))
		} else {
			buf.Write([]byte(fmt.Sprintf("%s", string(E[(i)/2]))))
		}
	}
	buf.Write([]byte("\n"))
	buf.Flush()

	// S := make([]byte, l)
	// for i := 0; i < l; i++ {
	// 	if (i+1)%2 != 0 {
	// 		S = append(S, O[(i)/2])
	// 	} else {
	// 		S = append(S, E[(i)/2])
	// 	}
	// }

	// fmt.Println(string(S))
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back

#define N 100010
#define MOD 1000000007

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

	int n;
	cin >> n;
	string s[n];
	map<string, ll> mi;
	for (int i = 0; i < n; ++i)
	{
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		mi[s[i]]++;
	}

	ll ans = 0;
	for(auto e : mi)
	{
		ans += (e.ss * (e.ss - 1)) / 2;
	}
	cout << ans;
	return 0;	
}



Measured memory_bytes: 16640
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	int N;
	cin >> N;
	vint A(N-1), B(N-1);
	for (int i = 0; i < N-1; i++)
	{
		cin >> A[i] >> B[i];
		A[i] --;
		B[i] --;
	}

	vvint branch(N);
	for (int i = 0; i < N-1; i++)
	{
		branch[A[i]].emplace_back(B[i]);
		branch[B[i]].emplace_back(A[i]);
	}

	int n_color = 0;
	for (int i = 0; i < N; i++)
	{
		n_color = max(n_color, (int)branch[i].size());
	}
	cout << n_color << endl;


	queue<pair<int, int>> past; // 前のノード、前のノードで使用済みの色
	past.push({ 0, -1 });

	vector<map<int, int>> ans(N);

	while (!past.empty())
	{

		pair<int, int> p = past.front();
		past.pop();

		int pre = p.first;
		int used = p.second;

		int next_color = 0;
		for (int i = 0; i < branch[pre].size(); i++)
		{
			if (ans[branch[pre][i]].size() != 0)
			{
				continue;
			}

			if (next_color == used)
			{
				next_color++;
			}

			ans[pre][branch[pre][i]] = next_color;
			past.push({ branch[pre][i], next_color });

			next_color++;
		}
	}

	for (int i = 0; i < N - 1; i++)
	{
		cout << ans[A[i]][B[i]] + 1, ans[B[i]][A[i]] + 1;
		cout << endl;
	}




}





Measured memory_bytes: 20864
import scala.io.StdIn.readInt

object Main {
  def fib(a:Int, b:Int, n:Int):Int = {
    if (n ==  0)
      a
    else
      fib(a+b, a, n-1)
  }

  def main(args: Array[String]) = {
    val n = readInt()
    println(fib(1, 0, n))
  }
}

Measured memory_bytes: 43628
#include<iostream>0=
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int a,b;
    while (scanf("%d %d",&a,&b)!=EOF){
        printf("%d\n",a*b-(a+b-1));
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[][] matrix = new int[n][n];

        for(int i = 0; i < n; i++) {
            int u = sc.nextInt() - 1;
            int k = sc.nextInt();
            for(int j = 0; j < k; j++) {
                matrix[u][sc.nextInt() - 1] = 1;
            }
        }

        for(int i = 0; i < n; i++) {
            StringBuilder sb = new StringBuilder();
            for(int j = 0; j < n; j++) {
                if(j != 0) sb.append(" ");
                sb.append(matrix[i][j]);
            }
            System.out.println(sb);
        }

        sc.close();
    }
}



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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll A, B, C;
  cin >> A >> B >> C;

  ll longest_edge = max(max(A, B), C);
  if (longest_edge % 2 == 0) {
    cout << 0 << endl;
  } else {
    if (longest_edge == A) {
      cout << B * C << endl;
    } else if (longest_edge == B) {
      cout << A * C << endl;
    } else {
      cout << A * B << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Max_N=2*1e3,Max_L=1e3;
int N,A[Max_N+10]={},P[Max_L*2+10]={};
inline int lowbit(int x){ return x & - x ; }
inline void Add(int x,long long k){
	for(;x<=Max_L*2;x+=lowbit(x)) P[x]+=k;
}
inline int Ask(int x){
	int Sum=0;
	for(;x;x-=lowbit(x)) Sum+=P[x];
	return Sum;
}
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++) scanf("%d",&A[i]);
	sort(A+1,A+N+1);
	long long Ans=0;
	for(int i=N;i>=1;i--){
		for(int j=i-1;j>=1;j--)
		 Ans+=Ask(A[i]+A[j]-1);
		Add(A[i],1);
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  int n,c,ans=1e9;
  cin>>n>>c;
  int a[n][n],d[c][c];
  int s[3][c];

  r(i,3)r(j,c)s[i][j]=0;

  r(i,c)r(j,c)cin>>d[i][j];
  r(i,n)r(j,n)cin>>a[i][j],a[i][j]--;

  r(i,n)r(j,n)s[(i+j)%3][a[i][j]]++;
  r(i,c)r(j,c)if(i!=j)r(k,c)if(i!=k&&j!=k){
    int sum=0;
    r(l,c){
      sum+=d[l][i]*s[0][l];
      sum+=d[l][j]*s[1][l];
      sum+=d[l][k]*s[2][l];
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2176
#include <stdio.h>
int main(){
	int n,m;
	scanf("%d",&n);
	scanf("%d",&m);
	int mai=2*n;
	int card[mai];
	int i,j;
	for(i=0;i<mai;i++){//カードの初期化
		card[i]=i+1;
	}
	int com;
	int temp[mai];
	for(i=0;i<m;i++){//動作
		scanf("%d",&com);
		if(com==0){
			for(j=0;j<mai;j++){
				temp[j]=card[j];
			}
			for(j=0;j<mai;j++){
				if(j%2==0){
					card[j]=temp[j/2];
				}
				else{
					card[j]=temp[n+j/2];
				}
			}
		}
		else{
			for(j=0;j<com;j++){
				temp[j]=card[j];
			}
			for(j=0;j<mai-com;j++){
				card[j]=card[j+com];
			}
			for(j=0;j<com;j++){
				card[mai-com+j]=temp[j];
			}
		}
	}
	for(i=0;i<mai;i++){
		printf("%d\n",card[i]);
	}
	return 0;
}

Measured memory_bytes: 600
import sys
def minimumchar(s1,s2):
	n,m=len(s1),len(s2)
	ans=sys.maxsize
	for i in range(m-n+1):
		minRemovedChar=0
		for j in range(n):
			if (s1[j]!=s2[i+j]):
				minRemovedChar+=1
		ans=min(minRemovedChar,ans)
	return ans
	
s2=input()
s1=input()

print(minimumchar(s1,s2))


Measured memory_bytes: 67644
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		int[] number = new int[1000000];
		Arrays.fill(number, 0);
		long sum = 0;
		for(int i = 0; i < N; i++) {
			int tmp = Integer.parseInt(sc.next());
			list.add(tmp);
			number[tmp]++;
			sum += tmp;
		}
		int Q = Integer.parseInt(sc.next());
		for(int i = 0; i < Q; i++) {
			int tmpA = Integer.parseInt(sc.next());
			int tmpB = Integer.parseInt(sc.next());
			int changeCount = number[tmpA];
			sum = sum + (tmpB - tmpA) * changeCount;
			number[tmpA] = 0;
			number[tmpB] += changeCount;
			System.out.println(sum);
		}
		sc.close();

	}
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
}
  return u;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key<y->key)y->left=z;
  else y->right=z;

}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s",com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
       if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}



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

int main()
{
    int N, odd_counter = 0;
    scanf("%d", &N);
    vector<int> A(N + 1);
    for (int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
        if (A[i] % 2 == 1) odd_counter++;
    }
    if (odd_counter % 2 == 1) {
        printf("NO\n");
    } else {
        printf("YES\n");
    }
}

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

int main(){
	int N, K, count = 0, sum = 0, num = 1;
	
	cin>>N>>K;
	
	for(;;){
		if(sum > num*K){
			num = (sum+K-1)/K;
			//cout<<"num = "<<num<<endl;
		}
		N -= num;
		sum += num;
		if(N < 0)break;
		count++;
		//cout<<count<<" "<<sum<<" "<<num<<endl;
	}
	
	cout<<count<<endl;
	
	return 0;
}




Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int n;
  unordered_set<int> S;
  cin >> n;
  rep(i, n) {
    int a;
    cin >> a;
    S.insert(a);
  }

  string ans = (S.size() == n) ? "YES" : "NO";

  cout << ans << endl;
}


Measured memory_bytes: 8520
<?php
$jud = 0;
$N = trim(fgets(STDIN));  // 入力
$Nlen = strlen($N);
for ($i = 0; $i <= ($Nlen - 1); $i++) {
    if ($N[$i] == 7) {
        echo 'Yes';
        $jud = 1;
        break;
    }
}
if ($jud == 0) {
    echo 'No';
}


Measured memory_bytes: 15996
def main():
    from bisect import bisect_left
    A, B, Q = map(int, input().split())
    INF = 2 * 10 ** 10
    S = [-INF] + [int(input()) for _ in range(A)] + [INF]
    T = [-INF] + [int(input()) for _ in range(B)] + [INF]
    S_rev = [-s for s in S][::-1]
    T_rev = [-t for t in T][::-1]

    for q in range(Q):
        x = int(input())
        ans = 5 * 10 ** 10

        # Case1: 右に直進
        cost1_s = S[bisect_left(S, x)] - x
        cost1_t = T[bisect_left(T, x)] - x
        ans = min(ans, max(cost1_s, cost1_t))

        # Case2: 左に直進
        cost2_s = S_rev[bisect_left(S_rev, -x)] + x
        cost2_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, max(cost2_s, cost2_t))

        # Case3: 右でS、左でT
        cost3_s = S[bisect_left(S, x)] - x
        cost3_t = T_rev[bisect_left(T_rev, -x)] + x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        # Case4: 右でT、左でS
        cost3_s = S_rev[bisect_left(S_rev, -x)] + x
        cost3_t = T[bisect_left(T, x)] - x
        ans = min(ans, 2 * min(cost3_s, cost3_t) + max(cost3_s, cost3_t))

        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25660
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from itertools import product
from collections import defaultdict
from collections import deque
def resolve():
    K = ir()
    s = deque([[i+1, 1, i+1] for i in range(9)])
    cnt = 0
    while cnt < K:
        v, keta, tmp = s.popleft()
        cnt += 1
        min_d = max(0, v-1)
        max_d = min(9, v+1)
        for i in range(min_d, max_d+1):
            s.append([i, keta+1, int(str(tmp)+str(i))])
    print(tmp)
resolve()

Measured memory_bytes: 69212
[n, m] = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
st = [set([]) for _ in range(n)]
for i in range(m):
    [a, b] = [int(i) for i in input().split()]
    st[a-1].add(b-1)
    st[b-1].add(a-1)
cnt = 0
for i, height in enumerate(h):
    line = []
    for huga in st[i]:
        line.append(h[huga])
    if len(line) == 0 or height > max(line):
        cnt += 1
print(cnt)

Measured memory_bytes: 110760
N = int(input())
A = list(map(int,input().split()))
xorValue = 0
sumValue = A[0] + A[1]
for i in range(2,N):
    xorValue ^= A[i]
if sumValue % 2 != xorValue % 2:
    print(-1)
else:
    Base = (sumValue - xorValue) // 2
    if Base > A[0]:
        print(-1)
    else:
        strXOR = bin(xorValue)[2:]
        minStoneMovement = A[0] - Base
        strBase = bin(Base)[2:]
        lenStrXOR = len(strXOR)
        cannotMove = False
        if Base < 0:
            cannotMove = True
        for i in range(-1,-1 * min(len(strXOR),len(strBase)) - 1,-1):
            if strBase[i] == '1' and strXOR[i] == '1':
                cannotMove = True
                break
        if not cannotMove:
            for i in range(lenStrXOR):
                if strXOR[i] == '1' and minStoneMovement >= 2 ** (lenStrXOR - 1 - i):
                    minStoneMovement -= 2 ** (lenStrXOR - 1 - i)
        if minStoneMovement == A[0] or cannotMove:
            print(-1)
        else:
            print(minStoneMovement)

Measured memory_bytes: 62016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
  int N;
  vi L(200);
  int cnt=0;
  cin>>N;
  rep(i,N) cin>>L[i];
  for(int i=0;i<N;i++) {
    for(int j=i+1;j<N;j++) {
      for(int k=j+1;k<N;k++) {
        int a=L.at(i);
        int b=L.at(j);
        int c=L.at(k);
        if(abs(b-c)<a&&a<b+c&&a!=b&&b!=c&&c!=a) cnt++;
      }
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<pair<int, int>> vec;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		vec.emplace_back(make_pair(a, i));
	}
	sort(vec.begin(), vec.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 != vec[i].second % 2) {
			ans++;
		}
	}
	cout << ans / 2 << endl;
}


Measured memory_bytes: 4292