akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_DEPRECATE  
#define _CRT_NONSTDC_NO_DEPRECATE

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cctype>
#include <numeric>
#include <cstring>
#include <bitset>
#include <complex>
#include <complex>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    //os << "{ ";
    for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
        os << "" << *it << "" << (it + 1 == v.end() ? "" : " ");
    //os << " }";
    return os;
}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(ull i=(a); i<(ull)(b); i++)
#define rep(i,b) loop(i,0,b)
#define iter(i,c) for(auto it=c.begin(); it!=c.end(); ++it)
#define pb push_back
#define mp make_pair
string const resstr[] = { "Impossible", "Possible", "No", "Yes" };

typedef complex<int> point;

int main() {
    int n;
    while (cin >> n && n){
        string s; cin >> s;
        vi a(n), b(n);
        rep(i, n){
            cin >> a[i] >> b[i];
            a[i]--; b[i]--;
        }
        reverse(all(a));
        reverse(all(b));
        rep(i,n){
            swap(s[a[i]], s[b[i]]);
            s[a[i]] = (s[a[i]] - 'a' + (b[i] - a[i]) + 26) % 26 + 'a';
            s[b[i]] = (s[b[i]] - 'a' + (b[i] - a[i]) + 26) % 26 + 'a';
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

//b以上の最初の要素の位置を返す。ない場合は-1
//vはソート済であること。あと、&v でなくvだと引数コピーが発生するので遅い。
//戻り値は b未満の要素の数である。
int lbound(vector<long long>&v, long long b){
	int s = 0, e = v.size() - 1;
	int l = v.size();
	int m;
	while(e - s > 1){
		m = (s + e) / 2;
		if(v[m] >= b){
			e = m;
		}
		else{
			s = m;
		}
	}
	if(v[max(s - 1, 0)] >= b) return max(s - 1, 0);
	else if(v[s] >= b) return s;
	else if(v[min(s + 1, l - 1)] >= b) return min(s + 1, l - 1);
	else return -1;
}

//bより大きいの最初の要素の位置を返す。ない場合は-1
//vはソート済であること。あと、&v でなくvだと引数コピーが発生するので遅い。
//戻り値は b以下の要素の数である。
int ubound(vector<long long>&v, long long b){
	int s = 0, e = v.size() - 1;
	int l = v.size();
	int m;
	while(e - s > 1){
		m = (s + e) / 2;
		if(v[m] <= b){
			s = m;
		}
		else{
			e = m;
		}
	}
	if(v[max(s - 1, 0)] > b) return max(s - 1, 0);
	else if(v[s] > b) return s;
	else if(v[min(s + 1, l - 1)] > b) return min(s + 1, l - 1);
	else return -1;
}

long long N, M;

vector<pair<long long, long long>> V; // (金額,　日数)
map<long long, vector<long long>> MP;  //(日数, vector<金額>)
vector<long long> D; //vector<distinct(日数)>
map<long long, int> MONEY; //ワーク用、金額を入れていく。

long long getMaxMoney(){
	long long ret = 0;
	long long m;
	int d;
	if(MONEY.size() == 0){
		return 0;
	}
	else if(MONEY.size() == 1){
		auto itr = MONEY.begin();
		m = itr->first;
		d = itr->second;
		if(d > 0){
			ret = m;
			MONEY[m]--;
			if(MONEY[m] == 0){
				MONEY.erase(itr); //itr = MONEY.end()のはず
			}
		}
	}
	else{
		for(auto itr = MONEY.crbegin(); itr != MONEY.crend(); itr++){
			m = itr->first;
			d = itr->second;
			if(d == 0){
				continue;
			}
			if(d > 0){
				ret = m;
				MONEY[m]--;
				if(MONEY[m] == 0){
					MONEY.erase(MONEY.find(m));
				}
			}
			break;
		}
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> M ;
	for(int i=0; i<N; i++){
		long long a, b;
		cin >> a >> b; //日数, 金額
		pair<long long, long long> p = make_pair(b, a);
		V.push_back(p);
	}
	sort(V.begin(), V.end());

	for(int i=0; i<N; i++){
		pair<long long, long long> p = V[i];
		long long m = p.first;
		long long d = p.second;
		MP[d].push_back(m);
	}

	for(auto itr = MP.begin(); itr !=MP.end(); itr++){
		long long d = itr->first;
		D.push_back(d);
	}

	//M日後から逆にたどる
	//M日後のi日前に受けるバイトは、i日以下の日数で金額が最大のもの
	long long ans = 0;
	int dp[100002] = {0};
	for(int i=1; i<=M; i++){
		long long d = ubound(D, i);
		if(d == 0) continue;
		if(d < 0){
			d = D.size();
		}

		vector<long long> &v = MP[D[d - 1]];
		if(dp[D[d - 1]] == 0){
			for(int j=0; j<v.size(); j++){
				long long w = v[j];
				if(MONEY.count(w)==0){
					MONEY[w] = 1;
				}
				else{
					MONEY[w]++;
				}
			}
		}
		ans += getMaxMoney();
		dp[D[d - 1]] = 1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

string SA, SB, SC;

signed main() {
    cin >> SA >> SB >> SC;
    char next = 'a';
    int a = 0, b = 0, c = 0;
    while (true) {
        if (next == 'a') {
            if (a == SA.length()) {
                cout << "A" << endl;
                return 0;
            }
            next = SA[a];
            a++;
        } else if (next == 'b') {
            if (b == SB.length()) {
                cout << "B" << endl;
                return 0;
            }
            next = SB[b];
            b++;
        } else {
            if (c == SC.length()) {
                cout << "C" << endl;
                return 0;
            }
            next = SC[c];
            c++;
        }

    }
}

Measured memory_bytes: 256
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n,w = map(int,input().split()) #n:頂点数　w:辺の数

d = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(w):
    x,y,z = map(int,input().split())
    d[x][y] = z 
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
distance=warshall_floyd(d)

for i in range(n):
    if distance[i][i]<0:
        print('NEGATIVE CYCLE')
        exit()
for i in distance:
    i=['INF' if x==float('inf') else x for x in i]
    print(*i)


Measured memory_bytes: 6564
#include <bits/stdc++.h>
     
    using namespace std;
     
    using int64 = long long;
     
    int main() {
      int H, W, V[500][500];
      cin >> H >> W;
      for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
          cin >> V[i][j];
        }
      }
      vector< tuple< int, int, int, int > > tt;
      for(int i = H - 1; i >= 0; i--) {
        if(i % 2 == 0) {
          for(int j = 0; j < W; j++) {
            if(V[i][j] % 2 == 1) {
              V[i][j]--;
              if(j + 1 == W) {
                if(i > 0) {
                  tt.emplace_back(i, j, i - 1, j);
                  V[i - 1][j]++;
                }
              } else {
                tt.emplace_back(i, j, i, j + 1);
                V[i][j + 1]++;
              }
            }
          }
        } else {
          for(int j = W - 1; j >= 0; j--) {
            if(V[i][j] % 2 == 1) {
              V[i][j]--;
              if(j == 0) {
                if(i > 0) {
                  tt.emplace_back(i, j, i - 1, j);
                  V[i - 1][j]++;
                }
              } else {
                tt.emplace_back(i, j, i, j - 1);
                V[i][j - 1]++;
              }
            }
          }
        }
      }
      cout << tt.size() << endl;
      for(auto &p : tt) {
        int a, b, c, d;
        tie(a, b, c, d) = p;
        cout << a + 1 << " " << b + 1 << " " << c + 1 << " " << d + 1 << endl;
      }
    }

Measured memory_bytes: 5104
N, K, L = gets.split.map(&:to_i)

road = [*0..N]
road_r = Array.new(N + 1) { 1 }

rail = [*0..N]
rail_r = Array.new(N + 1) { 1 }

def root uf, i
  uf[i] == i ? i : uf[i] = root(uf, uf[i])
end

def set_union_find n, uf, rank
  n.times do
    x, y = gets.split.map(&:to_i)
    x = root(uf, x)
    y = root(uf, y)

    next if x == y

    if rank[x] > rank[y]
      uf[y] = x
    else
      uf[x] = y
      rank[y] += 1 if rank[x] == rank[y]
    end
  end
end

set_union_find K, road, road_r
set_union_find L, rail, rail_r

h = Hash.new {|h, k| h[k] = [] }
(1..N).each do |i|
  h[[root(road, i), root(rail, i)]] << i
end

result = Array.new(N + 1) { 0 }
h.values.each do |arr|
  arr.each do |j|
    result[j] = arr.size
  end
end

puts (1..N).map {|i| result[i] }.join(' ')

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

int main()
{
    int A,B,flag=0;
    cin>>A;
    cin>>B;

    for(int i=0;i<A||i<B;i++)
    {
        if(abs(A-i)==abs(B-i))
        {
            flag=1;
            cout<<i<<endl;
            break;
        }
    }
    if(flag==0)
        cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;
int dp[1<<26];

int solve() {
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    const int n = (int)s.size();
    int b = 0;
    int ret;
    for (int i = 1; i <= n; i++) {
        b ^= (1<<(s[i-1]-'a'));
        int res = inf;
        for (int j = 0; j <= 25; j++) {
            int c = b ^ (1<<j);
            if (dp[c] >= 0) {
                res = min(res, dp[c]+1);
            }
        }
        if (dp[b] >= 0) {
            res = min(res, dp[b]+1);
        }
        dp[b] = min((dp[b]<0?inf:dp[b]), res);
        ret = res;
    }
    
    return ret;
}

void input() {
    cin >> s;
}

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

    input();
    cout << solve() << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int d;
	cin >> d;
	vector<int> c(26);
	for (int i = 0 ; i < 26 ; i++) {
		cin >> c[i];
	}
	vector<vector<int>> s(d, vector<int>(26));
	for (int i = 0 ; i < d ; i++) {
		for (int j = 0 ; j < 26 ; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 0 ; i < d ; i++) {
		int choice = i % 26 + 1;
		cout << choice << "\n";
	}

	return 0;
}


Measured memory_bytes: 3712
import sys
import math

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def main():
    N = ii()
    A = list(mi())
    for i in range(N):
        A[i] -= i+1
    median = sorted(A)[N//2]
    print(sum(abs(A[i]-median) for i in range(N)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 104380
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n;
	cin>>n;
	if(n%2==0){
		cout<<n/2-1<<endl;
	}else{
		cout<<n/2<<endl;
	}
	return 0;
}

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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}

int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    string s;
    ll q;
    cin >> s;
    cin >> q;
    vector<char>* front;
    vector<char>* back;
    vector<char>* tmp;
    front = new vector<char>();
    back = new vector<char>();
    ll cnt=0;

    rep(i,q){
        ll t;
        cin >> t;
        if(t==1){
            tmp = front;
            front = back;
            back =tmp;
            cnt++;
        }else{
            ll f;
            char c;
            cin >> f >> c;
            if(f==1){
                front->push_back(c);
            }else{
                back->push_back(c);
            }
        }
    }
    
    if(cnt%2)
        reverse(s.begin(),s.end());

    reverse(front->begin(),front->end());

    for(char c : *front){
        cout << c;
    }

    for(char c : s){
        cout << c;
    }

    for(char c : *back){
        cout << c;
    }

    cout << endl;

    delete front;
    delete back;
	return 0;
}



Measured memory_bytes: 976
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
 
int main() {
    int x,a,b;
    cin  >> x >> a >> b;
    x -= a;

    cout << x%b << '\n';
}

Measured memory_bytes: 256
/**
*   author:  akifpathan
*   created: Sunday 13.09.2020 03:56:48 PM
**/

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const ll base=31;

ll ara[6000],power[6000];

void solve()
{
	int n;
	cin>>n;
	
	string s;
	cin>>s;
	
	s='.'+s;
	
	power[0]=1LL;
	for(int i=1;i<=n;i++) power[i]=power[i-1]*base;
	
	for(int i=1,j=n-1;i<=n;i++,j--)
	{
		ara[i]=ara[i-1]+power[j]*s[i];
	}
	
	int ans=0;
	
	for(int i=1;i<=n/2;i++)
	{
		map<ll,vector<int>>indx;
		
		for(int j=1;i+j-1<=n;j++)
		{
			ll temp=ara[i+j-1]-ara[j-1];
			temp*=power[j-1];
			
			indx[temp].push_back(j);
		}
		
		for(auto it: indx)
		{
			if(it.second.size()>=2)
			{
				if(it.second[0]+i<=it.second.back()) ans=i;
			}
		}
	}
	
	cout<<ans;
	
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int testcase=1;
	//cin>>testcase;
	
	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}



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

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        c_ij = 0
        c_ji = 0
        for k in range(1, n + 1):
            temp = str(k)
            if temp[0] == str(i) and temp[-1] == str(j):
                c_ij += 1
            if temp[0] == str(j) and temp[-1] == str(i):
                c_ji += 1
        ans += c_ij * c_ji
print(ans)


Measured memory_bytes: 47204
N = int(input())
dp = [[0]*3 for i in range(N)]
dp[0] = list(map(int,input().split()))
for i in range(1,N):
    a,b,c = map(int,input().split())
    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a
    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b
    dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c
print(max(dp[N-1]))

Measured memory_bytes: 22772
#include <iostream>
#include <vector>
#include <set>
using namespace std;

vector <int> neigh[100000];

bool passed[100000] = { 0 };

vector <int> path;

void dfs(int p) {
	passed[p] = 1;
	path.push_back(p);
	for(int i = 0; i < neigh[p].size(); i++) {
		if(!passed[neigh[p][i]]) {
			dfs(neigh[p][i]);
			return;
		}
	}
}

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

	int n, m;
	cin >> n >> m;

	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		neigh[a - 1].push_back(b - 1);
		neigh[b - 1].push_back(a - 1);
	}

	dfs(0);

	vector <int> p1 = path;
	path = vector <int> ();

	dfs(0);

	cout << p1.size() + path.size() - 1 << '\n';

	for(int i = 0; i < path.size() - 1; i++) {
		cout << path[path.size() - 1 - i] + 1 << ' ';
	}

	for(int i = 0; i < p1.size(); i++) {
		cout << p1[i] + 1 << ' ';
	}

	return 0;
}


Measured memory_bytes: 9744
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    char c[4];
    for(int i=0;i<4;i++)
        cin >> c[i];
     
    sort(c, c + 4);

    if(c[0] == c[1] && c[1] != c[2] && c[2] == c[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gz[2005][2005],heng[2005][2005],shu[2005][2005],a[2005][2005];
int main(int argc, char** argv) {
	int n,m,q;
	ios::sync_with_stdio(false);
	cin >> n >> m >> q;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			char c;
			cin >> c;
			if(c-48) a[i][j]=1;
			gz[i][j]=gz[i-1][j]+gz[i][j-1]-gz[i-1][j-1]+a[i][j];
			heng[i-1][j]=heng[i-2][j]+heng[i-1][j-1]-heng[i-2][j-1]+(a[i][j]==a[i-1][j]&&a[i][j]==1),shu[i][j-1]=shu[i-1][j-1]+shu[i][j-2]-shu[i-1][j-2]+(a[i][j]==a[i][j-1]&&a[i][j]==1);
		}
	}
	while(q--)
	{
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		cout << gz[c][d]-gz[a-1][d]-gz[c][b-1]+gz[a-1][b-1]-heng[--c][d]+heng[a-1][d]+heng[c][b-1]-heng[a-1][b-1]-shu[++c][--d]+shu[a-1][d]+shu[c][b-1]-shu[a-1][b-1] << "\n";
	}
	return 0;
}
//dlstxdy!

Measured memory_bytes: 64640
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    ll x,c=0;
    cin>>x;
    ll m=100;
    while (m<x){
        m=m+(ll)(m*(1/(double)100));
        c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main(void)
{
	int p[10],s,i,j;
	scanf("%d%d%d",&p[0],&p[1],&p[2]);
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			if(p[i]<p[j]){
				s=p[i];
				p[i]=p[j];
				p[j]=s;
			}
		}
	}
	printf("%d\n",p[0]+p[1]);
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  vi a(n), o(n);
  rep(i, n){
    cin >> a[i];
    o[a[i]-1] = i;
  }

  set<int> s;
  s.insert(-1);
  s.insert(n);

  ll ans = 0;
  rep(i, n){
    auto itr = s.lower_bound(o[i]);
    ll r = *itr - o[i];
    itr--;
    ll l = o[i] - *itr;
    ans += a[o[i]]*l*r;
    s.insert(o[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;

int main(void){
	int a, b;
	cin.tie(0);

	cin >> a >> b;

	if (a > 0 && b > 0) {
		cout << "Positive\n";
	} else if (b >= 0 && a < 0) {
		cout << "Zero\n";
	} else if (b < 0 && (b - a + 1) % 2 == 1) {
		cout << "Negative\n";
	} else if (b < 0 && (b - a + 1) % 2 == 0) {
		cout << "Positive\n";
	}
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
D=[]
for i in range(N-1):
  if A[i]<A[i+1]:
    D.append((A[i],A[i+1]))
if len(D)==0:
  print(1000)
  exit()
money=1000
for a,b in D:
  k=money//a
  nokori=money-a*k
  money=nokori+k*b
print(money)

Measured memory_bytes: 9196
n, m = gets.split(" ").map(&:to_i)

s = []
k = []
m.times do |i|
  s[i] = gets.split(" ").map(&:to_i)
  s[i].length.times do |j|
    s[i][j] -= 1
  end
  k[i] = s[i].shift
end

p = gets.split(" ").map(&:to_i)

ans = 0
(1 << n).times do |i|
  #denkyu check
  m.times do |j|
    on = 0
    s[j].length.times do |k|
      on += 1 if 1 << s[j][k] & i > 0
    end
    break if on %2 != p[j]
    ans += 1 if j == m-1
  end
end

puts ans


Measured memory_bytes: 1788
#include<stdio.h>

#define N 100000
#define NIL -1

int depth(int);
int height(int);

struct Node{
    int pa;
    int le;
    int ri;
};

struct Node Te[N];

int main(){
  int n,i,id;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    Te[i].pa=Te[i].le=Te[i].ri=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&Te[id].le,&Te[id].ri);
    if(Te[id].le!=NIL) Te[Te[id].le].pa=id;
    if(Te[id].ri!=NIL) Te[Te[id].ri].pa=id;
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = ",i,Te[i].pa);
    if(Te[i].pa==NIL) printf("-1, ");
    else{
      if(Te[Te[i].pa].le==i) printf("%d, ",Te[Te[i].pa].ri);
      else printf("%d, ",Te[Te[i].pa].le);
      }
      printf("degree = ");
      if(Te[i].le==NIL && Te[i].ri==NIL) printf("0, ");
      else{
        if(Te[i].le!=NIL && Te[i].ri!=NIL) printf("2, ");
        else printf("1, ");
      }
      printf("depth = %d, height = %d, ",depth(i),height(i));
        if(Te[i].pa==NIL) printf("root");
        else{
          if(Te[i].le==NIL && Te[i].ri==NIL) printf("leaf");
          else printf("internal node");
        }
        printf("\n");
      }
      return 0;
    }

int depth(int x){
  if(Te[x].pa==NIL) return 0;
  return depth(Te[x].pa)+1;
}

int height(int x){
  int left=0,right=0;
  if(Te[x].le==NIL && Te[x].ri==NIL) return 0;
  if(Te[x].le!=NIL) left=height(Te[x].le)+1;
  if(Te[x].ri!=NIL) right=height(Te[x].ri)+1;
  if(left>right) return left;
  else return right;
}

Measured memory_bytes: 604
#include <stdio.h>

int main(void)
{
    int s[13]={0}, h[13]={0}, c[13]={0}, d[13]={0}, n, i, temp;
    char ch;

    scanf("%d", &n);

    for(i=0;i<n;i++) {
        scanf(" %c %d", &ch, &temp);
        switch(ch) {
            case 'S':
                s[temp -1]=1;
                break;
            case 'H':
                h[temp-1]=1;
                break;
            case 'C':
                c[temp-1]=1;
                break;
            case 'D':
                d[temp-1]=1;
                break;
        }
    }
    for(i=0;i<13;i++) {
        if(s[i]==0)
            printf("S %d\n", i+1);
    }
    for(i=0;i<13;i++) {
        if(h[i]==0)
            printf("H %d\n", i+1);
    }
    for(i=0;i<13;i++) {
        if(c[i]==0)
            printf("C %d\n", i+1);
    }
    for(i=0;i<13;i++) {
        if(d[i]==0)
            printf("D %d\n", i+1);
    }
    return 0;
}

Measured memory_bytes: 2660
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ins = sc.nextLine().split(" ");
        int n = Integer.parseInt(ins[0]);
        int d = Integer.parseInt(ins[1]);
        List<List<Integer>> locations = new ArrayList<>();
        for(int i = 0;i < n;i++){
            String[] locs = sc.nextLine().split(" ");
            List<Integer> loc1 = new ArrayList<>();
            for(String loc : locs){
                loc1.add(Integer.parseInt(loc));
            }
            locations.add(loc1);
        }
        int r = 0;
        for(int i = 0;i < locations.size();i++){
            for(int j = i; j < locations.size();j++){
                double calc = 0;
                for(int k = 0;k < d;k++){
                    double o = locations.get(i).get(k) - locations.get(j).get(k);
                    calc += o * o;
                }
                calc = Math.sqrt(calc);
                if ((calc == Math.floor(calc)) && calc != 0) {
                    r++;
                }
            }
        }
        System.out.println(r);
    }
}

Measured memory_bytes: 23252
import itertools
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
sum=[0]*m
for i in range(n):
  for j in range(1,m+1):
    sum[j-1]+=l[i][j]
for ss in sum:
  if ss<x:
    print(-1)
    exit()
list=[]
for p in itertools.product([1,0],repeat=n):
  cnt=[0]*m
  ans=0
  for i in range(n):
    if p[i]==1:
      ans+=l[i][0]
      for j in range(1,m+1):
        cnt[j-1]+=l[i][j]
  if all(cc>=x for cc in cnt):
    list.append(ans)
print(min(list))

Measured memory_bytes: 9272
function main(input) {
  const i = input.split('\n');
  const n = parseInt(i[0]);
  const map = new Map();
  for (let k = 1; k < n+1; k++) {
  	if (!map.get(i[k])) map.set(i[k], 1);
    else map.set(i[k], map.get(i[k]) + 1);
  }
  console.log(map.size);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 60460
/*
g++ -std=c++11 -o2 -Wall ABC111C.cpp -o .\out\ABC111C.out
.\out\ABC111C.out
*/

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

typedef long long ll;

pair<int, int> a[100005];
pair<int, int> b[100005];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i){
    int c;
    cin >> c;
    if (i % 2 == 0) {
      a[c] = make_pair(a[c].first+1, c);
    } else {
      b[c] = make_pair(b[c].first+1, c);;
    }
  }
  sort(begin(a), end(a));
  sort(begin(b), end(b));
  int ans = 0;
  if (a[100004].second != b[100004].second) {
    ans = (n - a[100004].first - b[100004].first);
  } else {
    ans = min((n - a[100003].first - b[100004].first), (n - a[100004].first - b[100003].first));
  }
  cout << ans << "\n";
}


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

using namespace std;

int main()
{
    string s,t;
    int c=0,i;
    cin>>s;
    cin>>t;
    int n=s.length();
    for(i=0;i<s.length();i++){
        if(s[i]!=t[i])
        c++;
    }
    cout<<c<<endl;

    
}

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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	


int main(){
	int n;
	
	cin >> n; 
	
	
	vi v(n);
	
	f(i,0,n){
		cin >> v[i];
	}
	
	sort(all(v)); 
	
	cout << v[n-1] - v[0] << endl;
	

    return 0;
}


Measured memory_bytes: 256
s = list(input())
x, y = map(int, input().split())

x_move = [0]
y_move = []
mode = 0
p = 0
q = -1
for c in s:
    if mode == 0:
        if c == 'F':
            x_move[p] += 1
        if c == 'T':
            mode = 1
            y_move.append(0)
            q += 1
    elif mode == 1:
        if c == 'F':
            y_move[q] += 1
        if c == 'T':
            mode = 0
            x_move.append(0)
            p += 1

temp_x = [x_move[0]]
for i in range(1, len(x_move)):
    next_x = []
    for temp in temp_x:
        next_x.append(temp - x_move[i])
        next_x.append(temp + x_move[i])
    temp_x = [] + list(set(next_x))

if x not in temp_x:
    print('No')
    exit()

temp_y = [0]
for i in range(len(y_move)):
    next_y = []
    for temp in temp_y:
        next_y.append(temp - y_move[i])
        next_y.append(temp + y_move[i])
    temp_y = [] + list(set(next_y))

if y not in temp_y:
    print('No')
    exit()

print('Yes')



Measured memory_bytes: 4092
# coding:utf-8

K, A, B = [int(i) for i in input().split()]

def cal(K, A, B):
    BNUM = 1
    TRANS_GET = B - A
    # 操作開始
    counter = 0
    while counter < K:
        nokori = K - counter
        if BNUM >= A:
        # 交換可能
            if nokori >= 2:
                syou = int(nokori / 2)
                BNUM += TRANS_GET * syou
                counter += syou * 2
            else:
                # 叩く
                BNUM += 1
                counter += 1
        else:
        # 交換不可
            atonanko = A - BNUM
            if atonanko <= nokori-2:
                BNUM += atonanko
                counter += atonanko
            else:
                BNUM += nokori
                break
    return BNUM


if B - A <= 2:
    max_b = 1 + K
else:
    max_b = cal(K, A, B)

print(max_b)

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(B<=C){
    cout << 0 << endl;
  }
  else if(D<=A){
    cout << 0 << endl;
  }
  else if(A<=C && B<=D){
    cout << B-C << endl;
  }
  else if(C<=A && B<=D){
    cout << B-A << endl;
  }
  else if(A<=C && D<=B){
    cout << D-C << endl;
  }
  else{
    cout << D-A << endl;
  }
}
  

Measured memory_bytes: 256
#!/usr/bin/ruby                                                                                                                                   
# -*- coding: utf-8 -*-                                                                                                                           

gets.chomp.chars{|c|
  23.times {
    if (c == 'Z')
      c = 'A'
    else
      c.next!
    end
  }
  print c
}
puts ""

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> c(M),dp(N+1,12345678);
    for(int i = 0; i < M; ++i) cin >> c[i];
    dp[0] = 0;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < M; ++j){
            if(i+c[j]<=N) chmin(dp[i+c[j]],dp[i]+1);
        }
    }
    cout << dp[N] << endl;

    return 0;
}



Measured memory_bytes: 3196
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a+b == c){
			System.out.println("Yes");
		}else if(a+c == b){
			System.out.println("Yes");
		}else if(b+c == a){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

int main(){
    vector<int> A(5,0);
    vector<int> B(5,0);
    int rec,max,sum;
    
    for(int i = 0;i < 5;i++){
        cin >> A[i];
    }

    for(int j = 0;j < 5;j++){
        if(A[j]%10 != 0){B[j] = abs(A[j] % 10 - 10);}
        if(max <= B[j]){
            max = B[j];
            rec = j;}
    }

for(int h = 0;h < rec;h++){
sum = sum + A[h] + B[h];
}

for(int n = rec + 1;n < 5;n++){
sum = sum + A[n] + B[n];
}

cout << sum + A[rec] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
using namespace std;
const int N = 2e5+5;
typedef long long ll;
ll a[N],n;
ll ans;
map<ll,ll>mp;
int main()
{
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	map<ll,ll>::iterator it;
	for(it=mp.begin();it!=mp.end();it++)
	ans+=it->second*(it->second - 1)/2;
	for(ll i=0;i<n;i++)
	{
		ll t=mp[a[i]];
		cout<<ans-t*(t-1)/2+(t-1)*(t-2)/2<<endl;
	}
	return 0;	
}

Measured memory_bytes: 11008
#include <stdio.h>

int
main(void)
{
    int x, y;
    while (scanf("%d %d", &x, &y) && (x || y))
        if (x <= y)
            printf("%d %d\n", x, y);
        else
            printf("%d %d\n", y, x);
    
    return 0;
}


Measured memory_bytes: 2044
n, m = map(int, input().split())
a_list = input().split()
a_sum = 0
for i in range(len(a_list)):
    a_list[i] = int(a_list[i])
    a_sum += a_list[i]
a_list.reverse()
 
ok_num = 0
kijyun = int(a_sum/(4*m))
if a_sum % (4*m) == 0:
    kijyun -= 1
for i in a_list:
    if i > kijyun:
        ok_num += 1
    if ok_num == m:
        print('Yes')
        quit()
print('No')
 

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

typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll x;

    cin >> x;

    cout << (x < 1200 ? "ABC" : "ARC") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

void solve(){
    int n;
    cin>>n;
    vi a(n);
    vi pre(n);
    cin>>a[0];
    pre[0]=a[0];
    rep(i,1,n){
        cin>>a[i];
        pre[i]=(a[i]+pre[i-1])%modF;
    }
    int ans=0;
    rep(i,0,n){
        ans=(ans+(a[i]*(pre[n-1]-pre[i]+modF))%modF)%modF;
    }
    cout<<ans<<ln;
}

signed main(){
	boost_io;
	solve();
	return 0;
}


Measured memory_bytes: 6336
N, x = map(int,input().split())
a = list(map(int,input().split()))
b = [a[i] + a[i+1] for i in range(N-1)]
ans = 0
for i in range(N-2):
    if b[i] > x:
        temp = min(b[i] - x, a[i+1])
        ans += temp
        b[i] -= temp
        b[i+1] -= temp
for i in range(N-1):
    if b[i] > x:
        ans += b[i] - x
print(ans)

Measured memory_bytes: 14548
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    vector<int> H(2);
    vector<int> S(2);
    cin >> H[0] >> S[0] >> H[1] >> S[1];

    int turn = 0;

    while (true) {
        int me = turn;
        int other = turn ^ 1;
        H[other] -= S[me];
        if (H[other] <= 0) {
            break;
        }
        turn = other;
    }

    if (H[0] > 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

s=input()
for i in range(3):
    if s[i]==s[i+1]:
        print("Bad")
        exit()
print("Good")

Measured memory_bytes: 3420
//============================================================================
// Name        : AOJ.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){

	int a,b;
	int e=0,f=0,g=0;
	int max=-100000000000000000;

	cin>>a;
	cin>>b;

	e=a+b;
	f=a-b;
	g=a*b;

	if(max<e){
		max=e;
	}
	if(max<f){
		max=f;
	}
	if(max<g){
		max=g;
	}

	cout<<max<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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


int main()
{
	string s;

	cin >> s;

	if(s.size() == 2){
		if(s[0] == s[1])cout << 1 << ' ' << 2 << endl;
		else cout << -1 << ' ' << -1 << endl;
		return 0;
	}

	map<char, int> m;
	m[s[0]]++;
	m[s[1]]++;
	m[s[2]]++;
	for(auto x : m){
		if(x.second > 1){
			cout << 1 << ' ' << 3 << endl;
			return 0;
		}
	}

	for(int i = 3; i < s.size(); i++){
		m[s[i]]++;
		m[s[i - 3]]--;
		for(auto x : m){
			if(x.second > 1){
				cout << i - 1 << ' ' << i + 1 << endl;
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 640
a = list(map(int,input().split()))
#print(a[0])
xy = [map(int, input().split()) for _ in range(a[0])]
x, y = [list(i) for i in zip(*xy)]
b=len(x)
#print(b)
#print(x)
#print(y)
cnt = 0
for i in range(b):
   if(x[i]*x[i]+ y[i]*y[i] <= a[1]*a[1]):
              cnt+=1

print(cnt)

Measured memory_bytes: 116608
let rec sum_k acc k ls =
  match k, ls with
  | 0, _ -> acc
  | _, [] -> acc
  | k, l::ls -> sum_k (l + acc) (k - 1) ls

let right (_, r) = r

let _ =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
  let xs = ref [] in
  let max_m, min_m = ref min_int, ref max_int in
  for i = 0 to m - 1 do
    Scanf.scanf (if i <> m - 1 then "%d " else "%d\n") (fun x -> xs := x::!xs);
    max_m := max !max_m (List.hd !xs);
    min_m := min !min_m (List.hd !xs)
  done;
  !xs
  |> List.sort compare
  |> (fun xs -> List.fold_left (fun (prev, acc) x -> (x, (x - prev)::acc)) 
                  (List.hd xs, []) @@ List.tl xs)
  |> right
  |> List.sort (fun x y -> 1 - (compare x y))
  |> sum_k 0 (n - 1)
  |> (fun ls -> (!max_m - !min_m) - ls)
  |> print_int

Measured memory_bytes: 10784
A,B,C = map(int,input().split())
a,b,c, = A%2,B%2,C%2
oe = (a+b+c)%2
M = max(A,B,C)
if M%2 == oe:
  print((3*M-A-B-C)//2)
else:
  print((3*(M+1)-A-B-C)//2)

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A=factorization(N)
P=[row[1] for row in A]
if A[0][0]==1:
    print(0)
    exit()

ans=0

for i in range(len(P)):
    c=1
    while P[i]>=c:
        P[i]-=c
        c+=1
        ans+=1

print(ans)

Measured memory_bytes: 9508
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        Set<Integer> s = new HashSet<Integer>();
        s.add(a);
        s.add(b);
        s.add(c);
        System.out.println(s.size());
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll n,b[222222];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  sort(b,b+n);
  vector<ll> a;
  vector<ll> cnt;
  for(int i=0;i<n;){
    int k=0;
    while(1){
	 if(i+k>=n)break;
	 if(b[i]!=b[i+k])break;
	 k++;
    }
    a.push_back(b[i]);
    cnt.push_back(k);
    i+=k;
  }
  n=a.size();
  ll ans=0;
  for(ll i=n-1;i>=0;i--){
    //cout<<a[i]<<" "<<cnt[i]<<endl;
    if(cnt[i]==0)continue;
    vector<ll> v;
    ll t=a[i];
    //cout<<"t "<<t<<endl;
    while(t){
	 v.push_back(t%2);
	 t/=2;
    }
    // for(int j=0;j<v.size();j++)cout<<"v "<<v[j]<<endl;
    int l=v.size();
    for(int j=(int)v.size()-1;j>=0;j--){
	 if(v[j]==0)break;
	 l--;
    }
    ll k=0;
    for(ll j=0;j<l;j++){
	 if(k==0&&v[j])k+=pow(2LL,j);
	 if(k&&v[j]==0)k+=pow(2LL,j);
    }
    //cout<<k<<endl;
    if(k==0&&v.size()==l+1){
	 ans+=cnt[i]/2;
	 continue;
    }
    if(k==0)k=pow(2LL,l);
    // cout<<k<<endl;
    ll ok=0,ng=n,mid;
    while(ng-ok>1){
	 mid=(ok+ng)/2;
	 if(a[mid]<=k)ok=mid;
	 else ng=mid;
    }
    if(a[ok]==k){
	 ans+=min(cnt[ok],cnt[i]);
	 cnt[ok]=max(0LL,cnt[ok]-cnt[i]);
    }
  } 
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5220
#include <iostream>
#include <algorithm>
#define N 10000
using namespace std;
int main(){
  int i,j,n,need[N],wait[N];
  long long sum;
  while(1){
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> need[i];
    }
    for(i=0;i<n;i++){
      for(j=1;j<n;j++){
	if(need[j]<need[j-1]) swap(need[j],need[j-1]);
      }
    }
    sum=0;
    wait[0]=0;
    for(i=1;i<n;i++){
      wait[i]=need[i-1]+wait[i-1];
      sum+=wait[i];
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int [] a = new int [n];
    int ansMin=0;
    int ansMax = 0;
    int sum = 0;
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
      sum += a[i];
    }
    int num = sum / n ;
    for(int i = 0; i < n; i++){
      ansMin += (num-a[i]) * (num-a[i]);
    }
    for(int i = 0; i < n; i++){
      ansMax += (num+1-a[i]) * (num+1-a[i]);
    }
    if(ansMin < ansMax) System.out.println(ansMin);
    else System.out.println(ansMax);
  }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll gcd(ll x, ll y) { return (y ? gcd(y, x % y) : x); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	init();

	int N; cin >> N;
	vector<int>a(N);
	for (auto& v : a)cin >> v;
	int four = 0, num = 0;
	bool is = false;
	rep(i, 0, N) {
		if (a[i] % 4 == 0)four++;
		else if (a[i] % 2 == 0)is = true;
		else num++;
	}
	if (is) {
		if (four >= num)cout << "Yes" << "\n";
		else cout << "No" << "\n";
	}
	else {
		if (four + 1 >= num)cout << "Yes" << "\n";
		else cout << "No" << "\n";
	}

	return 0;
}

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

const int N = 100 + 5;
const int M = 1e5 + 5;
int n, we;
ll w[N], v[N];
ll dp[N][M];

ll solve(int idx, int weight) {
    if (weight < 0)
        return -1e15;
    if (idx == n)
        return 0;
    if (dp[idx][weight] != -1)
        return dp[idx][weight];
    return dp[idx][weight] = max(solve(idx + 1, weight), v[idx] + solve(idx + 1, weight - w[idx]));

}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> we;
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0, we);
    return 0;
}


Measured memory_bytes: 82304
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  vector<P> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p.begin(), p.end());

  int c = 0;
  for (int i = 0; i < n; i++) {
    if (p[i].second != i){
      c++;
    }
  }
  if (c == 2 || c == 0) {
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256