akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int n, q, A[30], m[210];
bool solve(int, int);
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m[i];
	}
	for (int i = 0; i < q; i++) {
		if (solve(0, m[i])) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

bool solve(int i, int m) {
	//cerr << "solve(" << i << ", " << m << ") was called." << endl;
	if (m == 0) return true;
	if (i >= n) return false;
	bool res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    double res = v[0];
    rep(i,n-1){
        res = (res+v[i+1])/2;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n=gets.to_i
h=gets.split.map(&:to_i).reverse

flag=true
(0..n-2).each do |i|
  if h[i] >= h[i+1]
    next
  elsif h[i] == h[i+1] - 1
    h[i+1] -= 1
  else
    flag=false
    break
  end
end

if flag
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 9348
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::*;
use petgraph::unionfind::UnionFind;
use proconio::{input, fastout, marker::*};

#[fastout]
fn main() {
  input!{
      n:usize,
      m:usize,
      ab:[(usize,usize);m]
  }
  let mut UF:UnionFind<usize> = UnionFind::new(n+1);
  for (a,b) in ab {
      UF.union(a,b);
  }
  let mut map = collections::HashMap::new();
  for i in 1..=n {
      *map.entry(UF.find(i)).or_insert(0) += 1;
  }
  println!("{}",map.values().max().unwrap());
}


Measured memory_bytes: 10572
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	int ans = 0;
	int cnt = 1;
	makei(n);
	makev(a, n);
	Rep(1, n) {
		if (a[i - 1] == a[i])cnt++;
		else {
			ans += cnt / 2;
			cnt = 1;
		}
	}
	say(ans + cnt / 2);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int menseki(int xmin, int xmax, int ymin, int ymax) {
	int W,H;
	W = xmax - xmin;
	H=ymax - ymin;

	if (W > 0&&H>0) {
		return W*H;
	}
	else {
		return 0;
	}
}

int main() {
	int xmin, xmax, ymin, ymax;
	int W, H, N;
	int x, y, a;

	cin >> W >> H >> N;

	xmin = 0;
	xmax = W;
	ymin = 0;
	ymax = H;

	for (int i = 0;i < N;i++) {
		cin >> x >> y >> a;

		switch (a) {
		case 1:
			if (xmin < x)
				xmin = x;
			break;
		case 2:
			if (xmax > x)
				xmax = x;
			break;
		case 3:
			if (ymin < y)
				ymin = y;
			break;
		case 4:
			if (ymax > y)
				ymax = y;
			break;
		}
	}

	cout << menseki(xmin, xmax, ymin, ymax) << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
class aoj
{static void Main()
    {
        int[] a = new int[10];
        int i = 0, j = 0; 
        for (;;)
        {
            string y = Console.ReadLine();
            if (String.IsNullOrEmpty(y)) break;
            int b = int.Parse(y);
            if (b == 0)
            {
                
                j++;
                i--;
                Console.WriteLine(a[i]);
                Array.Clear(a, i, 1);
            }
            else
            {
                a[i] = b;
                i++;
            }
            
        }
    }
}

Measured memory_bytes: 8988
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;

int main()
{
    int H,W,h,w;
    cin >> H >> W;
    cin >> h >> w;
    cout << H*W-(h*W+w*H-h*w);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
signed main(){
	int a,b,c,ma=0,sum=0;
	cin>>a>>b;
	f(i,b){
		cin>>c;
		ma=max(ma,c);
		sum+=c;
	}
	cout<<max(0,ma*2-sum-1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b;
	cin >> a >> b;
	int ans = 0;
	if (a > b){
		ans += a;
		a--;
	}
	else {
		ans += b;
		b--;
	}

	if (a > b) {
		ans += a;
	}
	else ans += b;

	cout << ans << endl;
}



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

LL x[100123];

int main()
{
	Rep(i, 9) x[i] = i;
	int a = 1, b = 9;
	while(b < 100000) {
		LL c = x[a] * 10, d = x[a] % 10;
		if(d > 0) x[++b] = c + d - 1;
		x[++b] = c + d;
		if(d < 9) x[++b] = c + d + 1;
		++a;
	}
	int n;
	cin >> n;
	cout << x[n] << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main
{ //202 is the modular multiplicative inverse of 2019.
	static int mod(int x)
	{
		int an = x%2019;
		while(an<0)an+=2019;
		return an;
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		int n = s.length();
		int[] a = new int[n];
		
		for(int i = 0; i < n; i++)
		{
			a[i] = s.charAt(i) - '0';
		}
		
		long[] avail = new long[2019];
		
		int backtransmul = 1;
		int backtransadd = 0;
		long score = 0;
		int curval = 0;
		for(int i = 0; i < n; i++)
		{
			curval = mod(curval*10 + a[i]);
			int cura = mod((0 * backtransmul) - backtransadd);
			avail[cura]++;
			
			int curb = mod((0 * backtransmul) - backtransadd);
			
			backtransmul = mod(backtransmul*202);
			backtransadd = mod(backtransadd + backtransmul*a[i]);
			
			int curc = mod((0 * backtransmul) - backtransadd);
			score += avail[curc];
		}
		
		System.out.println(score);
	}

}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <ll, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e5 + 1;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;

int n, s;
int x[N], a[N];
ll ps[N], ss[N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> s;
    ll sum = 0;
    forn(i, 1, n) {
        cin >> x[i] >> a[i];
        sum += a[i];
    }
    int tl = lower_bound(x + 1, x + 1 + n, s) - x - 1;
    int tr = tl + 1;
    if (x[tr] == s) ++tr;

    vi order;
    ll fn = a[1], fp = a[n];
    int l = 1, r = n;
    for (; l <= tl && tr <= r;) {
        if (fn >= fp) {
            fn += fp;
            order.pb(x[r]);
            fp = a[--r];
        }
        else {
            fp += fn;
            order.pb(x[l]);
            fn = a[++l];
        }
    }
    for (; l <= tl; ++l) order.pb(x[l]);
    for (; r >= tr; --r) order.pb(x[r]);
    order.pb(s);
    reverse(order.begin(), order.end());
    ll ans = 0;
    forn(i, 1, order.size() - 1)
        ans += abs(order[i] - order[i - 1]);
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3704
#include "bits/stdc++.h"

/************* Using *************/
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using graph_t = vector<vector<ll>>;

/*********** Constants ***********/
const auto INF  = static_cast<int>(1e10);
const auto INFL = static_cast<ll>(1e18);
const auto MOD  = static_cast<ll>(1e9 + 7);
const auto NIL  = nullptr;

/*********** Variables ***********/
ll N;
vector<ll> P;
bool ANS;

/************* Utils *************/

/*********** Functions ***********/
bool init() {
    cin >> N;
    P.resize(N);
    for (auto &p : P) cin >> p;
    return true;
}

void solve() {
    ll cnt = 0;
    for (ll i = 0; i < N; i++) {
        if (P[i] != i + 1) {
            cnt++;
        }
    }
    if (cnt > 2) {
        ANS = false;
    }
    else {
        ANS = true;
    }
}

void output() {
    cout << (ANS ? "YES" : "NO") << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

// #define DEBUG 100

using namespace std;
using ll = unsigned long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 100010;
const double PI = acos(-1);
vector<pii> seg[4*maxn];
vector<ll> fat(maxn, -1), inv(maxn, -1);
vector<ll> v(maxn + 1);

ll fexp(ll base, ll p){
    ll ans = 1;

    while (p){
        if(p&1) ans = (ans * base)%mod;
        base = (base * base)% mod;
        p = p >> 1;
    }
    return ans;
}

void init(){
    fat[0] = fat[1] = inv[1] = 1;
    for (ll i=2; i<maxn; i++){
        fat[i] = (fat[i-1] * i)%mod;
        inv[i] = fexp(fat[i], mod-2);
    }
}

ll combina(ll n, ll k){
    if (n == k || k == 0) return 1;
    if (n < k) return 0;

    return (((fat[n] * inv[k])%mod)*inv[n - k])%mod;
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0); 
    string s;
    cin >> s;

    if (s == "AAA" ||s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, l;
  cin >> n >> l;
  vector<st> s(n);
  vin(s);
  sort(all(s));
  st ans = "";
  vrep(i, s) ans += i;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef bitset<2001> b100;

b100 a[2222];
b100 win[2222];
b100 dpl[2222];
b100 dpr[2222];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n; cin>>n;
	for(int i=1;i<n;i++)
	{
		string s; cin>>s;
		for(int j=0;j<s.length();j++)
		{
			if(s[j]=='1')
			{
				win[i].set(j,1);
			}
			else
			{
				win[j].set(i,1);
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		dpl[i].set(i,1); dpr[i].set(i,1);
	}
	for(int len=2;len<=n;len++)
	{
		for(int i=0;i+len-1<n;i++)
		{
			int r=i+len-1;
			dpl[i][r]=((win[r]&dpl[i]&dpr[r-1]).count()>0?1:0);
			dpr[r][i]=((win[i]&dpl[i+1]&dpr[r]).count()>0?1:0);
		}
	}
	cout<<(dpl[0]&dpr[n-1]).count()<<'\n';
}


Measured memory_bytes: 1920
// Author: πα

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

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long int64_t

const int N = 1e5 + 5;
int n, dp[N];
vector<int> g[N];
bool vis[N];

void dfs(int u)
{
    vis[u] = 1;
    for(auto v : g[u])
    {
        if(!vis[v])
            dfs(v);
        dp[u] = max(dp[u], 1+dp[v]);
    }
}

int main()
{
    FastIO;
    int i, m, u, v, ans = 0;
    cin >> n >> m;
    while(m--)
        cin >> u >> v, g[u].push_back(v);
    for(u = 1; u <= n; ++u)
        if(!vis[u])
            dfs(u);
    for(i = 1; i <= n; ++i)
        ans = max(ans, dp[i]);
    cout << ans;
    return 0;
}


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

int main(){
	ll n, x, m;
  	cin >> n >> x >> m;
  	vector<int> id(m, -1);
  	vector<int> a;
 
  	ll len = 0, tot = 0;
  	while(id[x] == -1){
      	a.push_back(x);
    	id[x] = len;
      	len++;
      	tot += x;
      	x = (x*x)%m;
    }
  
  	int c = len-id[x];
  	ll s = 0;
  	for(int i = id[x]; i < len; i++) s += a[i];
  
  	ll ans = 0;
	if(n <= len){
    	rep(i, n) ans += a[i];
    } else {
    	ans += tot;
      	n -= len;
      	ans += s * (n/c);
      	n %= c;
      	rep(i, n) ans += a[id[x]+i];
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    bool flag=false;
    for(int i=0;4*i<=n;i++){
        int t=n-4*i;
        if(t%7==0)flag=true;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

const ll INF = 1LL << 60;

struct Parser{
	string s;
	int N;
	int c;

	ll parse(string s){
		this->s = s;
		N = s.size();
		c = 0;
		try{
			ll ret = expr();
			if(c != N) throw "";
			return ret;
		}
		catch(...){
			return INF;
		}
	}

	void debug(string text){
		return;
		cout << text + " ";
		for(int i = 0; i < N; i++){
			if(i == c) cout << '[' << s[i] << ']';
			else cout << s[i];
		}
		cout << endl;
	}

	ll expr(){
		debug("expr");
		ll x = term();
		while(c < N){
			if(s[c] == '+'){
				c++;
				x += term();
			}
			else if(s[c] == '-'){
				c++;
				x -= term();
			}
			else break;
		}
		return x;
	}

	ll term(){
		debug("term");
		ll x = factor();
		while(c < N){
			if(s[c] == '*'){
				c++;
				x *= factor();
			}
			else break;
		}
		return x;
	}

	ll factor(){
		debug("factor");
		if(s[c] == '-'){
			c++;
			return -factor();
		}
		if(s[c] == '('){
			c++;
			ll ret = expr();
			if(s[c] != ')') throw "";
			//assert(s[c] == ')');
			c++;
			return ret;
		}
		return num();
	}

	ll num(){
		debug("num");
		if(!isdigit(s[c])) throw "";
		ll ret = 0;
		string digit;
		while(c < N && isdigit(s[c])){
			ret = ret * 2 + s[c] - '0';
			digit += s[c];
			c++;
		}
		if(digit != "0" && digit[0] == '0') throw "";
		return ret;
	}
} parser;

string s;
int ans;

vector<char> cs;
string op = "01+-*()=";
int used[10];
map<char, char> m;

void dfs(int n){
	if(n == cs.size()){
		string t = s;
		for(int i = 0; i < t.size(); i++){
			if(m.count(t[i])) t[i] = m[t[i]];
		}
		int eq = t.find('=');
		if(eq == string::npos) return;
		string e1 = t.substr(0, eq);
		string e2 = t.substr(eq + 1);
		if(e1 == "" || e2 == "") return;
		ll res1 = parser.parse(e1), res2 = parser.parse(e2);
		if(res1 != INF && res2 != INF && res1 == res2){
			ans++;
		}
		return;
	}

	for(int i = 0; i < op.size(); i++){
		if(used[i]) continue;
		used[i] = 1;
		m[cs[n]] = op[i];
		dfs(n + 1);
		used[i] = 0;
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	while(cin >> s){
		cs.clear();
		for(auto c : s){
			if(isalpha(c)) cs.push_back(c);
		}
		sort(cs.begin(), cs.end());
		cs.erase(unique(cs.begin(), cs.end()), cs.end());
		m.clear();

		ans = 0;
		dfs(0);
		//cout << s << endl;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3308
n,*a=map(int,open(0).read().split())
a.sort()
m=a[-1]+1
cnt=[0]*m
for ai in a:
  if cnt[ai]!=0:
    cnt[ai]+=1
    continue
  for i in range(ai,m,ai):
    cnt[i]+=1
ans=0
for ai in a:
  ans+=(cnt[ai]==1)
print(ans)

Measured memory_bytes: 33256
#include<iostream>
using namespace std;
int main(void)
{
	int n,m,i=0,c=0;
	cin>>n;
	while(n){
		n--;
		if(i==0){
			cin>>i;
			c++;
			continue;//処理のスキップ
		}
		cin>>m;
		if(m<=i){
			i=m;
			c++;
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const long long int MOD = 1000000007;

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

	int x, y;
	cin >> x >> y;
	for (int i = 0; i <= x; ++i) {
		int kame = i, turu = x - i;
		if (4 * kame + 2 * turu == y) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
int max(int x, int y) {
	return x > y ? x : y;
}
int min(int x, int y) {
	return x < y ? x : y;
}
typedef long long ll;
int main() {
	char s[500000];
	scanf("%s", s);
	ll ans = 0;
	int len = strlen(s);
	int i = 0;
	int cntB = 0, cntS = 0;
	while (i != len) {
		cntB = cntS = 0;
		while (i != len && s[i] == '<') {
			cntB++;
			i++;
		}
		while (i != len && s[i] == '>') {
			cntS++;
			i++;
		}
		ans += (ll)(max(cntB, cntS) + 1) * max(cntB, cntS) / 2;
		ans += (ll)(min(cntB, cntS) - 1) * min(cntB, cntS) / 2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int i, area[10001], n;
  area[0] = 1;
  for(i = 1;i <= 10000;i++)
    area[i] = area[i - 1] + i;

  while(scanf("%d", &n) != EOF)
    printf("%d\n", area[n]);

  return 0;
}

Measured memory_bytes: 636
use std::io;

fn main() {
    let mut tmp_str = String::new();
    io::stdin().read_line( &mut tmp_str ).expect( "No input val" );
    let ary_size = tmp_str.trim().parse().expect( "failed parse value" );

    tmp_str = String::new();
    io::stdin().read_line( &mut tmp_str ).expect( "No input val" );
    let mut num_vec: Vec<i32> = tmp_str.split_whitespace().
        filter_map( |k| k.parse().ok() ).collect::<Vec<i32>>();

    num_vec = selection_sort( num_vec ); 

    for i in 0..ary_size {
        if i == ary_size-1 {
            println!( "{}", num_vec[i as usize] );
        } else {
            print!( "{} ", num_vec[i as usize] );
        }
    }
    println!( "{}", num_vec[ary_size as usize] );
}

fn selection_sort( mut numv: Vec<i32> ) ->  Vec<i32> {
    let ary_size = numv.len();
    let mut minj;
    let mut cnt = 0;

    for i in 0..ary_size {
        minj = i;
        for j in i..ary_size {
            if numv[minj as usize] > numv[j as usize] {
                minj = j;
            }
        }

        if minj != i {
            let tmp_val = numv[minj as usize];
            numv[minj as usize] = numv[i as usize];
            numv[i as usize] = tmp_val;
            cnt = cnt + 1;
        }
    }

    numv.push( cnt );
    numv
}



Measured memory_bytes: 5040
N, C = list(map(int, input().split()))

D = []

for i in range(N):
  D.append(list(map(int, input().split())))
  
R = [[0, 0] for i in range(N + 1)]
cnt = 0
ma = 0
rma = 0
R[0][0] = -1
for i in range(N):
  cnt += D[i][1]
  if cnt - D[i][0] > ma:
    ma = cnt - D[i][0]
  if cnt - D[i][0] * 2 > rma:
    rma = cnt - D[i][0] * 2 
  R[i + 1] = [ma, rma]

cnt = 0
Ans = R[N][0]
tmp = 0
for i in range(N - 1, -1, -1):
  cnt += D[i][1]
  tmp = C - D[i][0]
  tmp2 = cnt - tmp * 2 + R[i][0]
  tmp2 = max(tmp2, cnt - tmp + R[i][1])
  if tmp2 > Ans:
    Ans = tmp2

print(Ans)

Measured memory_bytes: 80728
import Control.Applicative
import Control.Monad
import Data.List

type I = Int

main :: IO ()
main = do
  n <- readi <$> getLine
  as <- map readi . words <$> getLine
  print $ solve n as

solve :: I -> [I] -> I
solve n as = sum $ map (cost mean) as where
  mean = roundUpOn5 $ fromIntegral (sum as) / fromIntegral n
  cost x y = (x - y)^2

roundUpOn5 :: (RealFrac a, Integral b) => a -> b
roundUpOn5 x
  | n <= -0.5 = m - 1
  | n >= 0.5 = m + 1
  | otherwise = m
  where (m, n) = properFraction x

--  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --

readi :: String -> I
readi = read

toTuple :: [a] -> (a, a)
toTuple [x, y] = (x, y)

toTriple :: [a] -> (a, a, a)
toTriple [x, y, z] = (x, y, z)


Measured memory_bytes: 1020
#include<iostream>
#define NON 0
#define A 1
#define C 2
#define G 3
#define T 4
using namespace std;
typedef long long ll;

const int MAX_N = 101;
const ll MOD = 1e9 + 7;

int N;
ll memo[MAX_N][5][5][5][5];

ll dfs(int i, int c1, int c2, int c3, int c4) {
    // i-3, i-2, i-1, i文字目にそれぞれc1, c2, c3, c4がある時の通り数
    if (c2 == A && c3 == G && c4 == C) return 0;
    if (c2 == A && c3 == C && c4 == G) return 0;
    if (c2 == G && c3 == A && c4 == C) return 0;
    if (c1 == A && c2 == G && c3 == G && c4 == C) return 0;
    if (c1 == A && c2 == G && c3 == T && c4 == C) return 0;
    if (c1 == A && c2 == T && c3 == G && c4 == C) return 0;
    if (i == N) return 1;
    if (memo[i][c1][c2][c3][c4] > 0) return memo[i][c1][c2][c3][c4];
    for (int j = 1; j <= 4; j++) {
        memo[i][c1][c2][c3][c4] = (memo[i][c1][c2][c3][c4] + dfs(i + 1, c2, c3, c4, j)) % MOD;
    }
    return memo[i][c1][c2][c3][c4];
}

int main() {
    cin >> N;
    cout << dfs(0, NON, NON, NON, NON) << endl;
    return 0;
}

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

int mygcd(int m, int n) {
  if(n==0) {
    return m;
  }
  else {
    return mygcd(n, m % n);
  }
}

void solve(long long N){
  long long loops = floor(sqrt(N))+1;
  long long i, j;
  long long mymin = LLONG_MAX;

  for(long long i = loops; i > 0; i--) {
    if ((N % i) == 0) {
      j = (N / i);
      mymin = min(mymin, abs(1-i)+abs(1-j));
      break;
    }
  }

  cout << mymin << endl;
}

// 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);
    solve(N);
    return 0;
}


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

bool calc(vector<string> const &chars, vector<int> const &hswap, vector<int> const &wswap, vector<vector<int>> const &hgv, vector<vector<int>> const &wgv) {
    for (auto hs: hswap) {
        for (auto ws: wswap) {
            if (hs == -1 || ws == -1) continue;
            assert(hgv[hs].size() == 2);
            assert(wgv[ws].size() == 2);
            int y1 = hgv[hs][0];
            int x1 = wgv[ws][0];
            int y2 = hgv[hs][1];
            int x2 = wgv[ws][1];
            // cout << "checking " << y1 << " " << x1 << " and " << y2 << " " << x2 << endl;
            if (chars[y1][x1] != chars[y2][x2]) return false;
        }
    }
    return true;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> chars(h);
    for (int i = 0; i < h; i++) {
        cin >> chars[i];
    }

    vector<map<char,int>> cnth(h);
    vector<map<char,int>> cntw(w);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cnth[i][chars[i][j]]++;
            cntw[j][chars[i][j]]++;
        }
    }

    vector<int> hg(h, -1), wg(w, -1);
    int hgc = 0, wgc = 0;
    {
        int &g = hgc;
        for (int i = 0; i < h; i++) {
            if (hg[i] != -1) continue;
            for (int j = i+1; j < h; j++) {
                if (hg[j] != -1) continue;
                if (cnth[i] == cnth[j]) {
                    hg[i] = hg[j] = g++;
                    break;
                }
            }
        }
        if (g != h/2) { cout << "NO" << endl; return 0; }
    }

    {
        int &g = wgc;
        for (int i = 0; i < w; i++) {
            if (wg[i] != -1) continue;
            for (int j = i+1; j < w; j++) {
                if (wg[j] != -1) continue;
                if (cntw[i] == cntw[j]) {
                    wg[i] = wg[j] = g++;
                    break;
                }
            }
        }
        if (g != w/2) { cout << "NO" << endl; return 0; }
    }

    vector<vector<int>> hgv(h/2), wgv(w/2);
    for (int i = 0; i < h; i++) {
        // cout << hg[i] << endl;
        if (hg[i] != -1) hgv[hg[i]].push_back(i);
    }
    for (int i = 0; i < w; i++) {
        // cout << wg[i] << endl;
        if (wg[i] != -1) wgv[wg[i]].push_back(i);
    }

    vector<int> hswap(hgc), wswap(wgc);
    iota(hswap.begin(), hswap.end(), 0);
    iota(wswap.begin(), wswap.end(), 0);

    do {
        do {
            // cout << "testing [";
            // copy(hswap.begin(), hswap.end(), ostream_iterator<int>(cout, ","));
            // cout << "] and [";
            // copy(wswap.begin(), wswap.end(), ostream_iterator<int>(cout, ","));
            // cout << "]" << endl;
            if (!calc(chars, hswap, wswap, hgv, wgv)) {
                cout << "NO" << endl;
                return 0;
            }
        } while (next_permutation(wswap.begin(), wswap.end()));
    } while (next_permutation(hswap.begin(), hswap.end()));

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Console.ReadLine().Split(' ').Distinct().Count() == 2 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 26548
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;

ll N,K;
vector <ll> A;
vector <bool> visited;

int main(){
  cin>>N>>K;
  K++;
  // 1-indexed
  A.push_back(1);
  visited.push_back(false);
  REP(i,N){
    ll a; cin>>a;
    A.push_back(a);
    visited.push_back(false);
  }

  // simulation
  ll now = 0;
  visited[0] = true;
  ll s;

  ll cnt = 0;

  for(;;){
    //cout<<now<<endl;

    ll next = A[now];


    cnt++; // a + b

    if(visited[next] == true){
      s = next;
      break;
    }
    visited[next] = true;
    now = next;
    
  }

  //cout<<cnt<<endl;

  ll a = 0;
  now = 0;
  for(;;){
    ll next = A[now];
    a++;
    if(next == s){
      break;
    }
    now = next;
    if(a == K){
      cout<<next<<endl;
      return 0;
    }
  }
 // cout<<a<<endl;

 ll b = cnt - a;
 K -= a;
 ll t = K % b;

 now = s;

 //cout<<s<<endl;
 
 cnt = 0;

 for(;;){
   ll next = A[now];
   cnt++;
   if(cnt % b == t){cout<<next<<endl; return 0;}
   now = next;
  
 }

 



  
  



  return 0;
}

Measured memory_bytes: 5344
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int MAXN = 3005;
const int MOD = 1000000007;
ll memo[MAXN][MAXN][4];

class TaskE {
private:
	Debugger debugger;
	int rows, cols;
	vector<vector<int>> val;
	ll rec(int r, int c, int haveInRow) {
		if(r == rows - 1 && c == cols - 1) {
			if(haveInRow < 3 && val[r][c] > 0) {
				return val[r][c]; 
			}
			return 0;
		}
		ll &ans = memo[r][c][haveInRow];
		if(ans != -1) {
			return ans;
		}
		ans = 0;
		if(haveInRow < 3 && val[r][c] > 0) {
			if(r+1 < rows) {
				ans = max(ans, val[r][c] + rec(r+1, c, 0));
			}
			if(c+1 < cols) {
				ans = max(ans, val[r][c] + rec(r, c+1, haveInRow+1));
			}
		}
		if(r+1 < rows) {
			ans = max(ans, rec(r+1, c, 0));
		}
		if(c+1 < cols) {
			ans = max(ans, rec(r, c+1, haveInRow));
		}
		return ans;
	}

public:
	void solveOne(int it){
		int k;
		cin >> rows >> cols >> k;
		val.assign(rows, vector<int>(cols, 0));
		for(int i = 0; i < k; i++) {
			int x, y, c;
			cin >> x >> y >> c;
			x--; y--;
			val[x][y] = c;
		}
		memset(memo, -1, sizeof memo);
		cout << rec(0, 0, 0) << endl;
	
	}
	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskE solver;
	solver.solve();
	return 0;
}



Measured memory_bytes: 321396
n= int(input())
active = [[0, 0, 0]] * n

for i in range(n):
  a, b, c = map(int, input().split(' '))
  active[i] = [a, b, c]

dp = [[]] * (n + 1)
for i in range(n+1):
  dp[i] = [0, 0, 0]

#print(n, active, dp)

def chmin(arr, index_a, val):
  if arr[index_a] > val:
    arr[index_a] = val
    return True
  return False

def chmax(arr, index_a, val):
  if arr[index_a] < val:
    arr[index_a] = val
    return True
  return False

ans = 0
pre_active = None
for i in range(n):
  a, b, c = active[i]
  dp_i = i + 1 # dpの添字はi日目なので、i = 0 = 初期状態, この場合 i が前日になる
  
  # i日目に a を選ぶ
  dp[dp_i][0] = max(dp[i][1] + a, dp[i][2] + a)
  # i日目に b を選ぶ
  dp[dp_i][1] = max(dp[i][0] + b, dp[i][2] + b)
  # i日目に a を選ぶ
  dp[dp_i][2] = max(dp[i][0] + c, dp[i][1] + c)

#print(dp)
print(max(dp[n]))

Measured memory_bytes: 67544
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int a , b , c , d , e , k , _max , _min , dif ;
    cin >> a >> b >> c >> d >> e >> k ;
    _max = max(max(max(a,b),max(c,d)),e) ;
    _min = min(min(min(a,b),min(c,d)),e) ;
    dif = _max - _min ;
    if (dif <= k){
        cout << "Yay!" ;
    }
    else {
        cout << ":(" ;
    }
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
int a[100100];

int main() {
	cin >> n;
	int MAX = 0;
	int pos = 0;
	rep(i, n) {
		cin >> a[i];
		MAX = max(MAX, abs(a[i]));
		if (MAX == abs(a[i]))pos = i;
	}
	MAX = a[pos];
	if (MAX > 0) {
		vector<P> ans;
		rep(i, n - 1) {
			if (a[i] >= a[i + 1]) {
				a[i + 1] += MAX;
				ans.push_back({ pos + 1, i + 2 });
				if (MAX < a[i + 1]) {
					MAX = a[i + 1];
					pos = i + 1;
				}
			}
		}
		rep(i, n - 1) {
			if (a[i] >= a[i + 1]) {
				a[i + 1] += MAX;
				ans.push_back({ pos + 1, i + 2 });
				if (MAX < a[i + 1]) {
					MAX = a[i + 1];
					pos = i + 1;
				}
			}
		}
		cout << ans.size() << endl;
		rep(i, ans.size()) {
			cout << ans[i].first << " " << ans[i].second << endl;
		}
	}
	else {
		vector<P> ans;
		for (int i = n - 2; i >= 0; i--) {
			if (a[i] >= a[i + 1]) {
				a[i] += MAX;
				ans.push_back({ pos + 1, i + 1 });
				if (MAX > a[i]) {
					MAX = a[i];
					pos = i;
				}
			}
		}
		for (int i = n - 2; i >= 0;i--) {
			if (a[i] >= a[i + 1]) {
				a[i] += MAX;
				ans.push_back({ pos + 1, i + 1 });
				if (MAX > a[i]) {
					MAX = a[i];
					pos = i;
				}
			}
		}
		cout << ans.size() << endl;
		rep(i, ans.size()) {
			cout << ans[i].first << " " << ans[i].second << endl;
		}
	}
	//rep(i, n) {
	//	cout << a[i] << " ";
	//}
	//cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
	int n,a,b;
	scanf ("%d %d %d",&n,&a,&b);
	int sum = 0;
	for(int i=1;i<=n;i++){
		int digitSum=0;
		int temp=i;
		while (temp!=0){
			digitSum=digitSum+temp%10;
			temp/=10;
		}
	if(digitSum>=a&&digitSum<=b){
		sum+=i;
	}
	}
	printf ("%d\n",sum);
	return 0;
}	

Measured memory_bytes: 1732
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1'000'000'007;

ll N;
ll a[10000], b[10000];

int main(){
    cin>>N;
    rep(i,N) cin>>a[i];
    rep(i,N) cin>>b[i];

    ll sum=0;
    rep(i,N) sum+=b[i]-a[i];
    ll cnt=0;
    rep(i,N){
        if(a[i]<b[i]){
            cnt+=(b[i]-a[i]+1)/2;
        }
    }
    if(cnt<=sum){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3776
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
int aa[201000];
int lst[201000];
int n;
bool jud(int x)
{
	if(x==2)
		int oop=-1;
	int i;
	map<int,int>mp;
	for(i=1;i<=n;i++)
	{
		if(aa[i]<=aa[i-1])
		{
			while(!mp.empty())
			{
				int t=mp.rbegin()->first;
				if(t>aa[i])mp.erase(t);
				else break;
			}
			int j=aa[i];
			while(mp[j]+1==x)mp.erase(j),j--;
			if(j==0)return 0;
			mp[j]++;
		}
	}
	return 1;
}
void erfen()
{
	int ll=2,rr=n,mid;
	while(ll<rr)
	{
		mid=(ll+rr)/2;
		if(jud(mid))rr=mid;
		else ll=mid+1;
	}
	printf("%d\n",ll);
}
int main()
{
	int i;
	scanf("%d",&n);
	bool ppp=0;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&aa[i]);
		if(aa[i]<=aa[i-1])ppp=1;
	}
	if(ppp==0){printf("1\n");return 0;}
	erfen();
	return 0;
}

Measured memory_bytes: 1152
m,k=map(int,input().split())
m=2**m
if k>=m:
    print("-1")
elif m==1:
    if k==0:
        print("0 0")
    else:
        print("-1")
elif m==2:
    if k==0:
        print("0 0 1 1")
    else:
        print("-1")
else:
    for i in range(m):
        if i==k:
            continue
        print(i,end=" ")
    print(k,end=" ")
    for i in range(m):
        if m-1-i==k:
            continue
        print(m-1-i,end=" ")
    print(k)

Measured memory_bytes: 52184
def is_prime(k):
    import math
    if k % 2 == 0 and k != 2:
        return False
    for divisor in range(2, math.floor(math.sqrt(k))+1):
        if k % divisor == 0:
            return False
    return True
import sys
x = int(input())
while True:
    if is_prime(x):
        print(x)
        sys.exit()
    x+=1


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  long long d, t, s;
  cin >> d >> t >> s;
  if (t * s >= d) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3652
def resolve():
    '''
    code here
    '''
    N = int(input())
    K = int(input())
    xs = [int(item) for item in input().split()]

    res = 0
    for i in range(N):
        res += min(xs[i]*2, (K-xs[i])*2)

    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9188
#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, q;
    cin >> n >> q;
    queue<pair<string, int>> que;
    rep(i, n){
        pair<string, int> pr;
        cin >> pr.first >> pr.second;
        que.emplace(pr);
    }

    int total = 0;
    while (!que.empty())
    {
        pair<string, int> pr_;
        pr_ = que.front();
        que.pop();
        if(pr_.second > q){
            pr_.second -= q;
            total += q;
            que.emplace(pr_);
        }else
        {
            total += pr_.second;
            cout << pr_.first << " " << total << endl; 
        }
    }
    

    return 0;
}


Measured memory_bytes: 6208
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    string s,t;
    cin>>s>>t;

    ll ans=t.size();

    f(i,s.size())
    {
        if(i+t.size()<=s.size())
        {
            ll cnt=0;
            f(j,t.size())
            {
                if(s[i+j]!=t[j]) cnt++;
            }
            ans=min(cnt,ans);
        }
    }
    cout<<ans<<"\n";
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 3852
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        boolean flag = false;
        for (int i = 0; i < s.length-1; i++) {
            if(i<s.length-2){
                if(s[i]==s[i+1]||s[i]==s[i+2]){
                    out.printf("%d %d\n",i+1, i+3);
                    flag = true;
                }
            }else{
                if(s[i]==s[i+1]){
                    out.printf("%d %d\n",i+1, i+2);
                    flag = true;
                }
            }
            if(flag) break;
        }
        if(!flag) out.println("-1 -1");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22740
//problem_a.go

package main

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

const (
	constMod = int(1e9) + 7
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

// -----------------------------------------

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntSlice(n int) []int {
	ns := []int{}
	for i := 0; i < n; i++ {
		ns = append(ns, getInt())
	}
	return ns
}

func getIntDoubleSlice(m int, n int) [][]int {
	var nds [][]int
	for i := 0; i < m; i++ {
		ns := getIntSlice(n)
		nds = append(nds, ns)
	}
	return nds
}

func getFloat() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getFloatSlice(n int) []float64 {
	fs := []float64{}
	for i := 0; i < n; i++ {
		fs = append(fs, getFloat())
	}
	return fs
}

func getFloatDoubleSlice(m int, n int) [][]float64 {
	var fds [][]float64
	for i := 0; i < m; i++ {
		fs := getFloatSlice(n)
		fds = append(fds, fs)
	}
	return fds
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func getStringSlice(n int) []string {
	ss := []string{}
	for i := 0; i < n; i++ {
		ss = append(ss, getString())
	}
	return ss
}

func getStringDoubleSlice(m int, n int) [][]string {
	sds := [][]string{}
	for i := 0; i < m; i++ {
		ss := getStringSlice(n)
		sds = append(sds, ss)
	}
	return sds
}

// -----------------------------------------

// Num Fanction

func numAbs(x int) int {
	if x < 0 {
		return -x
	}

	return x
}

func numModPow(a int, n int, m int) int {
	result := 1

	for n > 0 {
		if n%2 == 1 {
			result = (result * a) % m
		}
		a = (a * a) % m
		n >>= 1
	}

	return result
}

func numGcd(a int, b int) int {
	if b == 0 {
		return a
	}

	return numGcd(b, a%b)
}

func numLcm(a int, b int) int {
	return a * b / numGcd(a, b)
}

func numModInv(a int, p int) int {
	if a == 1 {
		return 1
	}

	return p - numModInv(p%a, p)*(p/a)%p
}

func numModFrac(n int) []int {
	frac := []int{1}

	for i := 1; i <= n; i++ {
		frac = append(frac, i*frac[i-1]%constMod)
	}

	return frac
}

func numModConb(n int, r int) int {
	frac := numModFrac(n)

	return (frac[n] / ((frac[n-r] * frac[r]) % constMod)) % constMod
}

// -----------------------------------------

// sort
// sort.SliceStable(SLICENAME, func(i, j int) bool { return SLICENAME[i] < SLICENAME[j] })

// reverse sort
// sort.SliceStable(SLICENAME, func(i, j int) bool { return SLICENAME[i] > SLICENAME[j] })

// -----------------------------------------

func solve() {

	s := getString()

	if strings.Contains(s, "7") {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}

}

// -----------------------------------------

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}


Measured memory_bytes: 1764
N,K = [int(i) for i in input().split()]
A_list = [int(i) for i in input().split()]

mod = 10**9+7


rightlist = [0 for i in A_list]
alllist = [0 for i in A_list]

for i in range(len(A_list)):
    ct1 = 0
    ct2 = 0
    a = A_list[i]
    right = A_list[i:]
    
    for j in right:
        #print(a,j)
        if a > j:
            ct1+=1
    
    for j in A_list:
        if a > j:
            ct2+=1
    rightlist[i] = ct1
    alllist[i] = ct2


R = int(sum(rightlist))
A  =int(sum(alllist))
K = int(K%mod)
R = int(R%mod)
A = int(A%mod)

ans = int(int(R*K)+A*int(K*(K-1)//2))
print(ans%mod)





Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >

#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ll n; cin >> n;
	for (int i = 111; i <= 999; i += 111){
		if (n <= i){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
from collections import defaultdict
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def main():
    rr = []

    while True:
        r, n = map(int, input().split())

        if r == 0 and n == 0:
            break
        a = [list(map(int, input().split())) for _ in range(n)]

        d = defaultdict(int)
        for xl, xr, h in a:
            for x in range(xl, xr):
                if d[x] < h:
                    d[x] = h

        tr = float('inf')
        r2 = r**2
        for x in range(-r, r):
            h = d[x]
            k = min(abs(x), abs(x+1))
            t = (r2-k**2) ** 0.5
            xr = r-t+h
            if tr > xr:
                tr = xr
        rr.append('{:0.9f}'.format(tr))

    return '\n'.join(map(str, rr))


print(main())



Measured memory_bytes: 6072
n,k = map(int,input().split())
ans = 0
for b in range(1,n+1):
    p = n//b
    q = n%b
    ans += max(b-k,0)*p
    ans +=max(0,q-k+1)
    if k==0:ans-=1
    
print(ans)
    

Measured memory_bytes: 39408
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        Calc calc = new Calc();
        List<int> ans = new List<int>();

        int w = int.Parse(Console.ReadLine());
        int n = int.Parse(Console.ReadLine());

        List<int> number = new List<int>();
        for (int i = 0; i < w+1; i++)
        {
            number.Add(i);
        }

        for (int i = 0; i < n; i++)
        {
            List<int> input = Console.ReadLine().Split(',').Select(int.Parse).ToList();
            number = calc.Exchange(number,input);
        }

        for (int i = 1; i < w+1; i++)
        {
            Console.WriteLine(number[i]);
        }
    }
  
}
class Calc
{
    internal List<int> Exchange(List<int> number, List<int> input)
    {
        int change = number[input[0]];

        number[input[0]] = number[input[1]];
        number[input[1]] = change;

        return number;
    }
}
        


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

bool isPrime(int x) {
    if(x == 2) return true;
    if(x < 2 || x % 2 == 0) return false;

    for(int i=3; i<=sqrt(x); i=i+2) {
        if(x % i == 0) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for(int i=0; i<n; i++) {
        int x;
        cin >> x;
        if(isPrime(x)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3092