akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S, T;
  cin >> S;
  cin >> T;
  bool isMatch = false;
  int index = 0;
  for(int i = 0; i < S.size(); ++i)
  {
    int matchCnt = 0;
    for(int j = 0; j < T.size(); ++j)
    {
      if((i + j) >= S.size()) { continue; }
      if((S.at(i + j) == T.at(j) || S.at(i + j) == '?'))
      {
        // S文字列内でTの文字列と一致した部分、S文字列内で?の部分をカウント
        ++matchCnt;
      }
    }
    // カウントされたT文字列と?文字の数がTのサイズと同数だった場合に終了
    if(matchCnt == T.size())
    {
      isMatch = true;
      index = i;	// 比較開始位置を保存
    }
  }

  if(!isMatch)
  {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  // 比較開始位置からTに置き換え
  for(int j = 0; j < T.size(); ++j)
  {
    S.at(index + j) = T.at(j);
  }

  // それ以外に?があったら辞書順最小のaに置き換え
  for(int i = 0; i < S.size(); ++i)
  {
    if(S.at(i) == '?')
    {
      S.at(i) = 'a';
    }
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
// i --> 0 - 9までの数字
// sum --> 合計値
// cnt --> 和がSとなる組み合わせの数
// total --> 足す数(N個まで足す)
int N, S, cnt;
void dfs( int i, int sum, int total )
{
    //N回を満たしている 且つ 合計がSに達したものをcountする
    if( total == N && sum == S )
    {
        cnt++;
        return;
    }
    //0-9まで探索したら or 足す回数がN回に達したら 終わり
    if( i == 10 || total == N ) return;
    
    //合計に i を足す場合 -> 足す回数を +1 する
    dfs( i + 1, sum + i, total + 1 );
    //合計に i を足さない場合
    dfs( i + 1, sum, total );
}
int main()
{
    while( cin >> N >> S )
    {
        if( N == 0 && S == 0 ) break;
        //合計値の初期化
        cnt = 0;
        //dfs( 数字の0から, 合計値0から, 足す数字0から)
        dfs( 0, 0, 0 );
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3048
h, w = gets.split.map(&:to_i)
org = h.times.map { gets.chomp.chars }
ans = h.times.map { w.times.map { [] } }
h.times do |i|
  w.times do |j|
    if org[i][j] == '#'
      ans[i][j] = '#'
      next
    end

    v = 0
    (-1..1).each do |d_i|
      (-1..1).each  do |d_j|
        next if d_i == 0 && d_j == 0
        next if i + d_i < 0 || i + d_i >= h
        next if j + d_j < 0 || j + d_j >= w

        v += 1 if org[i + d_i][j + d_j] == '#'
      end
    end
    ans[i][j] = v.to_s
  end
end
ans.each { |s| puts s.join }


Measured memory_bytes: 2172
/* include */
#include "bits/stdc++.h"
/* namespace */
using namespace std;
/* using */
// data type
using ll = long long;
using ld = long double;
// vector
using vi = vector<int>;
using vd = vector<double>;
using vll = vector<ll>;
using vld = vector<ld>;
using vs = vector<string>;
/* define */
#define pb(x) push_back(x)          // push_back
#define all(x) x.begin(), x.end()   // all_range
#define PI M_PI                     // PI
#define gcd(a, b) __gcd(a, b)       // 最大公約数
#define lcm(a, b) (a / gcd(a, b) * b) // 最小公倍数

void Main(void)
{
    int x;
    cin >> x;
    if (30 <= x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

int main(int argc, char* argv[])
{
    ll now_time = clock();
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    if (argc == 2 && *argv[1] == 't')
    {
        // 時間計測
        cout << endl;
        cout << "Execution Time : " << 1.0 * (clock() - now_time) / CLOCKS_PER_SEC << "[sec]" << endl;
    }
    else
    {
        // 通常処理
    }

    return 0;
}  


Measured memory_bytes: 3552
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/14/20 07:28:46
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<pair<int, int>> primes(int x) {
  vector<pair<int, int>> p;
  int t = sqrt(x);
  for (int i = 2; i <= t and x > 1; i++) {
    int c = 0;
    while (x%i==0) {
      c++;
      x/=i;
    }
    if (c>0)
      p.emplace_back(i, c);
  }
  if (x > 1)
    p.emplace_back(x, 1);
  return p;
}

constexpr ll MOD = 1e9+7;
ll mod_pow(ll x, ll p) {
  ll u = x;
  ll t = 1;
  while (p) {
    if (p&1)
      (t *= u)%=MOD;
    (u *= u)%=MOD;
    p>>=1;
  }
  return t;
}

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

  int n; cin>>n;
  vector<int> A(n); for(auto& a:A) cin>>a;
  unordered_map<int, int> plcm;
  for (int i = 0; i < n; i++) {
    auto pa = primes(A[i]);
    for (auto p:pa)
      plcm[p.first] = max(plcm[p.first], p.second);
  }
  ll lcm = 1;
  for (auto p:plcm)
    (lcm *= mod_pow(p.first, p.second))%=MOD;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    (ans += lcm*mod_pow(A[i], MOD-2)%MOD)%=MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int n;
  cin>>n;
  int x = min({4*a, 2*b, c});

  if(2*x <= d){
    cout << (long)n*x << endl;
  } else {
    long ans = (long)(n/2)*d;
    if(n%2==1) ans += x;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

	//vector<int> di(K);
	vector<bool> Si_have_snack(N);
	for (int j = 0; j < N; j++) {
		Si_have_snack[j] = false;
	}
	
	for (int i = 0; i < K; i++) {
		int di;
		cin >> di;
		//vector<int> Ai(di);
		for (int j = 0; j < di; j++) {
			int temp;
			cin >> temp;
			//Ai[j] = temp - 1;
			Si_have_snack[temp - 1] = true;
		}
	}

	int ans = 0;
	for (int j = 0; j < N; j++) {
		if (Si_have_snack[j] == false) {
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <sstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

const int MAX_V=100;
int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];

int V;

void dj(int s){
	fill(d,d+V,INT_MAX/3);
	fill(used,used+V,false);
	d[s]=0;
	
	while(true){
		int v=-1;
		for(int u=0;u<V;u++){
			if(used[u]==false && (v==-1 || d[u]<d[v]))v=u;
		}
		
		if(v==-1)break;
		used[v]=true;
		
		for(int u=0;u<V;u++){
			d[u]=min(d[u],d[v]+cost[v][u]);
		}
	}
}

main(){
	int k;
	while(cin>>V>>k){
		if(V==0 && k==0)break;
		
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				cost[i][j]=INT_MAX/3;
			}
			cost[i][i]=0;
		}
		
		for(int i=0;i<k;i++){
			int t;
			cin>>t;
			if(!t){
				int a,b;
				cin>>a>>b;
				--a;--b;
				dj(a);
				if(d[b]==INT_MAX/3)cout<<-1<<endl;
				else cout<<d[b]<<endl;
			}else{
				int c,d,e;
				cin>>c>>d>>e;
				--c;--d;
				cost[c][d]=min(cost[c][d],e);
				cost[d][c]=min(cost[d][c],e);
			}
		}
	}
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  map<string, int> ans;
  rep(i, N)
  {
    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: 3632
N = int(input())
li = []
while(1):
    i = N % 26
    if i == 0:
        i += 25
        N -=1
    else:
        i -=1
    li.append(chr(97 + i))
    N = N // 26
    if N == 0:
        break

li.reverse()
for i in range(len(li)):
    print(li[i], end="")

Measured memory_bytes: 61788
#include <iostream>

// #include <string>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    int a, b, t;
    std::cin >> a >> b >> t;
    std::cout << (t - t%a) / a * b << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#define INF 0x3f3f3f3f
#define MAX_N 1001000
#define MOD 1000000007
#define ll long long
using namespace std;
void optimize_cpp_stdio()
{
    std::ios::sync_with_stdio(false);
    std::cout.tie(NULL);
    std::cin.tie(NULL);
}

int n;
int x[MAX_N];

int f(int x[], int i, int p)
{
    return (x[i] - p) * (x[i] - p);
}

int main()
{
    scanf("%d", &n);
    int l = INF, r = 0;
    for(int i = 0 ; i < n; i++)
    {
        scanf("%d", &x[i]);
        if(x[i] < l)
            l = x[i];
        if (x[i] > r)
            r = x[i];
    }
        ll ans, amin = INF;
    for(int p = l; p <= r; p++)
    {
        ans = 0;
        for(int i = 0; i < n; i++)
        {
            ans += f(x, i, p);
        }
        if(ans < amin)
        {
            amin = ans;
            //printf("%d\n", ans);
        }
    }
    printf("%d\n", amin);
}


Measured memory_bytes: 256
# 入力受け取り
N = int(input())
H = [int(i) for i in input().split(" ")]

num_int = 1 # 海を眺められる旅館の数
for i in range(1, N):
    j = 0
    while j < i and H[j] <= H[i]:
        j += 1
    if j == i:
        num_int += 1

print(num_int)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int  a[n],b[n],c[n];
	for(int i=0;i<n;i++)
	cin>>a[i]>>b[i]>>c[i];
    int dp1[n],dp2[n],dp3[n];
    dp1[0] = a[0];
    	dp2[0]= b[0];
    	dp3[0] = c[0];
    for(int i=1;i<n;i++)
    {
       dp1[i] = a[i] + max(dp2[i-1],dp3[i-1]);
       dp2[i] = b[i] + max(dp1[i-1],dp3[i-1]);
       dp3[i] = c[i] + max(dp2[i-1],dp1[i-1]);	
	}
	int  m = max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
	cout<<m<<endl;
}

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

int N;
vector<int> H;

int main(void) {
	cin >> N;
	H.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> H[i];

	int ans = 0;
	int cnt = 0;
	for (int i = 1; i <= N - 1; ++i) {
		if (H[i] <= H[i - 1])
			++cnt;
		else {
			ans = max(cnt, ans);
			cnt = 0;
		}
	}
	ans = max(cnt, ans);

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 640
from itertools import accumulate
n = int(input())
a = sorted(list(map(int,input().split())))
a2 = list(accumulate([2*i for i in a]))
l= [i+1 for i in range(n)]
#print(a)
#print(a2)
t = 0
for j,k,i in zip(a[1:],a2,l):
  if k<j:
    t = i
print(n-t)
 

Measured memory_bytes: 16988
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
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;}




// combination mod prime
// mintが必要
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int const MAX = 2500;
mint dp[2*MAX][2*MAX];

int main(){
    ll n;
    cin >> n;
    vector<P>s(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        s[i]={a,b};
    }
    map<P,int>mp;
    combination comb(1e5);
    rep(i,n){
        mp[s[i]]++;
    }
    mint ans = 0;
    for(auto it=mp.begin();it!=mp.end();it++){
        dp[MAX-it->first.first][MAX-it->first.second]+=it->second;
    }
    rep(i,2*MAX-1){
        rep(j,2*MAX-1){
            dp[i+1][j+1]+=dp[i][j+1]+dp[i+1][j];
        }
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        ans += dp[it->first.first+MAX][it->first.second+MAX]*it->second;
    }
    rep(i,n){
        P p = s[i];
        int a = p.first;
        int b = p.second;
        ans -= comb(2*a+b*2,2*a);
    }
    ans /= 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 212736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define INF (int) 2e9
#define MOD (int) 1e9 + 7

int main(){
    int n;
    cin >> n;
    int ans = 100000;
    rep(i, n){
        ans *= 1.05;
        if(ans%1000>0){
            ans /= 1000;
            ans++;
            ans *= 1000;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3116
import java.io.*;
public class Main {

    public static void main(String[] args) throws IOException  {
        
    	// ?¨??????\??????????????????????????????
    	int c;
        int keta = 0;
        // int hairetsu_keta[] = new int[4]; hairetsu_keta[0] = 0;hairetsu_keta[1] = 0;hairetsu_keta[2] = 0;hairetsu_keta[3] = 0;
        int hairetsu_keta[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // ???????????¨???????????¨????????£????????????
        int j = 0;
        int deru = 0;         
        // int hairetsu[] = new int[4]; hairetsu[0] = 0; hairetsu[1] = 0; hairetsu[2] = 0; hairetsu[3] = 0;
        int hairetsu[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//???????????¨???????????¨????????£???????????????????????????????????°????¢????????????????20???
        
        int i= 0;
        while ((c = System.in.read()) != -1  )
        {
        	// System.out.println(c);
        	if ( c > 47 && c < 58) // suuji ga kita
       	    {
        		hairetsu[i] = c-48;
        		i++;
        		keta++;
                 
        		//  System.out.println("Qurege_no_kazu_keta_hantaikara:" + Qurage_no_kazu);
       	    }
        	if ( c == 10) // return ga kita
        	{
        		hairetsu_keta[j] = keta;
        		deru++; //return ga  kitara while wo deru
        		j++; // damekamo
        	}
        	if ( c == 32) //space ga kita
        	{
            	
        		hairetsu_keta[j] = keta;
        		keta = 0;//space ga kitara tsugi no moji no tame keta ha sokomade
        		j++;
        	}
        	if (deru > 0)
        	{
        		break;
            	}
        }
           // ?¨??????\?????????????????????????????????????????????
        
        // ??°??????????????\??????
        //int hairetsu_suuchi[] = new int[4]; hairetsu_suuchi[0] = 0; hairetsu_suuchi[1] = 0; hairetsu_suuchi[2] = 0; hairetsu_suuchi[3] = 0;
        int hairetsu_suuchi[] = {0,0,0,0,0,0,0,0,0,0};//???????????¨???????????¨????????£????????????
        int k = 0;
        int m = 0;
        int n = 0;
        
        
        while( n < (j + 1))
        {
        while(j > 0 && hairetsu_keta[n] > 0 )
        {
        	hairetsu_suuchi[k] = hairetsu_suuchi[k]*10 + hairetsu[m];
        	hairetsu_keta[n] = hairetsu_keta[n] - 1;
        	m++;
        }
        if (hairetsu_keta[n] == 0)
        {
        	n++;
        	k++;
        }
        }   	

        //??°??????????????\???????????????
        /*
          for (int p = 0; p < k - 1 ; p++)
        
        {
        System.out.println("???????????°??????" + hairetsu_suuchi[p]);     
        }	
        	*/	
         System.out.println(
        		 (hairetsu_suuchi[0] / 3600) +":" +
        	     ((hairetsu_suuchi[0] % 3600) / 60) +":" +
        	     (( hairetsu_suuchi[0] % 3600) % 60)
        		 );
        	
        
            }

}

Measured memory_bytes: 24276
N, Q = gets.split.map(&:to_i)
Q.times do
    vw = gets.split.map(&:to_i).sort
    if N == 1
        puts vw.min
    else
        while vw[0] != vw[1]
            vw[1] = (vw[1]+N-2)/N
            vw.sort!
        end
        puts vw[0]
    end
end

Measured memory_bytes: 2812
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int straight(int c[]){
    int sum = 0;
    rep(i,5){
        sum += c[i];
    }
    if(sum / 5 == c[2]){
        return 1;
    }else if(sum == 47){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    int c[5];
    char g;
    int p,k;

    while(cin >> c[0] >> g >> c[1] >> g >> c[2] >> g >> c[3] >> g >> c[4]){
        int count[5] = {0};
        k = 0;
        sort(c, c+5);
        p = c[0];
        for(int i = 0; i < 5; i++){
            if(p == c[i]){
                count[k]++;
            }else{
                p = c[i];
                k++;
                count[k]++;
            }
        }
        sort(count, count+5);
        if(count[4] == 2){
            if(count[3] == 2){
                cout << "two pair" << endl;
            }else{
                cout << "one pair" << endl;
            }
        }else if(count[4] == 3){
            if(count[3] == 2){
                cout << "full house" << endl;
            }else{
                cout << "three card" << endl;
            }
        }else if(count[4] == 4){
            cout << "four card" << endl;
        }else{
            if(straight(c) == 1){
                cout << "straight" << endl;
            }else{
                cout << "null" << endl;
            }
        }
    }
}

Measured memory_bytes: 1176
#include <iostream>
#include <string.h>
#include <string>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main()
{
	int n,min,max,x;
	scanf("%d%d",&n,&min),max=min;
	while(--n)
	{
		scanf("%d",&x);
		if(x>max) max=x;
		if(x<min) min=x; 
	}
	printf("%d\n",max-min);
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> usagi(N);
  for( int i = 0; i < N; i++ ){
    cin >> usagi.at(i);
  }
  
  int count = 0;
  for( int i = 0; i < N; i++ ){
    if( usagi.at(usagi.at(i)-1) == i+1 ){
      count++;
    }
  }
  cout << count / 2 << endl;
  
}


Measured memory_bytes: 640
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5+5;

int n;
double m;
double sum;
int ar[N];

int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> ar[i];
        sum += ar[i];
    }
    double ls = sum / (4*m);
    //cout << ls << endl;
    sort(ar + 1 , ar + n + 1);
    reverse(ar + 1 , ar + n + 1);
    for(int i = 1; i <= n; i++){
        if(ar[i] < ls)
            continue;
        m--;
    }
    if(m <= 0){
        puts("Yes");
    } else {
        puts("No");
    }
}


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

int main() {
	int n;cin >> n;
	vector<int> a(n),b(n);
 	for ( int i = 0; i < n; ++i ) {
		cin >> a[i];
	}
	copy(a.begin(),a.end(),b.begin());
	sort(a.begin(),a.end());
	int MAX = a[n-1],secMAX = a[n-2];
	for ( int i = 0; i < n; ++i ) {
		if(b[i]==MAX)cout << secMAX << endl;
		else cout << MAX << endl;
	}
	return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a;
	vector< vector<int> > b;
	for (int i = 1; i <= m; i++) {
		int g;
		cin >> g;
		a.push_back(g);
	}
	for (int i = 0; i < m; i++) {
		vector<int> uu;
		for (int j = 0; j < n; j++) {
			int huhu;
			cin >> huhu;
			uu.push_back(huhu);
		}
		b.push_back(uu);
	}
	vector<int> result;
	for (int j = 0; j < n; j++) {
		result.push_back(0);
	}
	for (int i = 0; i < m; i++) {
		int target = a[i];
		int hazurenum = 0;
		for (int j = 0; j < n; j++) {
			if (b[i][j] == target) {
				result[j]++;
			}
			else {
				hazurenum++;
			}
		}
		result[target - 1] += hazurenum;
	}
	for (int j = 0; j < n; j++) {
		std::cout << result[j] << endl;
	}
	return 0;
}


Measured memory_bytes: 3188
import collections
n=int(input())
a=list(map(int,input().split()))

a_count=collections.Counter(a)

nctwo=[0,0,1]

def nc2(i):
    if(len(nctwo)>i):
        return nctwo[i]
    else:
        while(len(nctwo)<=i):
            nctwo.append(nctwo[-1] * len(nctwo) / (len(nctwo)-2))
        return nctwo[i]

allsum=0
for v in a_count.values():
    allsum+=nc2(v)

for i in range(n):
    ai_count=a_count[a[i]]
    print(int(allsum-(nc2(ai_count) - nc2(ai_count-1))))


Measured memory_bytes: 26780
import math

A, B, N = map(int, input().split())

max_value = 0
x = B - 1
if x > N:
    x = N
max_value = math.floor(A * x / B) - A * math.floor(x / B)
# for x in range(1, N+1):
#     value = math.floor(A * x / B) - A * math.floor(x / B)
#     print("X:", x, "value:", value)
#     max_value = max(max_value, value)

print(max_value)

Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9

// int('a') = 97

int alphabet_s[26];
int alphabet_t[26];

int main() {
	string S, T;
	cin >> S >> T;
	
	for (int i = 0; i < 26; i++) {
		alphabet_s[i] = 0;
		alphabet_t[i] = 0;
	}

	for (int i = 0; i < S.size(); i++) {
		alphabet_s[int(S[i]) - 97]++;
	}
	for (int i = 0; i < T.size(); i++) {
		alphabet_t[int(T[i]) - 97]++;
	}
	vector<int> vs, vt;

	for (int i = 0; i < 26; i++) {
		if (alphabet_s[i] != 0) vs.push_back(alphabet_s[i]);
		if (alphabet_t[i] != 0) vt.push_back(alphabet_t[i]);
	}

	sort(vs.begin(), vs.end());
	sort(vt.begin(), vt.end());

	if (vs == vt) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    vector<ll> f1(n), f2(n);
    REP(i, 0, n) {
        int x, y;
        cin, x, y;
        f1[i] = x - y;
        f2[i] = x + y;
    }
    sort(f1.begin(), f1.end());
    sort(f2.begin(), f2.end());
    ll ans = max(*f1.rbegin() - *f1.begin(), *f2.rbegin() - *f2.begin());
    print(ans);
    return 0;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m, q;
  cin >> n >> m >> q;
  vector <vector <ll>> v(n, vector <ll> ());
  rep(i, m) {
    ll l, r;
    cin >> l >> r;
    ll dis = r-l;
    v.at(l-1).push_back(dis);
  }
  rep(i, n) sort(v.at(i).begin(), v.at(i).end());
  rep(i, q) {
    ll l, r;
    cin >> l >> r;
    ll res = 0;
    for (ll j = l-1; j < r; j++) {
      if (v.at(j).size() == 0) continue;
      ll dis = r - j - 1;
      auto itr = upper_bound(v.at(j).begin(), v.at(j).end(), dis);
      res += distance(v.at(j).begin(), itr);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 4992
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		int n = in.nextInt();
		int d = in.nextInt();
		int count = 0;
		for(int i=0;i<n;i++){
			int x = in.nextInt();
			int y = in.nextInt();
			
			double distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
			if(distance <= d)
				count++;
		}
		out.println(count);
	}
}


Measured memory_bytes: 59628
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  ll n;
  cin >> n;

  ll i = 1;
  ll ans = (ll) 9e18;
  while (i * i <= n) {
    if (n % i == 0) {
      ll j = n / i;
      ans = min(ans, i + j - 2);
    }
    i++;
  }

  cout << ans << endl;

  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 2005;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2, class T3> void add( T1 &x, T2 y, T3 m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2, class T3> void sub( T1 &x, T2 y, T3 m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

int n,x,y;
vector<int>gr[MAXN];
vector<int>dist[MAXN];

void bfs( int node )
{
    queue<int>q;
    q.push(node);
    dist[node][node] = 0;
    vector<bool>vis(n);
    while( !q.empty() )
    {
        int now = q.front();
        q.pop();

        if( vis[now] )
            continue;
        vis[now] = 1;

        for(int next:gr[now])
        {
            if( !vis[next] )
            {
                q.push(next);
                dist[node][next] = min( dist[node][next], dist[node][now] + 1 );
            }
        }
    }
}

int main() 
{
    fastio();

    cin>>n>>x>>y;
    x--,y--;

    for(int i=0;i<n-1;i++)
    {
        gr[i].pb(i+1);
        gr[i+1].pb(i);
    }
    gr[x].pb(y);
    gr[y].pb(x);

    for(int i=0;i<n;i++)
    {
        dist[i].resize(n,MOD);
        bfs(i);
    }

    vector<int>ans(n);
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans[dist[i][j]]++;
        }
    }

    for(int i=1;i<n;i++)
        cout<<ans[i],nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 16128
import numpy as np

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    mod = int(1e9+7)
    p = []
    m = []
    for a in A:
        if a >= 0:
            p.append(a)
        else:
            m.append(a)
    p.sort(reverse=True)
    m.sort(reverse=False)
    ans = 1
    if sum(np.sign(A)) == -N and K%2 == 1:
        A = sorted(A, reverse=True)
        for i in range(K):
            ans = (ans*A[i])%mod
        print(ans)
        return
    if N == K:
        for i in range(K):
            ans = (ans*A[i])%mod
        print(ans)
        return

    m_pair = []
    p_pair = []
    if K%2 == 1:
        ans *= p.pop(0)%mod
    for i in range(0, len(m), 2):
        if i+1 < len(m):
            m_pair.append(m[i]*m[i+1])
        # else:
        #     m_pair.append(m[i])
    for i in range(0, len(p), 2):
        if i+1 < len(p):
            p_pair.append(p[i]*p[i+1])
        else:
            p_pair.append(p[i])
    pairs = m_pair[:]
    pairs.extend(p_pair)
    pairs.sort(reverse=True)
    for i in range(K//2):
        ans = (ans*pairs[i])%mod
    print(ans)

main()


Measured memory_bytes: 49712
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define ll long long
using namespace std;
const int N=3005;
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,m;
ll s[N][N],c[N][N],ans;
ll qp(ll x,ll k,ll mod){
	ll res=1;
	while(k){
		if(k&1) res=res*x%mod;
		k>>=1,x=x*x%mod;
	}
	return res;
}
int main(){
	n=read(),m=read();
	s[0][0]=1;
	inc(i,0,n+1){
		c[i][0]=1;
		inc(j,1,i) s[i][j]=(s[i-1][j-1]+j*s[i-1][j])%m,c[i][j]=(c[i-1][j]+c[i-1][j-1])%m;
	}
	inc(i,0,n){
		ll tmp=0;
		inc(j,0,i) (tmp+=s[i+1][j+1]*qp(2,j*(n-i),m)%m)%=m;
		tmp=tmp*qp(2,qp(2,n-i,m-1),m)%m*c[n][i]%m;
		(ans+=(i&1)?m-tmp:tmp)%=m;
	}
	printf("%lld",ans);
}
 

Measured memory_bytes: 139648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

	int n;
	cin >> n;
	vector<string> s(n);

	for (int i = 0; i < n; i++) {
		string input;
		cin >> input;
		for (int j = 0; j < 10; j++) {
			for (int k = j; k < 10; k++) {
				if (input[j] > input[k]) {
					char tmp = input[j];
					input[j] = input[k];
					input[k] = tmp;
				}
			}
		}
		s[i] = input;
	}

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

	int num = 0;
	long long ans = 0;
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == s[i]) {
			num++;
		}
		else {
			num = 0;
		}
		if(num != 0){
			ans += num;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  ll N,K;
  string s;
  cin >> N >> K;
  cin >> s;
  vector<pair<ll,ll> > num;
  for(ll i=0;i<s.size();i++){
    ll cnt = 0;
    if(s[i]=='0'){
      while(1){
        if(s[i]!='0'){
          num.pb(mp(0,cnt));
          i--;
          break;
        }
        i++;
        cnt++;
      }
    }else{
      while(1){
        if(s[i]!='1'){
          num.pb(mp(1,cnt));
          i--;
          break;
        }
        i++;
        cnt++;
      }
    }
  }
  ll zero = 0;
  rep(i,num.size()){
    if(num[i].first==0) zero++;
  }
  //0の個数がK以下だと、自動的にN
  if(zero<=K){
    cout << N << endl;
    return 0;
  }
  ll l=0,r=1;
  ll ans=0,before=0;
  //最初が1のとき
  if(num[0].first==1){
    for(ll i=0;i<2*K+1;i++){
      ans += num[i].second;
    }
    r = 2*K+1;
    before = ans;
    while(r<num.size()){
      ll tmp = before;
      tmp -= num[l].second;
      tmp -= num[l+1].second;
      l += 2;
      tmp += num[r].second;
      tmp += num[r+1].second;
      r += 2;
      before = tmp;
      if(ans<tmp) ans = tmp;
    }
  }else{
    for(ll i=0;i<2*K;i++){
      ans += num[i].second;
    }
    r = 2*K;
    before = ans;
    while(r<num.size()){
      ll tmp = before;
      tmp -= num[l].second;
      tmp -= num[l+1].second;
      l += 2;
      tmp += num[r].second;
      tmp += num[r+1].second;
      r += 2;
      before = tmp;
      if(ans<tmp) ans = tmp;
    }

    ll ans2=0;
    for(ll i=1;i<2*K+2;i++){
      ans2 += num[i].second;
    }
    l = 1, r = 2*K+2;
    before = ans2;
    while(r<num.size()){
      ll tmp = before;
      tmp -= num[l].second;
      tmp -= num[l+1].second;
      l += 2;
      tmp += num[r].second;
      tmp += num[r+1].second;
      r += 2;
      before = tmp;
      if(ans2<tmp) ans2 = tmp;
    }
    ans = max(ans,ans2);
  }

  cout << ans << endl;
}


Measured memory_bytes: 2548
open String;;let rec p=function|[]->false|"the"::_->true|"this"::_->true|"that"::_->true|_::t->p t and g l=if p l then print_endline(concat" "l)else g(List.map(fun s->map(fun c->if c>'`'&&c<'{'then Char.chr(((Char.code c-96)mod 26)+97)else c)s)l)and f()=f(g(Str.split(Str.regexp" ")(read_line())));;try f()with _->()

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

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

    if(s.at(2)==s.at(3) && s.at(4)==s.at(5)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

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

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	x := r.nextInt()
	const k = 100000
	b := make([]int, k+1)
	w := 0
	b[0] = 1
	b[1] = -1
	for i := 0; i <= k; i++ {
		w += b[i]
		if i == x {
			break
		}
		if w > 0 {
			if i+100 <= k {
				b[i+100]++
			}
			if i+106 <= k {
				b[i+106]--
			}
		}
	}
	fmt.Fprintln(stdout, b2i(w > 0))
}


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

int main() {
    
    int n,m;
    cin >> n;
    vector<string> blue(n);
    for(int i = 0;i < n;i++){
        cin >> blue[i];
    }
    
    cin >> m;
    vector<string> red(m);
    for(int i = 0;i < m;i++){
        cin >> red[i];
    }
    vector<int> count(n,1);
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            if(blue[i] == blue[j])count[i]++;
        }
        for(int j = 0;j < m;j++){
            if(blue[i] == red[j])count[i]--;
        }
    }
    sort(count.begin(), count.end(),greater<int>());
    count[0] = count[0]<0?0:count[0];
    cout << count[0] << endl;
    return 0;
}



Measured memory_bytes: 256
<?php
$n = (int)trim(fgets(STDIN));
$points = [];
for ($i=1; $i <= $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$ps = [];
	foreach ($input as $v) {
		$ps[] = (int)$v;
	}
	$points[] = $ps;
}

if ($n === 2) {
	echo dist($points[0], $points[1]);
	exit();
}

$sum = 0;
foreach ($points as $k1 => $p1) {
	foreach ($points as $k2 => $p2) {
		if ($k1 === $k2) {
			continue;
		}
		$sum += dist($p1, $p2) * fact($n-1);
	}
}
echo $sum / fact($n);



function dist($p1, $p2){
	return sqrt(pow($p1[0]-$p2[0], 2) + pow($p1[1]-$p2[1], 2));
}

function fact($n){
	$result = 1;
	for ($i=1; $i <= $n; $i++) { 
		$result *= $i;
	}
	return $result;
}

Measured memory_bytes: 4856
#include <stdio.h>

int main () {
  int a,b;
  char c;

  scanf("%d", &a);

  scanf(" %c", &c);

  scanf("%d", &b);

  if(c == '+') {
    printf("%d\n", a + b);
  } else {
    printf("%d\n", a - b);
  }
  return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

int a[575][575];

int ans1[250000];
int ans2[250000];
int ans3[250000];
int ans4[250000];

int
main(void){  
  int H, W, itr=0;
  
  cin >> H >> W;

  REP(i, H){
    REP(j, W){
      cin >> a[i][j];
    }
  }

  
  REP(i, H){
    REP(j, W-1){
      if(a[i][j]%2 != 0){
	a[i][j]--;
	a[i][j+1]++;
	//cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
	ans1[itr] = i+1;
	ans2[itr] = j+1;
	ans3[itr] = i+1;
	ans4[itr] = j+2;
	itr++;
      }
    }
  }

  REP(i, H-1){
    if(a[i][W-1]%2 != 0){
      a[i][W-1]--;
      a[i+1][W-1]++;
      //cout << i+1 << " " << W << " " << i+2 << " " << W << endl;
      ans1[itr] = i+1;
      ans2[itr] = W;
      ans3[itr] = i+2;
      ans4[itr] = W;
      itr++;      
    }
  }

  cout << itr << endl;
  REP(i, itr){
    cout << ans1[i] << " " << ans2[i] << " " << ans3[i] << " " << ans4[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.next();
            int[] used = new int['z' - 'a' + 1];
            for (int i = 0; i < S.length(); i++) {
                if (used[S.charAt(i) - 'a']++ > 0) {
                    System.out.println("no");
                    return;
                }
            }
            System.out.println("yes");
        }
    }
}


Measured memory_bytes: 26988
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string YABAI, WAYO;
  int A, B, C, D, E, F, G;
  
  cin >> A;
  
  B = A * A;
  C = B * A;
  
  A = A + B + C;
    
  cout << A << endl;
}


Measured memory_bytes: 3620
# 解説

def main():
    N, M, K = map(int, input().split())
    A = map(int, input().split())
    B = map(int, input().split())

    def accumulate(a):
        s = 0
        yield s
        for x in a:
            s += x
            yield s

    A = accumulate(A)
    *B, = accumulate(B)

    ans = 0
    j = M

    for i, x in enumerate(A):
        if x > K: break
        while B[j] > K - x: j -= 1
        ans = max(ans, i + j)

    print(ans)


if __name__ == '__main__':
    main()


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


def read():
    N, T = map(int, input().strip().split())
    U = map(int, input().strip().split())
    return N, T, U


def solve(N, T, U):
    tsum = 0
    t0 = 0
    for t1 in sorted(list(U)):
        if t1 - t0 < T:
            tsum += t1 - t0
        else:
            tsum += T
        t0 = t1
    return tsum + T


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

bool dp[100001];

int main(){
    i64 n;
    int sina[6]={100,101,102,103,104,105};
    cin>>n;
    for(i64 i=0;i<n;i++) dp[i]=0;
    dp[0]=1;
    for(i64 i=0;i<n+1;i++){
        for(i64 j=0;j<6;j++){
            if(sina[j]<=i) dp[i]|=dp[i-sina[j]];
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int n;
	while (cin >> n, n)
	{
		double memo1[40] = {};
		double memo2[40] = {};
		double ans = 0;

		memo1[0] = 1;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < 35; j++)
			{
				if (memo1[j] == 0) continue;
				double getexp = memo1[j] * pow(2, -j);
				memo2[j + 1] += getexp;
				memo2[0] += memo1[j] - getexp;
				ans += getexp;
				memo1[j] = 0;
			}
			swap(memo1, memo2);
		}

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

	return 0;
}

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

int main() {
        int N;
        int d[110];
        int Same=0;

        cin >> N;

        for(int i=0; i<N; i++) cin >> d[i];

        sort(d,d+N,greater<int>());

        for(int i=1; i<N; i++) if(d[i]==d[i-1]) Same++;

        cout << N-Same << endl;
        return 0;
}


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

struct Point{
    double x;
    double y;
    Point(double x, double y) : x(x), y(y){}
    Point operator+(Point p){
        return Point(x + p.x, y + p.y);
    }
    Point operator*(double d){
        return Point(x * d, y * d);
    }
};
typedef Point Vector;

double dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}

int main(){
    int x_p1, y_p1, x_p2, y_p2;
    cin >> x_p1 >> y_p1 >> x_p2 >> y_p2;
    Point p1(x_p1, y_p1);
    Point p2(x_p2, y_p2);
    Vector b(p2.x - p1.x, p2.y - p1.y);
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        Vector h(x - p1.x, y - p1.y);
        Point ans = p1 + b * (dot(h, b) / dot(b, b));
        cout << fixed << setprecision(10);
        cout << ans.x << " " << ans.y << endl;
    }
    return 0;
}



Measured memory_bytes: 3288