akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll tall = 0;
    ll ans = 0;
    rep(i, n) {
        if(tall > a[i]) ans += tall - a[i];
        chmax(tall, a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4776
m=(0..14).map{[0]*14}
while gets
x,y,t=$_.split(?,).map{|i|i.to_i+2}
(l=[*-2..2]).product(l).map{|a,b|m[x+a][y+b]+=1if a**2+b**2<=2**(t-3)}end
n=m[2..11].flat_map{|i|i[2..11]}
p n.count(0),n.max

Measured memory_bytes: 6116
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i< (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)x; i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, in;
	cin >> n;
	vector<int> p(n);
	rep(i, n){
		cin >> in;
		in--;
		p.at(in) = i;
	}
	int ans = 0, temp = -1;
	rep(i, n){
		if(i == n - 1 || p.at(i) > p.at(i+1)){
			ans = max(ans, i - temp);
			temp = i;
		}
	}
	cout << n - ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    s = S()
    cnt = 0
    tgt = "keyence"
    for i in range(8):
        if s[:i] + s[len(s)-7+i:] == tgt:
            print("YES")
            exit()
    print("NO")

Measured memory_bytes: 9068
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

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

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

constexpr ll MOD = 1e9 + 7;

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    ll n;
    std::cin >> n;

    auto sieve = [](ll n) -> vll {
        vll v(n + 1, 0);
        v[0] = v[1] = 1;
        for (ll i = 2; i * i <= n; i++) {
            if (v[i] == 1) continue;
            for (ll j = 2; i * j <= n; j++)
                v[i * j] = 1;
        }

        vll res;
        for (ll i = 2; i <= n; i++)
            if (v[i] == 0) res.push_back(i);

        return res;
    };

    vll prime = sieve(n);

    auto legendre = [&](ll n, ll p) -> ll {
        ll res = 0;
        for (ll i = 1; rpow(p, i) <= n; i++)
            res += n / rpow(p, i);

        return res;
    };

    ll ans = 1;
    for (ll p : prime)
        (ans *= legendre(n, p) + 1) %= MOD;

    std::cout << ans << '\n';
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

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

Measured memory_bytes: 4412
/**
 *      ABC 93 A
 *      author  : kyomukyomupurin
 *      created : 2018/08/29
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int count = 0;
    string S; cin >> S;
    for (char s = 'a'; s <= 'c'; ++s){
        if (string(S).find(s) != string::npos){
            ++count;
        }
    }
    if (count == 3){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

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

using ll = long long;

int main() {
    ll N;
    cin >> N;
    if (N % 2) cout << 0 << endl;
    else {
        ll ans = N / 10, d = 10;
        while (d <= N) {
            d *= 5;
            ans += N / d;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int X=x;
		for(int i=0;i<2;i++){
			X*=x;
		}
		System.out.println(X);
	}

}

Measured memory_bytes: 26004
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	double r, p;
	p = 3.141592653589;
	cin >> r;
	printf("%5lf", r*r*p);
	cout << " ";
	printf("%5lf\n", r * 2 * p);
	return 0;
	}


Measured memory_bytes: 3280
#include<iostream>
#include<stdio.h>
#define LEN 100005

typedef struct pp {
    
    char name[100];
    
    int t;
    
} P;

P Q[LEN];

int head, tail, n;

void enqueue(P x) {
    
    Q[tail] = x;
    
    tail = (tail + 1) % LEN;
    
}

P dequeue() {
    
    P x = Q[head];
    
    head = (head + 1) % LEN;
    
    return x;
    
}

int min(int a, int b) {
    
    return a < b ? a : b;
    
}

int main() {
    
    int elaps = 0,c;
    
    int i, q;
    
    P u;
    
    scanf("%d %d", &n, &q);
    
    for (i = 1; i <= n; i ++) {
        
        scanf("%s", Q[i].name);
        
        scanf("%d", &Q[i].t);
        
    }
    
    head = 1;
    
    tail = n + 1;
    
    
    while(head != tail) {
        
        u = dequeue();
        
        c = min(q, u.t);
        
        u.t -= c;
        
        elaps += c;
        
        if(u.t > 0) {
            
            enqueue(u);
            
        } else {
            
            printf("%s %d\n", u.name, elaps);
            
        }
    
    }
    
    return 0;
    
}


Measured memory_bytes: 13340
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    int x,a;
    cin >> x >> a;
    cout << ((x<a)?0:10) << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        ans += bisect_left(L, a+b) - 1 - j
print(ans)

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;





int main() {


	ll n, k;
	cin >> n >> k;
	VLL a(n);
	REP(i, n) {
		cin >> a[i];
	}

	ll ans = 0;

	REP(i, n) {

		ll cnt = 0;

		REP(j, i) {
			if (a[i] > a[j])cnt++;
		}

		ll b = (k*(k - 1)) / 2;
		b %= mod;

		ans += b * cnt;
		ans %= mod;

		cnt = 0;
		FOR(j, i, n) {
			if (a[i] > a[j])cnt++;
		}
		b = (k*(k + 1)) / 2;
		b %= mod;
		ans += b * cnt;
		ans %= mod;
	}

	cout << ans << endl;



}

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

int N, M;
int ec[114514];
int* es[114514];

void ae(int f, int t) {
	es[f] = realloc(es[f], sizeof(int) * (ec[f] + 1));
	if (es[f] == NULL) exit(2);
	es[f][ec[f]++] = t;
}

int ayaneru[114514];

int qs, qe;
int q[114514];

int main(void) {
	int i;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		int A, B;
		if (scanf("%d%d", &A, &B) != 2) return 1;
		ae(A, B);
		ae(B, A);
	}
	q[0] = 1;
	ayaneru[1] = -1;
	qs = 0;
	qe = 1;
	while (qs < qe) {
		int node = q[qs];
		qs++;
		for (i = 0; i < ec[node]; i++) {
			int next = es[node][i];
			if (ayaneru[next] == 0) {
				ayaneru[next] = node;
				q[qe++] = next;
			}
		}
	}
	for (i = 1; i <= N; i++) {
		if (ayaneru[i] == 0) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for (i = 2; i <= N; i++) {
		printf("%d\n", ayaneru[i]);
	}
	return 0;
}



Measured memory_bytes: 8444
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define fo(i,n) for(int i=0;i<n;++i)
#define Fo(i,k,n) for(int i=k;i<n;++i)
typedef long long int lli;
int main(){
    FIO
    int price; cin>>price;
    if(price%1000==0) cout<<0<<endl;
    else cout<<1000-(price%1000)<<endl;
}


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

using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

void solve(){
	ll x, k, d;
	cin >> x >> k >> d;

	if(x < 0) d *= -1;

	ll needed = x / d;
	if(needed >= k){
		cout << abs(x - k * d) << "\n";
		return;
	}

	k -= needed;

	auto solver = [](ll X, ll K, ll D){
		return K & 1 ? min(abs(X - D), abs(X + D)) : abs(X);
	};

	cout << min(solver(x - needed * d, k, d), solver(x - needed * d - d, k - 1, d)) << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int>ans(N);
    for(int i = 0; i < M; i++) {
        int a,b;
        cin >> a >> b;
        ans[a-1]++;
        ans[b-1]++;
    }
    for(int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s,t;
  cin >> s >> t;
  int n = sz(s);
  int ans = 0;
  rep(i,n)if(s[i]!=t[i])ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ‘ ‘
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k;
  cin >> n;
  vector<ll> a(n);
  rep(i, n - 1)
    cin >> a[i];
  a[n - 1] = a[n - 2];
  k = a[0];
  rep2(i, 1, n){
    k = k + min(a[i - 1], a[i]);
  }
  cout << k;
  memi;
}

Measured memory_bytes: 256
n=int(input())
s_list=[]
shiritori_list=[]
for i in range(n):
  s=input()
  s_list.append(s)
  schar = list(s)
  schar_list=[]
  schar_list.append(schar[0])
  schar_list.append(schar[len(schar)-1])
  shiritori_list.append(schar_list)

unique_list=set(s_list)

if len(s_list) != len(unique_list):
  print('No')
else:
  judge='Yes'
  for j in range(n-1):
    if shiritori_list[j][1] != shiritori_list[j+1][0]:
      judge='No'
      break
  print(judge)

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char a[100010];
int s[100010];

int main()
{
    #ifdef waltz
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    scanf("%s",a+1);int n=strlen(a+1);
    for (char c='a';c<='z';c++)
    {
        s[0]=0;
        for (int i=1;i<=n;i++) if (a[i]==c) s[i]=s[i-1]+1; else s[i]=s[i-1]-1;
        int j=0;
        for (int i=2;i<=n;i++)
        {
            if (s[i]>s[j]) {printf("%d %d\n",j+1,i);return 0;}
            if (s[i-1]<s[j]) j=i-1;
        }
    }
    puts("-1 -1");
    return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

const int BUCKET = 400,SIZE = 300;
int N,Q;
ll bucketAdd [BUCKET];
ll A [100000];

void add(int l,int r,int val)
{
	FOR(i,0,BUCKET){
		int bucket_l = i * SIZE,bucket_r = (i + 1) * SIZE;
		if(r <= bucket_l || bucket_r <= l) continue;
		if(l <= bucket_l && bucket_r <= r){
			bucketAdd [i] += val;
			continue;
		}
		FOR(j,bucket_l,bucket_r){
			if(l <= j && j < r){
				A [j] += val;
			}
		}
	}
}

ll get(int idx)
{
	return A [idx] + bucketAdd [idx / SIZE];
}

int main()
{
	scanf("%d%d",&N,&Q);
	vector<ll> ans;
	FOR(i,0,Q){
		int com;
		scanf("%d",&com);
		if(com == 0){
			int s,t,x;
			scanf("%d%d%d",&s,&t,&x);
			add(s - 1,t,x);
		}
		else{
			int idx;
			scanf("%d",&idx);
			ans.push_back(get(idx - 1));
		}
	}

	FOR(i,0,ans.size()){
		printf("%lld\n",ans [i]);
	}

	return 0;
}

Measured memory_bytes: 4240
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    ans = []

    def f(t, k, n):
        if n == N:
            ans.append(t)
            return

        for i in range(k+1):
            f(t+l_alp[i], max(k, i+1), n+1)

    f('a', 1, 1)

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()



Measured memory_bytes: 59352
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define int long long
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
const int maxn=2e3+7;
const int mod=1e9+7;
/*Almost copy pasted part :)*/

int32_t main(){
    ios::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    string s;
    cin>>s;
    deque<char> q;
    for(int i=0;i<s.size();i++)
        q.push_front(s[i]);
    bool y=0;
    int t;
    cin>>t;
    while(t--){
        int t;
        cin>>t;
        if(t==1){
            y=!y;
        }
        else{
            int f;
            char c;
            cin>>f>>c;
            if(f==1){
                if(y){
                    q.push_front(c); 
                }
                else{
                    q.push_back(c);
                }
            }
            else{
                if(y){
                    q.push_back(c);
                }
                else{
                    q.push_front(c);
                }
            }
        }
    }
    string ans="";
    while(!q.empty()){
        ans+=q.front();
        q.pop_front();
    }
    if(!y){
        reverse(ans.begin(),ans.end());
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1368
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	String s;

	void run(){
		s=sc.nextLine();
		solve();
	}

	char[] cs;
	int max;

	void solve(){
		s+="$";
		cs=s.toCharArray();
		max=-1;
		dfs(0);
		println(max+"");
	}

	void dfs(int i){
		char[] op={'0', '1', '+', '-', '*', '(', ')'};
		if(i==cs.length){
			max=max(max, calc());
			return;
		}
		if(cs[i]=='.'){
			for(char c : op){
				cs[i]=c;
				dfs(i+1);
				cs[i]='.';
			}
		}else{
			dfs(i+1);
		}
	}

	int calc(){
		Result r=E(0);
		r.good&=r.p==cs.length-1;
		if(r.good){
			int n=cs.length;
			for(int i=0; i<n; i++){
				if(cs[i]!='('){
					continue;
				}
				int left=i, right=left+1;
				int stack=0;
				boolean op=false;
				for(; cs[right]!=')'||stack!=0; right++){
					if(cs[right]=='('){
						stack++;
					}else if(cs[right]==')'){
						stack--;
					}
					if(stack==0)
						op|=cs[right]=='+'||cs[right]=='-'||cs[right]=='*';
				}
				r.good&=op;
			}
		}
		return r.good?r.value:-1;
	}

	Result E(int p){
		Result r=F(p);
		if(!r.good){
			return r;
		}
		for(; cs[r.p]=='+'||cs[r.p]=='-';){
			Result r2=F(r.p+1);
			if(!r2.good){
				return r2;
			}
			if(cs[r.p]=='+'){
				r.value+=r2.value;
			}else{
				r.value-=r2.value;
			}
			r.update();
			if(!r.good){
				return r;
			}
			r.p=r2.p;
		}
		return r;
	}

	Result F(int p){
		Result r=T(p);
		if(!r.good){
			return r;
		}
		for(; cs[r.p]=='*';){
			Result r2=T(r.p+1);
			if(!r2.good){
				return r2;
			}
			r.value*=r2.value;
			r.update();
			if(!r.good){
				return r;
			}
			r.p=r2.p;
		}
		return r;
	}

	Result T(int p){
		if(cs[p]=='('){
			Result r=E(p+1);
			if(!r.good||cs[r.p]!=')'){
				r.good=false;
				return r;
			}
			r.p++;
			return r;
		}else if(cs[p]=='0'||cs[p]=='1'){
			Result r=new Result(p, 0);
			for(; Character.isDigit(cs[r.p]); r.p++){
				r.value=r.value*2+cs[r.p]-'0';
				r.update();
			}
			return r;
		}else{
			return new Result(0, -1);
		}
	}

	class Result{
		int p, value;
		boolean good;

		Result(int p, int value){
			this.p=p;
			this.value=value;
			good=true;
			update();
		}

		void update(){
			if(value<0||value>=1024){
				good=false;
			}
		}
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define mod(d) d%1000000007
#define loop(i,s,e) for(ll i=s;i<e;i++)
#define vll vector<ll>
#define pii pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int N=2e6+3;
ll dp[105][100002];

ll solve(pii* A,ll w,ll s,ll e){
	if(w<0)return INT_MIN;
	if(s>=e)return 0;
	if(dp[s][w]!=-1)return dp[s][w];
	ll ans1=0;
	ll ans2=0;
	ans1+=solve(A,w,s+1,e);
	ans2+=A[s].ss+solve(A,w-A[s].ff,s+1,e);

	return dp[s][w]=max(ans1,ans2);
}


int main(){


	ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	ll n,w;
	cin>>n>>w;

	memset(dp,-1,sizeof(dp));

	pii* A= new pii[n];

	loop(i,0,n){
		ll x,y;
		cin>>x>>y;

		A[i].ff=x;
		A[i].ss=y;
	}

	cout<<solve(A,w,0,n);
}

Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
int main()
{
    bool ans=false;
int K,A,B;
cin>>K>>A>>B;
for(int i=A;i<=B;i++)
{

if(i%K==0){ans=true;}




}

if(ans){cout<<"OK"<<endl;}
else{cout<<"NG"<<endl;}

}


Measured memory_bytes: 3624
import heapq


class Dijkstra:
    """ダイクストラ法を行う.0-index"""

    def __init__(self, graph, start_point, goal_point=None):
        """Intialization.

        :param graph:List[Dict[int, int]]
        :param start_point: start index
        :param goal_point: goal index
        """
        node_num = len(graph)
        self.graph = graph
        self.start_point = start_point
        self.goal_point = goal_point
        self.dist = [float("inf") for _ in range(node_num)]
        self.prev = [float("inf") for _ in range(node_num)]

    def run(self):
        self.dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) != 0:
            # priority queueから最短距離の点をとりだす.
            prev_cost, src = heapq.heappop(heap_q)

            if self.dist[src] < prev_cost:
                continue

            for dest, cost in self.graph[src].items():
                if self.dist[dest] > self.dist[src] + cost:
                    self.dist[dest] = self.dist[src] + cost
                    # priority queueに到達可能な点を追加する.
                    heapq.heappush(heap_q, (self.dist[dest], dest))
                    self.prev[dest] = src
        if self.goal_point is not None:
            return self.get_path()
        else:
            return self.dist

    def get_path(self):
        path = [self.goal]
        dest = self.goal

        while self.prev[dest] != float("inf"):
            path.append(self.prev[dest])
            dest = self.prev[dest]

        return list(reversed(path))


N = int(input())
graph = [{} for _ in range(N)]
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c

Q, K = map(int, input().split())

solver = Dijkstra(graph, K - 1)
d = solver.run()

for _ in range(Q):
    x, y = map(int, input().split())
    print(d[x - 1] + d[y - 1])


Measured memory_bytes: 60204
#include<iostream>

using namespace std;

#define ios         ios_base::sync_with_stdio(false);
#define ll          long long
#define ld          long double
#define db(x)       cout << "[" << #x << ": " << (x) << "]\n"
#define db2(x,y)    cout << "[" << #x << ": " << (x) << "]  [" << #y << ": " << (y) << "]\n"
#define db3(x,y,z)  cout << "[" << #x << ": " << (x) << "]  [" << #y << ": " << (y) << "]  [" << #z << ": " << (z) << "]\n"
#define cn          107
#define sn          2007
#define bn          1000007
#define M           1000000007
#define inf         LLONG_MAX


ll dp[sn];

ll dpf(ll n)
{
        if(n < 3) return 0;
        if(dp[n]) return dp[n];
        dp[n] = 1;
        for(ll i = 3; i+3 <= n; i++)
        {
                dp[n] += dpf(n-i);
                dp[n] %= M;
        }
        return dp[n];
}

int main()
{
        ios;
        dp[0] = dp[1] = dp[2] = 0; dp[3] = 1;
        ll n; cin >> n;
        cout << dpf(n); cout << "\n";
	return 0;
}



Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1,0,1,0 }; const int dy[] = { 0,1,0,-1 };


char ans;
void saiki(string s, int &out, int &idx) {
	int num = 0;
	while (idx<s.length()) {
		if (isdigit(s[idx])) {
			num *= 10;
			num += s[idx] - '0';
			idx++;
		}
		else if(s[idx]=='('){
			idx++;
			int idx2;
			REP(i, num) {
				idx2 = idx;
				saiki(s, out, idx2);
				if (ans != '0'||out<0)
					return;
			}
			idx = idx2;
			num = 0;
		}
		else if (s[idx] == ')') {
			idx++;
			return;
		}
		else {
			string s2 = "";
			if (num == 0) {
				while ('A' <= s[idx] && s[idx] <= 'Z') {
					s2 += s[idx];
					idx++;
				}
			}
			else {
				s2 += s[idx];
				idx++;
			}
			REP(i,max(1,num))
			if (out < s2.length()) {
				ans = s2[out];
				return;
			}
			else {
				out -= s2.length();
				if (out < 0)
					return;
			}
			num = 0;
		}
	}
	return;
}
int main() {
	string s;
	int out;
	while (cin >> s >> out, s != "0") {
		int idx = 0;
		ans = '0';
		saiki(s, out, idx);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
ll n, m, x, y,z,w,h, sum= 0, ans = 0;
int main() {
    string s;
    cin >> n >> m >> s;
    rep(i, n - 1) {
        if (s[i] != s[i + 1]) sum++;
    }
    cout << n - 1 - max(sum - m * 2, 0LL) << endl;
}

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

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

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

int main() {
  std::string S;
  std::cin >> S;
  if(S[2] == S[3] && S[4] == S[5]) {
    std::cout << "Yes" << '\n';
  } else {
    std::cout << "No" << '\n';
  }
}


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

int main() {
    int n;
    cin>>n;
    int i,j,k;
    vector<ll> lst(10000,0);
    for(i=1;i<=100;i++){
        for(j=1;j<=100;j++){
            for(k=1;k<=100;k++){
                int ans=i*i+j*j+k*k+i*j+j*k+i*k;
                if(ans>n)
                    break;
                lst[ans]++;
            }
        }
    }
    for(i=1;i<=n;i++)
        cout<<lst[i]<<endl;
    return 0;
}



Measured memory_bytes: 3704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int K = sc.nextInt();
		char start = S.charAt(K - 1);

		//N要素のビルダーを作成。
		StringBuilder sb = new StringBuilder(N);

		for(int i = 0 ; i < N ; i++) {
			char flg = S.charAt(i);
			if(flg == start) {
				sb.append(start);
			}else {
				sb.append('*');
			}
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< (int)(n); i++)
int main(){
    int X,Y;
    cin >> X >> Y;
    if((X*4>=Y)&&(X*2<=Y)&&(Y%2==0)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_7_A
{
    class Program
    {
        static ScoreJudgeStandard _ScoreJudge = new ScoreJudgeStandard();
        static string _finalyScore;

        static void Main(string[] args)
        {
            while (true)
            {
                string[] Score = Console.ReadLine().Split(' ');
                int m = int.Parse(Score[0]);
                int f = int.Parse(Score[1]);
                int r = int.Parse(Score[2]);
                if (m == -1 && f == -1 && r == -1)
                {
                    break;
                }
                _finalyScore = _ScoreJudge.ScoreJudge(m, f, r);
                Console.WriteLine(_finalyScore);
            }
        }
    }
    class ScoreJudgeStandard
    {
        internal string ScoreJudge(int middle, int final, int retest)
        {
            string finalyScore;
            if (middle == -1 || final == -1)
            {
                finalyScore = "F";
            }
            else if (middle + final >= 80)
            {
                finalyScore = "A";
            }
            else if (65 <= middle + final && middle + final < 80)
            {
                finalyScore = "B";
            }
            else if (50 <= middle + final && middle + final < 65)
            {
                finalyScore = "C";
            }
            else if (30 <= middle + final && middle + final < 50)
            {
                finalyScore = "D";
                if (retest >= 50)
                {
                    finalyScore = "C";
                }
            }
            else
            {
                finalyScore = "F";
            }
            return finalyScore;
        }
    }
}



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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n, k;
	ll ans = INF;

	cin >> n >> k;

	vector<ll> v1[2000];
	vector<pair<ll, ll>> v2;

	REP(i, n - 1) {
		ll a, b;
		cin >> a >> b;
		v1[a - 1].push_back(b - 1);
		v1[b - 1].push_back(a - 1);
		v2.push_back(make_pair(a - 1, b - 1));
	}

	if (k % 2 == 0) {
		REP(i, n) {
			queue<ll> q;
			q.push(i);
			vector<ll> dist(n, INF);
			dist[i] = 0;
			ll count = 0;
			while (!q.empty()) {
				ll now = q.front();
				q.pop();
				REP(j, v1[now].size()) {
					ll next = v1[now][j];
					if (dist[next] != INF) {
						continue;
					}
					dist[next] = dist[now] + 1;
					if (dist[next] > k / 2) {
						count++;
					}
					q.push(next);
				}
			}
			ans = min(ans, count);
		}
	}
	else {
		REP(i, n - 1) {
			queue<ll> q;
			q.push(v2[i].first);
			q.push(v2[i].second);
			vector<ll> dist(n, INF);
			dist[v2[i].first] = 0;
			dist[v2[i].second] = 0;
			ll count = 0;
			while (!q.empty()) {
				ll now = q.front();
				q.pop();
				REP(j, v1[now].size()) {
					ll next = v1[now][j];
					if (dist[next] != INF) {
						continue;
					}
					dist[next] = dist[now] + 1;
					if (dist[next] > (k - 1) / 2) {
						count++;
					}
					q.push(next);
				}
			}
			ans = min(ans, count);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()

cap = C-1
dep = T[0] + K
ans = 1
for t in T[1:]:
    if cap and t <= dep:
        cap -= 1
    else:
        cap = C-1
        dep = t + K
        ans += 1
print(ans)

Measured memory_bytes: 7888
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL N, K; cin >> N >> K;
  LL x = N/K;
  cout << min(abs(N - x * K), abs(N - x * K - K)) << endl;
}


Measured memory_bytes: 256
import Data.List

score _ [] = []
score n x@((ih,vh):xs) = 
  let m = takeWhile (\ (i,v) -> v == vh) x
      r = dropWhile (\ (i,v) -> v == vh) x
      l = length m
      s = 3*n + l - 1
      y = map (\(i,v) -> (i,v,s)) m
  in
    y ++ (score (n+l) r)

ans i =
  let x = zip [1..] i
      s = sortBy (\(i0,v0) (i1,v1) -> compare v0 v1) x
      a = score 0 s
      s'= sortBy (\(i0,v0,s0) (i1,v1,s1) -> compare i0 i1) a
  in
    map (\(i0,v0,s0) -> s0) s'
  
main = do
  _ <- getLine
  c <- getContents
  let i = map read $ lines c :: [Float]
      o = ans i
  mapM_ print o



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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; // 合計金額
        if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3596
a, b = gets.split.map(&:to_i)
def gcd(a, b)
  return a if b == 0
  gcd(b, a % b)
end
g = gcd(a, b)
def factorize(n)
  res = {}
  i = 2
  while i ** 2 < n
    while n % i == 0
      n /= i
      res[i] ||= 0
      res[i] += 1 if res[i]
    end
    i += 1
  end
  res[n] = 1 if n != 1
  res
end
f = factorize g
puts f.size + 1



Measured memory_bytes: 1788
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll a, b;
    cin >> a >> b;
    cout << ceil((a+b)/2.0) << endl;
    return 0;
}


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

#define ll long long
#define ar array

void test(){
    string s = "abcdefghijkl";
    int n = s.size();
    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            cout << s[i] << s[j] << endl;
            ans ++;
        }
    }
    cout << "Answer : -> " << ans << endl;
    cout << "other answer " << n * (n - 1) / 2 << endl;
}

void solve(){
    int n, m;
    cin >> n >> m;
    int res = n * (n - 1) / 2 + m * (m - 1) / 2 ;
    cout << res << endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int testCases;
    testCases = 1;
    while(testCases --){
        solve();
    }
    return 0;
}




Measured memory_bytes: 256
//#pragma comment(linker,"/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
const int INF=0x3f3f3f3f;
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= b; ++i)
const int max_number=1000000;



int main()
{
    int a,b;
    cin>>a >> b;
    if(a<b)cout<<"a < b"<< endl;
    if(a>b)cout<<"a > b"<< endl;
    if(a==b)cout<<"a == b"<< endl;
    return 0;

}


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

int h, w, c[10][10];

int main() {
    cin >> h >> w;
    FOR(i, 10){
        FOR(j, 10){
            cin >> c[i][j];
        }
    }
    FOR(k, 10){
        FOR(i, 10){
            FOR(j, 10){
                if(c[i][j] > c[i][k] + c[k][j]) c[i][j] = c[i][k] + c[k][j];
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            int num;
            cin >> num;
            if(num >= 0) ans += c[num][1];
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    string x;
    cin>>x;
    if(x.size() == 1){
        cout<<-1<<" "<<-1<<endl;
    }else if(x.size() == 2){
        if(x[0] == x[1])
            cout<<1<<" "<<2<<endl;
        else cout<<-1<<" "<<-1<<endl;

    }else {
        for(int i = 0 ; i< x.size() -2 ; i++){
            if(x[i] == x[i+ 1] && x[i] != x[i+2]){
                cout<<i+ 1 <<" "<<i + 3 <<endl;
                return;
            }
            if(x[i] != x[i+ 1] && x[i + 1] == x[i + 2]){
                cout<<i + 1 <<" "<<i + 3 <<endl;
                return;
            }
            if(x[i] == x[i+2] && x[i] != x[i+1]){
                cout<<i+1 <<" "<<i + 3<<endl;
                return;
            }
            if(x[i] == x[i+1] && x[i] == x[i+2]){
                cout<<i+1<<" "<<i+3 <<endl;
                return;
            }
        }
        cout<<-1<<" "<<-1<<endl;
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 512
import Data.List

main :: IO ()
main = do
  n <- readLn
  as' <- sort . map read . words <$> getLine
  let
    as = map (pred.length) $ group (as' :: [Int])
    s = sum as
  case () of
    _ | s > 2 -> print $ n - (s+1)`div`2*2
      | s == 0 -> print n
      | otherwise -> print $ n-2

Measured memory_bytes: 31740
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=2e5+10,M=5e5+10,T=1e6+5,mod=924844033,sqr=5,sqrinv=554906420;
int n,siz[N],limit,lg,E,ot[M],ne[M],g[N];
int fac[N],inv[N],infac[N];
int a[T],b[T],r[T];
inline int ksm(int x,int y){
    int res=1;
    while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod; y>>=1;}
    return res;
}
inline void add(int &u,int &v){ot[++E]=v,ne[E]=g[u],g[u]=E;}
inline void init(){
    cin>>n;
    for(int i=1,u,v;i<n;i++){
        scanf("%d%d",&u,&v);
        add(u,v),add(v,u);
    }
}
void dfs(int x,int fa){
    siz[x]=1;
    for(int i=g[x];i;i=ne[i]){
        int to=ot[i];
        if(to==fa)continue;
        dfs(to,x); siz[x]+=siz[to];
        a[siz[to]]++;
    }
    a[n-siz[x]]++;
}
inline int solve_complex(int x,int tp){
    if(~tp)return ksm(sqr,x);
    else return ksm(sqrinv,x);
}
inline void DFT(int *A,int tp){
    for(int i=0;i<limit;i++)if(i<r[i])swap(A[i],A[r[i]]);
    for(int len=1;len<limit;len<<=1){
        int wn=solve_complex((mod-1)/(2*len),tp);
        for(int j=0;j<limit;j+=len<<1){
            int w=1;
            for(int k=0;k<len;++k,w=1ll*w*wn%mod){
                int x=A[j+k],y=1ll*w*A[j+k+len]%mod;
                A[j+k]=x+y,A[j+k+len]=x-y;
                if(A[j+k]>=mod)A[j+k]-=mod;
                if(A[j+k+len]<0)A[j+k+len]+=mod;
            }
        }
    }
}
inline void pre(){
    register int i; dfs(1,0);
    fac[0]=1;for(i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    inv[1]=1;for(i=2;i<=n;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
    infac[0]=1;for(i=1;i<=n;++i) infac[i]=1ll*infac[i-1]*inv[i]%mod;
}
inline void work(){
    a[0]=0; register int i;
    for(i=0;i<=n;i++)a[i]=1ll*a[i]*fac[i]%mod;
    for(i=0;i<=n;i++)b[i]=infac[n-i];
    limit=1; while(limit<=2*n)limit<<=1,++lg;
    for(i=1;i<limit;i++)r[i]=((r[i>>1]>>1)|((i&1)<<(lg-1)));
    DFT(a,1),DFT(b,1);
    for(i=0;i<limit;i++)a[i]=1ll*a[i]*b[i]%mod;
    DFT(a,-1);
    int INV=ksm(limit,mod-2);
    for(i=1;i<=n;i++)a[i+n]=1ll*a[i+n]*INV%mod*infac[i]%mod;
    for(i=1;i<=n;i++)a[i]=1ll*fac[n]*infac[i]%mod*infac[n-i]%mod*n%mod;
    for(i=1;i<=n;i++){
        a[i]-=a[i+n];
        if(a[i]<0)a[i]+=mod;
    }
    for(i=1;i<=n;i++)printf("%d\n",a[i]);
}
signed main(){
    init();pre();work();return 0;
}

Measured memory_bytes: 29312
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    VI A;
    REP(i, N) {
        int tmp;
        cin >> tmp;
        if (A.empty()) A.EB(tmp);
        else if (A.back() != tmp) A.EB(tmp);
    }
    N = A.size();

    LL cur_m = 1000, cur_s = 0;
    int i = 0;
    while (i + 1 < A.size()) {
        while (i + 1 < A.size() && A[i] > A[i + 1]) {
            i++;
        }

        int l = i;
        while (i + 1 < A.size() && A[i] < A[i + 1]) {
            i++;
        }

        cur_s = cur_m / A[l];
        cur_m %= A[l];
        cur_m += cur_s * A[i];
    }

    cout << cur_m << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<char> C(11);
  vector<char> out(11);
  int i=0;
  cin >> C.at(i);
  do{
    cin >> C.at(i+1);
    i++;
  }  while(C.at(i) != '\0');
  
  int count = 0;  
  
  for(int k=0;k<11;k++){
    if(C.at(k) == '0'){
      out.at(count) = '0';
      count+=1;
    }else if(C.at(k) == '1'){
      out.at(count) = '1';
      count+=1;
    }else if(C.at(k) == 'B'){
      if(count != 0){
        count-=1;
        out.at(count) = '\0';
      }
    } 
  }

  
  for(int j = 0;j<count;j++){
    cout << out.at(j);
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int s,w;
	cin >> s >> w;
	if(s <= w){
		cout << "unsafe" << endl;
	}else{
		cout << "safe" << endl;
	}
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p.at(i);
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += p.at(i);
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628