akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long X,A,B;
    cin>>X>>A>>B;
    if(A>=B)cout<<"delicious"<<endl;
    else if(A<B&&B-A<=X)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>;
#include <stdlib.h>;
using namespace std;
int main ()
{
    int a, b,t[999],s=0;
    cin>>a>>b;
    int sum=0,h[999];
    for (int i=1;i<=999;i++)
    {
        sum+=i;
        h[i-1]=sum;
    }
    cout<<h[abs(a-b)-1]-b<<endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    if (A[0] == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll LIM = 1000000000000000000LL;
    ll ans = 1;
    rep(i, N) {
        ans *= A[i];
        if (ans <= 0 || LIM < ans) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

int main()
{
    float n;
    cin >> n;
    vector<float> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    float ans = 0;
    rep(i, n - 1)
    {
        if (i == 0)
        {
            ans = (v[i] + v[i + 1]) / 2;
        }
        else
        {
            ans = (ans + v[i + 1]) / 2;
        }
    }
    cout << ans << endl;
}


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

int main(){
  int N;
  double T,A;
  cin>>N>>T>>A;
  double H[N];
  for (int i=0;i<N;i++){
    cin>>H[i];
  }
  double itemp=1000;
  double temp=0;
  int ans=0;
  for (int i=0;i<N;i++){
    temp=itemp;
    itemp=min(itemp,abs((T-H[i]*0.006)-A));
    if(!(temp==itemp)){
      ans=i+1;
    }
  }
  cout<<ans<<endl;
  return 0;
}

    
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  if(
    (a == 5 && b == 5 && c == 7)|| 
    (a == 5 && b == 7 && c == 5)|| 
    (a == 7 && b == 5 && c == 5) )cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
		// #ifndef ONLINE_JUDGE
  //      // for getting input from input.txt
  //      freopen("input.txt", "r", stdin);
  //      // for writing output to output.txt
  //      freopen("output.txt", "w", stdout);
  //     #endif
	string s;
	int k =0;
	cin>>s;
	vector<int> v;
	sort(s.begin(), s.end());
	// cout<<s;
	for (int i = 0; i < s.length(); ++i)
		if(s[i] > 96){
		{
			if(s[i] == s[i+1]){
				k++;
			}
			else{
				k = k+1;
				v.push_back(k);
				k = 0;
			}
		}	
	}
	for (int i = 0; i < v.size(); ++i)
	{
		if(v[i]%2 != 0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e20;

int N, K;

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

    ll x[N], y[N];

    vector<ll> xx,yy;

    REP(i,N){
        cin >> x[i] >> y[i];
        xx.push_back(x[i]);
        yy.push_back(y[i]);
    }
    sort(xx.begin(),xx.end());
    sort(yy.begin(),yy.end());

    ll ans = INF;
    FOR(i,0,N-1)FOR(j,i+1,N)FOR(k,0,N-1)FOR(l,k+1,N){
        int tmp = 0;
        FOR(m,0,N){
            if(xx[i] <= x[m] && x[m] <= xx[j] && yy[k] <= y[m] && y[m] <= yy[l]) tmp++;
        }
        if(K <= tmp){
//            printf("%lld %lld %lld %lld\n", xx[j],xx[i], yy[l], yy[k]);
            ans = min(ans, (xx[j]-xx[i])*(yy[l]-yy[k]));
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def solve():
    a,b,c,d = getList()
    while(a > 0 and c > 0):
        c -= b
        if c <= 0:
            print("Yes")
            return
        a -= d
        if a <= 0:
            print("No")
            return


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

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

#define int long long
#define inf (int)(1e18)

/*int can_achieve(int k, int *a, int N){
	int i, sum = 0;
	for(i = 0; i < N; i++){
		sum += (a[i] + k + 1) / (N + 1);
	}
	if(sum <= k){
		return 1;
	}
	else{
		return 0;
	}
}

int main(){
	int N, i;
	scanf("%lld", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &a[i]);
	}
	int l = 0, r = inf, h;
	while(r - l > 1){
		h = (l + r) / 2;
		if(can_achieve(h, a, N) == 1){
			r = h;
		}
		else{
			l = h;
		}
	}
	printf("%lld\n", r);
	return 0;
}*/

signed main(){
	int N, i, j, s, K = 0, f;
	scanf("%lld", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &a[i]);
	}
	for(i = 0; ; i = (i + 1) % N){
		s = a[i] / N;
		K += s;
		a[i] -= s * (N + 1);
		f = 0;
		for(j = 0; j < N; j++){
			a[j] += s;
			if(a[j] >= N){
				f = 1;
			}
		}
		if(f == 0){
			printf("%lld\n", K);
			return 0;
		}
	}
}

Measured memory_bytes: 128
#include<iostream>                                        
#include<string>                                          
using namespace std;                                      
                                                          
int main(){                                               
  string str,com,p;                                       
  int q,a,b;                                              
                                                          
  cin >> str >> q;                                        
  for(int t = 0;t < q;t++){                               
    cin >> com >> a >> b;                                 
    if(com == "print"){                                   
      cout << str.substr(a,b-a+1) << endl;                
    } else if (com == "reverse"){                         
      string tmp = str.substr(a,b-a+1);                   
      int n = tmp.size();                                 
      for(int i = 0;i < n;i++) str[i+a] = tmp[n-i-1];     
    } else if(com == "replace"){                          
      cin >> p;                                           
      str = str.replace(a,b-a+1,p);                       
    }                                                     
  }                                                       
                                                          
  return 0;                                               
} 

Measured memory_bytes: 3172
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll dist[101010];

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

	int K;
	cin >> K;
	min_priority_queue<pair<ll, int>>q;
	for (int i = 0; i < 101010; i++)dist[i] = inf;
	for (int i = 1; i <= 9; i++)dist[i%K] = min((ll)i, dist[i%K]);
	for (int i = 1; i <= 9; i++)q.push({ dist[i],i%K });
	while (q.size()){
		auto p = q.top();
		q.pop();
		ll cost = p.first;
		int v = p.second;
		if (cost > dist[v])continue;
		for (int i = 0; i <= 9; i++) {
			if (dist[(10 * v + i) % K] > dist[v] + i) {
				dist[(10 * v + i) % K] = dist[v] + i;
				q.push({ dist[v] + i,(10 * v + i) % K });
			}
		}
	}
	puts(dist[0]);

	return 0;
}

Measured memory_bytes: 6768
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public class Main {
	static final long MOD = 998244353L;
	//static final long INF = -1000000000000000007L;
	//static final long MOD = 1000000007L;
	//static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.ni();
		StringBuilder ans = new StringBuilder();
		String s = sc.next();
		String t = sc.next();
		for (int i = 0; i < N; i++) {
			ans.append(s.charAt(i));
			ans.append(t.charAt(i));
		}
		pw.println(ans);
		pw.close();
	}
	
	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) { 
		long ans = 1;
		x %= m;
		while (y > 0) { 
			if(y % 2 == 1) 
				ans = (ans * x) % m; 
			y /= 2;  
			x = (x * x) % m;
		} 
		return ans; 
	}
	
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr1[0]-arr2[0]; //ascending order
	          }
		});
		return array;
	}
    
    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] arr1, long[] arr2) {
				  return 0;
	          }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

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

const int N = 110000;

int a[N], frq[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	set<pair<int, int>> S1, S2;
	
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i += 2) frq[a[i]]++;
	for (int i = 0; i < N; i++) if (frq[i]) S1.emplace(-frq[i], i);
	for (int i = 0; i < N; i++) frq[i] = 0;
	for (int i = 1; i < n; i += 2) frq[a[i]]++;
	for (int i = 0; i < N; i++) if (frq[i]) S2.emplace(-frq[i], i);
	auto it1 = S1.begin(), it2 = S2.begin();
	if (it1 -> second != it2 -> second) {
		cout << n + it1 -> first + it2 -> first << "\n";
	} else {
		int ans = n;
		it1++;
		if (it1 == S1.end()) ans = min(ans, n + it2 -> first);
		else ans = min(ans, n + it1 -> first + it2 -> first);
		it1--;
		it2++;
		if (it2 == S2.end()) ans = min(ans, n + it1 -> first);
		else ans = min(ans, n + it1 -> first + it2 -> first);
		cout << ans << "\n";
	}
	
	return 0;
}


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


using namespace std;
using ll = long long;

int main(){

    int n;
    cin >> n;
    vector<ll> a(n);
    ll s = 0LL;
    ll sodd = 0LL;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        s += a[i];
        if (i%2) sodd += a[i];
    }

    vector<ll> x(n, 0);
    x[0] = s - 2*sodd;

    for(int i = 1; i < n; ++i){
        x[i] = 2*a[i-1] - x[i-1];
    }


    for(auto y : x){
        cout << y << ' ';
    }
    cout << endl;


    return 0;
}


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

int main() {
  int n, x;
  cin>>n>>x;
  int l[n];
  for (int i=0; i<n; i++) cin>>l[i];
  int cnt = 1;
  int d = 0;
  for (int i=0; i<n; i++) {
    d = d + l[i];
    if (d > x) {
      break;
    }
    ++cnt;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Here your code !

num_j = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

n = int(input())

for _ in range(n):
    b,r,f,v = map(int,input().split())
    num_j[b-1][r-1][f-1] += v

for i in range(4):
    for j in range(3):
        print(" ",end="")       
        print(" ".join(map(str,num_j[i][j])))
    
    if i != 3:
        print("#"*20)

Measured memory_bytes: 7708
//{{{
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

const int N = 20;
const int mod = 1e9 + 7;

int n;
int a[N];

vector<pii> words[N];

bool is_h(int status, int idx) { return (status & (1 << idx)) > 0; }
bool check(int status)
{
    for (int i = 0; i < n; i++)
    {
        // check ith person
        bool is_honest = is_h(status, i);
        if (is_honest == false) continue;

        for (int j = 0; j < a[i]; j++)
        {
            int p = words[i][j].first;
            int val = words[i][j].second;

            bool is_p_h = is_h(status, p);
            if (is_p_h != val) return false;
        }
    }
    return true;
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (cin >> n)
    {
        for (int i = 0; i < n; ++i)
        {
            words[i].clear();
            cin >> a[i];

            for (int j = 0; j < a[i]; ++j)
            {
                int x, y;
                cin >> x >> y;
                x--;
                words[i].push_back({x, y});
            }
        }

        int ans = -1;
        int lim = 1 << n;
        for (int st = 0; st < lim; st++)
        {
            // if (__builtin_popcount(st) <= ans) continue;

            // check
            if (check(st))
            {
                ans = max(ans, __builtin_popcount(st));
            }
        }

        // int v = __builtin_popcount(ans);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3600
// Problem : B - Mix Juice
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vdb vector<double>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define bloop(i,a,b) for(int i = a;i>=b;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define CHECK1(a) cout<<a<<endl
#define CHECK2(a,b) cout<<a<<' '<<b<<endl;
#define br '\n'
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
// int extendedgcd(int a,int b,int &x,int &y){
	// if(a == 0){
		// x = 0; y = 1;
		// return b;
	// }
	// int x1,y1;
	// int d = extendedgcd(b%a,a,x1,y1);
	// x = y1 - (b/a)*x1;y = x1;
	// return d;
// }
// int expmod(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = expmod(a,b/2)%mod;
// 	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
// 	return (m1*m1)%mod;
// }
// int power(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = power(a,b/2);
// 	if(b%2) return m1*m1*a;
// 	return m1*m1;
// }
// int logn(int n, int r) 
// { 
//     return (n > r - 1) ? 1 + logn(n / r, r) : 0; 
// } 

// int nCr(int n,int r)
// {
	// r = min(r,n-r);
	// if(r<0)
		// return 0;
	// if(r == 0)
		// return 1;
	// int ans = 1;
	// for(int i = 1;i<=r;i++)
	// {
		// ans = ans*(n-i+1)/i;
	// }
	// return ans;
// 		
// }
// vi factmod(int n)
// {
	// vi ans(n+1);
	// ans[0] = 1;
	// loop(i,1,n+1)
	// {
		// ans[i] = (ans[i-1]*i)%mod;
	// }
	// return ans;
// }
// int nCrmod(int n,int r,vi &fact)
// {
	// int x1,y1;
	// extendedgcd(fact[r],mod,x1,y1);
	// int x2,y2;
	// extendedgcd(fact[n-r],mod,x2,y2);
	// int ans = (fact[n]*((x1+mod)%mod))%mod;
	// ans = (ans*((x2+mod)%mod))%mod;
	// return ans;
// }

// void dfs(vector<vector<int> > &adj,int root,vbool &vis)
// {
// 	vis[root] = true;
// 	for(int i = 0;i<adj[root].size();i++){
// 		int v = adj[root][i];
// 		if(!vis[v])		
// 			dfs(adj,v,vis);
// 	}
// }

int32_t main() 
{
	FastIO; PRECISION;
	int t = 1;
	// cin>>t;
	while(t--)
	{
		int n,k;
		cin>>n>>k;
		vi arr(n);
		scan(arr,n);
		sort(all(arr));
		int ans = 0;
		loop(i,0,k)
		{
			ans+=arr[i];
		}
		cout<<ans<<'\n';
	}
}

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

const int MN = 1e5;
int pa[MN+1],de[MN+1],cnt[MN+1];
long long int sz[MN+1];
void Init(){
   for(int i=0;i<=MN;i++)
      de[pa[i]=i]=1,sz[i]=cnt[i]=0;
}
int Find(int x){
   return x==pa[x]?x:pa[x]=Find(pa[x]);
}
void Union(int x,int y){
   x=Find(x);y=Find(y);
   if(x!=y){
      if(de[x]<de[y])    swap(x,y);
      pa[y]=x;
      if(de[x]==de[y])    de[x]++;
   }
}

vector<pair<pair<int,int>,int> > p;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	Init();
	int n,a,b;
	cin>>n>>a>>b;
	a--;b--;
	p.resize(n);
	for(int i=0,x,y;i<n;i++){
		cin>>p[i].first.first>>p[i].first.second;
		x=p[i].first.first;
		y=p[i].first.second;
		p[i].first.first=x+y;
		p[i].first.second=x-y;
		p[i].second=i;
	}
	int d=max(abs(p[a].first.first-p[b].first.first),abs(p[a].first.second-p[b].first.second));
	sort(p.begin(),p.end());
	int now=0;
	long long int ans=0;
	for(int i=0;i<n;i++){
		int x=p[i].first.first,y=p[i].first.second;
		int l=lower_bound(p.begin(),p.end(),make_pair(make_pair(x-d,y-d),0))-p.begin();
		int r=upper_bound(p.begin(),p.end(),make_pair(make_pair(x-d,y+d),n))-p.begin()-1;
		cnt[p[i].second]=r-l+1;
		for(int j=max(now,l);j<r;j++)
			Union(p[j].second,p[j+1].second);
		if(r-l+1>0)
			Union(p[r].second,p[i].second);
		now=r;
	}
	now=0;
	for(int i=0;i<n;i++)
		swap(p[i].first.first,p[i].first.second);
	sort(p.begin(),p.end());
	for(int i=0;i<n;i++){
		int x=p[i].first.first,y=p[i].first.second;
		int l=lower_bound(p.begin(),p.end(),make_pair(make_pair(x-d,y-d),0))-p.begin();
		int r=upper_bound(p.begin(),p.end(),make_pair(make_pair(x-d,y+d),n))-p.begin()-1;
		cnt[p[i].second]+=r-l+1;
		if(r-l+1>=1){
			if(p[l].first.second==y-d)	cnt[p[i].second]--;
			if(p[r].first.second==y+d)	cnt[p[i].second]--;
		}
		for(int j=max(now,l);j<r;j++)
			Union(p[j].second,p[j+1].second);
		if(r-l+1>0)	
			Union(p[i].second,p[r].second);
		now=r;
	}
	for(int i=0;i<n;i++)
		sz[Find(i)]+=cnt[i];
	cout<<sz[Find(a)]<<endl;
}


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

int main()
{
    int n, m;
    cin >> n;

    map<string, int> mp;

    for (int i = 0; i < n; i++)
    {
        string val;
        cin >> val;
        mp[val] += 1;
    }

    cin >> m;
    for (int i = 0; i < m; i++)
    {
        string val;
        cin >> val;
        mp[val] -= 1;
    }

    int max = mp.begin()->second;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        if (max < itr->second)
        {
            max = itr->second;
        }
    }

    max < 0 ? cout << 0 : cout << max;
}


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

using namespace std;

int main(){
        vector <int> a;
        int N, K;
        cin>>N>>K;
        for(int i=0;i<N;i++){
                int aa;
                cin>>aa;
                a.push_back(aa);
        }
        sort(a.begin(), a.end());
        vector <int> cnt;
        cnt.push_back(1);
        for(int i=1;i<N;i++){
                if(a[i-1]!=a[i]){
                        cnt.push_back(1);
                }
                else{
                        cnt[(int)cnt.size()-1]++;
                }
        }
        int res=0;
        sort(cnt.begin(), cnt.end());
        for(int i=0;i<(int)cnt.size()-K;i++){
                res+=cnt[i];
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 2548
#include <stdio.h>

int main(void)
{
    int Seconds;
    scanf("%d", &Seconds);
    //int Hour = Seconds / 60 / 60;
    int Mitutes = Seconds / 60 % 60;
    int Hour = Seconds % 60;
    printf("%d:%d:%d\n", Seconds / 60 / 60, Mitutes, Hour);
    return 0;
}


Measured memory_bytes: 2736
#include <iostream>
#include <algorithm>

using namespace std;
int main() {
	int n[3] = {0};
	int ans = 0;
	cin >> n[0] >> n[1] >> n[2];
	sort(&n[0], &n[3]);
	if (n[0] % 2 != n[1] % 2) {
		if (n[0] % 2 == n[2] % 2) {
			n[0]++;
		} else {
			n[1]++;
		}
		n[2]++;
		ans++;
	}

	ans += (2 * n[2] - n[0] - n[1]) / 2;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<limits.h>
#include<algorithm>
#include<string>
#include<vector>
#include<unordered_map>
#include<cmath>
#include<queue>

using namespace std;

int main() {
    int n;
    cin>>n;
    vector<int> a(n),dp(n);
    for (int i=0; i<n ;i++)
    {
        cin>>a[i];
    }
    if(n<=1)cout<<0<<endl;
    
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
        //cout<<i<<dp[i]<<endl;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 300001;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    vector<int> cntx(MAX), cnty(MAX);
    map<pii, int> mp;
    int H, W, N;
    cin >> H >> W >> N;
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        cntx[x]++;
        cnty[y]++;
        mp[pii(x, y)]++;
    }
    int mx = *max_element(cntx.begin(), cntx.end());
    int my = *max_element(cnty.begin(), cnty.end());
    vector<int> X, Y;
    for (int i = 1; i < MAX; i++) {
        if (cntx[i] == mx) X.push_back(i);
        if (cnty[i] == my) Y.push_back(i);
    }
    for (int x : X) {
        for (int y : Y) {
            if (mp.count(pii(x, y)) == 0){
                cout << mx + my << '\n';
                return 0;
            }
        }
    }
    cout << mx + my - 1 << '\n';
}


Measured memory_bytes: 27344
fun main(arr: Array<String>) {
    val (n,m,x) = readLine()!!.split(" ").map { it.toInt() }
    val gates = readLine()!!.split(" ").map { it.toInt() }
    val ans = Math.min(gates.filter { it < x }.count(), gates.filter { it > x }.count())
    println(ans)
}

Measured memory_bytes: 36568
import sys
from collections import deque

input = sys.stdin.readline

def bfs(N, G, p):
    # Connected compoponent
    c_comp_p_list = []
    c_comp_i_list = []
    visited = [False] * N
    for i in range(N):
        if visited[i]:
            continue
        visited[i] = True
        c_comp_p_list.append([p[i]])
        c_comp_i_list.append(set([i + 1]))
        cc_p_add = c_comp_p_list[-1].append
        cc_i_add = c_comp_i_list[-1].add

        queue = deque(G[i])
        while queue:
            u = queue.popleft()
            if visited[u]:
                continue
            visited[u] = True
            cc_p_add(p[u])
            cc_i_add(u + 1)

            for v in G[u]:
                if visited[v]:
                    continue
                queue.append(v)

    res = 0
    for c_comp_p, c_comp_i in zip(c_comp_p_list, c_comp_i_list):
        for pp in c_comp_p:
            if pp in c_comp_i:
                res += 1
    return res


def main():
    N, M = map(int, input().split())
    p = tuple(map(int, input().split()))
    G = [[] for _ in range(N)]
    for _ in range(M):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        G[x].append(y)
        G[y].append(x)
    
    ans = bfs(N, G, p)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 65992
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

void debug_out(){cerr<<endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr<<(H)<<" ";debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr<<"#"<<#__VA_ARGS__<<":\n",debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

int dp[MAX][2][4],k;
vector<int> digi;

int call(int id, int ls, int sm){
	if(sm> k) 
		return 0;
	if(id==digi.size()){
		if(sm==k)
			return 1;
		else
			return 0;
	}
	if(dp[id][ls][sm]!=-1)
		return dp[id][ls][sm];
	int dans=0;
	if(!ls){
		for(int i=0;i<=digi[id];i++)
			dans+=call(id+1,ls|(i<digi[id]),sm+(i>0));
	}else{
		for(int i=0;i<=9;i++)
			dans+=call(id+1,ls,sm+(i>0));	
	}
	return dp[id][ls][sm]=dans;
}

int solve(string &s){
	digi.clear();
	memset(dp,-1,sizeof(dp));	
	for(auto &c:s){
		digi.push_back(c-'0');
	}
	return call(0,0,0);
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	string s;
	int i;
	cin>>s>>k;
	cout<<solve(s);
	return 0;
}


Measured memory_bytes: 6528
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

int f(vector<vi>c,int k){
  int h=c.size();
  int w=c[0].size();
  int p=1;
  bool ch=1;
  int ans=0;
  while(ch){
    ch=0;
    if (0){
      cerr<<"p="<<p<<" ans="<<ans<<endl;
      rep(i,h){
	rep(j,w)cerr<<" "<<c[i][j];
	cerr<<endl;
      }
      cerr<<endl;
    }
    //fall
    rep(i,w){
      vi col;
      for(int j=h-1;j>=0;--j){
	if(c[j][i]!=0)
	  col.push_back(c[j][i]);
      }
      rep(j,h){
	int nv=j<col.size()?col[j]:0;
	if(c[h-1-j][i]!=nv)ch=1;
	c[h-1-j][i]=nv;
      }
    }
    vector<vector<bool> > dis(h,vector<bool>(w));
    rep(i,h){
      int con=0;
      rep(j,w+1){
	if(j==0||j==w||c[i][j]!=c[i][j-1]){
	  if(con>=k){
	    rep(l,con){
	      dis[i][j-l-1]=true;
	      ans+=p*c[i][j-l-1];
	    }
	  }
	  con=0;
	}
	if(j==w)break;
	con++;
      }
      rep(j,w)if(dis[i][j])c[i][j]=0;
    }
    p*=2;
  }
  return ans;
}

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  vector<vi>b(h,vi(w));
  rep(i,h){
    string s;
    cin>>s;
    rep(j,w){
      b[i][j]=s[j]-'0';
    }
  }
  int m=0;
  rep(i,h){
    rep(j,w){
      vector<vi>c(b);
      c[i][j]=0;
      m=max(m,f(c,k));
    }
  }
  cout<<m<<endl;
}


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#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>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	ll n, m;
	cin >> n >> m;
	if (n > m) {
		swap(n, m);
	}
	if (n >= 2) {
		cout << (n - 2) * (m - 2) << endl;
	} else {
		if (m >= 2) {
			cout << (m - 2) << endl;
		} else {
			cout << 1 << endl;
		}
	}
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3576
import java.util.*;

class Main{

    int n, m, sz;
    char[] kakko;
    int[] a, bkt, add;

    void solve(){
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        kakko = sc.next().toCharArray();

        sz = Math.max(1, (int)Math.sqrt(n) - 1);
        a = new int[n];
        bkt = new int[n/sz+10];
        add = new int[n/sz+10];
        TreeSet<Integer> set = new TreeSet<Integer>();

        for(int i=0; i<n; i++){
            if(i==0) a[i] = 1;
            else{
                if(kakko[i]=='(') a[i] = a[i-1] + 1;
                else{
                    a[i] = a[i-1] - 1;
                    set.add(i);
                }
            }
            bkt[i/sz] = Math.min(a[i], bkt[i/sz]);
        }

        for(int i=0; i<m; i++){
            int q = sc.nextInt()-1;
            int idx = 0;
            if(kakko[q]=='('){
                kakko[q] = ')';
                set.add(q);
                add(q, n, -2);
                //idx = set.higher(new Integer(-1));
                idx = set.pollFirst();
                kakko[idx] = '(';
                set.remove(idx);
                add(idx, n, 2);
            }else{
                kakko[q] = '(';
                set.remove(q);
                add(q, n, 2);
                idx = search(q);
                kakko[idx] = ')';
                add(idx, n, -2);
                set.add(idx);
            }
            //System.out.println(Arrays.toString(kakko));
            System.out.println(idx+1);
        }
    }

    void add(int start, int last, int num){
        int from = start - start%sz;
        int to = from + sz;
        for(int i=start/sz; i * sz <=last; i++){
            if(start<=from && to<=last){
                add[i] += num;
            }else{
                for(int j=Math.max(from, start); j<to && j<last; j++){
                    a[j] += num;
                }
                int min = Integer.MAX_VALUE;
                for(int j=from; j<to && j<a.length; j++){
                    min = Math.min(min, a[j]);
                }
                bkt[i] = min;
            }
            from = to;
            to += sz;
        }
    }

    int search(int f){        
        int from = f - f%sz;
        int to = from + sz;
            
        for(int i=f/sz; i>=0; i--){
            if(bkt[i]+add[i]<=1){
                for(int j=Math.min(f-1, to-1); j>=from; j--){
                    if(a[j]+add[i]==1) return j+1;
                }
            }
            to = from;
            from -= sz;
        }
        return 0;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 114304
#include <cstdio>

bool vis[1000006];
int k;

int main()
{
    scanf("%d", &k);
    for(int i = 1, x = 7 % k; ; ++i)
    {
        if(x == 0)
        {
            printf("%d", i);
            return 0;
        } else {
            if(!vis[x]) vis[x] = true, x = (x * 10 + 7) % k;
            else break;
        }
    }
    printf("-1");
    return 0;
}

Measured memory_bytes: 2652
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    
    ll N,M=0,A=0,R=0,C=0,H=0;
    cin>>N;
    string s;
    rep(i,0,N){
        cin>>s;
        if(s.at(0)=='M'){
            M++;
        }
        if(s.at(0)=='A'){
            A++;
        }
        if(s.at(0)=='R'){
            R++;
        }
        if(s.at(0)=='C'){
            C++;
        }
        if(s.at(0)=='H'){
            H++;
        }
    }
    cout<<M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H<<endl;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define str       string
#define pi        2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define test      cout<<"THIS_AND_THIS"<<endl;
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			ll x=n/i;
			if(x<=9 and i<=9){
				cout<<"Yes";return;
			}
		}
	}
	cout<<"No";
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int sum = 0;

		for(int i = 0; i < m; i++) {
			sum += sc.nextInt();
		}

		if(sum > n) {
			System.out.println(-1);
			System.exit(0);
		}

		System.out.println(n - sum);

		sc.close();
	}
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



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

    if(s.size()==2){
        if(s[0]==s[1]) cout << "1 2" << endl;
        else cout << "-1 -1" << endl;
    } else {
        REP(i,s.size()-1){
            if(s[i]==s[i+1]) {
                cout << i+1 << " " << i+2 << endl;
                return 0;
            }
        }

        REP(i,s.size()-2){
            if(s[i]==s[i+2]) {
                cout << i+1 << " " << i+3 << endl;
                return 0;
            }
        }

        cout << "-1 -1" << endl;
    }

    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9) + 7;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[] cl = new int[26];
        for(char c : s){
            cl[c - 'a']++;
        }
        long ans = 1;
        for(int i : cl){
            ans *= i+1;
            ans %= mod;
        }
        System.out.println(ans-1);
    }
}

Measured memory_bytes: 27092
n = int(input())
A = list(map(int, input().split()))
m = {}
ans = 0
for i in range(n):
    x = A[i] + i   #i番目と当該数字の和
    if x not in m:
        m[x] = 0   #和の属性値を0とする
    m[x] += 1      #和の属性値に１を足す
    if i - A[i] in m: #i番目と当該数字の差
        ans += m[i - A[i]] #差の位置に当たる属性値を答えに足す
print(ans)

Measured memory_bytes: 40292
n = int(input())

s = n//3
t = n % 3

if n >=3:
    if t == 0:
        print(s**3)
    else:
        print((n/3)**3)
else:
    if n == 1:
        print(0.333333333333333**3)
    else:
        print(0.666666666666666**3)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n , c , k;
  cin >> n >> c >> k;
  vector<int>t(n);
  for(int i=0;i<n;i++){
    cin >> t.at(i) ;
  }
  sort(t.begin(),t.end());
  int ans = 0;
  for(int i = 0 ; i<n ; i++){
    ans += 1;
    if(i == n -1){
      break;
    }
    for(int j = i+1 ; j<n;j++){
      if(j -i > c -1 ){
        i = j-1;
        break;
      }
      if( t.at(j) - t.at(i) > k){
        i = j-1;
        break;
      }
      if( j == n -1){
        i = j;
      }
    }
  }
  cout << ans << endl;
}

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

void Main()
{
  string S; cin >> S;
  vector<char> s; 
  for(char c : S) s.push_back(c);
  ll Q; cin >> Q;
  
  vector<char>::iterator it;
  bool rev = false;
    
  rep(i,Q) {
    int command;
    cin >> command;
    if (command == 1) {
      rev = !rev;
    } else {
      int f; char c;
      cin >> f >> c;
      if (f == 1) {
        if (rev) s.push_back(c);
        else {
          it = s.begin();
	      s.insert(it, c);
        }
      } else {
        if (rev) {
          it = s.begin();
	      s.insert(it, c);
        } else s.push_back(c);
      }
    }
  }
  if (rev) {
    reverse(s.begin(), s.end());
  } 
  rep(i, s.size()) cout << s[i];
  cout << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
int f(int x,int y,int n){
if(x<=n/2 && n/2+1<=y)
  return 1;
  else if(x<=n/2 &&y<=n/2)
    return f(x,y,n/2)+1;
  else
    return f(x-n/2,y-n/2,n-n/2)+1;
}
int main(){
  int N;cin>>N;
  for(int i=1;i<N;i++){
  for(int j=i+1;j<N;j++)
    cout<<f(i,j,N)<<" ";
    cout<<f(i,N,N)<<endl;
   }
  return 0;
}

Measured memory_bytes: 3588
import sys

n = int(input())

dif_max = -float("inf")
min_v = float("inf")

for i in range(n):
    r = int(sys.stdin.readline())
    dif_max = max(dif_max, r - min_v)
    min_v = min(min_v, r)

print(dif_max)

Measured memory_bytes: 7676
#include<stdio.h>

int main(){
  int N,A[100],i,v,j,k;

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

  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i != N-1)
      printf(" ");
  }
  printf("\n");

  for(i=1;i<N;i++){
    v = A[i];
    j = i-1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k != N-1)
	printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define ll long long
#define sf(n) scanf("%lld",&n)
#define pf(n) printf("%lld\n",n)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define pff(x,y) printf("%lld %lld\n",x,y)
#define REP(I,N) for(I=0;I<N;I++)
#define REPP(I,A,B) for(I=A;I<=B;I++)
#define MS0(X) memset(X,0,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define F first
#define S second
#define Mod 1000000007
#define pb push_back
#define RF freopen("riyad.txt","r",stdin)
#define WF freopen("out.txt","w",stdout)
#define YES printf("YES\n")
#define NO printf("NO\n")

using namespace std;

typedef unsigned long long Ull;
typedef pair < int , int > Pii;
typedef pair < ll , ll > Pll;

map < ll , ll > mp;
map <ll , ll > bel;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //RF;
    //WF;
    ll i,tc,cs=1,n,m,k,cnt=0,j,q;
    cin>>n;
    ll a[n+5],sum=0;
    for(i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    ll res = 0;
    for(i=0;i<n;i++){
        if(bel[a[i]] == 0){
            bel[a[i]] = (mp[a[i]] * (mp[a[i]]-1))/2;
            sum += bel[a[i]];
        }
    }
    for(i=0;i<n;i++){
        k = mp[a[i]]-1;
        k *= k - 1; k /=2;
        cout<<sum-bel[a[i]]+k<<endl;
    }
    return 0;
}



Measured memory_bytes: 18944
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

const int INF = 1e8;

int main() {
	ll n;
	cin >> n;

	ll ans = 1;
	for (int i = 1; i <= n; i++) {
		ans = ans * i % 1000000007;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
C = []
for _ in range(3):
    c = list(map(int,input().split()))
    C.append(c)

if((C[0][0]-C[1][0]==C[0][1]-C[1][1]==C[0][2]-C[1][2])                    
        and(C[0][0]-C[2][0]==C[0][1]-C[2][1]==C[0][2]-C[2][2])):                  
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(){
	//freopen("in/0006.txt","r",stdin);
	char str[21];
	fgets(str,21,stdin);
	int i=0,len=strlen(str),mid=len/2;
	char c,*ptr=str;
	do{
		int j=len-2*i-1;
		c=*ptr;*ptr=*(ptr+j);*(ptr+j)=c;
		i++;
		ptr+=1;
	}while(i<mid);
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 524