akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int x[16][16];

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

	int n, d;
	scanf("%d%d", &n, &d);
	for (int i = 0; i < n; i++) for (int j = 0; j < d; j++)
		scanf("%d", &x[i][j]);

	int ans = 0;
	for (int i = 0; i < n; i++) for (int j = i+1; j < n; j++) {
		int ds = 0;
		for (int k = 0; k < d; k++)
			ds += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
		int sq = (int)sqrt((double)ds + .5);
		if (sq * sq == ds) ++ans;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int v[100002];

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int ans = 0;
  for (int i = 0; i < n-1;i++){
    if (i+1 == v[i]){
      swap(v[i],v[i+1]);
      ans++;
    }
  }
  if (v[n-1] == n) ans++;
  cout << ans << endl;
  

  
  return 0;
}

Measured memory_bytes: 640
s = input()
def x(n):
    return n//2 + n%2
s= s+'R'
a = 'R'
ren =1
m = len(s)
ls = [0] * m
for i in range(1, m):
    b = s[i]
    if a == b:
        ren += 1

    else:
        if b == 'L':
            ls[i] +=ren-x(ren)
            ls[i-1] +=x(ren)
        else:
            ls[i-ren] +=x(ren)
            ls[i-ren-1] +=ren-x(ren)
        a = b
        ren = 1
print(*ls[:-1])

Measured memory_bytes: 11284
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
main(){
  while(1){
    ll q1;
    scanf("%lld",&q1);
    if(!q1) break;
    ll b,c1,c2,q2;
    scanf("%lld %lld %lld %lld",&b,&c1,&c2,&q2);
    ll res1=0,res2=0;

    if(c1<=c2){
      if(b >= c1*q2){
	b-=c1*q2;
	res1 = q2;
      }else{
	res1 = b/c1;
	b-=(b/c1)*c1;
      }
      res2 = b/c2;
      if(res1 + res2 < q1 || res1==0) puts("NA");
      else printf("%lld %lld\n",res1,res2);
      continue;
    }

    ll st=1,ed=q2;
    while(st<=ed){
      ll h=(st+ed)/2;
      ll x=b;
      x -= c1*h;
      if(x < 0){
	ed = h-1;
	continue;
      }
      ll t2 = (x/c2);
      x -= t2*c2;
      if( x>=0 && h+t2>=q1 ){
	res1 = h;
	res2 = t2;
	st = h+1;
      }else{
	ed = h-1;
      }
    }
    if(!res1 && !res2) puts("NA");
    else printf("%lld %lld\n",res1,res2);
  }
}

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

int main()
{
  double x1,x2,y1,y2,d;
  cin >> x1 >> y1 >> x2 >> y2;
  d=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
  cout.precision(10);
  cout << showpoint << sqrt(d) << endl;

  return 0;
}

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

bool solve(string &S, string &T){
    const int N = S.size();
    vector<int> table(26, -1);
    
    for(int i=0; i<N; i++)
        table[S[i]-'a'] = T[i]-'a';
    for(int i=0; i<26; i++)
        for(int j=0; j<i; j++)
            if(table[i] != -1 && table[j] != -1 && table[i] == table[j])
                return false;
    for(int i=0; i<N; i++)
        if(table[S[i]-'a'] != T[i]-'a')
            return false;
    return true;
}

int main(){
    string S, T; cin >> S >> T;
    cout << (solve(S, T)? "Yes": "No") << endl;
}


Measured memory_bytes: 776
from collections import deque

num = int(input())

d = deque()
for i in range(num):
    c = [int(x) for x in input().split()]
    if c[0] == 0:
        if c[1] == 0:
            d.insert(0, c[2])
        else:
            d.append(c[2])
            
    elif c[0] == 1:
        print(d[c[1]])
    elif c[0] == 2:
        if c[1] == 1:
            d.pop()
        else:
            d.popleft()



Measured memory_bytes: 21960
from sys import stdin

input = stdin.readline
mi = lambda: map(int, input().split())
lmi = lambda: list(mi())
si = lambda: input().strip('\a')
ii = lambda: int(input())


a, b = mi()
ap = set()
for i in range(2, int(a**.5) + 1):
    while a%i == 0:
        ap.add(i)
        a/=i
if a != 1:
    ap.add(a)

bp = set()
for i in range(2, int(b**.5) + 1):
    while b%i == 0:
        bp.add(i)
        b/=i
if b != 1:
    bp.add(b)

print(len(bp.intersection(ap))+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m, c; cin >> n >> m >> c;
	vector<int> b(m);
	int cnt = 0;
	for( auto &i : b ) cin >> i;
	for( int i = 0; i < n; ++i ){
		int sum = 0;
		for( int j = 0; j < m; ++j ){
			int k; cin >> k;
			sum += k*b[j];
		}
		if( sum + c > 0 ) ++cnt;
	}
	cout << cnt << endl;
	return 0;
}

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


bool linearSearch(vector<int> A, int key){
    int n = A.size();
    A.push_back(key);
    int i = 0;
    while(A[i] != key){
        i++;
    }
    if (i==n){
        return false;
    }
    return true;
}

// main
int main(){
    int n, q;
    cin >> n;
    vector<int> S(n, 0);

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

    cin >> q;
    vector<int> T(q, 0);
    for(int i = 0; i < q; ++i){
        cin >> T[i];
    }

    int count = 0;
    for(int i = 0; i< q; ++i){
        if( linearSearch(S, T[i]) ){
            count++;
        }
    }

    cout << count << "\n";
    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N));
    rep(i, N) rep(j, N) cin >> A[i][j];
    vector<vector<int>> use(N, vector<int>(N, 1));
    rep(i, N) rep(j, N) rep(k, N) {
        if (i == j || j == k || k == i) continue;
        if (A[i][j] + A[j][k] < A[i][k]) {
            cout << -1 << "\n";
            return 0;
        }
        if (A[i][j] + A[j][k] == A[i][k]) {
            use[i][k] = 0;
        }
    }
    lint ans = 0;
    rep(i, N) rep(j, N) {
        if (use[i][j]) ans += A[i][j];
    }
    ans /= 2;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

string next(string s) {
  int n = s.length();
  bool nine = true;
  for (int i = 0; i < n; i++) nine &= s[i] == '9';
  if (nine) {
    string ret = "1";
    rep(i, n) ret += "0";
    return ret;
  }

  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '9') continue;
    int diff = 0;
    if (i > 0) diff = s[i - 1] - s[i];
    if (diff == 0 || diff == 1) {
      s[i]++;
      for (int j = i + 1; j < n; j++) {
        char c = s[j - 1] - 1;
        s[j] = max('0', c);
      }
      break;
    }
  }
  return s;
}

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

  string ans = "0";
  rep(i, k) ans = next(ans);

  cout << ans << endl;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            string In = Console.ReadLine();
            if(In[0]=='7' || In[1] == '7' || In[2] == '7')
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
        }
    }
}

Measured memory_bytes: 25760
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#define pi acos(-1)
using namespace std;
double aabs(double x)
{
	if(x<0)return -x;
	return x;
}
int main()
{
	int a[107];
	int n,x;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)
	{
		int x=a[i];
		int j=i-1;
		while(j>=0&&a[j]>x)
		{
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=x;
		for(int k=0;k<n;k++)
		{
			if(k!=n-1)cout<<a[k]<<" ";
			else cout<<a[k]<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3116
N, W = map(int, input().split())

wv = [list(map(int, input().split())) for _ in range(N)]

# print(wv)

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if (j-wv[i][0]) >= 0:
            dp[i+1][j] = max(dp[i][j-wv[i][0]]+wv[i][1], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

Measured memory_bytes: 171784
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    int shu[10],gw[10];
    for(int i=0;i<5;i++)
    {
        cin>>shu[i];
        gw[i]=shu[i]%10;
    }
    int minm=9;
    int jl=-1;
    for(int i=0;i<5;i++)
    {
        if(gw[i]!=0)
        {
            if(gw[i]<=minm)
            {
                jl=i;minm=gw[i];
            }
        }
    }
    int sum=0;
    for(int i=0;i<5;i++)
    {
        if(i!=jl)
        {
            if(gw[i]!=0)
                sum+=(shu[i]/10*10+10);
            else
                sum+=shu[i];
        }
    }
    sum+=shu[jl];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

#define S first.first
#define T first.second
#define X second

#define f first
#define s second

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	priority_queue<pair<pair<int,int>,int>, vector<pair<pair<int,int>,int>>,greater<pair<pair<int,int>,int>>> Q;
	int N, q, D;
	vector<pair<pair<int,int>,int>> I, temp;
	
	cin>>N>>q;
	
	I.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>I[i].S>>I[i].T>>I[i].X;
		temp.push_back(make_pair(make_pair(I[i].S - I[i].X,I[i].T - I[i].X),I[i].X));
		
		// temp.push_back(make_pair(make_pair(I[i].T - I[i].X,I[i].S - I[i].X,),I[i].X));
		// cout<<i<<" "<<temp[i].f.f<<" "<<temp[i].f.s<<" "<<temp[i].s<<endl;
	}
	
	sort(temp.begin(), temp.end());
	
	// cout<<"XXXXXXX"<<endl;
	for(int i = 0, j = 0; i < q; i++){
		cin>>D;
		// cout<<"D "<<D<<endl;
		for(; j < N; j++){
			// cout<<"D "<<D<<" "<<temp[j].f.f<<endl;
			if(D >= temp[j].f.f){
				Q.push(make_pair(make_pair(temp[j].s, temp[j].f.f),temp[j].f.s));
			} else {
				break;
			}
		}
		for(;Q.size();){
			pair<pair<int,int>,int> p = Q.top();
			// cout<<"p.s "<<p.s<<" <= D "<<D<<endl;
			if(p.s > D) break;
			Q.pop();
		}
		
		if(Q.size()) cout<<(Q.top()).f.f<<endl;
		else cout<<-1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 20204
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Atomic Car Race
public class Main{

	double[] dist;
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int[] a = new int[n+1];
			for(int i=1;i<=n;i++)a[i]=sc.nextInt();
			double b = sc.nextDouble();
			int r = sc.nextInt();
			double v = sc.nextDouble(), e = sc.nextDouble(), f = sc.nextDouble();
			double[] s = new double[a[n]+1];
			for(int x=0;x<a[n];x++){
				double c = r<=x?(1/(v-e*(x-r))):(1/(v-f*(r-x)));
				s[x+1] = s[x]+c;
			}
			dist = new double[n+1];
			Arrays.fill(dist, 1<<29);
			dist[0] = 0;
			PriorityQueue<Integer> q = new PriorityQueue<Integer>(n, new Comparator<Integer>() {
				public int compare(Integer o1, Integer o2) {
					return (int) Math.signum(dist[o1]-dist[o2]);
				}
			});
			q.add(0);
			while(!q.isEmpty()){
				int p = q.poll();
				if(p==n){
					System.out.printf("%.4f\n", dist[n]);break;
				}
				for(int k=p+1;k<=n;k++){
					double w = dist[p]+s[a[k]-a[p]]+(p==0?0:b);
					if(w<dist[k]){
						q.remove(k);
						dist[k] = w;
						q.add(k);
					}
				}
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
N,T = map(int, input().split())
cList=[]
tList=[]
ans=999999999999999999999999999999999999999
flag=0
for i in range(N):
  c,t=map(int, input().split())
  if t <= T:
    flag=1
    if c < ans:
        ans=c

if flag==0:
  print("TLE")
else:
  print(ans)

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

int main () {
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if (r + x > w) {
		cout << "No" << endl;
	} else if (r > x) {
		cout << "No" << endl;
	} else if (r + y > h) {
		cout << "No" << endl;
	} else if (r > y) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
<?php

  list($n, $k) = explode(" ", trim(fgets(STDIN)));

  if($k >= $n){
    echo "0";
    exit;
  }  
  $h = explode(" ", trim(fgets(STDIN)));
  sort($h);

  $ans=0;
  for($i=0;$i<$n-$k;$i++){
    $ans+=$h[$i];
  }
  echo $ans;

Measured memory_bytes: 23200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); 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 main(){
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A.at(i) >> B.at(i);

    vector<vector<ll> > dp(N+1, vector<ll>(H+1, INF));
    dp[0][0] = 0;
    rep(i, N){
        rep(j, H+1){
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j+A[i], H)], dp[i+1][j] + B[i]);
        }
    }
    cout << dp[N][H] << endl;
}

Measured memory_bytes: 81540
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(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 main() {
    int n; cin >> n;
    map<int, int> mp;
    rep(i, n){
        int a; cin >> a;
        mp[a]++;
    }
    bool fg = true; int siz = mp.size();
    if(siz == 1 && mp[0] != 0) fg = true;
    else if(n%3 != 0) fg = false;
    if(siz > 3) fg = false;
    if(siz == 3){
        vector<int> key,v;
        for(auto m: mp){
            key.push_back(m.first);
            v.push_back(m.second);
        }
        sort(all(v));
        if(v[0] != v[2]) fg = false;
        if(mp.count(0) == 1) fg = false;
        else{
            int xor_ = key[0] ^ key[1];
            if(xor_ != key[2]) fg = false;
        }
    }
    if(siz == 2){
        if(mp.count(0) == 0) fg = false;
        else{
            if(mp[0] == n / 3) fg = true;
            else fg = false;
        }
    }
    if(siz == 1 && mp[0] == 0) fg = false;

    if(fg) cout << "Yes" << ln;
    else cout << "No" << ln;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
const int nax = 5e5 + 5;
char sl[nax];

const int _ = 0, _0 = 1, _1 = 2, _00 = 3, _01 = 4, _10 = 5, _100 = 6, WIN = 7;

int f(int a, int b) {
	if(a == _) {
		if(b == 0) return _0;
		return _1;
	}
	if(a == _0) {
		if(b == 0) return _00;
		return _01;
	}
	if(a == _1) {
		if(b == 0) return _10;
		return WIN;
	}
	if(a == _00) {
		if(b == 0) return _0;
		return _0;
	}
	if(a == _01) {
		if(b == 0) return _0;
		return _1;
	}
	if(a == _10) {
		if(b == 0) return _100;
		return _1;
	}
	if(a == _100) {
		if(b == 0) return _10;
		return _10;
	}
	assert(a == WIN);
	return WIN;
}

const int mod = 1e9 + 7;

int main() {
	scanf("%s", sl);
	int n = strlen(sl);
	vector<int> dp(8);
	dp[0] = 1;
	for(int where = 0; where < n; ++where) {
		vector<long long> nowe(8);
		for(int i = 0; i < 8; ++i) {
			if(sl[where] == '?' || sl[where] == '0')
				nowe[f(i, 0)] += dp[i];
			if(sl[where] == '?' || sl[where] == '1')
				nowe[f(i, 1)] += dp[i];
		}
		for(int i = 0; i < 8; ++i)
			dp[i] = nowe[i] % mod;
		//for(int i = 0; i < 8; ++i) printf("%d ", dp[i]); puts("");
	}
	printf("%d\n", (dp[WIN] + dp[_1]) % mod);
}

Measured memory_bytes: 512
import Control.Applicative
import qualified Control.Monad as Monad

type Card = (String, Int)

main = do
    n <- read <$> getLine
    hc <- map (toCard . words) <$> Monad.replicateM n getLine
    mapM_ (putStrLn . fromCard) $ missingCards hc

toCard :: [String] -> Card
toCard [p,r] = (p, read r)

fromCard :: Card -> String
fromCard (p,r) = p ++ " " ++ (show r)

missingCards :: [Card] -> [Card]
missingCards hc = [ (p,r) | p <- ["S","H","C","D"], r <- [1..13], not $ (p,r) `elem` hc ]


Measured memory_bytes: 3984
#include <stdio.h>

int N,P[100100];

int main()
{
	scanf ("%d",&N);
	int a = 0, l = 0;
	for (int i=1;i<=N;i++){
		int p; scanf ("%d",&p);
		if (i != p) a += (l + 1) / 2, l = 0;
		else l++;
	}
	a += (l + 1) / 2;
	printf ("%d\n",a);

	return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    string s, t;
    cin >> s >> t;
    vector<int> a, b;
    set<char> sts, stt;
    map<char, int> mps, mpt;
    int now = 0;
    rep(i, s.size()){
        if(sts.count(s[i])){
            a.push_back(mps[s[i]]);
        }else{
            sts.insert(s[i]);
            mps[s[i]] = now;
            a.push_back(now);
            ++now;
        }
    }
    now = 0;
    rep(i, t.size()){
        if(stt.count(t[i])){
            b.push_back(mpt[t[i]]);
        }else{
            stt.insert(t[i]);
            mpt[t[i]] = now;
            b.push_back(now);
            ++now;
        }
    }
    bool flag = true;
    rep(i, a.size()){
        if(a[i] != b[i]){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
s = input()
input_len = len(s)

# 先頭に1を足す
s = "1" + s

# 正解になるパターンの作成(先頭に1を入れておく)
str1 = "1" + "01" * (input_len//2)
str2 = "1" + "10" * (input_len//2)

if(input_len%2 == 1):
	#要素数が奇数の場合は1個足す
	str1 = str1 + "0"
	str2 = str2 + "1"

# print(str1)
# print(str2)

#2進数に変換
input_num = int(s, 2)
num1 = int(str1, 2)
num2 = int(str2, 2)

# print(input_num, num1, num2)
# print(bin(input_num), bin(num1), bin(num2))

# 排他的論理和を求める
ans1 = input_num ^ num1
ans2 = input_num ^ num2
# print(ans1, ans2)
# print(bin(ans1), bin(ans2))

#ビットが立っている数を数える
ans_str1 = list(bin(ans1)[2:])
ans_list1 = list(filter(lambda x: x == "1", ans_str1)) 
a1 = len(ans_list1)

ans_str2 = list(bin(ans2)[2:])
ans_list2 = list(filter(lambda x: x == "1", ans_str2)) 
a2 = len(ans_list2)

if a1 < a2:
	print(a1)
else:
	print(a2)


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

int b[6][2] = { {0,1}, {0,1}, {0,2}, {0,2}, {1,2}, {1,2} };

int main(){
    vector<pair<int,int>> v;
    int x, y;

    for(int i = 0; i < 6; i++){
        cin >> x >> y;
        if(x > y)   swap(x, y);
        v.push_back({x, y});
    }

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

    bool judge = false;
    
    //do{
        int a[3] = {v[0].first, v[0].second, v[2].second};
        bool inner = true;
        for(int i = 0; i < 6; i++){
            inner &= v[i].first == a[b[i][0]];
            inner &= v[i].second == a[b[i][1]];
        }
        if(inner)   judge = true;
    //}while(next_permutation(v.begin(), v.end()));

    if(judge)   cout << "yes" << endl;
    else        cout << "no" << endl;

    return 0;
}


Measured memory_bytes: 3128
nml=list(map(int,input().split()))
n=nml[0]
m=nml[1]
l=nml[2]

A=[]
B=[]
for i in range(n+m):
    if i<n:
        A.append(list(map(int,input().split())))
    else:
        B.append(list(map(int,input().split())))

for i in range(n):
    for k in range(l):
        c=0
        for j in range(m):
            c=c+A[i][j]*B[j][k]
        if k<l-1:
            print(str(c)+" ",end="")
        else:
            print(c)



Measured memory_bytes: 6576
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    string s;
    cin >> s;

    if(s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }

    set<char> st;
    vector<int> bucket(26, 0);
    rep(i, s.size()){
        st.insert(s[i]);
        ++bucket[s[i] - 'a'];
    }

    if(st.size() != 26){
        cout << s;
        rep(i, 26){
            if(bucket[i]) continue;
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }

    string res = s.substr(0, 25);
    vector<char> poped;
    poped.push_back(s[25]);
    
    for(int i = 25; i >= 0; --i){
        char bk = res.back();
        char target = 'z' + 1;

        rep(j, poped.size()){
            if(bk<poped[j]) target = min(target, poped[j]);
        }

        if(target <= 'z'){
            cout << res.substr(0, res.size()-1) << target << endl;
            return 0;
        }

        poped.push_back(res.back());
        res = res.substr(0, res.size()-1);
    }
    
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import math
a,b,c=map(float,input().split())

S=a*b*math.sin(math.radians(c))/2
h=b*math.sin(math.radians(c))

L= a+b+math.sqrt((a**2)+(b**2)-(2*a*b*math.cos(math.radians(c))))

print("{0:.8f}".format(S))
print("{0:.8f}".format(L))
print("{0:.8f}".format(h))



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


#define INF 1000000000000


signed main()
 {
int n;
cin>>n;
vector<string>s(n);
rep(i,n){cin>>s.at(i);}

sort(s.begin(),s.end());
int ans=1;
rep(i,n-1){
  if(s[i]!=s[i+1]){
    ans++;
  }
}
cout<<ans;
}


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

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

	map<int, int> temp;
	temp[a]++;
	temp[b]++;
	temp[c]++;

	if (temp[5] == 2 && temp[7] == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a.at(i);
    sort(all(a));
    bool ok = true;
    if(n % 2 == 0){
        if(a.at(0) != a.at(1) || a.at(0) % 2 != 1)ok = false;
        for(int i = 2; i < n; i+=2){
            if(a.at(i) != a.at(i+1) || a.at(i) % 2 != 1 || a.at(i)-a.at(i-1) != 2)ok = false;
        }
    }else{
        if(a.at(0) != 0)ok = false;
        for(int i = 1; i < n; i+=2){
            if(a.at(i) != a.at(i+1) || a.at(i) % 2 != 0 || a.at(i)-a.at(i-1) != 2)ok = false;
        }
        n--;
    }
    if(ok){
        ll ans = 1;
        rep(i, n/2){
            ans = ans % mod * 2 % mod;
        }
        cout << ans;
    }
    else cout << 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  ll N=s.size(),M=t.size();
  vector<ll> vs(N),vt(M);
  for (ll i=0;i<N;i++) {
    ll x=s.at(i)-'a';
    vs.at(i)=x;
  }
  sort(vs.begin(),vs.end());
  for (ll i=0;i<N;i++) {
    s.at(i)=(char)(vs.at(i)-'a');
  }
   for (ll i=0;i<M;i++) {
    ll x=t.at(i)-'a';
    vt.at(i)=x;
  }
  sort(vt.begin(),vt.end());
  reverse(vt.begin(),vt.end());
  for (ll i=0;i<M;i++) {
    t.at(i)=(char)(vt.at(i)-'a');
  }
 
  ll judge=0,possible=0;
  if (N < M) {
    for (ll i=0;i<N;i++) {
      if (s.at(i)!=t.at(i)) {
        judge=1;
        break;
      }
    }
    if (judge==0) possible=1;
  }
  
  for (ll i=0;i<min(N,M);i++) {
    if (s.at(i)-'a' < t.at(i)-'a') {
      possible=1;
      break;
    }
  }
  
  if (possible==1) cout << "Yes";
  else cout << "No";
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void) {
    long int K,A,B,ans;
    string S,T;
    cin >> S >> T ; 
   bool m = true;
   if(S.size()!=T.size()-1){
       m = false;
   }
for(int i = 0; S[i] != '\0'; ++i){
   if(S[i]!=T[i]){
       m = false;
   }
}
if(m){
    cout << "Yes" << "\n";
}
else{
    cout << "No" << "\n";
}


  return 0;
}

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

int main(){
  long long n,sum=0;
  cin>>n;
  long long a[n+4]={},k=0;
  if(n==3){
    cout<<"2 5 63"<<endl;
    return 0;
  }else if(n==4){
    cout<<"2 5 20 63"<<endl;
    return 0;
  }else if(n==5){
    cout<<"2 5 20 30 63"<<endl;
    return 0;
  }
  for(long long i=0;i<=n;i+=4){
    a[i]=6*k;
    a[i+1]=6*k+2;
    a[i+2]=6*k+3;
    a[i+3]=6*k+4;
    k++;
    sum+=a[i]+a[i+1]+a[i+2]+a[i+3];
  }
  sum-=a[n+1]+a[n+2]+a[n+3];
  if(sum%6==2){
    a[5]=a[n-n%4]+6;
  }else if(sum%6==3){
    a[6]=a[n-n%4]+6;
  }else if(sum%6==5){
    a[6]=a[n-n%4]+4;
  }
  for(long long j=1;j<n;j++) cout<<a[j]<<" ";
  cout<<a[n]<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N;
std::map<std::string, int> cnt;

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

  rep( i, N )
  {
    std::string S;
    std::cin >> S;

    ++cnt[S];
  }

  int ma = 0;
  for( auto it = cnt.begin(); it != cnt.end(); ++it )
    ma = std::max( ma, it->second );

  for( auto it = cnt.begin(); it != cnt.end(); ++it ) if( it->second == ma )
    std::cout << it->first << std::endl;

  return 0;
}

Measured memory_bytes: 26240
import math
A, B, N = map(int, input().split())
# for x in range(1, N+1):
#     print(x, math.floor(A*x/B), A*math.floor(x/B), math.floor(A*x/B) - A*math.floor(x/B))

if N >= B-1:
    print(math.floor(A*(B-1)/B) - A*math.floor((B-1)/B))
else:
    print(math.floor(A*N/B) - A*math.floor(N/B))

Measured memory_bytes: 62088
from collections import defaultdict
N = input()
A = list(map(int, input().split()))

acc_sum_dict = defaultdict(int)
acc_sum_dict[0] += 1
acc_sum = 0

cnt = 0
for a in A:
    acc_sum += a
    if acc_sum_dict.get(acc_sum):
        cnt += acc_sum_dict[acc_sum]
    acc_sum_dict[acc_sum] += 1
print(cnt)

Measured memory_bytes: 39296
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int main(void){
    int n,count=0;
    string s;
    cin>>s;
    vector<int> v(26,0);
    rep(i,s.size()) v[s[i]-'a']++;
    int c=100;
    rep(i,26){
        if(v[i]==0){
            c=i;
            break;
        }
    }
    char a=3;
    if(c!=100){
        a=c+'a';
        cout<<a<<endl;
    }
    else {
        cout<<"None"<<endl;
    }    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
int main(){
  string s;
  cin >> s;
  r(i,4)cout << s.at(i);
  cout << " ";
  for(int i=4;i<s.length();i++)cout << s.at(i);
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
    int N,M,i,A,B,fa;
    fa = 0;

    cin >> N >> M;

    vector<int64_t> H(N);
    vector<bool> ans(N,true);

    for(i=0;i<N;i++){
        cin >> H[i];
    }

    for(i=0;i<M;i++){
        cin >> A >> B;
        A--;
        B--;
        if(H[A] == H[B]){
            ans[A] = false;
            ans[B] = false;
        }else if(H[A] > H[B]){
            ans[B] = false;
        }else{
            ans[A] = false;
        }
    }

    for(i=0;i<N;i++){
        if(ans[i]){
            fa++;
        }
    }

    cout << fa << endl;

    return 0;
}

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

#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define endl "\n"

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep(i,n)      for(i = 0; i < n; i++)
#define repit(it,type)  for(auto it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

int main()
{
  IOS

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll x1, y1,x2,y2;

  x1 = max(a,b); y1 =max(c,d);
  x2 = min(a,b); y2 =min(c,d);

  ll r1 = (a*c),r2 = a*d,r3 = b*c,r4 =b*d;
  ll ans = max(max(r1,r2),max(r3,r4));
  cout<<ans;

  // if(x1>0 &&y1>0){
  //   cout<<(x1*y1);
  // }
  // else if(x1<0 && y1<0){
  //   cout<<(x2*y2);
  // }
  // else if(x1<0){
  //   cout<<(x1*y2);
  // }
  // else
  //   cout<<(x2*y1);

  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N; cin>>N;
  ll ans = 0, pre = 0;
  rep(i, N){
    ll a; cin >>a;
    ans += max(pre - a, 0LL);
    pre = max(pre, a);
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 3624
use proconio::{input, fastout};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        mut t: Chars,
    }

    for i in 0..t.len() {
        match t[i] {
            '?' => {
                t[i] = 'D';
            },
            _ => {}
        }
    }
    let ans = t.iter().collect::<String>();
    println!("{}", ans);
}


Measured memory_bytes: 3312
#include <iostream>
using namespace std; 
int main(){
  
  int n;
  cin >> n;
  long long  arr[n];
  for (int i = 0; i < n; i++){
    cin >> arr[i];
  }
  int maxi = 0,cnt = 0;
  for(int i = 0; i < n - 1; i++){
    if(arr[i] >= arr[i + 1]){
      cnt += 1;
      maxi = max(maxi,cnt);
      continue;
    }
    cnt = 0;
  }
  cout << maxi;
    
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    int x, y; cin >> x >> y;
    x--; y--;

    vvi d(n, vi(n));
    REP(i,0,n){
        REP(j,i+1,n){
            d[i][j] = j - i;
        }
    }
    int diff = y - x - 1;
    REP(i,0,n){
        REP(j,i+1,n){
            d[i][j] = min(d[i][j], abs(x - i) + 1 + abs(j - y));
        }
    }
    debug(d)

    vi ans(n-1);
    REP(i,0,n) REP(j,i+1,n){
        ans[d[i][j]-1] += 1;
    }
    rep(i,n-1) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 16000
import java.util.*;

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

        int n = in.nextInt();
        int m = in.nextInt();

        int even = 0;
        int odd = 0;
        for (int i = 0; i < n ; i++) {
            even += i;
        }
        for (int i = 0; i < m ; i++) {
            odd += i;
        }

        System.out.println(even+odd);
    }
}

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

using namespace std;

int main()
{

    string s;
    int n;
    cin>>n;

    cin>>s;
    if(n%2!=0)
        cout<<"No"<<endl;
    else
    {
        int m = n/2;
        bool flag = false;
        for(int i=0; i<m; i++)
        {

            if(s[i]!=s[m+i])
            {
                flag = true;
                cout<<"No"<<endl;
            }
        }
        if(flag==false)
            cout<<"Yes"<<endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
using namespace std;
 
int main(){
 
int H,A;
 
cin>>H>>A;
  
  if(H % A != 0){
    cout << H/A+1 << endl;
  }else{
    cout << H/A << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        
	        int N = sc.nextInt();
	        Integer[][] a = new Integer[N][3];
	        Integer[][] b = new Integer[N][3];
	        for(int i=0;i<N;i++) {
	        	a[i][0] = Integer.parseInt(sc.next());
	        	a[i][1] = Integer.parseInt(sc.next());
	        	a[i][2] = i;
	        	b[i][0] = a[i][0];
	        	b[i][1] = a[i][1];
	        	b[i][2] = a[i][2];
	        }
	        Arrays.sort(a, (d, c) -> Integer.compare(d[0], c[0]));
	        Arrays.sort(b, (d, c) -> Integer.compare(c[1], d[1]));
	        long ans=0;
	        if(N%2==1) {
	        	Integer min = a[N/2][0];
	        	Integer max = b[N/2][1];
        		Integer r = 0;
        		ans=max-min+1;
	        	for(int i=0;i<N;i++) {
	        		if(r>=max)break;
	        		if(r<a[i][0]&&min<a[i][0]) {
	        			ans=ans-(Math.min(a[i][0], max)-Math.max(r, min)-1);
	        		}
	        		r=Math.max(r, a[i][1]);
	        	}
	        	
	        } else {
	        	Integer min = a[N/2-1][0]+a[N/2][0];
	        	Integer max = b[N/2-1][1]+b[N/2][1];
        		ans=(max-min+1);
	        	
	        }
	        
	        System.out.println(ans);
	    }
	}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int A[3][3];
  rep(i, 3) {
    rep(j, 3) {
      std::cin >> A[i][j];
    }
  }
  int N;
  std::cin >> N;
  std::vector<int> b(N);
  rep(i, N) {
    std::cin >> b[i];
  }

  bool marked[3][3] = {};
  rep(t, N) {
    rep(i, 3) {
      rep(j, 3) {
        if(b[t] == A[i][j]) {
          marked[i][j] = true;
        }
      }
    }
  }

  bool flg = false;
  rep(i, 3) {
    if(marked[i][0] && marked[i][1] && marked[i][2]) {
      flg = true;
    }
  }
  rep(j, 3) {
    if(marked[0][j] && marked[1][j] && marked[2][j]) {
      flg = true;
    }
  }
  if(marked[0][0] && marked[1][1] && marked[2][2]) {
    flg = true;
  }
  if(marked[0][2] && marked[1][1] && marked[2][0]) {
    flg = true;
  }

  if(flg) {
    std::cout << "Yes" << '\n';
  } else {
    std::cout << "No" << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;



int main(){
    ll N, K; cin >> N >> K;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    ll ans = INF;
    for(int b = 0; b < (1<<N); b++){
        bitset<15> B = b;
        if(B.count() != K) continue;
        ll MAX = A[0], SUM = 0;
        for(int i = 0; i < N; i++){
            if(B[i]){
                if(i != 0) {
                    SUM += max(0LL, MAX-A[i]+1);
                    MAX = max(MAX+1, A[i]);
                }
            }
            else{
                MAX = max(MAX, A[i]);
            }
            

        }
        ans = min(ans, SUM);
    }
    cout << ans << endl;
} 


Measured memory_bytes: 3580
s = gets.chomp
t = gets.chomp

done = []
s.length.times do |i|
  next if done.include?(t[i])
  orig = s[i]
  s.gsub!(t[i], "!")
  s.gsub!(orig, t[i])
  s.gsub!("!", orig)
  done << t[i]
end

if s == t
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 12096
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int answer = 0;
    string s;
    cin >> s;
    REP(i,s.length()){
        if(s[i] == '+')answer++;
        else answer--;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
def abc042_c():
  n, _ = map(int, input().split())
  D = list(map(int, input().split()))
  for i in range(n, 10**5):
    like = True
    for s in str(i):
      if int(s) in D:
        like = False
        break
    if like:
      print(i)
      return

abc042_c()

Measured memory_bytes: 3060
package main

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

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

	n := io.ScanInt()
	a := io.ScanInts(n)
	numCountMap := map[int]int{}
	possibleXNums := map[int]bool{}
	for _, num := range a {
		numCountMap[num] += 1
		possibleXNums[num-1] = true
		possibleXNums[num] = true
		possibleXNums[num+1] = true
	}

	var max int
	for num := range possibleXNums {
		xCount := numCountMap[num-1] + numCountMap[num] + numCountMap[num+1]
		if xCount > max {
			max = xCount
		}
	}
	fmt.Println(max)
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


Measured memory_bytes: 12792
#include<bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int,int>P;

#define INF INT_MAX;
#define F first
#define S second

int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  printf("%d\n",n*m);
  
  return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

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

  if ((a <= c && c <= b) || (b <= c && c <= a))
    puts("Yes");
  else
    puts("No");

  return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for˜(ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]) {
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

signed main() {
  solve();

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


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;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t; cin >> s >> t;
	vector<char>a(26, '*'), b(26, '*');
	rep(i, s.size()) {
		if (a[s[i] - 'a'] == '*')a[s[i] - 'a'] = t[i];
		else if (a[s[i] - 'a'] != t[i]) {
			cout << "No" << endl; return 0;
		}
		if (b[t[i] - 'a'] == '*')b[t[i] - 'a'] = s[i];
		else if (b[t[i] - 'a'] != s[i]) {
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 916