akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastReader in = new FastReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    CVacation solver = new CVacation();
    solver.solve(1, in, out);
    out.close();
  }

  static class CVacation {

    public void solve(int testNumber, FastReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] a = new int[n];
      int[] b = new int[n];
      int[] c = new int[n];
      for (int i = 0; i < n; ++i) {
        a[i] = in.nextInt();
        b[i] = in.nextInt();
        c[i] = in.nextInt();
      }
      int[][] dp = new int[3][n + 1];
      for (int i = 1; i <= n; ++i) {
        dp[0][i] = Math.max(dp[1][i - 1] + a[i - 1], dp[2][i - 1] + a[i - 1]);
        dp[1][i] = Math.max(dp[0][i - 1] + b[i - 1], dp[2][i - 1] + b[i - 1]);
        dp[2][i] = Math.max(dp[1][i - 1] + c[i - 1], dp[0][i - 1] + c[i - 1]);
      }
      out.println(Math.max(dp[0][n], Math.max(dp[1][n], dp[2][n])));
    }

  }

  static class FastReader {

    BufferedReader reader;
    StringTokenizer st;

    public FastReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      st = null;
    }

    public String next() {
      while (st == null || !st.hasMoreTokens()) {
        try {
          String line = reader.readLine();
          if (line == null) {
            return null;
          }
          st = new StringTokenizer(line);
        } catch (Exception e) {
          throw new RuntimeException();
        }
      }
      return st.nextToken();
    }

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

  }
}



Measured memory_bytes: 42808
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
typedef vector<ll> vll;
vll prime;
vector<pair<ll,ll> > Pair(100001);
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
int main() 
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	ll t=1;
//	cin>>t;
	while(t--)
	{
	    int a[32]={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};
	    int k;
	    cin>>k;
	    cout<<a[k-1]<<endl;
	    
		
	}
	return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,k,sum=1000000000,j;
  cin>>n;
  long long int a[n],i;
  for(i=0;i<n;i++)
  {
    cin>>a[i];

  }
  for(int i = 1; i <= 100; i++) {
    long long int cost = 0;
    for(j=0;j<n;j++) cost += (a[j] - i) * (a[j] - i);
    sum = min(sum, cost);


  }
  cout<<sum;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b, c;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c;
  map<int, int> mp;
  mp[a]++;
  mp[b]++;
  mp[c]++;

  if(mp[5] == 2 && mp[7] == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = [list(input()) for _ in range(3)]
for i in range(3):
    s[i] = [ord(x) - ord('a') for x in s[i]][::-1]
now = 0
while True:
    if s[now] == []:
        print(chr(ord('A') + now))
        break
    now = s[now].pop()
    

Measured memory_bytes: 10248
D = int(input())

cs = [int(i) for i in input().split()]

last = {n: 0 for n in range(1, 27)}
ans = []
for day in range(1, D):
    ss = [int(i) for i in input().split()]
    max_score = 0
    max_i = 1
    for i, s in enumerate(ss, 1):
        human = day-last[i]
        s_human = s + cs[i-1] * (human*2)
        if s_human > max_score:
            max_score = s_human
            max_i = i
    ans.append(max_i)
    last[max_i] = day
ss = [int(i) for i in input().split()]
m = 0
mi = 1
for i, s in enumerate(ss,1):
    if s > m:
        m = s
        mi = i
for a in ans:
    print(a)
print(mi)

Measured memory_bytes: 9264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll MOD = 1e9+7;
const ll N = 1e7+10;
ll f[N], rf[N];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < N; i++) f[i] = (f[i - 1] * i) % MOD;
    rf[N - 1] = inv(f[N - 1]);
    for(int i = N-2; i >= 0; i--) rf[i] = (rf[i + 1] * (i + 1)) % MOD;
}
ll C(int n, int k) {
    if(k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!
    ll bc = (b * c) % MOD;
    return (a * bc) % MOD;
}
ll p(int n, int k) {
    if (k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n - k]; // = (n-k)!
    return (a * b) % MOD;
}
ll H(int n, int k) {
    if (n == 0 && k == 0) return 1;
    return C(n + k - 1, k);
}
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;
}

int main()
{
    int x, y;
    cin >> x >> y;
    if(x > y) swap(x, y);
    init();
    if(2 * x < y || (x+y) % 3 != 0)
    {
        cout << 0 << endl;
    }
    else
    {
        int count = y - x;
        int n = (x+y) / 3;
        cout << C(n, x-n) << endl;
    }
}


Measured memory_bytes: 156544
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = float("inf")
for i in range(A[0], A[-1]+1):
    med = i
    tmp = 0
    for j in range(N):
        tmp += (A[j] - med)**2
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 3060
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    X, N = map(int, input().split())
    p = list(map(int, input().split()))

    #output
    answer1 = X
    answer2 = X
    while answer1 in p:
        answer1 -= 1
    while answer2 in p:
        answer2 += 1

    if X - answer1 == answer2 - X:
        print(answer1)
    elif X - answer1 < answer2 - X:
        print(answer1)
    elif X- answer1 > answer2 - X:
        print(answer2) 

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 9204
l, r = map(int, input().split())

if r - l > 2019:
  l = 0
  r = 2018
  
def solve():
  md = 2019
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      md = min((i * j) % 2019, md)
  return md

print(solve())

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#define BIT(x) (1<<(x))
using namespace std;
int ans;
vector<int> o_line;
int main(){
    int N, M;
    cin>>N>>M;
    vector<int> side(M);
    ans = M;
    o_line.resize(N);
    for(int i=0;i<N;++i){
        o_line[i] = i;
    }
    for(int i=0;i<M;++i){
        cin >> side[i];
        --side[i];
        swap(o_line[side[i]], o_line[side[i]+1]);
    }
    vector<int> use(M);
    for(int i=0;i<M;++i){
        use[i] = i;
    }
    do{
        vector<int> line(N);
        for(int i=0;i<N;++i){
            line[i] = i;
        }
        for(int i=0;i<M;++i){
            swap(line[side[use[i]]], line[side[use[i]]+1]);
        }
        if(o_line == line){
            int count = 1;
            int used = 0;
            for(int i=0;i<M;++i){
                int num = side[use[i]];
                if((used & BIT(num)) || (used & BIT(num + 1))){
                    ++count;
                    used = BIT(num)*3;
                }else{
                    used += BIT(num)*3;
                }
            }
            ans = min(count, ans);
        }
    }while(next_permutation(use.begin(), use.end()));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;

int main(){
	lli n,m;
	cin >> n >> m;
	vector<lli> a(n+1, 0);
	for(int i=0; i<n; i++){
		cin >> a[i+1];
	}
	for(int i=0; i<n; i++){
		a[i+1] = (a[i] +a[i+1]) %m;
	}

	map<lli, lli> num;
	for(int i=1; i<=n; i++){
		num[a[i]]++;
	}

	lli ans = 0;
	for(int i=1; i<=n; i++){
		ans += num[(a[i-1])%m];
		num[a[i]]--;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(void)
{
    ll N;
    cin >> N;

    vector<int> a(N + 1);
    for(int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }

    vector<int> box(N + 1);

    ll ans = 0;
    vector<ll> ans_arr;

    for(ll i = N / 2 + 1; i <= N; i++)
    {
        box[i] = a[i];

        if(box[i] == 1)
        {
            ans++;
            ans_arr.push_back(i);
        }
    }

    for(ll i = N / 2; i > 0; i--)
    {
        ll ball_num = 0;
        ll loop_count = N / i;

        for(ll j = 2; j <= loop_count; j++)
        {
            if(box[i * j] == 1)
            {
                ball_num++;
            }
        }

        if(ball_num % 2 == a[i])
        {
            box[i] = 0;
        }
        else
        {
            box[i] = 1;

            ans++;
            ans_arr.push_back(i);
        }
    }

    sort(ans_arr.begin(), ans_arr.end());

    cout << ans << endl;

    ll arr_size = ans_arr.size();
    for(ll i = 0; i < arr_size; i++)
    {
        if(i != arr_size - 1)
        {
            cout << ans_arr[i] << " ";
        }
        else
        {
            cout << ans_arr[i] << endl;
        }
    }

    // for(int bit = 0; bit < (1 << N); bit++)
    // {
    //     ll ans = 0;
    //     vector<ll> ans_arr;

    //     bool isAns = true;

    //     for(int i = 1; i <= N; i++)
    //     {
    //         ll loop_count = N / i;
    //         ll ball_count = 0;

    //         for (int j = 1; j <= loop_count; j++)
    //         {
    //             if (bit & (1 << i * j - 1))
    //             {
    //                 ball_count++;

    //                 if(i == 1)
    //                 {
    //                     ans++;
    //                     ans_arr.push_back(j);
    //                 }
    //             }
    //         }

    //         if(ball_count % 2 != a[i - 1])
    //         {
    //             isAns = false;
    //             break;
    //         }
    //     }

    //     if (isAns)
    //     {
    //         cout << ans << endl;
    //         for (int i = 0; i < ans_arr.size(); i++)
    //         {
    //             if (i != ans_arr.size() - 1)
    //             {
    //                 cout << ans_arr[i] << " ";
    //             }
    //             else
    //             {
    //                 cout << ans_arr[i] << endl;
    //             }
    //         }

    //         return 0;
    //     }
    // }
}

Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template<typename T> using Graph = vector<vector<T>>;
template<typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template<typename T> struct is_pair : false_type{};
template<typename T1, typename T2> struct is_pair<pair<T1, T2>> : true_type{};
template<typename T> struct is_vector : false_type{};
template<typename T> struct is_vector<vector<T>> : true_type{};

template<typename T1, typename T2>
istream &operator >> (istream &istr, pair<T1, T2> &p) {
  istr >> p.first >> p.second;
  return istr;
} 
template<typename T1, typename T2>
ostream &operator << (ostream &ostr, const pair<T1, T2> &p) {
  ostr << p.first << " " << p.second;
  return ostr;
}
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) return ostr;
  bool vp = is_vector<T>() || is_pair<T>();
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    ostr << (vp ? "\n" : " ") << *itr;
  }
  return ostr;
}

template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int modpow(int a, long long n, int mod = MOD) {
  int ret = 1;
  do {
    if (n & 1) ret = 1LL * ret * a % mod;
    a = 1LL * a * a % mod;
  } while (n >>= 1);
  return ret;
}

template<typename T>
T GCD(T a, T b) { return b ? GCD(b, a%b) : a; }
template<typename T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

template<typename T1, typename T2>
bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) {
  return a.second != b.second ? a.second < b.second : a.first < b.first;
}
template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) return a.first < b.first;
  if (a.first == 0) return a.second >= 0 || b.first > 0;
  if (b.first == 0) return b.second < 0 && a.first < 0;
  return a.second * b.first < a.first * b.second;
}


/* -------- <templates end> -------- */


void solve() {
  int h, a; cin >> h >> a;
  cout << (h-1)/a+1 << endl;
}


/* -------- <programs end> -------- */


signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>

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

  uint32_t N;
  std::cin >> N;

  std::vector<std::pair<double, double>> m(N, {0, 0});
  std::vector<uint32_t> cm;
  for (uint32_t i = 0; i < N; i++) {
    std::cin >> m[i].first >> m[i].second;
    cm.push_back(i);
  }

  std::vector<double> all;
  uint32_t z = 0;
  do {
    z++;
    double ret = 0;
    for (uint32_t i = 1; i < N; i++) {
      auto j = cm[i];
      auto pj = cm[i - 1];
      ret += std::sqrt(std::pow(m[j].first - m[pj].first, 2) + std::pow(m[j].second - m[pj].second, 2));
    }
    all.push_back(ret);
  } while (next_permutation(cm.begin(), cm.end()));

  double r = 0;
  for (const auto &v: all) {
    r += v;
  }

  std::cout << std::fixed << std::setprecision(10) << (r / all.size()) << std::endl;

  return 0;
}


Measured memory_bytes: 892
def cal(x,y):
  if x>=y:
    return x-y
  else:
    a=y-x
    b=a//2
    if a%2!=0:
      b+=2
    return b
A,B,C=map(int,input().split())
ans=10**3

for i in range(51):
  kans=cal(A,i)+cal(B,i)+cal(C,i)
  ans=min(ans,kans)
print(ans)

Measured memory_bytes: 3060
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};


fn solve(x: u64, t: u64) -> u64 {
    if x < t { 0 } else { x - t }
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next(), sc.next()));
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_foreach<T: Display>(answer: &[T]) {
    for x in answer {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_yn(answer: bool, yes: &str, no: &str) {
    println!("{}", if answer { yes } else { no });
}


#[allow(dead_code)]
fn print_or<T: Display>(answer: &Option<T>, or: &T) {
    match *answer {
        Some(ref x) => println!("{}", x),
        None => println!("{}", or),
    }
}


Measured memory_bytes: 4352
import itertools
n, x, y = map(int, input().split())

lst = [0 for _ in range(1, n)]
for _ in itertools.combinations([_ for _ in range(1, n+1)], 2):
    i, j = _[0], _[1] 
    ans = min(abs(i-j), abs(x-j)+1+abs(y-i),abs(x-i)+1+abs(y-j))
    lst[ans-1] += 1
    
for _ in lst:
    print(_)


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

int N, M;
int WA[105000];
bool AC[105000];

void solve() {
    cin >> N >> M;
    int WAnum = 0;
    int ACnum = 0;
    for(int i = 1; i <= N; i++) {
        WA[i] = 0;
        AC[i] = false;
    }
    while(M--) {
        int p;
        string S;
        cin >> p >> S;
        if(AC[p]) continue;
        if(S == "AC") {
            AC[p] = true;
            ACnum++;
            WAnum += WA[p];
        } else if(S == "WA") {
            WA[p]++;
        }
    }
    cout << ACnum << " " << WAnum << endl;
    return;
}

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


Measured memory_bytes: 4104
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b,k;
  cin>>a>>b>>k;
  for(Int i=a;i>=1;i--){
    if(a%i) continue;
    if(b%i) continue;
    k--;
    if(k==0) cout<<i<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;
int main (){
    int a,b;
    cin >> a >> b;
    int ta=-1;
    int tb=b*10;
    for (int i = 0; i < 10; i++){
        if(floor((tb+i)*0.08)==a){
            ta=tb+i;
            break;
        }
    }
    cout << ta << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

//#include <set>
//#include <unordered_map>

using namespace std;

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

#define max_n 100

int N,M;

vector<pair<int,int>> BA;


int main() {
	
	cin >> N >> M;

	rep(i, N) {
		int j, k;
		cin >> j >> k;
		BA.push_back(make_pair(k,j));
	}
	
	sort(BA.begin(), BA.end(),greater<pair<int,int>>());    //  文字列 → 整数 のハッシュ連想配列

	vector<int> box(M);
	rep(i, M)box[i] = i+1;


	long long ans = 0;
	rep(i,N){
		if (BA[i].second > M)continue;

		if (box.size() <= 0)break;
		int f = 0;
		int e = box.size() - 1;
		while (f<e)
		{
			int m = (f + e) / 2;
			if (box[m] >= BA[i].second) {
				e = m;
			}else{
				f = m + 1;
			}
		}
		if (box[f] < BA[i].second)continue;
		box.erase(box.begin() + f);
		ans += BA[i].first;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

int IsPrime(int n){
	int i;
	if(n==1) return 0;
	if(n==2){
		return 1;
	}else if(n%2==0){
		return 0;
	}
	for(i=3;i*i<=n;i+=2){
		if(n%i==0){
			return 0;
		}
	}
	return 1;
}

int main(void){
	int n , p[10001] , count = 2 , sum_p[10001];
	p[1] = 2;
	for(n=3;count<=10000;n+=2){
		if(IsPrime(n)){
			p[count] = n;
			count++;
		}
	}
	sum_p[1] = 2;
	for(n=1;n<10000;n++){
		sum_p[n+1] = sum_p[n] + p[n+1];
	}
	while(1){
		scanf("%d" , &n);
		if(n==0) break;
		printf("%d\n" , sum_p[n]);
	}
	return 0;
}

Measured memory_bytes: 0
mod = 1000000007
N, M = map(int, input().split())
A = list(set([int(input()) for _ in range(M)]))
M = len(A)
for i in range(M-1):
    if A[i] + 1 == A[i+1]:
        print(0)
        exit()

check = [0]*(N+2)
for i in range(M):
    check[A[i]] = 1
    check[A[i]+1] = 1
    check[A[i]+2] = 1

dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1
i = 2
while i <= N:
    if check[i]:
        dp[i] = dp[i-1]    
        i += 1
    else:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
        i += 1
print(dp[N])




Measured memory_bytes: 57336
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define nd second                   
#define fori(i, a, b, c) 	for (int i = (int)(a); i <= (int)(b); i += (int)(c))
#define ford(i, a, b, c) 	for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define MOD 998244353

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lol;
typedef vector<lol> vlol;

ifstream in ("input");

const int NR = 3e3 + 5;

int n, S;
lol dp [NR];
lol ans;

int main()	{
	int i;
	int x;
	ios::sync_with_stdio(false);
	cin >> n >> S;
	fori(i, 1, n, 1) {
		cin >> x;
		if ( x > S )	continue;
		if ( x == S )	{
			( ans += i * (n-i+1) ) %= MOD;
			continue;
		}
		if ( dp [S - x] )	{
			(ans += dp [S-x]*(n-i+1) ) %= MOD ;
		} 
		ford(j, S-1, x+1, 1)	{
			( dp [j] += dp [j - x] ) %= MOD;
		}
		( dp[x] += i ) %= MOD;
	}			
	cout << ans;		
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
#include <functional>

using namespace std;


int main() {
	string s,ans;
	cin >> s;
	int a = s.length() -2;
	ans = s[0] + to_string(a) + s[s.length()-1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;
const ld pi = (acos(-1));


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  ld r; cin >> r;
  cout << 2*r*pi << endl;
  
 }

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

#define NIL -2000000000

typedef struct{
  int k;
  int lk;
  int rk;
}Node;

int main(){

  Node *A;
  int h,i,x;

  scanf("%d",&h);

  A = malloc((h+1)*sizeof(Node));

  for(i = 1 ; i <= h ; i++) A[i].k = A[i].lk = A[i].rk = NIL;


  for(i = 1 ; i <= h ; i++){
    scanf("%d",&x);

    A[i].k = x;
    if(i%2 == 0) A[i/2].lk = x;
    else if(i%2 == 1) A[i/2].rk =x;

  }

  for(i = 1 ; i <= h ; i++){

    if(i == 1)
      printf("node %d: key = %d, left key = %d, right key = %d, "
             , i, A[i].k, A[i].lk, A[i].rk);

    else if(A[i].lk == NIL && A[i].rk ==NIL)
      printf("node %d: key = %d, parent key = %d, "
             , i, A[i].k, A[i/2].k);

    else if(A[i].lk == NIL)
      printf("node %d: key = %d, parent key = %d, right key = %d, "
             , i, A[i].k, A[i/2].k, A[i].rk);

    else if(A[i].rk == NIL)
      printf("node %d: key = %d, parent key = %d, left key = %d, "
             , i, A[i].k, A[i/2].k, A[i].lk);

    else
      printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, "
             , i, A[i].k, A[i/2].k, A[i].lk, A[i].rk);

    printf("\n");

  }

  return 0;

}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct UnionFind {
  vector<int> data;
  UnionFind(int n):data(n, -1){}
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};

int modPow(int x, int n) {
  int res = 1;
  while(n > 0) {
    if(n&1) (res *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m;
  while(cin >> n >> m, n) {
    UnionFind uf(n);
    rep(i, m) {
      int a, b;
      cin >> a >> b;
      --a, --b;
      uf.unite(a, b);
    }
    int kind = 0;
    rep(i, n) kind += (uf.find(i) == i);
    if(kind == n) cout << modPow(2, kind) << endl;
    else cout << modPow(2, kind)+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3896
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

string s[114514];
signed main() {
	IOS();
	string s;
	cin >> s;
	ll ans = 0;
	int n  = s.size();
	for (int i = 0; i < n; i++) {
		for (int j = 1; i + j <= n; j++) {
			string t = s.substr(i, j);
			bool ok  = true;
			for (int k = 0; k < j; k++) {
				if (t[k] == 'A' || t[k] == 'T' || t[k] == 'G' || t[k] == 'C') continue;
				ok = false;
			}
			if (ok) ans = max(ans, (ll)j);
		}
	}
	dump(ans);
	return 0;
}

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

int main(){
    long long n, m;
    cin >> n >> m;
    
    vector<pair<long long, long long>> p(n);
    rep(i, n){
        cin >> p.at(i).first >> p.at(i).second;
    }
    sort(p.begin(), p.end());
    
    long long sum = 0;
    rep(i, n){
        if(m >= p.at(i).second){
            m -= p.at(i).second;
            sum += p.at(i).first * p.at(i).second;
        } else {
            sum += p.at(i).first * m;
            break;
        }
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
<?php
// $str1 = trim(fgets(STDIN));
// $str2 = trim(fgets(STDIN));
// $array = explode(" ", $str2);
// $d2 = $array[1];

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class SubmitAnswer {
    public static function println($answer = "") {
        echo $answer . PHP_EOL;
    }
}


$sc = new Scanner();
$s = $sc->nextInt();
$s = $sc->nextInt();
$s = $sc->nextInt();
$d2 = $sc->nextInt();


if($d2 < 2){
  $answer = 1;
} else {
  $answer = 0;
}

SubmitAnswer::println("$answer");

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
 
const ll MAX_N=1000000;
 
ll n,rmq[2*MAX_N-1];
 
void init(ll x){
    n=1;
    while(n<x)n*=2;
    rep(i,2*n-1)rmq[i]=INT_MAX;
}
 
void update(ll k,ll a){
    k+=n-1;
    rmq[k]=a;
    while(k>0){
        k=(k-1)/2;
        rmq[k]=min(rmq[k*2+1],rmq[k*2+2]);
    }
}
 
ll query(ll a,ll b,ll k,ll l,ll r){
    if(r<=a||b<=l)return INT_MAX;
     
    if(a<=l&&r<=b)return rmq[k];
     
    else{
        ll vl=query(a,b,k*2+1,l,(l+r)/2);
        ll vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}
 
int main(){
    ll q;
    cin>>n>>q;
    ll r=n;
    init(r);
    rep(i,q){
        ll s;
        ll x,y;
        cin>>s>>x>>y;
        if(s==0) update(x,y);
        else{
            cout<<query(x,y+1,0,0,n)<<endl;
        }
    }
}


Measured memory_bytes: 5140
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<ll,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;
struct edge { int to, cost; };

int n,m,s,t;
vector<edge> G[2][100009];
ll d[2][100009];

void add_edge(int u,int v,int cost,int slc){
    G[slc][u].push_back({v,cost});
    G[slc][v].push_back({u,cost});
}

void dijkstra(int s,int slc) {
    
    priority_queue< pii, vector<pii>, greater<pii> > que;   // first:cost second:頂点 cost基準の昇順
    que.push({0,s});
    d[slc][s] = 0;
    
    while(!que.empty()){
        pii p = que.top(); que.pop();
        int v = p.second;
        if(d[slc][v]<p.first) continue;
        for(auto e:G[slc][v]){
            if(d[slc][e.to]>d[slc][v]+e.cost){
                d[slc][e.to] = d[slc][v]+e.cost;
                que.push({d[slc][e.to],e.to});
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m>>s>>t;
    s--,t--;
    rep(i,m){
        int u,v,a,b;
        cin>>u>>v>>a>>b;
        u--,v--;
        add_edge(u,v,a,0);
        add_edge(u,v,b,1);
    }
    
    rep(i,n){
        d[0][i]=LLINF;
        d[1][i]=LLINF;
    }
    
    dijkstra(s,0);
    dijkstra(t,1);
    
    priority_queue< pii, vector<pii>, greater<pii> > ans;
    rep(i,n){
        ll tcost=d[0][i]+d[1][i];
        ans.push({tcost,i});
    }
    
    ll num=1e15-ans.top().first;
    rep(i,n){
        while(ans.top().second<i){
            ans.pop();
            num=1e15-ans.top().first;
        }
        cout1(num);
    }
}

Measured memory_bytes: 17020
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

//#define int ll

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

void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

signed main(){
    cin>>h>>w;
    rep(i,0,10)rep(j,0,10){
        cin>>d[i][j];
    }
    warshall_floyd(10);
    
    int res=0;
    rep(i,0,h)rep(i,0,w){
        int a;
        cin>>a;
        if(a!=-1)res+=d[a][1];
    }
    
    cout<<res<<endl;
    return 0;
}

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

bool solve() {
    string S;
    cin >> S;
    int p = S.size();
    vector<string> t{"dream", "dreamer", "erase", "eraser"};
    while ( p > 0 ) {
        bool ok = false;
        for ( int i = 0; i < 4; i++ ) {
            int tsz = t[i].size();
            if ( p < tsz ) continue;
            if ( S.substr(p-tsz, tsz) == t[i] ) {
                p -= tsz;
                ok = true;
                break;
            }
        }
        if ( !ok ) break;
    }
    return p == 0;    
}

int main() {
    string ans = solve() ? "YES" : "NO";
    cout << ans << "\n";
    return 0;
}

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

int main() {

long k,a,b;
cin>>k>>a>>b;

for(int i=a;i<=b;i++){
  if(i%k==0){
    cout<<"OK"<<endl;
    return 0;
  }
}
cout<<"NG"<<endl;
}


Measured memory_bytes: 3632
def solve():
    s = input()
    ans = 0
    hoge = [0]
    for i in s:
        if i == "R":
            ans += 1
            hoge.append(ans)
        else:
            ans = 0
    print(max(hoge))
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 61736
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int a=0;
  int count=0;
  for(int i;i<3;i++){
    a=n%10;
    n/=10;
    if(a==7){
      count++;
    }
  }
    if(count>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
    string a, b;
    cin>>a>>b;
    lli c, d;
    cin>>c>>d;
    string u;
    cin>>u;
    if(u == a)
        cout<<c-1<<" "<<d<<"\n";
    else
        cout<<c<<" "<<d-1<<"\n";
    return 0;
}   
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	var A, B, C, D int
	fmt.Scanf("%d %d %d %d\n", &A, &B, &C, &D)

	t := A
	a := C
	for {
		a -= B
		if a <= 0 {
			fmt.Println("Yes")
			break
		}
		t -= D
		if t <= 0 {
			fmt.Println("No")
			break
		}
	}

}


Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    int cnt=0;
    for(int i=0;i<a.size();i++)
	{
        if(a[i]=='C')
		{
            cnt=1;
        }
        if(a[i]=='F'&&cnt==1)
		{
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s;
    cin >> s;
    int n = s.length();
    for(int i = 0; i + 1 < n; ++i){
        if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    for(int i = 0; i + 2 < n; ++i){
        if(s[i] == s[i + 2]){
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int ans = 3;
  if (a == b) {
    ans--;
    if (a == c)
      ans--;
  } else if (a == c) {
    ans--;
    if (a == b)
      ans--;
  } else if (b == c) {
    ans--;
    if (a == b)
      ans--;
  }
  cout << ans << endl;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var a = ReadArrayInt();
            var aSum = new long[a.Length + 1];
            for (int i = 1; i < aSum.Length; i++) aSum[i] = aSum[i - 1] + a[i - 1];
            var min = new PriorityQueue<int>((i, j) => i - j);
            var max = new PriorityQueue<int>((i, j) => j - i);
            for (int i = 0; i < N; i++) min.Enqueue(a[i]);
            var minS = new long[N + 1];
            for (int i = N; i < 2 * N; i++)
            {
                min.Enqueue(a[i]);
                minS[i - N + 1] += minS[i - N] + min.Dequeue();
            }
            for (int i = 2 * N; i < a.Length; i++) max.Enqueue(a[i]);
            var maxS = new long[N + 1];
            for (int i = 2 * N - 1; i >= N; i--)
            {
                max.Enqueue(a[i]);
                maxS[i - N] += maxS[i - N + 1] + max.Dequeue();
            }
            var ans = long.MinValue;
            for (int i = 0; i <= N; i++)
            {
                var minT = aSum[i + N] - minS[i];
                var maxT = aSum[3 * N] - aSum[i + N] - maxS[i];
                if (minT - maxT > ans) ans = minT - maxT;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }

    class PriorityQueue<T>
    {
        readonly List<T> heap;
        readonly Comparison<T> compare;
        int size;
        public PriorityQueue(Comparison<T> compare)
        {
            heap = new List<T>();
            this.compare = compare;
        }
        public void Enqueue(T val)
        {
            heap.Add(val);
            int i = size++;
            while (i > 0)
            {
                int p = (i - 1) >> 1;
                if (compare(heap[p], val) <= 0) break;
                heap[i] = heap[p];
                i = p;
            }
            heap[i] = val;
        }
        public T Dequeue()
        {
            T ret = heap[0];
            T x = heap[--size];
            int i = 0;
            while ((i << 1) + 1 < size)
            {
                int a = (i << 1) + 1;
                int b = (i << 1) + 2;
                if (b < size && compare(heap[b], heap[a]) < 0) a = b;
                if (compare(heap[a], x) >= 0) break;
                heap[i] = heap[a];
                i = a;
            }
            heap[i] = x;
            heap.RemoveAt(size);
            return ret;
        }
        public T Peek() { return heap[0]; }
        public int Count { get { return size; } }
        public bool Any() { return size > 0; }
    }
}

Measured memory_bytes: 46008
#include <iostream>  
#include <cstdio>  
using namespace std;  
#define DIRECTSIZE 4  
struct _direct {  
    int drow;  
    int dcol;  
} direct[DIRECTSIZE]={{0, -1}, {0, 1}, {-1, 0}, {1, 0}};  
  
const int N = 100;  
string grid[N];  
int h, w, ans;  
void dfs(int row, int col, char c)  
{  
    if(grid[row][col] == c) {  
        grid[row][col] = ' ';  
  
        for(int i=0; i<DIRECTSIZE; i++)
		{  
            int nextrow = row + direct[i].drow;  
            int nextcol = col + direct[i].dcol;  
  
            if(0 <= nextrow && nextrow < h && 0 <= nextcol && nextcol < w)  
                if(grid[nextrow][nextcol] != ' ') dfs(nextrow, nextcol, c);  
        }  
    }  
}  
  
int main()  
{      
    while(cin >> h >> w && (h || w))
	{  
        getchar();  
        for(int i=0; i<h; i++)  
            getline(cin, grid[i]);  
        ans=0;  
        for(int i=0;i<h;i++)  
            for(int j=0; j<w; j++)
			{  
                char c=grid[i][j];  
                if(c!=' ')
				{  
                    ans++;  
                    dfs(i, j, c);  
                }  
            } 
        cout<<ans<< endl;  
    }  
    return 0;  
}  


Measured memory_bytes: 3828
<?php
fscanf(STDIN, "%d", $n);
$l = array_map('intval', explode(' ', trim(fgets(STDIN))));
$s1 = 0;
$s2 = array_sum($l);
$diff_b = $s2;
for ($i=0; $i < $n - 1; $i++) {
  $s1 += $l[$i];
  $s2 -= $l[$i];
  $diff = abs($s1 - $s2);
  if ($diff > $diff_b) {
    $diff = $diff_b;
    break;
  }
  $diff_b = $diff;
}
echo $diff;
?>


Measured memory_bytes: 3956
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  int n,x,l[110],ans=0;
  cin>>n>>x;
  l[0]=0;
  for(int i=1;i<=n;i++){
    int temp;
    cin>>temp;
    l[i]=l[i-1]+temp;
  }
  for(int i=0;i<=n;i++){
    if(l[i]<=x) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256