akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	in := NewScanner()
	bit := 0
	for _, v := range in.NextLine() {
		switch v {
		case 'N':
			bit |= 1 << 0
		case 'S':
			bit |= 1 << 1
		case 'W':
			bit |= 1 << 2
		case 'E':
			bit |= 1 << 3
		}
	}
	if bit == (1 << 4) - 1 || bit == 3 || bit == 12 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

const ll mod = 1e9 + 7;

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

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

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

    int a[3][3];
    int n;
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    cin >> n;
    rep(i, n) {
        int b;
        cin >> b;
        rep(i, 3) rep(j, 3) if(a[i][j] == b) a[i][j] = 0;
    }
    bool ans = 0;
    rep(i, 3) {
        if(a[i][0] + a[i][1] + a[i][2] == 0) ans = 1;
        if(a[0][i] + a[1][i] + a[2][i] == 0) ans = 1;
    }
    if(a[0][0] + a[1][1] + a[2][2] == 0) ans = 1;
    if(a[0][2] + a[1][1] + a[2][0] == 0) ans = 1;
    cout << (ans ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

long long N;
cin>>N;
long long ans=0;
for(long long p=sqrt(N);p>0;p--){

    if(N%p==0){
        ans=p;
        break;
    }
}

ans=max(ans,N/ans);
long long  x=10;
int cnt=0;
while(1){
cnt++;
if(ans<x){
    cout<<cnt<<endl;
    return 0;
}
x*=10;
}

 return 0;
}
/*
10000

3

1000003

7

9876543210

6
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[20];
int main()
{
	cin>>str;
	bool flag=false;
	for(int i=0;i<strlen(str);i+=2)
	{
		if(str[i]=='h'&&str[i+1]=='i')
			flag=true;
		else
			flag=false;
	}
	if(flag)
		puts("Yes");
	else
		puts("No");
	return 0;
}


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

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

const int MAX_N = 3005;
const int MAX_W = 3005;
long dp[MAX_N][MAX_W];
long res;

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

  long n, t;
  cin >> n >> t;

  vector<P> foods;
  rep(i, n) {
    long a, b;
    cin>>a>>b;
    foods.push_back({a, b});
  }

  sort(foods.begin(), foods.end(), greater<P>());

  per(i, n) rep(j, t) { 
    res = max(res, dp[i+1][j] + foods[i].second);
    if (j < foods[i].first) {
      dp[i][j] = dp[i+1][j];
    } else {
      dp[i][j] = max(dp[i+1][j], dp[i+1][j-foods[i].first] + foods[i].second);
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 70784
n = int(input())
row = list(map(int,input().split()))

a = row[0]
b =0
fumi = 0
for i in row:
  b = i
  if a <= b:
    a = b
    next
  else:
    fumi += (a - b)
    a = max(a, b)
print(fumi)

Measured memory_bytes: 32064
import copy

def minTG(TG):
    indexes1 = [i for i, x in enumerate(TG) if x == 1]
    indexes2 = [i for i, x in enumerate(TG) if x == 2]
    TG24 = [1] + [0] * 23    
    if 12 in indexes1:
        indexes1.pop(-1)
        TG24[12] = 1
    for i in indexes1 + indexes2:
        TG24[i], TG24[24-i] = 1, 1
    
    ans = 0
    for i in range(2**len(indexes1)):
        TG24c = copy.copy(TG24)
        bit = i
        for j in range(len(indexes1)):
            if bin(bit>>(j+1))[-1] == '1':
                TG24c[indexes1[j]] = 0
            else:
                TG24c[24 - indexes1[j]] = 0
        temp = minTG_search(TG24c)
        if ans < temp:  ans = temp
    return ans

def minTG_search(TG24):
    s, temp, i = 24, 0, 1
    while i < 24:
        if TG24[i] == 1:
            if i - temp < s:
                s = i - temp
            temp = i
        i += 1
    if 24 - temp < s:
        s = 24 - temp
    return s

N = int(input())
D = sorted(list(map(int, input().split())))
TG = [0] * 13
for i in range(N):
    TG[D[i]] += 1

if TG[0] > 0 or max(TG) > 2:
    print(0)
else:
    print(minTG(TG))

Measured memory_bytes: 3528
#include <stdio.h>

int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    int n;
    int a[100],b[100];
    int count=0;
    int max=0;

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d %d",&a[i],&b[i]);
    }
    for(int i=0;i<n;i++){
        if(a[i]==b[i]){
            count++;
            if(count>max){
                max=count;
            }
        }else{
            
            count=0;
        }
    }
    
    if(max>=3){
        puts("Yes");
    }else{
        puts("No");
    }

 
    
    return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define INF (long long int)(9223372036854775807)
#define IINF (int)(2147483647)

int main(void) {
  int n, m, a;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &a);
    n -= a;
    if (n < 0) {
      n = -1;
      break;
    }
  }
  printf("%d\n", n);
}

Measured memory_bytes: 1732
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 1e5 + 5;

int n, m;
int a[maxn], cnt[maxn];
vector<int> vals;

void read_input()
{
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        vals.push_back(a[i]);
    }
}

void solve()
{
    sort(vals.begin(), vals.end());
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    for(int i = 1; i <= n; ++i)
    {
        a[i] = lower_bound(vals.begin(), vals.end(), a[i]) - vals.begin() + 1;
        ++cnt[a[i]];
    }
    m = sz(vals);
    lli ans = 0;
    for(int i = 1; i <= m; ++i)
        if(cnt[i] >= 4) ans = max(ans, vals[i - 1] * 1LL * vals[i - 1]);
    int i = m;
    while(i > 0)
    {
        if(cnt[i] >= 2)
        {
            int j = i - 1;
            while(j > 0)
            {
                if(cnt[j] >= 2)
                {
                    ans = max(ans, vals[i - 1] * 1LL * vals[j - 1]);
                    break;
                }
                else --j;
            }
            break;
        }
        else --i;
    }
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 4492
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <set>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INF64 = 3e18;
const unsigned long long HASHBASE=1222827239ull;
/////////////////////////

/////////////////////////
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int a[3];
    for(int i=0;i<3;++i)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;
    return 0;
}


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

using namespace std;

using cap_t = int;
using cost_t = long long;

const cap_t cap_inf = 1 << 30;
const cost_t cost_inf = 1ll << 60;

namespace flow {
struct edge {
  int to, rev;
  cost_t cost;
  cap_t cap;

  edge(int t, cap_t c, cost_t w, int r) {
    to = t;
    rev = r;
    cap = c;
    cost = w;
  }
};

vector<vector<edge>> adj;
vector<cost_t> dist;
int n, source, sink;
vector<bool> visit;
vector<int> cur;
cost_t res;
cap_t ans;

void init(int v, int s, int t) {
  n = v;
  ans = res = 0;
  source = s;
  sink = t;
  adj.clear();
  adj.resize(n);
  cur.resize(n);
  dist.resize(n);
  visit.resize(n);
}

void add(int x, int y, cap_t c, cost_t w) {
  adj[x].emplace_back(y, c, w, adj[y].size());
  adj[y].emplace_back(x, 0, -w, adj[x].size() - 1);
}

bool spfa() {
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    dist[i] = cost_inf;
    visit[i] = false;
    cur[i] = 0;
  }
  dist[source] = 0;
  q.push(source);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    visit[x] = false;
    for (auto e : adj[x]) {
      if (e.cap && dist[e.to] > dist[x] + e.cost) {
        dist[e.to] = dist[x] + e.cost;
        if (!visit[e.to]) {
          visit[e.to] = true;
          q.push(e.to);
        }
      }
    }
  }
  return dist[sink] != cost_inf;
}

cap_t dfs(int x, cap_t f) {
  if (x == sink) {
    return f;
  }
  visit[x] = true;
  cap_t res = 0;
  for (int &i = cur[x]; i < (int) adj[x].size(); ++i) {
    edge &e = adj[x][i];
    if (e.cap && dist[e.to] == dist[x] + e.cost && !visit[e.to]) {
      cap_t w = dfs(e.to, min(e.cap, f - res));
      res += w;
      e.cap -= w;
      adj[e.to][e.rev].cap += w;
      if (res == f) {
        visit[x] = false;
        return res;
      }
    }
  }
  dist[x] = cost_inf;
  return res;
}

pair<cap_t, cost_t> min_cost_max_flow() {
  while (spfa()) {
    cap_t flow = dfs(source, cap_inf);
    ans += flow;
    res += flow * dist[sink];
  }
  return make_pair(ans, res);
}
}

using flow::source;
using flow::sink;
using flow::init;
using flow::add;
using flow::min_cost_max_flow;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  init(n * 2 + 6, n * 2, n * 2 + 1);
  for (int i = 0; i < n; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    add(source, i, z, 0);
    add(i, n * 2 + 2, z, x + y);
    add(i, n * 2 + 3, z, x - y);
    add(i, n * 2 + 4, z, y - x);
    add(i, n * 2 + 5, z, -(x + y));
  }
  for (int i = 0; i < n; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    add(i + n, sink, z, 0);
    add(n * 2 + 2, i + n, z, -(x + y));
    add(n * 2 + 3, i + n, z, y - x);
    add(n * 2 + 4, i + n, z, x - y);
    add(n * 2 + 5, i + n, z, x + y);
  }
  cout << -min_cost_max_flow().second << "\n";
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>                                                                                                         
 int main(){
     char op;
     int A,B;
     std::cin >> A >> op >> B;
     if(op=='+'){
         std::cout << A+B << std::endl;
     } else{
         std::cout << A-B << std::endl;
     }
     return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,k=0;
  
  int A,B;
  
  scanf("%d %d",&A,&B);
  
  for(i=0;i<2;i++){
    if(A>B){
      k+=A;
      A--;
    }
    else{
      k+=B;
      B--;
    }
  }
  
  printf("%d\n",k);
  return 0;
}
  



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

typedef long double Real;
Real*** cache;

#define INIT -1
Real EV(const int a[3], const int n) {
	auto& res = cache[a[0]][a[1]][a[2]];
	if (res != INIT) return res;
	int total = a[0] * 1 + a[1] * 2 + a[2] * 3;
	int remain = a[0] + a[1] + a[2];
	if (!remain) return res = 0;	
	res = (Real) n / remain;
//	cerr << "remain = " << total << " -> moves required : " << res << "\n";
	for (int i = 0; i < 3; i++) if (a[i]) {
		int b[3] = {a[0], a[1], a[2]};
		--b[i];
		if (i) ++b[i - 1];
		res += (Real) a[i] / remain * EV(b, n);
//		cout << "i = " << i << " --> : " << b[0] << "," << b[1] << "," << b[2] << "\n";
//		cout << "prob. for " << i << " to happen = " << a[i] << " / " << remain << "\n";
	}
//	cout << "EV(" << a[0] << "," << a[1] << "," << a[2] << ") = ";
//	cout << fixed << setprecision(8) << res << "\n";
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, a[3] = {0, 0, 0};
	cin >> n;
	for (int x, i = 0; i < n; i++) 
		cin >> x, ++a[--x];
	cache = new Real**[n + 1];
	for (int x = 0; x <= n; x++) {
		cache[x] = new Real*[n + 1];
		for (int y = 0; y <= n; y++) {
			cache[x][y] = new Real[n + 1];
			for (int z = 0; z <= n; z++)
				cache[x][y][z] = INIT;
		}
	}
	cout << fixed << setprecision(12) << EV(a, n);
}

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

int main(){
  int n;
  cin >> n;
  vector<int> r;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  while(n != 1){
    int rr;
    if(n%(-2) == -1){
      rr = 1;
      n = n/(-2) + 1;
    }
    else{
      rr = n%(-2);
      n /= (-2);
    }
    r.push_back(rr);
  }
  r.push_back(1);
  reverse(r.begin(), r.end());
  for(int i=0; i<r.size(); i++){
    cout << r.at(i);
  }
  cout << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k=s.nextInt();
        int[] arr = new int[n];
      for(int i=0;i<n;i++)
        	arr[i]=s.nextInt();
      
        int[] dp = new int[n];
        
        for (int i = n - 2; i >= 0; i--) {
            int bop=Integer.MAX_VALUE;

            for(int j=1;j<=k&&i+j<n;j++){
                int cop=Math.abs(arr[i]-arr[i+j])+dp[j+i];
                bop=Math.min(bop,cop);
            }

            dp[i]=bop;

            
        }
      
        System.out.println(dp[0]);
    }
}

Measured memory_bytes: 59124
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	string S, T;
	cin >> S >> T;
	string ans = "No";

	string C = S;
	REP(i, S.length())
	{
		if (C == T)
		{
			ans = "Yes";
			break;
		}
		C = C[C.length() - 1] + C.substr(0, C.length() - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int h, w, a, b;
ll MOD = 1000000007;
ll fact[200005], inv[200005];

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

ll comb(int n, int k) {
	return (fact[n] * inv[k] % MOD) * inv[n-k] % MOD;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> h >> w >> a >> b;
	fact[0] = 1LL;
	inv[0] = 1LL;
	for (int i = 1; i < 200005; i++) {
		fact[i] = fact[i-1] * i % MOD;
		inv[i] = mod_pow(fact[i], MOD-2LL) % MOD;
	}

	ll all = comb(h+w-2, h-1);
	FOR(i, a) {
		int x = b-1, y = h-1-i;
		ll ret = comb(x+y, x) * comb(w-x-2 + h-y-1, h-y-1) % MOD;
		all -= ret;
	}
	while (all < 0) all += MOD;
	cout << all << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll C, h[210000];
ll dp[210000];


int main(){
    int N;

    cin >> N >> C;

    for(int i = 0; i < N; i++){
        cin >> h[i];
    }

    vector<P> line;
    dp[0] = 0;
    for(int i = 1; i < N; i++){
        while(line.size() >= 2){
            ll a3 = -2 * h[i-1], b3 = dp[i-1] + h[i-1] * h[i-1];
            ll a2 = line[line.size()-1].fs, b2 = line[line.size()-1].sc;
            ll a1 = line[line.size()-2].fs, b1 = line[line.size()-2].sc;
            if((b3 - b2) * (a2 - a1) >= (b2 - b1) * (a3 - a2)){
                line.pop_back();
            }
            else{
                break;
            }
        }
        line.emplace_back(P(-2 * h[i-1], dp[i-1] + h[i-1] * h[i-1]));
        int l = -1;
        int r = line.size()-1;
        auto value = [&line, &h, &i](int ind){
//            cout << line[ind].fs * h[i] + line[ind].sc << " " << i << " " << ind << endl;
            return line[ind].fs * h[i] + line[ind].sc;
        };
        while(r - l > 1){
            int m = (l + r) / 2;
//            cout << value(m+1) << " " << m+1 << endl;
//            cout << value(m) << " " << m << endl;
//            cout <<  endl;
            if(value(m+1) > value(m)){
                r = m;
            }
            else{
                l = m;
            }
        }
        dp[i] = value(r) + h[i] * h[i] + C;
    }

    cout << dp[N-1] << endl;



    return 0;
}


Measured memory_bytes: 10480
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
ll c[26],s[400][30],last[400][30],d,now = -100000000000;
vector<ll> ans,w;
ll score(int l, int r, vector<ll> &v){//[l,r)
    ll i,j,res = 0;
    for(i=l;i<r;i++){
        for(j=0;j<26;j++){
            last[i][j] = 0;
        }
    }
    for(i=l;i<r;i++){
        int x = v[i]; x--;
        if(x<0 || x>25){
            cout << " b " << x << endl;
            exit(1);
        }
        res += s[i][x];
        if(i!=0){
            for(j=0;j<26;j++){
                last[i][j] = last[i - 1][j];
            } 
        }
        last[i][x] = i + 1;
        for(j=0;j<26;j++){
            res -= c[j]*(i + 1 - last[i][j]);
        }
    }
    return res;
}

void score2(int x,int y){
    vector<ll> vv; vv.resize(d);
    vector<ll> st,ww;
    int i,j;
    for(i=0;i<d;i++){
        ll k = -1,mx = -1000000000;
        for(j=0;j<26;j++){
            if(s[i][j]>mx){
                mx = s[i][j]; k = j + 1;
            }
        }
        if(k!=-1 && mx>x) vv[i] = k;
        else st.push_back(i);
    }
    for(i=0;i<d;i++){
        if(vv[i]==0){
            bool flag = true;
            for(int x:st){
                if(x==i) flag = false;
            }
            if(flag){
                cout << " a " << -1 << endl;
                exit(1);
            }
        }
    }
    for(i=0;i<26;i++){
        if(c[i]>=y) ww.push_back(i + 1);
    }
    int sz = ww.size();
    if(sz==0) return;
    for(j=1;j<=sz;j++){
        int y = j;
        for(int x:st){
            vv[x] = ww[y - 1]; y++;
            if(y==sz + 1) y = 1;
        }
        ll sc = score(0,d,vv);
        if(sc>now){
            swap(ans,vv); now = sc; 
        }
    }
}

/*vector<int> score3(){
    vector<int> vv; vv.resize(d);
    int i,j,l = 0;
    for(i=0;i<d;i++){
        if(i%26!=25 && i!=d - 1) continue;
        for(j=l;j<=i;j++){
            
        }
        l = i + 1;
    }
}*/

int main(){
    int i,j; cin >> d;
    for(i=0;i<26;i++) cin >> c[i];
    for(i=0;i<d;i++){
        for(j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    for(i=0;i<d;i++) ans.push_back(i%26 + 1);
    now = score(0,d,ans);
    for(j=1;j<26;j++){
        w.clear();
        for(i=0;i<d;i++) w.push_back((i + j)%26 + 1);
        int sc = score(0,d,w);
        if(sc>now){
            swap(ans,w); now = sc;
        }
    }
    for(i=0;i<=20000;i+=10) score2(i,0);
    for(i=0;i<=20000;i+=10) score2(i,1);
    for(i=0;i<d;i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 3816
N = int(input())
ARR = list(map(int, input().split()))


# N = 3
# ARR = [1000000000, 0, 9]
#
# N = 31
# ARR =  [4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0]

def calculate(n, arr):
    res = 1
    for i in range(n):
        if arr[i] == 0:
            res = 0
            break

        if res == -1:
            continue

        res = res * arr[i]
        if res > 1000000000000000000:
            res = -1

    return res


print(calculate(N, ARR))


Measured memory_bytes: 21660
import math
n, k = input().strip().split(' ')
n, k = [int(n), int(k)]

def fx(m):
    a = m - k 
    if(m - k) < 0:
        a  = - (m - k)
    if a >= m:
        return m
    return fx(a)

l = n
if n>= k:
    i = n//k
    l = n - k * i

ans = fx(l)
print(ans)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
int morex[N];
int lessx[N];
int morey[N];
int lessy[N];

vector<pair<ll, ll>> vpx;

int main()
{
  int n , k;
  cin>>n>>k;
  rep(i, 0, n)
  {
    ll x, y;
    cin>>x>>y;
    vpx.pb({x, y});
  }
  sort(vpx.begin(), vpx.end());
  ll ans = LONG_MAX;
  rep(i, 0, n)
    rep(j, i, n)
    {

      ll x1, x2, y1, y2;
      x1 = vpx[i].f;
      x2 = vpx[j].f;
      ll co = 0;
      vector<pair<ll, ll>> vpy;
      repn(kk, i, j)
      {
        vpy.pb({vpx[kk].s, vpx[kk].f});
      }
      sort(vpy.begin(), vpy.end());
      if(vpy.size() >= k)
      {
        ll aa = x2 - x1;
        for(int kk=0;(kk+k)<=vpy.size(); kk++)
        {
          ll y1 = vpy[kk].f;
          ll y2 = vpy[kk+k-1].f;
          ll area = aa * (y2- y1);
          if(area < ans) ans = area;
        }
      }

    }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int ary[2][265][265]={};
int main(){
	int N,K;
	vector<int> ve;
	int a;
	
	for(int i=0;i<2;i++){
		for(int j=0;j<=255;j++){
			for(int k=0;k<=255;k++){
				ary[i][j][k]=0;
			}
		}
	}
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>a;
		ve.push_back(a);
	}
	sort(ve.begin(),ve.end());
	int in=0,ou=1,hog,cnt=0;
	ary[in][0][0]=1;
	for(vector<int>::iterator it=ve.begin();it!=ve.end();it++){
		ary[ou][0][0]=1;
		for(int i=0;i<=cnt;i++){
			for(int j=0;j<=255;j++){
				hog=j^(*it);
				ary[ou][i+1][hog]=(ary[in][i][j]+ary[in][i+1][hog])%1000000007;
			}
		}
		swap(in,ou);
		cnt++;
	}
	long long res=0,bak=1;
	for(int i=1;i<=N;i++){
		bak=(bak*i)%1000000007;
		res=(res+ary[in][i][K]*bak)%1000000007;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    int n;
    scanf("%d", &n), n %= 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) printf("hon\n");
    else if(n == 0 || n == 1 || n == 6 || n == 8) printf("pon\n");
    else printf("bon\n");
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  cin >> S;
  bool possible = false;
  for (int i=0; i<S.size()-1; i++) {
    if (S[i]=='A'&&S[i+1]=='C') {
      possible = true;
      break;
    }
  }
  if (possible) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[101][101];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++)
			scanf("%d",&b[i+1][j+1]);
	for(int i=0;i<101;i++){
		for(int j=1;j<101;j++){
			b[i][j]=b[i][j-1]+b[i][j];
		}
	}
	for(int i=0;i<101;i++){
		for(int j=1;j<101;j++){
			b[j][i]=b[j-1][i]+b[j][i];
		}
	}
	int ret=-99999999;
	for(int i=0;i<a;i++){
		for(int j=i;j<a;j++){
			for(int k=0;k<a;k++){
				for(int l=k;l<a;l++){
					ret=max(ret,b[j+1][l+1]-b[j+1][k]-b[i][l+1]+b[i][k]);
				}
			}
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1068
import Data.Bits
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Lazy.Char8 as B
--import Debug.Trace

main :: IO ()
main = do
  [a,b] <- map read.words <$> getLine :: IO [Int]

  print $ maximum [a+b,a-b,a*b]


Measured memory_bytes: 508
object Main{
  def main(args: Array[String]){
    val sc=new java.util.Scanner(System.in)
    val n=sc.nextInt()
    val std=mysprit(n,sc).map(x=>(List(0,0)::mysort(x.sorted,Nil)).sortBy(-_(1))).sortBy(l=>l(0)(1)-l(1)(1))
    std match{
      case List(a:List[List[Int]],b:List[List[Int]]) if a(0)(0)==b(0)(0) => println(n-(a(1)(1)+b(0)(1)))
      case List(a:List[List[Int]],b:List[List[Int]]) => println(n-(a(0)(1)+b(0)(1)))
    }
  }
  def mysort(l:List[Int],r:List[List[Int]]) : List[List[Int]] = {
    l match{
      case Nil => r
      case x::xs => {
        val n = xs.indexWhere(_!=x)
        if( n == -1) mysort(Nil,(x :: l.size :: Nil) ::r)
        else mysort(xs.drop(n), (x :: n+1 :: Nil) :: r )
      }
    }
  }
  def mysprit(n:Int,s:java.util.Scanner):List[List[Int]] = {
    def myspritlocal(c:Int,l1:List[Int],l2:List[Int]):List[List[Int]] ={
      c match{
        case 0 => List(l1,l2)
        case a:Int => myspritlocal(a-2,s.nextInt()::l1,s.nextInt()::l2)
      }
    }
    myspritlocal(n,Nil,Nil)
  }
}

Measured memory_bytes: 70028
void main() {
    int[] ab = readln.split.to!(int[]);
    writeln(ab.all!"a % 2 == 1" ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

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

using namespace std;

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

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

void inputVector(vector<int> *p,int a){
	rep(i,1){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	double T,X;
	T=(double)inputValue();
	X=(double)inputValue();
	output(T/X,0);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N, M;
cin >> N >> M;
int keta[11];
int num[11];

for(int i = 0; i < M; i++){
    cin >> keta[i] >> num[i];
}

int ans = -1;
for(int i = 0; i < 1000; i++){
    bool check = true;
if(i < pow(10, N-1)){
check = false;
}
int I = i;
int kari = i;
int hun, ten, one;
hun = 11;
ten = 11;
one = 11;
if(N > 2){
hun = I % 10;
I /= 10;
}
if(N > 1){
ten = I % 10;
I /= 10;
}
if(N > 0){
one = I % 10;
I /= 10;
}

for(int j = 0; j < M; j++){
if(1 == keta[j]){
    if(one != num[j]){
     check = false;
    }
}
else if(2 == keta[j]){
    if(ten != num[j]){
     check = false;
    }
}
else if(3 == keta[j]){
    if(hun != num[j]){
     check = false;
    }
}
}

if(check == true){
    ans = kari;
    break;
}
}
if(N == 1){
    bool a = true;
for(int i = 0; i < M; i++){
    if(num[i] != 0){
a = false;
    }
}
if(a == true) ans = 0;
}

cout << ans << endl;

}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

vector<long long> divisor_enumeration(long long n){
    vector<long long> ret;
    for(long long i=1; i*i<=n; i++){
        if(n%i == 0){
            ret.push_back(i);
            if(i*i != n) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}

template<typename T>
T power(T x, long long n, const T& m){
    if(n == 0) return 1;
    if(n == 1) return x;
    T tmp = power(x, n/2, m);
    if(n%2 == 0) return tmp * tmp % m;
    else return tmp * tmp % m * x % m;
}

int N;
ll K;

ll memo[100000];

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

    for(ll g=1; g<=K; g++){
        memo[g] = power(K/g, N, MOD);
    }

    ll ans = 0;
    for(ll g=K; g>=1; g--){
        ans += g*memo[g];
        ans %= MOD;
        //cout << g << " " << memo[g] << endl;
        auto v = divisor_enumeration(g);
        rep(i, v.size()){
            if(v[i] != g){
                memo[v[i]] -= memo[g];
                if(memo[v[i]] < 0) memo[v[i]] += MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4428
#include <iostream>
#include <string>

std::string s;
char first;
char second;
char third;
char forth;

int main() {
    std::cin >> s;

    first = s.at(0);
    second = s.at(1);
    third = s.at(2);
    forth = s.at(3);

    if (
        ((first == second) && (third==forth) && (first != third)) ||
        ((first == third) && (second==forth) && (first != second)) ||
        ((first == forth) && (third==second) && (first != second))
    ) {
        std::cout << "Yes";
    } else {
        std::cout << "No";
    }

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int H, W, N;
int a[100010], b[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }  
  map<pii, int> mp;
  for (int i = 0; i < N; i++) {
    for (int dy = 0; dy < 3; dy++) {
      for (int dx = 0; dx < 3; dx++) {
        int ny = a[i] + dy;
        int nx = b[i] + dx;
        if (ny >= 3 && ny <= H && nx >= 3 && nx <= W) {
          mp[pii(ny, nx)]++;
        }
      }
    }
  }
  vector<ll> ans(10);
  ans[0] = (ll)(H - 2) * (W - 2) - mp.size();
  for (auto p : mp) {
    ans[p.second]++;
  }
  for (int i = 0; i < 10; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

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

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	public void run() {
		main : while (true) {
			int a = in.nextInt(), l = in.nextInt();
			if (a == 0 && l == 0) break;
			ArrayList<Integer> list = new ArrayList<Integer>();
			list.add(a);
			for (int res = 1; ; res++) {
				int[] str = new int[l];
				for (int i = 0, j = 1; i < l; i++, j *= 10) {
					str[i] = (a/j) % 10;
				}
				int max = 0, min = 0;
				Arrays.sort(str);
				for (int i = 0, j = 1, k = (int)Math.pow(10, l-1); i < l; i++, j *= 10, k /= 10) {
					max += str[i] * j;
					min += str[i] * k;
				}
				int dif = max - min;
				for (int i = 0; i < list.size(); i++) {
					if (list.get(i) == dif) {
						System.out.println(i + " " + dif + " " + (res-i));
						continue main;
					}
				}
				list.add(dif);
				a = dif;
			}
		}
		out.close();
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

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

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

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 17028
#include <stdio.h>
using namespace std;

int main()
{
    int a[800000];
    int q;
    int t,x,y;
    int f = 399999;
    int l = 400000;

    scanf("%d", &q);

    for (int i = 0; i < q; i++) {
        scanf("%d", &t);
        if (t == 0){
          scanf("%d", &x);
          if (x == 0){
            scanf("%d", &y);
            a[f] = y;
            f=f-1;
          } else if (x == 1){
            scanf("%d", &y);
            a[l] = y;
            l=l+1;
          }
        } else if(t == 1){
            scanf("%d", &x);
            printf("%d\n",a[f+x+1]);
        } else if(t == 2){
            scanf("%d", &x);
            if (x == 0){
              f=f+1;
            } else if (x == 1){
              l=l-1;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 4256
d=[0]*13
d[0]=1
for c in input():
	e=[0]*13
	for k in(range(10)if c>'>'else[int(c)]):
		for j in range(13):e[(j*10+k)%13]+=d[j]
	d=[e%(10**9+7)for e in e]
print(d[5])

Measured memory_bytes: 42732
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException  {
        
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
 
        String[] line = reader.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        
        if(a < b){
            System.out.println("a < b");
        }
        
        if(a > b){
            System.out.println("a > b");
        }
        
        if(a == b){
            System.out.println("a == b");
        }
    
    }
    
}

Measured memory_bytes: 24324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll mod = 1000000007;
const int MAX = 1000100;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ll ans = 1;
    vector<ll> num(n);
    for(int i = 0; i < n; i++){
        if(a[i] == 0){
            ans *= 3 - num[0];
            num[0]++;
        }
        else{
            ans *= num[a[i] - 1] - num[a[i]];
            num[a[i]]++;
        }
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4824
// D - Div Game
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N; cin>>N;
	ll ans = 0;
  for(ll n=N, p=2; p*p<=N; ++p){
    if (N%p) continue;
		ll c = 0;
   	while(N%p == 0){ N /= p; c++; }
		for(ll pi=p, i=1; i<=c; i++, pi*=p){
			if(n%pi) continue;
			n /= pi;
			ans++;
		}
  }
  if(N != 1) ans++;
	cout<< ans <<endl;
}


Measured memory_bytes: 3628
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	string s; cin >> s;
	if(s[0] == s[1]) return cout << 1 << " " << 2 << endl, 0;
	rep(i,0,sz(s)-3) {
		char a = s[i], b = s[i+1], c = s[i+2];
		if(a == b) return cout << i+1 << " " << i+2 << endl, 0;
		if(b == c) return cout << i+2 << " " << i+3 << endl, 0;
		if(a == c) return cout << i+1 << " " << i+3 << endl, 0;
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

int main(){
    int N;
    ll ans = 0;
    cin >> N;
    for(int i=1; i<=N; ++i){
        if(i%3!=0&&i%5!=0) ans+=i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
    //奇数のとこと偶数のとこで1位, 2位を覚えておく
    //
    int N; 
    cin >> N;
    P ki[100100];
    P gu[100100];
    for(int i=0; i<100100; i++){
        ki[i].first=0;
        ki[i].second=i;
        gu[i].first=0;
        gu[i].second=i;
    }

    for(int i=0; i<N/2; i++){
        int u,v;
        cin >> u >> v;
        ki[u].first--;
        gu[v].first--;
    }

    sort(ki, ki+100100);
    sort(gu, gu+100100);

    if(ki[0].second != gu[0].second){
        cout << N+ki[0].first+gu[0].first << endl;
    }
    else{
        cout << N+min(ki[0].first+gu[1].first, ki[1].first+gu[0].first) << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std;

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

  int perfect = (int)(s[0] - '0') + 9 * (s.size() - 1);
  int sum = 0;

  for (int i = 0; i < s.size(); i++) {
    sum += (int)(s[i] - '0');
  }

  if (sum == perfect) {
    cout << perfect << endl;
  } else {
    cout << perfect - 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        c: [Chars;2],
    }

    if (c[0][0]==c[0][2] && c[1][0]==c[1][2] && c[0][1]==c[1][1]) 
    || (c[0][0]==c[1][2] && c[0][2]==c[1][0] && c[0][1]==c[1][1]) {
        println!("YES");
    } else {
        println!("NO");
    }

}


Measured memory_bytes: 2168
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, m = Is()
PY = []
for i in range(m):
    p, y = Is()
    PY.append((i, p, y))
PY.sort(key=itemgetter(1, 2))
ANS = [[0]*2 for _ in range(m)]
tmp = -1
count = -1
for i, p, y in PY:
    if tmp != p:
        count = 1
        tmp = p
    else:
        count += 1
    ANS[i][0] = p
    ANS[i][1] = count
for a, b, in ANS:
    print("{}{}".format(str(a).zfill(6), str(b).zfill(6)))


Measured memory_bytes: 109400
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		String s = scn.next();
      	String t = scn.next();
      	String[] list1 = s.split("");
      	String[] list2 = t.split("");
      	String ans = "";
      	for(int i=0; i<n; i++){
          ans = ans + list1[i] + list2[i];
        }
      	System.out.println(ans);
	}
}


Measured memory_bytes: 39224
import java.util.Scanner;
class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   String s = sc.next();
   int n = s.length();
   String x , y;
   x = s.substring(0,n/2);
   y = s.substring(n/2+1,n);
   if(x.equals(y)){
     System.out.println("Yes");
   }else{
     System.out.println("No");
   }

 }
}

Measured memory_bytes: 21972
import Control.Monad
import Control.Applicative

strShuffle s i = drop i s ++ take i s

main = do
    strLn <- getLine
    if strLn == "-" then return () else do
        n <- read <$> getLine
        shuffles <- replicateM n $ read <$> getLine :: IO [Int]
        putStrLn $ foldl strShuffle strLn shuffles
        main

Measured memory_bytes: 4176
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))

const int mod = 998244353;
typedef unsigned long long lu;

inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (lu)x * y % mod; }
inline int Mul(int x, int y, int z) { return (lu)x * y % mod * z % mod; }

inline int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}

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

const int maxn = 2e5;

int n;
char str[maxn + 1];
int A, B, C, D;

bool Check1(int l, int r) {
  for (int i = l; i < r; ++i) {
    if (str[i] == '#' && str[i + 1] == '#') return false;
  }
  return true;
}

int main(void) {
  scanf("%d%d%d%d%d%s", &n, &A, &B, &C, &D, str);
  --A; --B; --C; --D;
  bool ans = Check1(B, D) && Check1(A, C);
  if (C > D) {
    bool sp = false;
    for (int i = B; i <= D; ++i) {
      if (str[i] == '.' && str[i - 1] == '.' && str[i + 1] == '.') {
        sp = true;
        break;
      }
    }
    ans &= sp;
  }

  puts(ans ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int D[100009];

int main() {
    int K; scanf("%d",&K);
    for(int i=0; i<K; i++) D[i] = 1e9;
    priority_queue<pii> pq;
    pq.push({-1, 1});
    D[1] = 1;
    while(pq.size()) {
        int c, x; tie(c, x) = pq.top(); pq.pop();
        c *= -1;
        for(int i=1; (x+i)%10; i++) {
            int nxt = (x+i) % K;
            if(D[nxt] > c + i) {
                D[nxt] = c + i;
                pq.push({-D[nxt], nxt});
            }
        }
        int nxt = x*10 % K;
        if(D[nxt] > D[x]) {
            D[nxt] = D[x];
            pq.push({-D[nxt], nxt});
        }
    }
    printf("%d",D[0]);
    return 0;
}


Measured memory_bytes: 1784
n,m = map(int,input().split())
if n % 2 == 1:
  n = 2*m+1
  for i in range(m):
    print(m-i,m+1+i)
else:
  n = 2*m+2
  for i in range(m):
    l = m-i
    r = m+1+i
    if r-l >= m+1:
      r += 1
    print(l,r)

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

int main() {
  int A,B;
  cin>>A>>B;
  int sum=-1;
  for(int i=1;i<1500;i++){
    int a=i*0.08;
    int b=i*0.1;
    if(a==A&&b==B){
      sum=i;
      break;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
def main():
    ary = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
           1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

    K = int(input())

    print(ary[K - 1])


main()


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
void dump(int* a, int n){
	for(int k = 0; k < n; ++k){
		cout << a[k];
		if( k != n - 1)
			cout << " ";
	}
	cout << "\n";
}

int main()
{
	int n, i, j, k, v, a[100] = {};
	cin >> n;
	for(i = 0; i < n; ++i) cin >> a[i];
	dump(a, n);

	if( n == 1)
		return 0;

	for(i = 1; i <= n-1; ++i){
		v = a[i];
		j = i - 1;
		while( j >= 0 && a[j] > v ){
			a[j+1] = a[j];
			--j;
		}
		a[j+1] = v;
		dump(a, n);
	}

	return 0;
}

Measured memory_bytes: 1160