akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

class dice
{
	int ue,mae,migi,hidari,sita,usiro;
	public:
	dice(int a,int b,int c,int d,int e,int f)
	{
		ue = a;
		mae = b;
		migi = c;
		hidari = d;
		sita = f;
		usiro = e;
	}
	void N()
	{
		swap(ue,mae);
		swap(mae,sita);
		swap(sita,usiro);
	}
	void S()
	{
		swap(ue,usiro);
		swap(usiro,sita);
		swap(sita,mae);
	}
	void E()
	{
		swap(ue,hidari);
		swap(hidari,sita);
		swap(sita,migi);
	}
	void W()
	{
		swap(ue,migi);
		swap(migi,sita);
		swap(sita,hidari);
	}
	int top()
	{
		return ue;
	}
	int right()
	{
		return migi;
	}
	int front()
	{
		return mae;
	}
	void turn_right()
	{
		swap(mae,migi);
		swap(migi,usiro);
		swap(usiro,hidari);
	}
	bool serch_turn(dice E)
	{
		for(int i = 0;i<4;i++)
		{
			turn_right();
			if(same(E))
			{
				return true;
			}
		}
		return false;
	}
	bool same(dice E)
	{
		if(mae==E.mae
		&&ue==E.ue
		&&sita==E.sita
		&&migi==E.migi
		&&hidari==E.hidari
		&&usiro==E.usiro)
		{
			return true;
		}
		return false;
	}
	bool same2(dice D2)
	{
		if(top()==D2.top())
		{
			if(serch_turn(D2))return true;
		}
		N();
		if(top()==D2.top())
		{
			if(serch_turn(D2))return true;
		}
		N();
		if(top()==D2.top())
		{
			if(serch_turn(D2))return true;
		}
		N();
		if(top()==D2.top())
		{
			if(serch_turn(D2))return true;
		}
		N();
		E();
		if(top()==D2.top())
		{
			if(serch_turn(D2))return true;
		}
		W();
		W();
		if(top()==D2.top())
		{
			if(serch_turn(D2))return true;
		}
		return false;
	}
};



int main()
{
	int n;
	cin >> n;
	vector<dice> dices(n,dice(1,1,1,1,1,1));
	for(int i =0;i<n;i++)
	{
		int a,b,c,d,e,f;
		cin >> a >> b >> c >> d >> e >> f;
		dices[i] = dice(a,b,c,d,e,f);
	}
	for(int i = 0;i<n;i++)
	{
		for(int j = i+1;j<n;j++)
		{
			if(dices[i].same2(dices[j]))
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

using namespace std;

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

const int maxn=1e6+5;

const ll mod=1e9+7;

char s[maxn];

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<=10000;i++){
		double tmp=i;
		int k=tmp*0.08,kk=tmp*0.1;
		if(k==a&&kk==b){
			printf("%d\n",i);return 0;
		}
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct edge{
    int from, to;
    lint cost;
};

int n, m;
lint p;
vector< vector<edge> > g;
vector<edge> edges;
vector<lint> cost;

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

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

bool bellman_ford(int start, int goal){
    cost.resize(n);
    fill(cost.begin(), cost.end(), -LLINF);
    cost[start] = 0;
    for(int i = 0 ; i < n * 2 ; ++i){
        for(int j = 0 ; j < m ; ++j){
            edge now = edges[j];
            if(cost[now.from] != -LLINF && cost[now.to] < cost[now.from] + now.cost){
                cost[now.to] = cost[now.from] + now.cost;
                if(i >= n - 1 && now.to == goal){
                    return false;
                }
            }
        }
    }
    return true;
}

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

    cin >> n >> m >> p;

    g.resize(n);
    rep(i, m){
        int a, b;
        lint c;
        cin >> a >> b >> c;
        g[--a].push_back({a, --b, c});
        edges.push_back({a, b, c - p});
    }

    if(bellman_ford(0, n - 1)){
        cout << max(cost[n - 1], 0LL) << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 640
from sys import stdin
from itertools import accumulate


def main():
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    c = list(accumulate(range(1, 1000)))
    for i in range(len(c) - 1):
        if (c[i + 1] - c[i]) == (b - a):
            print(c[i] - a)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N,M=map(int,input().split())
H=list(map(int,input().split()))
B=[1]*N
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        B[b-1]=0
    elif H[a-1]<H[b-1]:
        B[a-1]=0
    else:
        B[b-1]=0
        B[a-1]=0
print(sum(B))

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

using namespace std;

#define int  long long

int n;
int a[100010], b[100010];

signed main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i] >> b[i];
	}

	int nowCount = 0, ans = 0;
	for(int i = n - 1; i >= 0;i--){
		a[i] += nowCount;
		int m = a[i] / b[i];
		if(a[i] % b[i] != 0){
			int ret = (m + 1) * b[i];
			int how = ret - a[i];
			ans += how;
			nowCount += how;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 510000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a)
int main(){
  lli A=INF,B=INF,C=INF,D=INF,E,F,N,M,K,sum=0,num=0,cnt=1,next=0;
  string S;cin >> S;
  Vec(P,int,4,0);
  rep(i,0,S.size()){
    if(S[i]=='W')P[0]=1;
    else if(S[i]=='E')P[1]=1;
    else if(S[i]=='S')P[3]=1;
    else P[2]=1;
  }
  A=(P[1]+P[0])%2;
  B=(P[2]+P[3])%2;
  if(!A&&!B)Out("Yes");
  else Out("No");
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    val n = scanner.nextInt
    var maxVal = Int.MinValue
    var minR = scanner.nextInt
    for(_ <- 2 to n) {
      val r = scanner.nextInt
      if(r - minR > maxVal) maxVal = r - minR
      if(r < minR) minR = r
    }
    println(maxVal)
  }
}



Measured memory_bytes: 194196
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {
        n:usize,k:i64,
        mut a:[i64;n],
    }
    a.sort();
    let g = gcd_list(&a);
    for &x in a.iter() {
        if x >= k {
            if x % g == k % g {
                yn(true);
                return;
            }
        }
    }
    yn(false);
}
pub fn yn(ans: bool) {
    if ans {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}
pub fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn gcd_list(list: &[i64]) -> i64 {
    list.iter().fold(list[0], |a, &b| gcd(a, b))
}


Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for (int i = 0; i < (int)(n); ++i)
#define mod 1000000007
#define bigger(a,b) (a>b?a:b)
#define smaller(a,b) (a<b?a:b)
#define mem(A,g) memset(A,g,sizeof(A))
#define gc getchar_unlocked
#define positive(a) (bigger(a,-a))

const int INF = 1e9 + 5;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int n;
cin>>n;
vector<vector<int>>a;
for(int i=0;i<n;i++){
	vector<int>temp(3);
	for(int j = 0; j<3; j++)
	cin>>temp[j];
	a.push_back(temp);
}
int dp[n][3];
for(int i=0;i<n;i++){
	if(i==0){
		dp[i][0] = a[i][0];
		dp[i][1] = a[i][1];
		dp[i][2] = a[i][2];
	} else {
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i][0];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + a[i][1];
		dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + a[i][2];
	}
}
int answer = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
cout<<answer<<"\n";
return 0;
}

Measured memory_bytes: 7472
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]

ans = False
count = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
    else:
        count = 0
    if count == 3:
        ans = True

if ans == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9180
<?php

$input = explode(' ', trim(fgets(STDIN)));
$a = (int)$input[0];
$b = (int)$input[1];
$k = (int)$input[2];

$count = 0;
for ($i=100; $i > 0; $i--) { 
	if ($a%$i===0 && $b%$i===0) {
		++$count;
		if ($count === $k) {
			echo $i;
			exit();
		}
	}
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

        int N;
        std::cin >> N;

        map<string, vector<pair<int, int>>> R;
        REP(i, N) {
            string s;
            int p;
            std::cin >> s >> p;
            auto itr = R.find(s);
            if(itr != R.end()) {
                itr->second.emplace_back(p, i + 1);
            }
            else {
                R.insert(make_pair(s, vector<pair<int, int>>{make_pair(p, i + 1)}));
            }
        }

        for(auto& r : R) {
            RSORT(r.second);
            for(auto& v : r.second) {
                std::cout << v.second << std::endl;
            }
        }
    }
    catch(const exception& e) {
        std::cout << e.what() << std::endl;
        exit(1);
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

//    ll ans=0;
    cout<<n*n*n<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <locale>
#include <algorithm>
#include <cctype>
#include <math.h>
#include <cstring>
#include <stdio.h>
#include <vector>
#include <bits/stdc++.h>
#include <sstream>

using namespace std;


main(){
    int a, b, c;

    cin >> a >> b >> c;

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

}

/*

    for (int i = 0; i<n; i++){

    }

*/


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){

  ll N;cin>>N;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];
  SORT(a);

  double ans = a[0];
  repn(i,N-1){
    ans = (ans+a[i])*1.0/2.0;
  }
  cout<<ans<<endl;
}


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

int main() {
    int n, m; cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    rep(i, m) {
        cin >> l.at(i) >> r.at(i);
    }

    int minv = l.at(0),maxv = r.at(0);
    int ans = -1;
    for (int i = 1; i < m; i++) {
        minv = max(minv, l.at(i));
        maxv = min(maxv, r.at(i));
        if (minv > maxv) {
            ans = 0;
        }
    }
    if (ans == 0)
        cout << ans << endl;
    else if (minv == maxv)
        cout << 1 << endl;
    else
        cout << (maxv - minv)+1 << endl;
    return 0;
}

Measured memory_bytes: 1024
"""
強連結成分分解
"""

import sys

sys.setrecursionlimit(1000000)

def dfs(v, visited, edges, order):
  visited[v] = True
  for to in edges[v]:
    if not visited[to]:
      dfs(to, visited, edges, order)
  order.append(v)

def search_strongly_connection(v, visited, reverse_edges, parent, num):
  visited[v] = True
  for to in reverse_edges[v]:
    if not visited[to]:
      parent[to] = num
      search_strongly_connection(to, visited, reverse_edges, parent, num)

v_num , e_num = map(int, input().split())
edges = [[] for _ in range(v_num)]
reverse_edges = [[] for _ in range(v_num)]
for _ in range(e_num):
  s, t = map(int, input().split())
  edges[s].append(t)
  reverse_edges[t].append(s)


order = []
visited = [False] * v_num
for v in range(v_num):
  if not visited[v]:
    dfs(v, visited, edges, order)
order.reverse()


visited = [False] * v_num
parent = [i for i in range(v_num)]
for v in order:
  num = v
  if not visited[v]:
    search_strongly_connection(v, visited, reverse_edges, parent, num)

q_num = int(input())
for _ in range(q_num):
  u, v = map(int, input().split())
  if parent[u] == parent[v]:
    print(1)
  else:
    print(0)


Measured memory_bytes: 19196
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

int main(void)
{
	fast;
	#ifndef ONLINE_JUDGE
	// freopen("in", "r", stdin);
	// freopen("out", "w", stdout);
	#endif

	int n, h, w; cin >> n >> h >> w;
	cout << (n-h+1)*(n-w+1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    string s1;
    cin>>s1;
    int n= s1.size();
    map<char,int> m1;
    loop(i,0,n)
    {
        m1[s1[i]]++;
    }
    int chk = true;
    loop(i,0,m1.size())
    {
        if(m1[i]%2!=0)
        {
            chk = false;
            break;
        }
    }
    if(chk)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}



Measured memory_bytes: 3572
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll a,b;
  cin >> a >> b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) cout <<"Possible\n";
  else cout <<"Impossible\n";
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  
  int i,j=1,N,key,n;
  int data[101];
  
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&data[i]);
  }
  
  for(j=1;j<=N;j++){
    key = data[j];
    i = j -1;
    
    while(i>0 && data[i] > key){
      data[i+1] = data[i];
      i=i-1;
      data[i+1] = key;
    }
    
    
    for(n=1;n<=N;n++){
      printf("%d",data[n]);
      if(n<N) printf(" ");
    } 
    
  printf("\n");
  
  }

  return 0;

}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int a,p;
    cin >> a >> p;
    p += a*3;
    cout << p/2 << endl;
}

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

int main(){
    string s;
    cin >> s;
  string head = s.substr(0,4);
  string bottom = s.substr(5,2);
  int heads = atoi(head.c_str());
  int bottoms = atoi(bottom.c_str());
    if (heads>2019){
        cout << "TBD" << endl;
    }
    else if (heads==2019&&bottoms>4){
        cout << "TBD" << endl;
    }
    else cout << "Heisei" << endl;
}

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

#define M 1049569
#define L 14

char H[M][L];

int getChar(char ch){

	if(ch == 'A') return 1;
	else if(ch == 'C') return 2;
	else if(ch == 'G') return 3;
	else if(ch == 'T') return 4;
	else return 0;

}

long long getKey(char str[]){
	int i;
	long long sum = 0, p = 1;
	for(i=0;i<strlen(str);i++){
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]){
	long long key,i,h;
	key = getKey(str);
	for(i=0;;i++){
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h],str) == 0) return 1;
		else if(strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key,i,h;
	key = getKey(str);
	for(i=0;;i++){
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h],str) == 0) return 1;
		else if(strlen(H[h]) == 0){
			strcpy(H[h],str);
			return 0;
		}
	}
}


int main(void){
	int i,n,h;
	char str[L],in[9];
	for(i=0;i<M;i++){
		H[i][0] = '\0';
	}
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",in,str);

		if(in[0] == 'i'){
			insert(str);
		}else{
			if(find(str)){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
	return 0;
}

















Measured memory_bytes: 16088
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       int A = sc.nextInt();
       int B = sc.nextInt();
       int len = A + B + 1;
       int hit = A;
       String s = sc.nextLine();
       String line = sc.nextLine();
       String []array = line.split("");
       String SS = array[A];
       
       if((array.length == len) && SS.equals("-")){
           for(int i = 0; i < array.length; i++){
               String m = array[i];
               if((!m.matches("^[0-9]+$")) && i != A){
                    System.out.println("No");
                    System.exit(0); 
                }
           }
           System.out.println("Yes");
           System.exit(0);
       }else{
           System.out.println("No");
           System.exit(0);
       }
    }
}


Measured memory_bytes: 23124
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long ans = a * (n / (a+b));
        n %= (a+b);
        if(n >= a){
            System.out.println(ans+a);
        }else{
            System.out.println(ans+n);
        }
        
    }
}
 

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int x[110];
int y[110];

int main() {
  // 入力
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  P mini = P(INF, -1);
  P maxi = P(-INF, -1);
  for (int i = 0; i < N; i++) {
    if (mini.first > a[i]) {
      mini = P(a[i], i);
    }
    if (maxi.first < a[i]) {
      maxi = P(a[i], i);
    }
  }

  int m = 0;
  // 非負と負が混在していたらどちらかに統一
  if (mini.first < 0 && maxi.first >= 0) {
    if (maxi.first >= -mini.first) {
      for (int i = 0; i < N; i++) {
        x[m] = maxi.second;
        y[m] = i;
        m++;
      }
      mini.first = 0;
    } else {
      for (int i = 0; i < N; i++) {
        x[m] = mini.second;
        y[m] = i;
        m++;
      }
      maxi.first = -1;
    }
  }

  // 非負か負かで場合分けをして累積和をとる
  if (maxi.first >= 0 && mini.first >= 0) {
    for (int i = 1; i < N; i++) {
      x[m] = i - 1;
      y[m] = i;
      m++;
    }
  } else {
    for (int i = N - 2; i >= 0; i--) {
      x[m] = i + 1;
      y[m] = i;
      m++;
    }
  }

  // 解答
  cout << m << endl;
  for (int i = 0; i < m; i++) {
    cout << x[i] + 1 << " " << y[i] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N, M;
    cin >> N >> M;
    vector<ll> A(N,0);
    ll sum_=0;
    for(auto &a:A){
        cin >> a;
        sum_+=a;
        a*=4*M;
    }
    int cnt=0;
    for(auto &a:A){
        if(a>=sum_){
            cnt++;
        }
    }
    //cout << sum_ << endl;
    if(cnt>=M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main(){
	int n; cin >> n;
	vector<int> v(n+2);
	int a = 0;
	rep(i,n){
		cin >> v[i+1];
		a += abs(v[i+1] - v[i]);
	}
	a += abs(v[n]);
	rep(i,n){
		cout << a+abs(v[i+2]-v[i]) - abs(v[i+1] - v[i]) - abs(v[i+2] - v[i+1]) << endl;
	}
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int N; cin >>N;
  vector<string> S;
  rep(i,0,N) {
    string temp; cin >>temp;
    S.push_back(temp);
  }
  vector<string> li{"AC","WA","TLE","RE"};
  rep(i,0,li.size()) {
    cout <<li[i] <<" x " <<count(S.begin(),S.end(),li[i]) <<endl;
  }
  return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h) cin >> s[i];
    queue<pii> q;
    vector<vi> dist(h, vi(w, INF));
    q.emplace(0, 0);
    dist[0][0] = (s[0][0]=='.'?0:1);
    while (!q.empty()) {
        auto p = q.front(); q.pop();
        int y = p.first, x = p.second, d = dist[y][x];
        char col = s[y][x];
        const vi dy = { 0, 1 }, dx = { 1, 0 };
        rep(i, 2) {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny<0||ny>=h||nx<0||nx>=w) continue;
            int nd = d + (s[ny][nx]==col?0:1);
            if (dist[ny][nx]<=nd) continue;
            q.emplace(ny, nx);
            dist[ny][nx] = nd;
        }
    }
    int ans = (dist[h-1][w-1] + (s[h-1][w-1]=='.'?0:1)) / 2;
    cout << ans << endl;
    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int p[200000];

double exp(int i) {
  return p[i] * (p[i] + 1) / 2 / (double)(p[i]);
}

int main() {
  CIN(int, N, K);
  REP(i, N) cin >> p[i];
  double sum = 0;
  double ans = 0;
  REP(i, N) {
    if (i >= K) sum -= exp(i - K);
    sum += exp(i);
    if (i >= K - 1) ans = max(ans, sum);
  }
  printf("%.12f\n", ans);
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
public class ABC125D {
    public static void Main() {
        long N, ans = 0;
        List<long> A = new List<long>();
        N = long.Parse(System.Console.ReadLine());
        string[] str = System.Console.ReadLine().Split(' ');
        foreach (string s in str) {
            A.Add(long.Parse(s));
        }
        long min = Abs(A[0]);
        bool minus = false;
        for(int i = 0; i < A.Count; i++) {
            long a = Abs(A[i]);
            ans += a;
            if (a < min) min = a;
            if (A[i] < 0) minus = !minus;
        }
        if (minus) ans -= min * 2;
        System.Console.WriteLine(ans);
    }
    public static long Abs(long x) {
        if (x < 0) return -x;
        else return x;
    }
}

Measured memory_bytes: 28252
#include<stdio.h>
int isHamingNum(int n){
	for(;n!=1;){
		if(n%2&&n%3&&n%5)return 0;
		if(!(n%2))n/=2;
		else if(!(n%3))n/=3;
		else if(!(n%5))n/=5;
	}
	return 1;
}
int main(){
	int m,n,i,j,c;
	for(;scanf("%d %d",&m,&n)&&m;){
		c=0;
		for(i=m;i<=n;i++){
			if(isHamingNum(i))c++;
		}
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 404
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 3005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int k, r, c;
int val[mn][mn];
int dpret[mn][mn][4];
int dp(int u, int v, int cnt) {
    if (u<0 || u>r || v<0 || v>c || cnt<0 || cnt>3) return -inf; 
    if (dpret[u][v][cnt] != -1) return dpret[u][v][cnt];
    if (u==0 && v==0 && cnt==0) return dpret[u][v][cnt] = 0;

    int ret = dp(u, v, cnt-1);
    if (val[u][v] > 0 && cnt>0) {
        ret = max(ret, dp(u, v-1, cnt-1) + val[u][v]);
        ret = max(ret, dp(u-1, v, 3) + val[u][v]);
    }
    ret = max(ret, dp(u, v-1, cnt));
    ret = max(ret, dp(u-1, v, 3));
    return dpret[u][v][cnt] = ret;
}

// main solution goes here:
void execute(int test_number)
{
    for (int i=0; i<3005; i++) for (int j=0; j<3005; j++) for (int c=0; c<4; c++) {
        dpret[i][j][c] = -1;
    }
    cin>>r>>c>>k;
    int u, v, w;
    for (int i=1; i<=k; i++) {
        cin>>u>>v>>w;
        val[u][v] = w;
    }
    // cerr<<dp(2, 4, 3)<<"\n";
    cout<<dp(r, c, 3);
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 357424
#include<cstdio>
#include<algorithm>

using namespace std;

#define INF 1 << 29

int main(){
	int n, a[100];
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	int res = INF;
	for(int i = -100; i <= 100; i++){
		int t = 0;
		for(int j = 0; j < n; j++) t += (a[j] - i) * (a[j] - i);
		res = min(res, t);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


def main():
    n=int(input())
    rg=int(n**(0.25))+10
    # print(rg)
    for b in range(-rg,rg+1):
        # print((n+b**5)**(0.2))
        if (n+b**5)<0:
            l=-int((-n-b**5)**(0.2))
        else:
            l=int((n+b**5)**(0.2))
        while l**5<n+b**5:
            l+=1
        while l**5>n+b**5:
            l-=1
        if l**5-b**5==n:
            print(l,b)
            exit(0)
        

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 63544
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;

bool check(const ll n)
{
    const string s = to_string(n);
    for (int i = 0; i < (int)s.size() - 1; i++) {
        if (s[i + 1] - s[i] != 1) {
            return false;
        }
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    constexpr ll INF = -1;
    ll mini = INF;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            const ll p = a[i] * a[j];
            if (check(p)) {
                mini = max(mini, p);
            }
        }
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 3272
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] s = new int[n];
        for(int i=0; i<n; i++){
            s[i] = stdIn.nextInt();
        }

        int q = stdIn.nextInt();
        int[] t = new int[q];
        for(int i=0; i<q; i++){
            t[i] = stdIn.nextInt();
        }

        java.util.Arrays.sort(s);

        int counter = 0;
        for(int i=0; i<q; i++){
            if(binarySearch(s, t[i])){
                counter++;
            }
        }

        System.out.println(counter);
    }

    static boolean binarySearch(int[] a, int x){
        int from = 0;
        int to = a.length-1;
        int mid;
        do{
            mid = (from + to) / 2;
            if(x < a[mid]){
                to = mid - 1;
            }else{
                from = mid+1;
            }
        }while(x != a[mid] && from <= to);

        return (a[mid] == x);
    }
}


Measured memory_bytes: 81052
#include <bits/stdc++.h>
#include <atcoder/string>

using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
using ll = long long;
string S;
inline void input(){
    fast_io();
    cin >> S;
}

inline int solve(){
    auto sa = atcoder::suffix_array(S);
    debug(sa);
    ll N = S.length();
    ll ans = N*(N+1)/2;
    auto lcp = atcoder::lcp_array(S,sa);
    for(ll x:lcp) ans -= x;
    cout << ans << endl;
    return 0;
}   

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


Measured memory_bytes: 15624
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ea=[0]
for i in range(n):
    ea.append(ea[i]+a[i])
eb=[0]
for i in range(m):
    eb.append(eb[i]+b[i])
if n>m:
    ea,eb=eb,ea
    n,m=m,n
tb=m
p=0
for i in range(n+1):
    while ea[i]+eb[tb]>k:
        if tb==0:
            break
        tb-=1
    if ea[i]+eb[tb]<=k:
        p=max(i+tb,p)
print(p)

Measured memory_bytes: 47448
#include <iostream>

using namespace std;

int main()
{
  int s, h, m;
  cin >> s;

  h = s / ( 60 * 60 );
  s -= h * 60 * 60;
  m = s / 60;
  s -= m * 60;

  cout << h << ":" << m << ":" << s << endl;

  return 0;
}

Measured memory_bytes: 1168
import math
def using_sqrt(limit):
    n = 0
    primes = set()
    for k in range(2, limit+1):
        factor = 0
        
        # 2以外の偶数は素数ではないので無視する
        if k % 2 == 0 and k != 2:
            continue
        
        # 繰り返しの上限を対象の平方根にする
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
                factor += 1
                
        if factor == 0:
            primes.add(k)
            
    return primes

primes = using_sqrt(10**5+1)

likely = []
count = 0
for i in range(10**5+1):
    if i in primes and (i+1)/2 in primes:
        count += 1
    likely.append(count)
        
q = int(input())
    
for i in range(q):
    l, r = map(int,input().split())
    print(likely[r]-likely[l-1])

Measured memory_bytes: 5080
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    s = [ord(c) for c in S()]
    c = collections.defaultdict(int)
    r = 0
    c[s[0]] += 1
    m = sum(ord(c) for c in "RGB")
    for j in range(1,n):
        t = s[j]
        for k in range(j+1,n):
            u = s[k]
            if t == u:
                continue
            r += c[m-t-u]
            i = j - (k-j)
            if i >= 0 and s[i] == m-t-u:
                r -= 1

        c[t] += 1

    return r


print(main())





Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifndef MY_ALGORITHM
template<typename T>
struct UnionFind
{
    vector<T> parents;
    vector<T> rank;
    UnionFind(T n);
    T root(T x);
    bool unite(T x, T y);
    bool same(T x, T y);
};
#endif

template<typename T>
UnionFind<T>::UnionFind(T n):parents(n),rank(n,0){
        for (T i=0;i<n;i++){
            parents[i] = i;
        }
    }


template<typename T>
T UnionFind<T>::root(T x){
        //再帰的に根をつけなおす//rootを返す
        return parents[x] == x ? x: parents[x] = root(parents[x]);
}

template<typename T>
bool UnionFind<T>::unite(T x, T y){
        if (x==y) return false;
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        parents[y] = x;
        return true;
}

template<typename T>
bool UnionFind<T>::same(T x, T y){
        if (x==y) return true;
        return root(x) == root(y);
}


template<typename NodeIdx, typename Cost>
Cost kruskal(vector<tuple<NodeIdx,NodeIdx,Cost>> graph, NodeIdx V, NodeIdx E){
    using Edge =  tuple<NodeIdx,NodeIdx,Cost>;
    auto comp = [ ](const Edge &e1,const Edge &e2){
        return get<2>(e1) < get<2>(e2);
    };
    sort(graph.begin(),graph.end(),comp);
    UnionFind<NodeIdx> uf(V);
    Cost res = 0;
    for (const auto e: graph){
        if (!uf.same(get<0>(e),get<1>(e))){
            uf.unite(get<0>(e),get<1>(e));
            res +=get<2>(e);
        }
    }
    return res;

}

template<typename T>
vector<size_t> argsort(vector<T> &array){
    vector<size_t> indices(array.size());
    std::iota(indices.begin(),indices.end(),0); //range
    std::sort(indices.begin(), indices.end(), [&array](size_t i1, size_t i2) {
        return array[i1] < array[i2];
    });
    return indices;
}

void solve(long long N, std::vector<long long> x, std::vector<long long> y){
    vector<tuple<ll,ll,ll>> graph;
    auto x_idx = argsort<ll>(x);
    auto y_idx = argsort<ll>(y);
    for (ll i=0;i<N-1;i++){
        graph.push_back(
            make_tuple(
                x_idx[i],x_idx[i+1],abs(x[x_idx[i]] -x[x_idx[i+1]]) 
            )
        );
        graph.push_back(
            make_tuple(
                y_idx[i],y_idx[i+1],abs(y[y_idx[i]] -y[y_idx[i+1]]) 
            )
        );
    }
    printf("%lld\n",kruskal<ll,ll>(graph,N,2*N-2));
    
}


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 15724
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<map>

using namespace std;
typedef long long int ll;
const int inf=1e9;

int main(){
    map<string,int> mp;
    int n,m,ans=0;

    //辞書を作成
    string tmp;
	cin >> n;
    for(int i=0;i<n;i++){
        cin >> tmp;
        if(mp.find(tmp) == mp.end()){
            mp[tmp]=1;
        }else{
            mp[tmp]+=1;
        }
    }
    cin >> m;
    for(int i=0;i<m;i++){
        cin >> tmp;
        if(mp.find(tmp) == mp.end()){
            mp[tmp]=1;
        }else{
            mp[tmp]-=1;
        }
    }

    //辞書の全ての要素から最も大きいものをansに入れる
    for(auto itr = mp.begin();itr != mp.end();itr++){
        if(ans < itr->second) ans = itr->second;
    }
	
	cout << ans << endl;
}


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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N;
    cin >> N;
    vector<pair<pair<unsigned long, unsigned long>, unsigned long>> tapi(1048576, {{1, 0}, 0});
    unsigned long ans{0}, t{500000004}, a{0}, z{0}, A;
    while(cin >> A)
        if(a ^= A){
            (tapi[a].first.second += (tapi[a].first.first += tapi[a].first.second * (z - tapi[a].second)) %= MOD) %= MOD;
            ans += tapi[a].first.first;
            tapi[a].second = z;
        }else ++z, (t *= 2) %= MOD;
    cout << (a ? tapi[a].first.first : (ans + t) % MOD) << endl;
    return 0;
}

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

int main(){
    int n , k ;
    cin >> n >> k ;
    vector<int> a(n) ;
    ll sum = 0 ;
    rep(i,n){
        cin >> a[i] ;
        sum += a[i] ;
    } 
    sort(a.begin(),a.end()) ;
    cout << (k - sum)/a[0] + n <<endl;
}

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

int main() {
   int n, m;
   cin >> n >> m;
   if (n == m) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }

   return 0;
}

Measured memory_bytes: 256