akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int X; cin>>X;
  YesNo(X >= 30);
  return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>

int answer (int a, int b){
	int solution[4];
	solution[0] = a*b;
	solution[1] = a-b;
	solution[2] = a+b;
	int ans = -2000;
	
	for(int i = 0 ; i < 3 ; i++){
		if(solution[i] > ans){
			ans = solution[i];
		}
	}
	
	return ans;
}

int main(){
	int a, b;
	scanf("%d %d", &a, &b); fflush(stdin);
	
	printf("%d", answer(a,b));
	
	return 0;
}

Measured memory_bytes: 128
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-03-07 20:56:36
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    string s;
    cin >> s;
    
    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x){cout << x << endl; exit(0);}
#define ll long long

int n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    vector <int> cnt(2);
    for(int i = 0 ; i < n ; i++){
        int x;
        cin >> x;
        cnt[x % 2]++;
    }
    if(cnt[1] % 2) cout << "NO\n";
    else cout << "YES\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;

bool sex[100000];

void input_sex(int n) {
	cout << n << endl;
	string str;
	cin >> str;
	if (str == "Male")sex[n] = true;
	else sex[n] = false;
}
int main() {
	int n;
	cin >> n;
	int lo, hi;
	string str;
	lo = 0, hi = n - 1;
	input_sex(n - 1);
	for (int i = 0; i<20; i++) {
		int mid;
		bool gyaku;
		mid = (lo + hi) / 2;
		input_sex(mid);
		bool flg = sex[mid];
		if ((hi - mid) % 2 == 1)flg = !flg;
		if (sex[hi] == flg)hi = mid;
		else lo = mid + 1;
	}

	return 0;
}


Measured memory_bytes: 852
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

#a = list(map(int, input().split()))

n,k = list(map(int, input().split()))
a = list(map(int, input().split()))

sums = [0 for i in range(n+1)]

for i in range(n):
    sums[i+1] = sums[i]+a[i]

mat = -1
for i in range(n-k+1):
    nowsum = -sums[i] + sums[i+k]
    #print(nowsum)
    if(nowsum>mat):
        mat = nowsum

print(mat/2+k/2)











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

int main()
{
    int n, k;
    cin >> n >> k;
    set<int> s;
    int d, r;
    for (int i = 0; i < k; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> r;
            s.insert(r);
        }
    }
    cout << n - s.size();
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp

void print_list(int a[], int n) {
    int i = 0;
    for (i = 0; i < n; i++) {
        printf("%d", a[i]);
        if (i == n - 1)
            printf("\n");
        else
            printf(" ");
    }
}

int main(int argc, char **argv) {
    int a[1024] = {0};
    int n = 0;
    int i = 0;
    int j = 0;
    int v = 0;
    scanf("%d", &n);
    // printf("n=%d\n", n);
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        // printf("%d\n", a[i]);
    }
    for (i = 1; i < n; i++) {
        print_list(a, n);
        v = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
    }
    print_list(a, n);
    return 0;
}


Measured memory_bytes: 2112
A,B,C = map(int,input().split())
list = [A, B, C]
list.sort(reverse = True)

a = list[0]
b = list[1]
c = list[2]
ans = (a -b) + (b-c)//2

if (b - c) % 2 == 0:
  print(ans)
else:
  ans += 2
  print(ans)


Measured memory_bytes: 3060
'use strict';

var hasN = true; // has N *only* line
var type = "a";
// a: 2D split
// b: space split
// c: line split
// z: other (only source)
function main(N, p, s) {
  // N, processed data, source
  var a = p[0].map(function (e, i) {
    return p[1][i] - p[0][i];
  }).filter(function (e) {
    return e < 0;
  }).reduce(function (p, c) {
    return p + c;
  }, 0);

  console.log(Math.abs(a));
}
function common(a) {
  var line = a.split('\n').slice(0, a.split('\n').length - 1);
  if (hasN) var N = Number(line.shift());
  switch (type) {
    case "a":
      main(N, line.map(function (e) {
        return e.split(' ').map(function (ee) {
          return Number(ee);
        });
      }), a);
      break;
    case "b":
      main(N, line[0].split(' ').map(function (e) {
        return Number(e);
      }), a);
      break;
    case "c":
      main(N, line, a);
      break;
    case "z":
      main(N, null, a);
  }
}
common(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
n,k = input().split()
k = int(k)
#print(n,k)
p = [int(s) for s in input().split()]
p.sort()
#print(p)
#print(k)
p2 = p[0:k]
#print(p2)
s = sum(p)
#print(s)
print(sum(p2))

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[105];
long long f[105][100005];
long long INF=1e9  +7;
long long sum[105][100005];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
	    scanf("%d",&a[i]);
	f[0][0]=1;
    for(int i=0;i<=k;++i)
       sum[0][i]=1;
	for(int i=1;i<=n;++i)
	{
		for(int j=0;j<=k;++j)
		{
			f[i][j]=sum[i-1][j] + INF; //a [i ] =2  j-1 j-2  
			if(j-a[i] > 0) f[i][j]-=sum[i-1][j-a[i]-1];
			f[i][j] %=INF;
			if(j>0) sum[i][j] = sum[i][j-1] +f[i][j];
			else sum[i][j]=f[i][j];
			sum[i][j] %=INF;
			//cout<<f[i][j]<<" "<<i<<" "<<j<<endl;
		}
	}
	printf("%lld\n",f[n][k]); 
	return 0;
}

Measured memory_bytes: 160700
from operator import mul
from functools import reduce

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 
N = 10**4
g1 = [1, 1]
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N_with_K = list(map(int, input().split()))
N = N_with_K[0]
K = N_with_K[1]


for i in range(K+1):
  if i == 0:
    pass
  else:
    post_pattern = cmb(N-K+1, i, mod)
    num_pattern =  cmb(K-1, i-1, mod)
    all_pattern = post_pattern * num_pattern
    print(all_pattern % mod)
 

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

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int last = scanner.nextInt();
        for (int i = 1; i < n; i++) {
            int h = scanner.nextInt();
            if (last <= h) {
                last = h;
            } else if (last <= h + 1) {
                last = h + 1;
            } else {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 40032
#include <stdio.h>

#define NMAX 100000
#define D(x,y) (pos[(x)]-pos[(y)])

long long A[NMAX];
long long pos[NMAX*2];
int N;
long long L;

long long solve() {
    long long max = 1;
    int p0 = 0, p1 = 1, p2 = 2;
    while (p0 < N) {
        while (p1 - p0 < N-1 && D(p1, p0) <= max) p1++;
        if (D(p1, p0) <= max) goto L1;

        while (p2 - p0 < N && D(p2,p1) < D(p1, p0)) p2++;
        if (D(p2, p1) < D(p1, p0)) goto L1;

        if (L - D(p2, p0) >= D(p1, p0)) {
            max = D(p1, p0);
            if (max >= L/3) return max;
            continue;
        }
L1:
        p0 += 1;
        while (D(p2, p1) > D(p1, p0)) p2--;
    }
    return max;
}

int main(void) {
    int i;
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
        L += A[i];
    }
    for (i = 0; i < 2*N; i++) {
        pos[i] = pos[i-1] + A[(i-1)%N];
    }
    printf("%lld\n", solve());
    return 0;
}

Measured memory_bytes: 5092
require "prime"

def get_lcm arr
    h = Hash.new(0)
    arr.each{|x| Prime.prime_division(x).each{|p, n| h[p] = n if h[p] < n}}
    lcm = 1
    h.to_a.each{|p, n| lcm *= (p ** n)}
    lcm
end

while true
    n = gets.to_i
    break if n == 0
    arr = []
    n.times{arr << gets.chomp.split.map(&:to_i)}
    arr2 = []
    arr.each{|d, v| arr2 << v}
    lcm = get_lcm(arr2)
    arr2 = []
    arr.each{|d, v| arr2 << lcm * d / v}
    lcm2 = get_lcm(arr2)
    arr.each{|d, v| puts lcm2 * v / d / lcm}
end



Measured memory_bytes: 7044
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll N;
  cin>>N;
  ll L[100];
  L[0]=2,L[1]=1;
  for(int i=2; i<=86; ++i){
  cin>>L[i];
  }
  for(int i=2; i<=86; ++i){
  L[i]=L[i-1]+L[i-2];
  }
  cout<<L[N]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;


inline int64 _5(int64 x) {
    return x*x*x*x*x;
}


int main() {
    int64 x;
    cin >> x;

    int64 a = -200;
    int64 b = -200;
    for (; a<=200; a++) {
        int64 a5 = _5(a);
        b = -200;
        int64 b5 = 0;
        for (; b<=200; b++) {
            b5 = _5(b);
            if (a5 - b5 == x) break;
        }
        if (a5 - b5 == x) break;
    }

    cout << a << " " << b << endl;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 200000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &x){
    x=0; 
    T f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-'){
            f=-1;
        }
        ch=getchar();
    }
    while(ch<='9' && ch>='0'){
        x=x*10+(ch-'0');
        ch=getchar();
    }
    x*=f;
}
string a,b;
int main(){
    cin>>a>>b;
    string s=a+b;
    ll pol=stoll(s);
    ll qwe=floor(sqrt(pol));
    if(qwe*qwe==pol){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

void solve() {
	LL N;
	cin >> N;
	string S;
	cin >> S;
	string base = "RGB";
	vector<vector<int>> A(3);
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'R') {
			A[0].push_back(i);
		}
		else if (S[i] == 'G') {
			A[1].push_back(i);
		}
		else {
			A[2].push_back(i);
		}
	}

	vector<int> sum(3);
	for (int i = 0; i < 3; ++i) {
		sum[i] = A[i].size();
	}
	int zenbu = sum[0] + sum[1] + sum[2];

	LL ans = 0;
	for (int Aind = 0; Aind < sum[0]; ++Aind) {
		for (int Bind = 0; Bind < sum[1]; ++Bind) {
			int a = A[0][Aind];
			int b = A[1][Bind];
			int C = sum[2];
			int haba = abs(b - a);
			vector<int>::iterator itr;
			itr = lower_bound(A[2].begin(), A[2].end(), min(a, b) - haba);
			if (itr!=A[2].end() && (*itr) == min(a, b) - haba) {
				C--;
			}
			itr = lower_bound(A[2].begin(), A[2].end(), max(a, b) + haba);
			if (itr != A[2].end() && (*itr) == max(a, b) + haba) {
				C--;
			}
			if (haba % 2 == 0) {
				itr = lower_bound(A[2].begin(), A[2].end(), min(a, b) + haba/2);
				if (itr != A[2].end() && (*itr) == min(a, b) + haba / 2){
					C--;
				}
			}
			ans += C;
		}
	}

	cout << ans << endl;
	return;
/*
	LL ans = N * (N - 1) * (N - 2) / 6;
	LL haba = 0;//幅でけずるやつ
	for (int i = 0; 3+i*2 <= N ; ++i) {
		int ter = 3 + i * 2;
		haba += (N-ter)+1;
	}
	ans -= haba;

	for (int i = 0; i < 3; ++i) {
		LL nokori = zenbu - sum[i];
		LL res = nokori * sum[i] * (sum[i] - 1)/2;
		for (int Aind = 0; Aind < sum[i] - 1; ++Aind) {
			for (int Bind = Aind + 1; Bind < sum[i]; ++Bind) {
				int a = A[i][Aind];
				int b = A[i][Bind];
				
				int haba = b - a;
				if (a - haba >= 0) {
					if (S[a - haba] != base[i]) {
						res--;
					}
				}
				if (b + haba < N) {
					if (S[b + haba] != base[i]) {
						res--;
					}
				}
				if (haba % 2 == 0) {
					if (S[a + haba / 2] != base[i]) {
						res--;
					}
				}

				int ter = b + haba;
				vector<int>::iterator itr;
				itr = lower_bound(A[i].begin(), A[i].end(), ter);
				if(itr!=A[i].end() && ((*itr)==ter)){
					res--;
				}
			}
		}
		ans -= res;
	}
	cout << ans << endl;
	*/
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

using namespace std;
int n,m,k,i,j,x,y,a[500005];
int tree[2000005];
queue <int>q[500005];
struct queries{
int l,r,poz,sol;
}v[500005];
bool cmp1(queries a,queries b)
{
    return a.l<b.l;
}
bool cmp2(queries a,queries b)
{
    return a.poz<b.poz;
}
void update(int nod,int st,int dr,int poz)
{
    if(st==dr)
        tree[nod]=1;
    else{
        int mij=(st+dr)>>1;
        if(poz<=mij)update(2*nod,st,mij,poz);
        else update(2*nod+1,mij+1,dr,poz);
        tree[nod]=tree[2*nod]+tree[2*nod+1];
    }
}
int query(int nod,int st,int dr,int l,int r)
{
    if(l<=st&&dr<=r)
        return tree[nod];
    else {
        int mij=(st+dr)>>1,x1=0,x2=0;
        if(l<=mij)x1=query(2*nod,st,mij,l,r);
        if(mij<r)x2=query(2*nod+1,mij+1,dr,l,r);
        return x1+x2;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
            if(q[a[i]].size()==0)
                update(1,1,n,i);
            q[a[i]].push(i);

        }
    for(i=1;i<=m;i++)
    {
         cin>>v[i].l>>v[i].r;
         v[i].poz=i;
    }
    sort(v+1,v+m+1,cmp1);
    j=1;
    for(i=1;i<=m;i++)
    {
        while(j<v[i].l)
        {
            q[a[j]].pop();
            if(!q[a[j]].empty())
                update(1,1,n,q[a[j]].front());
            j++;
        }
        v[i].sol=query(1,1,n,v[i].l,v[i].r);
    }
    sort(v+1,v+m+1,cmp2);
    for(i=1;i<=m;i++)
        cout<<v[i].sol<<'\n';
    return 0;
}


Measured memory_bytes: 355176
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdint>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;

void presentation_array(int A[], int N){
    for(int i=0; i<N; i++){
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

int main(){
    //?????°?????£?¨?
    int A[100];
    int N;
    int count_swap;

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

    //?????????


    //??¢?????´?????????
    int flag = 1;
    while(flag){
        flag = 0;
        for(int j = N-1; j > 0; j--){
            if (A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                flag = 1;
                count_swap++;
            }

        }
    }

    //??????
    presentation_array(A, N);
    printf("%d\n", count_swap);
    return 0;
}

Measured memory_bytes: 1176
import sys

def divisors(n):
  res = set()
  for i in range(1, int(n ** 0.5) + 1):
    if n % i: continue
    res.add(i)
    res.add(n // i)
  return res

x = int(sys.stdin.readline().rstrip())

def f(a, b):
    return pow(a, 5) - pow(b, 5)

def binary(d):
    lo, hi = -1, 10 ** 18
    while lo + 1 < hi:
        a = (lo + hi) // 2 
        b = a - d 
        bl = a >= abs(b)
        bl2 = f(a, b) >= x
        if bl ^ bl2: lo = a
        else: hi = a

        # if f(a, b) >= x:
        #     hi = a 
        # else:
        #     lo = a
    return hi, hi - d

def main():
    diffs = divisors(x)
    for d in diffs:
        a, b = binary(d)
        if f(a, b) == x:
            print(a, b)
            return 

if __name__ == '__main__':
    main()

Measured memory_bytes: 9372
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int N, K;
int ub, lb;
int ans[1008];
vector<vector<int>> v(1001);

bool check()
{

    for (int i = 0; i < K; ++i)
    {
        int cnt = 0;
        for (int j = 0; j < N / 2; ++j)
        {
            cnt += ans[v[i][j]];
        }
        if (cnt < lb || cnt > ub)
            return false;
    }
    return true;
}

void solve()
{
    for (int i = 0; i < N / 2; ++i)
        ans[i] = 1;
    while (1)
    {
        std::random_device seed_gen;
        std::mt19937 engine(seed_gen());
        shuffle(ans, ans + N, engine);
        if (check())
            break;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int arr[8];
    for (int i = 0; i < 8; ++i)
        cin >> arr[i];

    cout << max(arr[0] + arr[1] + arr[2] + arr[3], arr[4] + arr[5] + arr[6] + arr[7]) << endl;
    
    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    ll n,x;
    cin >> n >> x;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    ll ans = 0;
    REP(i,n - 1){
        if(a[i] + a[i + 1] > x){
            ans += a[i] + a[i + 1] - x;
            a[i + 1] -= a[i] + a[i + 1] - x;
            if(a[i + 1] < 0) a[i + 1] = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main()
{
	int K, A, B, i;
	int start= 0;
	scanf("%d", &K);
	scanf("%d %d", &A, &B);
	
	for (i = A; i <= B; i++)
	{
		if (i % K == 0)
		{
			start++;
		}
	}
	
	if (start > 0)
	{
		printf("OK\n");
	}
	
	else
	{
		printf("NG\n");
	}
	
	return 0;
}

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

int main() {
    int n;cin>>n;
    int a[n+1];
    int b[n];
    for (int i=0;i<=n;i++)
        cin>>a[i];
    for (int i=0;i<n;i++)
        cin>>b[i];
    ll ans=0;
    for (int i=0;i<n;i++) {
        int dec=min(b[i],a[i]);
        b[i]-=dec;
        ans+=dec;
        dec=min(b[i],a[i+1]);
        a[i+1]-=dec;
        ans+=dec;
    }
    cout<<ans<<endl;
}

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

int main()
{
  int n, l;
  cin >> n >> l;
  int ans = 0;
  int taste = 1000000007;
  for (int i = 1; i <= n; i++)
  {
    ans += l + i - 1;
    taste = min(taste, abs(0 - (l + i - 1)));
  }
  if (ans > 0)
  {
    cout << ans - taste << endl;
  }
  else
  {
    cout << ans + taste << endl;
  }
}


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

int main()
{
int n;
cin>>n;
string s;
cin>>s;
int count=0;

for(int i=0;i<n-2;i++)
{
	if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')count++;
}	

cout<<count<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
s = [0]*(N+1)
for i in range(N):
    s[i+1] = s[i] + A[i]

mod = 10**9 + 7
ans = 0
for i in range(N-1):
    ans += A[i] * (s[-1] - s[i+1])
    ans %= mod

print(ans)


Measured memory_bytes: 31752
#include <iostream>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  string tmp;
  vector<vector<int>> ans;
  for (int i=0; i<H; i++){
    ans.emplace_back(vector<int>(W, 0));
  }
  int S = 1;
  vector<bool> is_exist(W, false);
  for (int i=0; i<H; i++){
    cin >> tmp;
    for (int j=0; j<W; j++){
      if (tmp[j] == '#'){
        ans[i][j] = S;
        S++;
        is_exist[j] = true;
      }
    }
  }
  int prev = 0;
  for (int i=0; i<W; i++){
    prev = 0;
    for (int j=0; j<H; j++){
      if (ans[j][i] == 0){
        ans[j][i] = prev;
      }
      prev = ans[j][i];
    }
    prev = 0;
    for (int j=H-1; j>=0; j--){
      if (ans[j][i] == 0){
        if (ans[j][i] != 0){
          prev = ans[j][i];
          continue;
        }
        ans[j][i] = prev;
      }
      prev = ans[j][i];
    }
  }
  bool flag = true;
  while (flag){
    flag = false;
    for (int i=0; i<W; i++){
      if (!is_exist[i]){
        flag = true;
        prev = 0;
        for (int j=0; j<H; j++){
          if (ans[j][i] != 0) continue;
          if (i == 0 || i == W - 1){
            ans[j][i] = (i == 0 ? ans[j][i+1] : ans[j][i-1]);
          }
          else{
            if (ans[j][i-1] * ans[j][i+1] == 0){
              ans[j][i] = (ans[j][i-1] == 0 ? ans[j][i+1] : ans[j][i-1]);
            }
            else{
              ans[j][i] = ans[j][i+1];
            }
          }
          if (ans[j][i] != 0) is_exist[i] = true;
        }
      }
    }
  }
  for (auto v : ans){
    for (int e : v){
      cout << e << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <utility>

using namespace std;

int main(const int argc, const char **argv){
  string input;
  cin >> input;

  char first = input[0];
  int next = first - '0' + 1;

  for(int i = 1; i < input.size(); i++){
    if(input[i] > first){
      cout << next << next << next << endl;
      return 0;
    }
  }

  cout << first << first << first << endl;;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int ans = 0;
  vector<int> a(5, 0);
  int mini = 9;
  int m = 0;
  for(int i = 0; i < 5; i++) {
    cin >> a[i];
    if(a[i] % 10 != 0 && a[i] % 10 < mini){
      mini = a[i] % 10;
      m = i;
    }
  }
  for(int i = 0; i < 5; i++){
    if(i == m){
      ans += a[i];
    }else{
      if(a[i] % 10 != 0){
        ans += (a[i] + (10 - a[i] % 10));
      }else{
        ans += a[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
 
int main() {
  int x,n;
  cin >> x >> n;
  if (!n)
  {
    cout << x << endl;
    return 0;
  }
  vector<int> boll(n);
  for (int i = 0; i < n; ++i)
    cin >> boll[i];
  sort(boll.begin(), boll.end());
  int start = 0, end = n - 1;
  if (x < boll[start] || x>boll[end])
  {
    cout << x << endl;
    return 0;
  }
  if (x == boll[start])
  {
    cout << (boll[start]-1)<< endl;
    return 0;
  }
  int i;
  for (i = 0; i < n; ++i)
    if (boll[i] == x)
      break;
  if (i == n)
  {
    cout << x << endl;
    return 0;
  }
  int j = i, k = i;
  while (j >= 0 && k <= end)
  {
    if (j-1>=0 &&  abs(boll[j] - boll[j -1]) > 1)
    {
      cout << (boll[j] - 1);
      return 0;
    }
    if (k+1<=end &&  abs(boll[k] - boll[k + 1]) > 1)
    {
      cout << (boll[k] + 1);
      return 0;
    }
    --j;
    ++k;
  }
  if (abs(x - (boll[0] - 1)) > abs(x - (boll[end] + 1)))
  {
    cout << (boll[end] + 1);
    return 0;
  }
  cout << (boll[0] - 1) << endl;
  return 0;
}

Measured memory_bytes: 3636
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        a: i32,
        b: i32,
    );

    if (a - b) % 2 == 0 {
        let c = (a - b).abs() / 2;
        println!("{}", c + min(a, b));
    }
    else {
        println!("IMPOSSIBLE");
    }
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#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 pb push_back
#define pi 3.14159265359


ll gcd(ll a, ll b)
{
	ll c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	ll n;
	string S;
	cin >> S;
	if (S == "ooo") {
		cout << 1000;
	}
	else if (S == "oox") {
		cout << 900;
	}
	else if (S == "oxo") {
		cout << 900;
	}
	else if (S == "xoo") {
		cout << 900;
	}
	else if (S == "xxx") {
		cout << 700;
	}
	else cout << 800;
	

	return 0;


}

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

const int MaxN = 1e6;
using namespace std;

int n, x, y;
int main()
{
	cin >> n;
	if(n < 3)
	{
		cout << 0 << endl;
	}
	else 
	{
			y = n / 3;
			cout << y <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

s = input()
n = len(s)
t = input()
s*=2

ans = 0
for c in t:
    d = s[ans%n:].find(c)
    if d == -1:
        print(-1)
        exit()
    ans += d+1
print(ans)


Measured memory_bytes: 3700
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String n = sc.next();
            int sum = 0;
            if(n.equals("0")){
                break;
            }else{
                char []numbers = n.toCharArray();
                for(char number : numbers){
                    sum += Character.getNumericValue(number);
                }
            }
            System.out.println(sum);
        }
        
    }
}


Measured memory_bytes: 26092
string=""
directionx=""



sx, sy, tx, ty = map(int, input().split())
dx=tx-sx
dy=ty-sy

if dx>=0:
    directionx="R"
    directionxr="L"
else:
    directionx="L"
    directionxr="R"


if dy>=0:
    directiony="U"
    directionyr="D"
else:
    directiony="D"
    directionyr="U"
    
for _ in range (dx):
    string=string+directionx
for _ in range (dy):
    string=string+directiony
for _ in range (dx):
    string=string+directionxr
for _ in range (dy):
    string=string+directionyr

string=string+directionyr
for _ in range (dx+1):
    string=string+directionx
for _ in range (dy+1):
    string=string+directiony
string=string+directionxr
string=string+directiony
for _ in range (dx+1):
    string=string+directionxr
for _ in range (dy+1):
    string=string+directionyr
string=string+directionx
    
print(string)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

vector<pair<string,int>> str(100000);
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int count = 0;
    int c_n = 0;
    while (cin >> str[count].first) {
        cin >> str[count].second;
        count++;
    }
    sort(str.begin(), str.begin() + count);
    cout << str[0].first << endl;
    cout << str[0].second;
    for (int i = 1; i < count; i++) {
        if (str[i].first != str[i-1].first) {
            cout << endl << str[i].first << endl;
            cout << str[i].second;           
        } else {
            cout << " " << str[i].second;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4232
using System;
using System.Text.RegularExpressions;

class Insertion_Sort
{
    int[] cards;
    public Insertion_Sort(int n)
    {
        cards = new int[n];
        string[] s = Console.ReadLine().Split(' ');
        for (int i = 0; i < cards.Length; i++)
        {
            cards[i] = int.Parse(s[i]);
        }
    }
    public void insertionSort(int n)
    {
        for (int i = 0; i < cards.Length;i++ )
        {
            if(i == cards.Length-1)
                Console.WriteLine(cards[i]);
            else
                Console.Write("{0} ",cards[i]);
        }
            for (int i = 1; i <= n - 1; i++)
            {
                int v = cards[i];
                int j = i - 1;
                while (j >= 0 && cards[j] > v)
                {
                    cards[j + 1] = cards[j];
                    j--;
                }
                cards[j + 1] = v;
                for (int k = 0; k < cards.Length; k++)
                {
                    if (k == cards.Length - 1)
                        Console.WriteLine(cards[k]);
                    else
                        Console.Write("{0} ", cards[k]);
                }
            }
    }
}
class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        Insertion_Sort IS = new Insertion_Sort(N);
        IS.insertionSort(N);
    }
}

Measured memory_bytes: 9364
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

class F {
    static constexpr int M = 1e6 + 10;
    vector<ll> t;
    vector<bool> prime;
public:
    F() : t(M, -1), prime(M, true) {
        iota(t.begin(), t.end(), 0);

        for (ll i = 2; i < M; i++) {
            if (t[i] == i) {
                for (ll j = 1; i * j < M; j++) {
                    t[i * j] = t[i * j] / i * (i - 1);
                }
            }
        }

        t[1] = 2;
            
        FOR(i, 2, M) t[i] += t[i-1];
    }
    
    const ll operator[] (int i) {
        assert(0 <= i && i < M);
        return t[i];
    }
};

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

    F f;

    REP(_, t) {
        int n; cin >> n;    
        cout << f[n] << endl;
    }

    return 0;
}



Measured memory_bytes: 10676
#include<stdio.h>
int main()
{
  int a,b,c,d,e,k;
  while(scanf("%d%d",&a,&b)==2){
  c=a+b;
  k=0;
  while(c>0){
   d=c%10;
   e=c-d;
   c=e/10;
   k++;
   }
  printf("%d\n",k);
  }
  return 0;
  }

Measured memory_bytes: 596
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n, k;
  std::vector<long> xs;
  Solver() {
    S002 reader;
    reader >= n >= k >n>= xs;
  }
  void solve() {
    std::sort(xs.begin(), xs.end());
    long dp[10000] = {};
    dp[0] = 1;
    for(long ai : xs) {
      if( ai >= 5000 ) continue;
      for(long j = 5000; j >= 0; --j) { 
        if( j - ai >= 0 ) {
          dp[j] = dp[j] + dp[j-ai];
        }
        else {
          dp[j] = dp[j];
        }
      }
    }
    // for(long i = 0; i < 20; ++i) {
    //   dumpll(i, dp[i]);
    // }
    long temp[10000] = {};
    long res = (long)xs.size();
    for(long ai : xs) {
      if( ai >= 5000 ) {
        res -= 1;
        continue;
      }
      for(long j = 0; j <= 5000; ++j) {
        if( j >= k ) break;
        if( j - ai >= 0 ) temp[j] = dp[j] - temp[j-ai];
        else temp[j] = dp[j];
        if( temp[j] != 0 and k <= j + ai ) {
          res -= 1;
          break;
        }
      }
    }
    printf("%ld\n", res);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

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

int main(){
    //入力
    int N,M,ans;
    cin >> N >> M;

    vector<int64_t> a(N),b(N),c(M),d(M);
    int64_t distance_min,distance_cur;

    for(int i=0;i<N;i++){
        cin >> a.at(i) >> b.at(i) ;
    }
    for(int i=0;i<M;i++){
        cin >> c.at(i) >> d.at(i) ;
    }

    //計算と出力
    for(int i=0;i<N;i++){
        distance_min=4*pow(10,8);
        for(int j=0;j<M;j++){
            distance_cur=abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));
            if(distance_min>distance_cur){
                distance_min=distance_cur;
                ans=j+1;
            }
        }
        cout << ans << endl;
    }
    

    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 2e9;

ll dist[505][505];

bool warchall_floyd(int N){
    rep(k,N)rep(i,N){
        rep(j,N){
            if(dist[i][j] > dist[i][k] + dist[k][j]) return true;
        }
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n)rep(j,n) cin >> dist[i][j];
    if(warchall_floyd(n)){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            bool flag = true;
            rep(k,n){
                if(k == i || k == j) continue;
                if(dist[i][j] == dist[i][k] + dist[k][j]){
                    flag = false;
                    break;
                }
            }
            if(flag) ans += dist[i][j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int mod=1e9+7;
const int N = 1e5+5;

string now;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>now;
  if(now.size() == 2){
    if(now[0] == now[1]) cout<<"1 2"<<endl;
    else cout<<"-1 -1"<<endl;
    return 0;
  }
  for(int i = 0;i < now.size();i++){
    if(i+1 < now.size() && now[i] == now[i+1]) {
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
    }
    else if(i+2 < now.size() && now[i] == now[i+2]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }
  cout<<"-1 -1"<<endl;
  return 0;
}


Measured memory_bytes: 512
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [ss] <- getInts
  ; let (mm,s) = ss `divMod` 60
  ; let (h,m)  = mm `divMod`60
  ; putStrLn (intercalate ":" (map show [h,m,s]))
  }

getInts :: IO [Int]
getInts = do
  { line <- getLine
  ; let ints = map readInt (words line)
  ; return ints
  }

getInts' :: IO [Int]
getInts' = do
  { line <- getLine
  ; return (map readInt (words line))
  }

getInts'' :: IO [Int]
getInts'' = map readInt . words <$> getLine


readInt :: String -> Int
readInt = read

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;
ll const inf = 3e3;
bool isdif(ll a, ll b, ll c)
{
    if( a!=b && b!=c && c!=a )
        return 1;
    return 0;
}
bool poss(ll a, ll b, ll c)
{
    if( (a+b>c) && (b+c>a) && (c+a>b) )
        return 1;
    return 0;
}

void solve()
{
    ll n; cin >> n;
    ll a[n] ; f(i,0,n) cin >> a[i];

    ll ans = 0;
    f(i,0,n){
        f(j,i+1,n){

            f(k,j+1,n)
                if(poss(a[i],a[j],a[k]) && isdif(a[i],a[j],a[k]))
                    ans++;
        }
    }
    cout << ans << endl;
}
int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
        
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define forg(i,x) for(int i=first[x];i;i=nxt[i])
#define uu unsigned
#define fi first
#define se second
#define od(x) ((x)&1)
#define ev(x) (od(x)^1)
#define mi2(x) (1<<(x))
#define scanf a1234=scanf
#define fre(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
int a1234;
char buf[1<<18],*bufs=buf,*buft=buf;
inline int gc(){
    return bufs==buft&&(buft=(bufs=buf)+fread(buf,1,1<<18,stdin)),bufs==buft?-1:*bufs++;
}
inline void xxx(){for(;;);}

const int mxn=4003,base=2001,mxm=2e5+3;
const uu mod=2e9+14;
uu dp[mxn][mxn],C[mxn*2][mxn*2];
int n,a[mxm],b[mxm];

int main(){
	//cout<<(sizeof(C)>>20)<<endl;
	for(int i=0;i<=8000;++i){C[i][0]=C[i][i]=1;for(int j=1;j<i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;}
	scanf("%d",&n);for(int i=1;i<=n;++i)scanf("%d%d",a+i,b+i);
	for(int i=1;i<=n;++i)++dp[base-a[i]][base-b[i]];
	for(int i=1;i<=4001;++i)for(int j=1;j<=4001;++j)dp[i][j]+=dp[i-1][j]+dp[i][j-1],dp[i][j]%=mod;
	uu ans=0;
	for(int i=1;i<=n;++i)ans+=mod-C[2*(a[i]+b[i])][2*a[i]],ans%=mod;
	for(int i=1;i<=n;++i)ans+=dp[base+a[i]][base+b[i]],ans%=mod;
	printf("%u\n",ans>>1);
    return 0;
}


Measured memory_bytes: 222948
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

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

	rep(i,0,n){
		int x=0,y=0;
		bool f = 1;
		rep(j,0,10){
			
			int b;
			if(!f){
				cin >> b;
				continue;
			}

			cin >> b;
			if( b - x > 0 && b - x <= b - y )
				x = b;
			else if( b - y > 0 )
				y = b;
			else{
				f = 0;
			}
			//cout << x << " " << y << endl;
		}

		if(f)
			YES;
		else
			NO;
	}
	
	ret 0;
}


Measured memory_bytes: 3084
#include <stdio.h>

int main(void){
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    for(int i=0; i<(a>b ? a: b); ++i){
        printf("%d", a>b ? b: a);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1724