akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
LR = list(zip(m,m))

if N==2:
    L1,R1 = LR[0]
    L2,R2 = LR[1]
    answer = (R1-L1+1) + (R2-L2+1)
    print(answer)
    exit()

# 片方に集める場合
max_width = max(R-L+1 for L,R in LR)

LR.sort()

INF=10**18
# Rが最小のもの
i = -1
opt_R = INF
for n,(L,R) in enumerate(LR):
    if opt_R>=R:
        opt_R=R
        i=n
j = -1
opt_L = -INF
for n,(L,R) in enumerate(LR):
    if opt_L<=L:
        opt_L=L
        j=n

if i==j:
    L,R = LR[i]
    answer = max_width + (R-L+1)
    print(answer)
    exit()

L1,R1 = LR[i]; L2,R2 = LR[j]

LR = [(L,R) for n,(L,R) in enumerate(LR) if n != i and n != j]

LR.sort(key = lambda x: (x[0],-x[1]))

n = len(LR)
dpl = [(-INF,INF)]*(n+1)
dpr = [(-INF,INF)]*(n+1)

for i in range(n):
    a,b = dpl[i]
    L,R = LR[i]
    dpl[i+1] = (max(a,L),min(b,R))
for i in range(n,0,-1):
    a,b = dpr[i]
    L,R = LR[i-1]
    dpr[i-1] = (max(a,L),min(b,R))

answer = 0
for (a,b),(c,d) in zip(dpl,dpr):
    l1 = max(L1,a); r1 = min(R1,b)
    l2 = max(L2,c); r2 = min(R2,d)
    x = max(0,r1-l1+1) + max(0,r2-l2+1)
    if answer < x:
        answer = x

x = max_width + max(0,min(R1,R2)-max(L1,L2)+1)
if answer < x:
    answer = x

print(answer)


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

int main()
{
    long long int n;
    cin >> n;
    vector<long long int> v;
    for(long long int i=0;i<n;i++)
    {
        long long int k;
        cin >> k;
        v.push_back(k);
    }
    sort(v.begin(),v.end());
    float ans=v[0]+v[1];
    for(long long int i=2;i<n;i++)
    {
        ans+=pow(2,i-1)*v[i];
    }
    ans=ans/pow(2,n-1);
    printf("%0.6f",ans);
}

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

#define INF (1LL<<60)

int main(){
	int n,k;	cin>>n>>k;
	vector<int> candles(n,0);

	for(int i=0;i<n;i++){
		cin>>candles[i];
	}
	long long ans=INF;
	if(k>1){
		int lPos=0,rPos=0;
		while(rPos+1<n){
			rPos++;
			int count=rPos-lPos;
			if(count>k-1){
				lPos++;
				count--;
			}

			if(count==k-1){
				//printf("%d <--> %d\n",candles[lPos], candles[rPos]);
				long long tmp1=abs(candles[lPos]) + abs(candles[rPos]-candles[lPos]);
				long long tmp2=abs(candles[rPos]) + abs(candles[rPos]-candles[lPos]);
				long long tmp=min(tmp1,tmp2);

				ans=min(ans,tmp);
			}
		}
	}else{
		ans=candles[0];
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
class Something_on_It
{
public:
    int solve(string s)
    {
       int ans=700;
       for(int i=0;i<s.size() ;i++)if(s[i]=='o')ans+=100;
       return ans;
    }
};
int main()
{
    Something_on_It S;
    string s;
    cin>>s;
    cout<<S.solve(s)<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<set>
#include<algorithm>
#include<vector>
using namespace std;
bool t[4100][4100];
short ul[4100][4100];
short dl[4100][4100];
short ll[4100][4100];
short rl[4100][4100];
int bit[5000];
int sum(int a,int b){
	if(a)return sum(0,b)-sum(0,a-1);
	int ret=0;
	for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];
	return ret;
}
void add(int a,int b){
	for(;a<5000;a|=a+1)bit[a]+=b;
}
pair<int,int>ev[5000];
int P;
long long count(vector<int>L,vector<int>R){
	int n=L.size();
	for(int i=0;i<5000;i++)bit[i]=0;
	for(int i=0;i<n;i++)ev[i]=make_pair(i-L[i],i);
	std::sort(ev,ev+n);
	long long ret=0;
	int at=0;
	for(int i=0;i<n;i++){
		while(at<n&&ev[at].first<i){
			add(ev[at].second,1);
			at++;
		}
		int left=i+P-1;
		int right=i+R[i]-1;
		if(left<=right)ret+=sum(left,right);
	}
	//printf("%lld ",ret);
	return ret;
}
int main(){
	int H,W,L;
	scanf("%d%d%d%d",&H,&W,&P,&L);
	bool hanten=false;
	if(H>W){
		swap(H,W);
		hanten=true;
	}
	for(int i=0;i<L;i++){
		int p,q;
		scanf("%d%d",&p,&q);
		p--;q--;
		if(hanten)swap(p,q);
		t[p][q]=1;
	}
	for(int i=0;i<H;i++)for(int j=0;j<W;j++){
		if(t[i][j]){
			ul[i][j]=ll[i][j]=0;
		}else{
			if(i==0)ul[i][j]=1;
			else ul[i][j]=ul[i-1][j]+1;
			if(j==0)ll[i][j]=1;
			else ll[i][j]=ll[i][j-1]+1;
		}
	}
	for(int i=H-1;i>=0;i--)for(int j=W-1;j>=0;j--){
		if(t[i][j]){
			dl[i][j]=rl[i][j]=0;
		}else{
			if(i==H-1)dl[i][j]=1;
			else dl[i][j]=dl[i+1][j]+1;
			if(j==W-1)rl[i][j]=1;
			else rl[i][j]=rl[i][j+1]+1;
		}
	}
	for(int i=0;i<H;i++)for(int j=0;j<W;j++){
		rl[i][j]=min(rl[i][j],dl[i][j]);
		ll[i][j]=min(ll[i][j],ul[i][j]);
	}
	long long ret=0;
	for(int i=1;i<H;i++){
		vector<int>tl(i);
		vector<int>tr(i);
		for(int j=0;j<i;j++){
			tl[j]=ll[H-i+j][j];
			tr[j]=rl[H-i+j][j];
		}
		ret+=count(tl,tr);
	}
	for(int i=1;i<H;i++){
		vector<int>tl(i);
		vector<int>tr(i);
		for(int j=0;j<i;j++){
			tl[j]=ll[j][W-i+j];
			tr[j]=rl[j][W-i+j];
		}
		ret+=count(tl,tr);
	}
	for(int i=0;i<=W-H;i++){
		vector<int>tl(H);
		vector<int>tr(H);
		for(int j=0;j<H;j++){
			tl[j]=ll[j][i+j];
			tr[j]=rl[j][i+j];
		}
		ret+=count(tl,tr);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 148556
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 16)
#define INF (1 << 30)

int mem[MAXN];
int a[MAXN], b[MAXN];
int h, n;

int f(int k) {
	if (k <= 0) {
		return 0;
	}
	int & ret = mem[k];
	if (ret != -1) {
		return ret;
	}
	ret = INF;
	for (int i = 0; i < n; i++) {
		int cur = f(k - a[i]) + b[i];
		ret = min(ret, cur);
	}
	return ret;
}

int main() {
	memset(mem, -1, sizeof(mem));
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	cout << f(h) << endl;
	return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    ll t[10][10]={};
    for(int i=1;i<=n;i++){
        if(i%10==0)continue;
        int a=i%10;
        int b;
        int j=i;
        while(j>0){
            b=j;
            j/=10;
        }
        t[b][a]++;
    }
    ll ans=0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans+=t[i][j]*t[j][i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n=int(input())
d=[0]+[float('inf')]*(n-1)

v=[[]]*n
for i in range(n):
    tmp=list(map(int,input().split()))
    tmp=[i-1 for i in tmp[2:]]
    v[i]=tmp

que=[0]
while que!=[]:
    m=que.pop(0)
    for i in v[m]:
        if d[i]==float('inf'):
            que.append(i)
            d[i]=d[m]+1
for i in range(n):
    if d[i]==float('inf'):
        d[i]=-1
    print(i+1,d[i])


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

typedef pair<int, int> P;

typedef long long LL;

const int MOD = 1000000007;

int N;
vector<P> v;
int dp[4001][4001];

int main() {
  cin >> N;
  int a_max = 0;
  int b_max = 0;
  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    v.push_back(P(a, b));
    a_max = max(a_max, a);
    b_max = max(b_max, b);
  }

  int a_end = a_max * 2 + 1;
  int b_end = b_max * 2 + 1;
  for (int i = 0; i < a_end; ++i) {
    for (int j = 0; j < b_end; ++j) {
      dp[i][j] = 0;
    }
  }

  for (int i = 0; i < N; ++i) {
    ++dp[a_max - v[i].first][b_max - v[i].second];
  }

  for (int i = 0; i < a_end; ++i) {
    for (int j = 0; j < b_end; ++j) {
      if (i > 0) {
        dp[i][j] += dp[i - 1][j];
      }
      if (j > 0) {
        dp[i][j] += dp[i][j - 1];
      }
      dp[i][j] %= MOD;
    }
  }

  int t = 0;
  for (int i = 0; i < N; ++i) {
    t += dp[a_max + v[i].first][b_max + v[i].second];
    t %= MOD;
  }

  for (int i = 0; i < a_end; ++i) {
    for (int j = 0; j < b_end; ++j) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;

  for (int i = 0; i < a_end; ++i) {
    for (int j = 0; j < b_end; ++j) {
      if (i > 0) {
        dp[i][j] += dp[i - 1][j];
      }
      if (j > 0) {
        dp[i][j] += dp[i][j - 1];
      }
      dp[i][j] %= MOD;
    }
  }

  for (int i = 0; i < N; ++i) {
    t -= dp[2 * v[i].first][2 * v[i].second];
    t %= MOD;
  }

  LL inv2 = (MOD + 1) / 2;
  LL ans = (t * inv2) % MOD;
  ans = (ans + MOD) % MOD;

  cout << ans << endl;

  return 0;
}


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

int dp[5005][5005];

int main(){
  int n;
  string s;
  cin>>n>>s;
  for(int i=n-1;i>=0;i--){
    for(int j=i;j>=0;j--){
      if(i==n-1){
	if(s[i]==s[j]) dp[i][j]=1;
	else dp[i][j]=0;
      }
      if(s[i]==s[j])
	dp[i][j]=dp[i+1][j+1]+1;
      else
	dp[i][j]=0;
    }
  }
  int ans=0;
  for(int i=n-1;i>=0;i--){
    for(int j=i;j>=0;j--){
      dp[i][j]=min(i-j,dp[i][j]);
      ans=max(ans,dp[i][j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 96384
N=int(input())
H=list(map(int,input().split()))
 
ans = 0
i = 0
cnt = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
       cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;
     

bool binarySearch(int s[], int n, int key){
    int left = 0, right = n, mid;
    while(left < right){
        mid = (left + right)/2;
        if(s[mid] == key){
            //cout<<s[mid]<<endl;
            return true;
        }
        else if(key < s[mid]){
            right = mid;
        }
        else{
            left = mid + 1;
        }
    }
    return false;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, q;
    cin>>n;
    int s[n];
    rep(i, n){
        cin>>s[i];
    }
    cin>>q;
    int t[q];
    rep(i, q){
        cin>>t[i];
    }
    int cnt = 0;
    rep(i, q){
        if(binarySearch(s, n, t[i])){
            cnt += 1;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
const double eps = 1e-7;
int N, M, K, Q, T;
ll gcd(ll a, ll b) {
	if (b == 0LL) return a;
	return gcd(b, a % b);
}

int main()
{
	int i, j;
	int x, y;
	scanf("%d%d", &x, &y);
	printf("%d", x * y);
}

Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const ll inf = 1LL << 60;
 
struct Edge{
    int number;
    int to;
    int color;
    Edge(int n,int t,int c){
        number = n;
        to = t;
        color = c;
    }
};
 
int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N; cin>>N;
    vector<vector<Edge> > G(N);
    vector<int> ans(N-1,0);
    vector<bool> done(N,false);
    int maxi = 0;
    REP(i,N-1){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(Edge(i,b,0));
        G[b].push_back(Edge(i,a,0));
        int now = max(G[a].size(),G[b].size());
        maxi = max(now,maxi);
    }

    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int now = que.front(); que.pop();
        done[now] = true;
        //if(!done[now]){
        int now_color = 1;
        set<int> have;
        REP(i,G[now].size()){
            Edge next = G[now][i];
            have.insert(ans[next.number]);     
        }
        REP(i,G[now].size()){
            Edge next = G[now][i];
            if(ans[next.number] != 0)continue;
            while(have.find(now_color) != have.end()){
                now_color++;
            }
            ans[next.number] = now_color;
            have.insert(now_color);
            if(done[next.to] == false){
                que.push(next.to);
            }
        }
        //}
    }
    cout << maxi<<endl;
    REP(i,ans.size()){
        cout << ans[i]<<endl;
    }

}

Measured memory_bytes: 10172
//Difference between Knapsack -1 and Knapsack -2 is W constraints.
#include<bits/stdc++.h>
#define ll long long
#define inf 1e12 
using namespace std;
int main()
{
	ll n,max_w;
	cin>>n>>max_w;
	ll w[n+1],v[n+1];
	for(ll r=1;r<=n;r++)
	{
		cin>>w[r]>>v[r];
	}
	ll max_val=n*1000;
	ll dp[n+1][max_val+1];
	//dp[i][j] denotes minimum possible weight in which we can gain values{0....max_val}.
	for(ll e=0;e<=max_val;e++)
	{
		dp[1][e]=inf;
	}
	dp[1][0]=0;
	dp[1][v[1]]=w[1];//Minimum possible weight to do so is to w[1]. 
	for(ll z=2;z<=n;z++)
	{
		for(ll p=0;p<=max_val;p++)
		{
			dp[z][p]=dp[z-1][p];//Exclusion
			if(v[z]>p)
			{
				continue;
			}
			dp[z][p]=min(dp[z][p],dp[z-1][p-v[z]]+w[z]);
		}
	}
	ll ans=0;
	for(ll e=0;e<=max_val;e++)
	{
		if(dp[n][e]<=max_w)
		{
			ans=e;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 78336
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

M,D=get_i
if M<4 or D<22
    puts 0
    exit
end
ans=0
4.upto(M) do|m|
  22.upto(D) do|d|
    d_=d.to_s.split("").map(&:to_i)
    next unless d_[0]>=2 and d_[1]>=2
    ans+=1 if d_[0]*d_[1]==m
  end
end
puts ans

Measured memory_bytes: 2172
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 100005;
int n, a[MX], in[MX], no, res[MX];
set<int> st;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		in[a[i]]++;
		st.insert(i);
	}

	if (n == 2 && a[1] == 2 && a[2] == 1) {
		cout << -1 << endl;
		return 0;
	}

	for (int i = 1; i <= n; i++) {
		auto it = st.begin();
		if (*it == no) it++;
		int nex = a[*it];

		if (i == n - 2) {
			vi v;
			for (auto x : st)
				if (st.count(a[x]))
					v.pb(x);

			if (v.size() == 2) {
				sort(all(v));
				
				if (a[v[0]] == v[1] && a[v[1]] == v[0]) {
					if (v[0] == no) swap(v[0], v[1]);
					cout << v[0] << " ";
					no = a[v[0]];
					in[no]--;
					st.erase(v[0]);
					continue;
				} 
			}
		}

		if (st.count(nex) && in[nex] == n - i) {
			assert(nex != no);
			cout << nex << " ";
			no = a[nex];
			in[no]--;
			st.erase(nex);
		} else {
			cout << *it << " ";
			no = a[*it];
			in[no]--;
			st.erase(it);
		}
	}

	cout << endl;

	return 0;
}

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

int main() {
    int n1, n2, n3, n4;
    cin >> n1 >> n2 >> n3 >> n4;
    map<int, bool> MP;
    MP[n1] = MP[n2] = MP[n3] = MP[n4] = true;
    if (MP[1] && MP[9] && MP[7] && MP[4]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a, b, ag, bg, gc = 0;
  int g[] = {1, 3, 5, 7, 8, 10, 12,
             4, 6, 9, 11,
             2};

  string r;

  cin >> a >> b;

  for (size_t i = 0; i < 12; i++)
  {
    if (i == 7 || i == 11)
      gc++;
    if (a == g[i])
      ag = gc;
    if (b == g[i])
      bg = gc;
  }

  r = ag == bg ? "Yes" : "No";

  cout << r << "\n";

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N , K = map(int,input().split())
h = list(map(int,input().split()))
inf = float('inf')
dp = [inf] * N
if K == 1:
    ans = 0
    for i in range(N - 1):
        ans += abs(h[i + 1] - h[i])
    print(ans)
    exit()

for i in range(N):
    if i == 0:
        min_cost = 0
    elif i == 1:
        min_cost = abs(h[1] - h[0])
    else:
        current = h[i]
        tmp_min = min(abs(current - h[i - K]) + dp[i - K] , abs(current - h[i - K + 1]) + dp[i - K + 1])
        for j in range(K - 2):
            tmp_min = min(abs(current - h[i - K + 2 + j]) + dp[i - K + 2 + j], tmp_min)
        min_cost = tmp_min
    dp[i] = min_cost
#print(dp)
print(dp[N - 1])

Measured memory_bytes: 56224
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

if len(a) == len(set(a)):
    for i in range(n):
        print(0)
else:
    kw = Counter(a)
    ans = sum([x * (x - 1) // 2 for x in kw.values()])

    for i in range(n):
        print(ans - kw[a[i]] + 1)


Measured memory_bytes: 26780
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<double,int> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  char a,b;
  int m,n;
  cin>>a>>b;
  m=a-'A';n=b-'A';
  if(a>b)cout<<">"<<endl;
  if(a==b)cout<<"="<<endl;
  if(a<b)cout<<"<"<<endl;
  return 0;
  } 


Measured memory_bytes: 256
class UnionFindTree():
    def __init__(self, N):
        self.N = N
        self.__parent_of = [None] * N
        self.__rank_of = [0] * N
        self.__size = [1] * N

    def root(self, value):
        if self.__parent_of[value] is None:
            return value
        else:
            self.__parent_of[value] = self.root(self.__parent_of[value])
            return self.__parent_of[value]

    def unite(self, a, b):
        r1 = self.root(a)
        r2 = self.root(b)
        if r1 != r2:
            if self.__rank_of[r1] < self.__rank_of[r2]:
                self.__parent_of[r1] = r2
                self.__size[r2] += self.__size[r1]
            else:
                self.__parent_of[r2] = r1
                self.__size[r1] += self.__size[r2]
                if self.__rank_of[r1] == self.__rank_of[r2]:
                    self.__rank_of[r1] += 1

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def size(self, a):
        return self.__size[self.root(a)]

    def groups(self):
        groups = {}
        for k in range(self.N):
            r = self.root(k)
            if r not in groups:
                groups[r] = []
            groups[r].append(k)
        return [groups[x] for x in groups]


def main():
    N, Q = map(int, input().split())
    uft = UnionFindTree(N)
    for _ in range(Q):
        t, u, v = map(int, input().split())
        if t == 0:
            uft.unite(u-1, v-1)
        else:
            print(1 if uft.is_same(u-1, v-1) else 0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 83036
n = gets.chomp.to_i
ary1 = gets.chomp.split(" ").map(&:to_i)
sum1 = ary1.inject(&:+)
#ave1 = sum1 /n.to_f
ave1 = sum1 /n
ave2 = ave1 + 1
def sum_sq(ary2,m)
  return ary2.map{|elem| (elem-m)**2}.inject(&:+)
end
sum_sq1 = sum_sq(ary1,ave1)
sum_sq2 = sum_sq(ary1,ave2)
if sum_sq1 <= sum_sq2
  puts sum_sq1
else
  puts sum_sq2
end


Measured memory_bytes: 1788
#include <stdio.h>
#include <algorithm>
using namespace std;


int main()
{
	int a, b, c, d, e; scanf ("%d %d %d %d %d", &a, &b, &c, &d, &e);

	int p = a * 60 + b, q = c * 60 + d;
	printf ("%d\n", max(0, q - p - e));
	return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a + b, min(a + c, b + c));
}


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

using namespace std;

#define int long long

signed main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += i;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
dictionary = {}
for word in S:
  if word in dictionary:
    dictionary[word] += 1 #辞書の中にその言葉があったら、keyを+1
  else:
    dictionary[word] = 1#無いなら、その言葉を登録して,keyを1にする
maximum = max(dictionary.values()) #辞書のkeyの最大値を返す
for key,value in sorted(dictionary.items()): #keyとvalueの両方に対してfor文
  if value == maximum:
    print(key)

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

int main() {
	int X, A, B;

	cin >> X >> A >> B;

	X = X - A;

	X = X % B; //%を間に入れることで、X-Aの余りを出力させることができる

	cout << X << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],sum=0;
	for(int i=0;i<n;++i){
		cin>>a[i];
		sum+=a[i];
	}
	int xsum=0,mins=0x7fffffff;
	for(int i=0;i<n;++i){
		xsum+=a[i];
		mins=min(mins,abs(xsum-(sum-xsum)));
	}
	cout<<mins<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <regex>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    string s;
    cin >> s;
    int i;
    int ci = -1;
    for (i = 0; i < s.size(); i++) {
        if (s[i] == 'C') {
            ci = i;
            break;
        }
    }
    int fi = -1;
    for (; i < s.size(); i++) {
        if (s[i] == 'F') {
            fi = i;
            break;
        }
    }
    if (ci != -1 && fi != -1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=1e5+10;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,u,v,ans,fa[maxn],dep[maxn],far[maxn];
vector<int> g[maxn];

void dfs(int x,int pre)
{
    dep[x]=far[x]=dep[pre]+1;
    fa[x]=pre;
    for(unsigned int i=0;i<g[x].size();i++)
    {   
        int to=g[x][i];
        if(to==pre) continue;
        dfs(to,x);
        far[x]=max(far[x],far[to]);
    }
}

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    int a,b;
    cin>>n>>u>>v;
    _rep(i,1,n-1)
    {
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(v,0);    
    int now=u;
    while(1)
    {
        if(dep[u]-dep[now]<dep[now]-dep[v])
        {
            ans=max(ans,far[now]-1);
            now=fa[now];
        }
        else break;        
    }
    cout<<ans-1<<endl;

    return 0;
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a, b;
string s;
cin >> a >> b;
cin >> s;
for (int i = 0; i < a; i++)
{
	if (i == b-1){
		s[i] = tolower (s[i]);
		break;
	}
}
cout << s;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, t;
    cin >> n >> t;
    yukari<int> dp(t + 1, akari<int>(2));
    while (n--)
    {
        int a, b;
        cin >> a >> b;
        yukari<int> nx(dp);
        for (int i = t - a; i >= 0; i--)
        {
            nx[i + a][0] = max(nx[i + a][0], dp[i][0] + b);
        }
        for (int i = t - a - 1; i >= 0; i--)
        {
            nx[i + a][1] = max(nx[i + a][1], dp[i][1] + b);
        }
        for (int i = t - 1; i >= 0; i--)
        {
            nx[i][1] = max(nx[i][1], dp[i][0] + b);
            nx[i + 1][1] = max(nx[i + 1][1], nx[i][1]);
            nx[i + 1][0] = max(nx[i + 1][0], nx[i][0]);
        }
        swap(dp, nx);
    }
    cout << max(dp[t][0], dp[t][1]) << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ff(i,n) for(i=0;i<n;i++)
ll bg=1000000007;
ll gcd(ll a,ll b)
{
if(b==0)
   return a;
else
   return gcd(b,a%b);   
}
ll power(ll x,ll y)
{
	if(y==0)
		return 1;
	ll h=power(x,y/2);	
	h=(h*h);
	if(y%2==1)
	  return (x*h);
	else
	  return h;  
}
ll isp(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.length() - 1;
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        {  
            return -1; 
        } 
    } 
    return 1; 
} 
vector<vector<pair<ll,ll> > >adj(300000);
ll dis[300000],vis[300000],p[300000];

int main()
{
	ll t;
	t=1;
	while(t--)
	{	
	    ll i,n,m=0,k;
	    cin>>k>>n;
		ll  arr[n];
		ff(i,n)   cin>>arr[i];
		sort(arr,arr+n);
		for(i=1;i<n;i++)
		   m=max(m,arr[i]-arr[i-1]);
		m=max(m,arr[0]+k-arr[n-1]);  
		cout<<k-m ;     	  	   
	}
return 0;
}

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

int main(){
int n,l,m,r; int i=0; int ans=0;
cin >> n;
vector<int> p(n); 
while(i<n){
     cin >> p.at(i++);
}

for(int j=1; j<n-1; j++){
l=p.at(j-1); m=p.at(j); r=p.at(j+1);
    if(((l<m) && (m<r)) || ((l>m) && (m>r))) ans++;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
	int Have_money = 0;
	int happiness = 0;

	cin >> Have_money;

	if (Have_money >= 500) {
		int tmp = 0;
		tmp = Have_money / 500;

		Have_money = Have_money - (tmp * 500);
		happiness += (tmp * 1000);
		
	}

	if (Have_money >= 5) {
		int tmp = 0;
		tmp = Have_money / 5;

		Have_money = Have_money - (tmp * 5);
		happiness += (tmp * 5);
	}

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

Measured memory_bytes: 256
#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() {
    ll a, b, m; cin >> a >> b >> m;
    vector<ll> A(a), B(b); ll ma=INF, mb=INF;
    rep(i, a) {cin >> A[i]; chmin(ma, A[i]);}
    rep(i, b) {cin >> B[i]; chmin(mb, B[i]);}
    ll res = ma + mb;
    rep(i, m){
        ll x, y, c; cin >> x >> y >> c; x--; y--;
        chmin(res, A[x] + B[y] - c);
    }
    cout << res << ln;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } 
int main(){
  vector<int>dp(1000000,INF);
  int n;
  cin >> n;
  vector<int>a(n);
  rep0(i,n)cin >> a[i];
  dp[0] = 0;
  dp[1] = abs(a[0] - a[1]);
  REP(i,2,n){
    dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]),dp[i - 2] + abs(a[i - 2] - a[i])); 
  }
  cout << dp[n-1] << endl;
  return 0;
}

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

int main() {
  int r,D,x2000;
  cin >> r >> D >> x2000;

  vector<int> x(11);

  x.at(0)=x2000;
  for(int i=0;i<10;i++){
    x.at(i+1)=r*x.at(i)-D;
    cout << x.at(i+1) << endl;
  }




}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


int main(){

    string a, b;
    cin >> a >> b;
    string c = a + b;

    int n = stoi(c);

    int flag = 0;
    for (int i=1; i <= 10000; i++){
        if (i*i == n) flag = 1;
    }


    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}





//              g++ -std=c++1z

Measured memory_bytes: 888
#include<stdio.h>
int n,A[50];

int solve(int i, int m){
    if(m == 0) return 1;
    if(i >= n) return 0;
    int res = solve(i+1,m)||solve(i+1,m-A[i]);
    return res;
}

int main(){
    int q,M,i;
    
    scanf("%d",&n);
    for(i = 0; i< n; i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i = 0; i < q; i++){
        scanf("%d",&M);
        if(solve(0,M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


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

int main(void){
    int A,B;
    cin>>A>>B;

    if(A==B)
        cout<<"Draw"<<endl;
    else if(A==1)
        cout<<"Alice"<<endl;
    else if(B==1)
        cout<<"Bob"<<endl;
    else if(A-B>0)
        cout<<"Alice"<<endl;
    else
        cout<<"Bob"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
class Program {
  static void Main(string[] args) {
    int output = -1; //outbuf
    //input
    int a = int.Parse(Console.ReadLine());
    int b = int.Parse(Console.ReadLine());
    if(a*b == 2) output = 3;
    else if(a*b == 3) output = 2;
    else if(a*b == 6) output = 1;
    Console.WriteLine(output);
  }
 }

Measured memory_bytes: 11092
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(void)
{
	int i, t;
	int flag = 0;
	char a = 'A';
	string str[27][27];
	int h, w;
	cin >> h >> w;
	for (i = 0; i < h; i++)
	{
		for (t = 0; t < w; t++)
		{
			cin >> str[i][t];
		}
	}
	for (i = 0; i < h; i++)
	{
		for (t = 0; t < w; t++)
		{
			if (str[i][t] == "snuke")
			{
				flag = 1;
				break;
			}
		}
		if (flag == 1)
		{
			break;
		}
	}
	printf("%c%d\n", a + t, i+ 1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

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

    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    map<P, int> mp;
    int mx;
    rep(i, n) {
        rep(j, n) {
            if (i == j) continue;
            int dx = x[j] - x[i], dy = y[j] - y[i];
            chmax(mx, ++mp[P(dx, dy)]);
        }
    }
    cout << n - mx << endl;
}

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

int main(){
  string S;
  cin >> S;
  int N= S.size();
  
  auto is_palindrome= [](string str){
    int tail= str.size()- 1;

    bool ans= true;
    for(int i=0; i<str.size(); i++){
      if(str.at(i) != str.at(tail- i)){
        ans= false;
        break;
      }
    }

    return ans;
  };

  string ans= (N%2==1 && is_palindrome(S) && is_palindrome(S.substr(0, (N-1)/2)) && is_palindrome(S.substr((N+1)/2))) ? "Yes"
                                                                                                                      : "No";

  cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAXN = 1e5;
const int MAX = 45;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	
	LL n, m;
	cin >> n >> m;

	if (n > m)
		swap(n, m);

	if (n == 1)
	{
		if (m == 1)
		{
			cout << 1;
			return 0;
		}

		cout << m - 2;
		return 0;
	}

	if (n == 2)
	{
		cout << 0;
		return 0;
	}

	LL ans = (n - 2)*(m - 2);
	cout << ans;



	cin >> n;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


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

int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  int g = 0;
  for(int i = 1; i < S.size(); ++i) {
    if(S[i] == S[i-1]) g++;
  }
  cout << min(N-1, 2*K+g) << endl;

  return 0;
}


Measured memory_bytes: 512
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
    }
    let ans = 6 - a - b;
    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())

s = input()

t = input()

temp = N
flag = True
if s==t:
    print(N)
else:
    while(temp > 0 and flag):
        temps = s[N-temp:N]
        tempt = t[:temp]
        if(temps==tempt):
            flag = False
        else:
            temp -= 1

    print(N+N-temp)

Measured memory_bytes: 3192
import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range, std.functional;
 
void main() {
    auto N = readln.chomp.to!long;
    auto as = sort(readln.split.to!(long[]));
    sort(as.map!(a => [a-1, a, a+1]).join).uniq
    .map!(a => as.upperBound(a-2).lowerBound(a+2).count).reduce!max.writeln;
}


Measured memory_bytes: 9776
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll a, b, c;
  cin >> a >> b >> c;
  
  ll s = a + b + c;
  if (a == b && b == c && a % 2 == 0){
    cout << -1 << endl;
  }
  else {
    int res = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
      a = (s - a) / 2;
      b = (s - b) / 2;
      c = (s - c) / 2;
      res++;
    }

    cout << res << endl;
  }

  return 0;
}


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

int main(){
	string S, T;
	cin >> S >> T;
	int N = (int)S.length();
	int M = (int)T.length();
	int ans = M;
	for(int i=0;i+M-1<N;i++){
		int tmp = 0;
		for(int j=0;j<M;j++){
			if(S[i+j] != T[j])tmp++;
		}
		ans = min(tmp, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int count=-1;
		char c ='c';
		int[][] an = new int[w+1][h+1];
		for(int i=0;i<h;i++){
			char[] s = sc.next().toCharArray();
			for(int j=0;j<w;j++){
				if(c==s[j]){
					count=0;
					an[j][i]=0;
				}
				else{
					if(count>=0){
						count+=1;
						an[j][i]=count;
					}
					else an[j][i]=count;
				}
			}
			count=-1;
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(j==w-1) System.out.println(an[j][i]);
				else {
					System.out.print(an[j][i]);
					System.out.print(" ");
				}
			}
		}
    }
}

Measured memory_bytes: 35652
#include <iostream>

using namespace std;

int main ()
{
  int N;
  cin>>N;
  while(N>=100)
  {
    N=N-100;
  }
  while(N>=10)
  {
    N=N-10;
  }
  if(N==3)
  {
    cout<<"bon"<<endl;
  }
  else if(N==0||N==1||N==6||N==8)
  {
    cout<<"pon"<<endl;
  }
  else
  {
    cout<<"hon"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3676
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int tmp;
    int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n-1) cin >> a[i];
	int ans[n] ={};
	REP(i, n-1) ans[a[i] - 1]++;
    REP(i, n) cout << ans[i] << endl;
}

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

using namespace std;

int n;

int main()
{
	cin>>n;
	while (n--)
	{
		int x;
		cin>>x;
		if (x%2==0 && (x%3!=0 && x%5!=0)) 
		{
			cout<<"DENIED"<<endl;
			return 0;
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
} 

Measured memory_bytes: 256
N = int(input())
count = 0
for n in range(1,N + 1):
    c = 0
    if n % 2 == 0:
        continue
    for i in range(1, n + 1):
        if n % i == 0:
            c = c + 1
    if c == 8:
        count = count + 1
print(count)


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

int main(){
    vector<int> v(3);
    for(int i=0;i<3;i++) cin>>v[i];
    sort(v.begin(),v.end());
    cout<<(v[0]+v[1]==v[2] ? "Yes":"No")<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
const int N=5005;
typedef long long LL;
int d[N];
int main(){
	int k,q,n,n1,m,x,w;LL sum;scanf("%d%d",&k,&q);
	for(int i=0;i<k;i++)scanf("%d",d+i);// nhập mảng d tính từ 0
	for(int i=0;i<q;i++){
		scanf("%d%d%d",&n,&x,&m),n--;
		x%=m,sum=w=0,n1=n/k;
		for(int j=0;j<k;j++){
			sum+=d[j]%m;
			if(d[j]%m==0)w+=n1;
		}
		sum*=n1,n1=n,n%=k;
		for(int j=0;j<n;j++){
			if(d[j]%m==0)w++;
			sum+=d[j]%m;
		}
		sum+=x;
		// tính tổng hết tất cả các các d[j] sau khi mod
		printf("%d\n",n1 - sum/m - w);
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            String S = in.next();

            int east_outers = 0;
            for (int i = 0; i < N; i++) {
                if (S.charAt(i) == 'E') east_outers++;
            }

            int ans = Integer.MAX_VALUE;
            int west_outers = 0;
            for (int i = 0; i < N; i++) {
                int opposits;
                if (S.charAt(i) == 'E') {
                    east_outers--;
                    opposits = east_outers + west_outers;
                } else {
                    opposits = east_outers + west_outers;
                    west_outers++;
                }
                ans = Math.min(ans, opposits);
            }

            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 27128
import java.util.*;

public class Main {
    private static final long INF = 1L<<60;
    private static long[][] dp = new long[3][100010];
    //dp[do][day] ... day日目にした行動と、day日目の幸福度の総和の最大値
    //do = 0 海 , do = 1 山 , do = 2 家 それ以外の行動を取る
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[][] doArray = new int[3][N+10];
        //doArray[do][day] ... day日目にする行動によって得られる幸福度
        for(int i=0;i<N;i++){
            for(int j=0;j<3;j++){
                doArray[j][i] = Integer.parseInt(sc.next());
            }
        }
        for(int i=0;i<N;i++){
            for(int j=0;j<3;j++){
                for(int k=0;k<3;k++){
                    if(j == k) continue; //j = k は不成立(前日と同じ行動はできないため)
                    dp[k][i+1] = Math.max(dp[k][i + 1] , dp[j][i] + doArray[k][i]);
                }
            }
        }
        long res = 0;
        for(int i=0;i<3;i++){
            res = Math.max(res,dp[i][N]);
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 66148
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int A[] = new int[N];
        int total=0;
        for(int i=0;i<N;i++){
            A[i]=sc.nextInt();
            total+=A[i];
        }
        Arrays.sort(A);
        if(A[N-M]*4*M>=total){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


    }
}

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

int main() {
  int N, K;
  string S;
  cin >> N >> S >> K;
  for (int i=0; i<S.size(); i++) {
    if (S.at(K-1) != S.at(i)) cout << '*';
    else cout << S.at(i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256