akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>

using namespace std;
struct node{
    node *l,*p,*r;
    int key;
};
node *t ,*NIL;
void insert(int k){
    node *y=NIL;
    node *x=t;
    node *z;
    z = new node;
    z->key = k;
    z->l = NIL;
    z->r = NIL;
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->l;
        }
        else{
            x=x->r;
        }
    }
    z->p=y;
    if(y==NIL){
        t=z;
    }
    else {
        if(z->key<y->key)y->l=z;
        else y->r=z;
    }
}
void find(node *c,int k){
    if(c==NIL){
        cout<<"no"<<endl;
    }
    else if(k<c->key){
        find(c->l,k);
    }
    else if(k>c->key) {
        find(c->r,k);
    }
    else{
        cout<<"yes"<<endl;
    }
}
void In(node *c){
    if (c== NIL){
        return;
    }
    In(c->l);
	printf(" %d",c->key);
    In(c->r);
}
void Pre(node *c){
    if (c== NIL){
        return;
    }
    printf(" %d",c->key);
	Pre(c->l);
    Pre(c->r);
	
}
int main(){
    int n,x;
    string com;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            cin>>x;
            insert(x);
        }
        else if(com=="find"){
            cin>>x;
            find(t,x);
        }
        else{
            In(t);
            cout<<endl;
            Pre(t);
            cout<<endl;
        }
    }
    return 0;
}






Measured memory_bytes: 22012
import math
from collections import Counter

N, P = map(int, input().split())
primes = []
mx =int(math.sqrt(P)+2)
for i in range(2,mx):
  while P%i == 0:
      primes +=[i]
      P = P//i
if P>1: primes+=[P]

c = Counter(primes) 
ans = 1
for key in c:
  ans *= max(key** (c[key]//N),1)
print(ans)

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main()
{
    int A,B,X;
    scanf("%d %d %d",&A,&B,&X);
    if(1<=A<=100&&1<=B<=100&&1<=X<=200){
            for(int i=0;i<=B&&X>A;i++){
               B--;
               A++;

            }
            if(A==X){
                printf("YES");
            }
            else{
                printf("NO");
            }
    }
    return 0;
}


Measured memory_bytes: 256
n, k = gets.split(" ").map(&:to_i)
v = gets.split(" ").map(&:to_i)

ans = 0

0.upto(k) do |i|
  break if i > n
  0.upto(i) do |r| #右からr
    l = i - r
    tmp = []
    l.times do |x|
      tmp << v[x]
    end
    r.times do |x|
      tmp << v[n-1-x]
    end
    tmp = tmp.sort_by{|e| e}
    (k-i).times do |x|
      if !tmp.empty?
        tmp.shift if tmp[0] < 0
      end
    end
    sum = tmp.inject(:+) if !tmp.empty?
    ans = sum if !sum.nil? && sum > ans
  end
end
puts ans
 

Measured memory_bytes: 2556
#include <stdio.h>
#include <stdlib.h>
#define MOD 1000000007

int compare(const void *a,const void *b){
	return *(int*)a - *(int*)b;
}

int main(void) {
	int n,i,ans;
	int a[100000];
	
	scanf("%d",&n);
	for (i = 0;i < n;i++) {
		scanf("%d",&a[i]);
	}
	
	qsort(a,n,sizeof(int),compare);
	
	ans = 0;
	int tmp = 0;
	if (n%2) {
		if (a[0] == 0) {
			tmp = 2;
			ans = 1;
			for (i = 1;i < n;i+=2) {
				if (a[i] == tmp && a[i+1] == tmp) {
					tmp += 2;
					ans *= 2;
					ans %= MOD;
				} else {
					ans = 0;
					break;
				}
			}
		}
	} else {
		if (a[0] == 1 && a[1] == 1) {
			ans = 2;
			tmp = 3;
			for (i = 2;i < n;i+=2) {
				if (a[i] == tmp && a[i+1] == tmp) {
					tmp += 2;
					ans *= 2;
					ans %= MOD;
				} else {
					ans = 0;
					break;
				}
			}
		}
	}
	
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 892
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
main(){
    vector<int> xs(5); for(auto& x:xs) cin>>x;
    int k; cin>>k;
    vector<pair<int,int>> xss;
    for(int i=0; i<=3; ++i)
        for(int j=i+1; j<=4; ++j)
            xss.push_back({xs[i], xs[j]});
    for(auto xs:xss){
        int p=xs.first, q=xs.second;
        if(abs(p-q) > k) {
            printf(":(\n");
            exit(0);
        }
    }
    printf("Yay!\n");
}

Measured memory_bytes: 256
from collections import deque
L = deque()
cnt = 0
n = int(input())
for i in range(n):
    tmp = input().split()
    if tmp[0] == "0":
        L.append(tmp[1])
    elif tmp[0] == "1":
        L.rotate(int(tmp[1]))
        cnt-=int(tmp[1])
    else:
        L.pop()
L.rotate(cnt)
L.reverse()
for i in L:
    print(i)


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


int main(){
	long long int a, b, c;
	cin >> a >>b >> c;
	bool flag = true;

	if(a == b){
		if(a != c) flag = false;
	}
	else if(a == c){
		if(a != b) flag = false;
	}
	else if(b == c){
		if(b != a) flag = false;
	}


	if(flag) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

s = STR()
print(s[:3])

Measured memory_bytes: 72636
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int vertexes = in.nextInt();
		int[][] graph = new int[vertexes][vertexes];
		int[] in_msp = new int[vertexes];
		int total_weight = 0;
		
		// Make an array of vertexes in our MSP. Set to -1 if not in MSP yet. 0 starts in it.
		for(int i = 1; i < vertexes; i++) {
			in_msp[i] = -1;
		}
		
		// Take in initial graph
		for(int i = 0; i < vertexes; i++) {
			for(int j = 0; j < vertexes; j++) {
				graph[i][j] = in.nextInt();
			}
		}
		
		// Remove all connections in the graph to 0, our starting vertex
		for(int i = 0; i < vertexes; i++) {
			graph[i][0] = -1;
		}
		
		for(int i = 1; i < vertexes; i++) {
			int min_across_cut = 2001;
			int next_vert = 0;
			int j = 0;
			while(in_msp[j] != -1) {
				for(int k = 0; k < vertexes; k++) {
					if(min_across_cut > graph[in_msp[j]][k] && graph[in_msp[j]][k] != -1) {
						min_across_cut = graph[in_msp[j]][k];
						next_vert = k;
					}
				}
				j++;
			}
			total_weight += min_across_cut;
			in_msp[i] = next_vert;
			for(int k = 0; k < vertexes; k++) {
				graph[k][next_vert] = -1;
			}
		}
		
		System.out.println(total_weight);
		in.close();
	}

}



Measured memory_bytes: 40964
class BinaryIndexedTree():
    def __init__(self, max_n):
        self.size = max_n + 1
        self.tree = [0] * self.size
        self.depth = self.size.bit_length()
 
    def initialize(self, seq):
        for i, x in enumerate(seq[1:], 1):
            self.tree[i] += x
            j = i + (i & (-i))
            if j < self.size:
                self.tree[j] += self.tree[i]
 
    def __repr__(self):
        return self.tree.__repr__()
 
    def get_sum(self, i):
        s = 0
        while i:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i += i & -i
 
    def find_kth_element(self, k):
        x, sx = 0, 0
        dx = (1 << self.depth)
        for i in range(self.depth - 1, -1, -1):
            dx = (1 << i)
            if x + dx >= self.size:
                continue
            y = x + dx
            sy = sx + self.tree[y]
            if sy < k:
                x, sx = y, sy
        return x + 1


n,q = map(int,input().split())
a = list(map(int,input().split()))
bit = BinaryIndexedTree(n+2)
for i in range(n):
    bit.add(i+1,a[i])
for i in range(q):
    w,b,c = map(int,input().split())
    if w:
        t = bit.get_sum(c)-bit.get_sum(b)
        print(t)
    else:
        bit.add(b+1,c)

Measured memory_bytes: 132492
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

ll n, m, k[100005], dp[100005];
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
	}

	memset(dp, 9999, sizeof(dp));
	dp[0] = 0;

	for (int i = 1; i < n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (i >= j) {
				dp[i] = min(dp[i], dp[i - j] + abs(k[i] - k[i - j]));
			}
		}
	}

	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
"""
--- アルゴリズム概要 ---
前計算で頂点Kから各ノードへの最短路を記録しておき、
各クエリに対しては、dp[a]+dp[b]を返せばよい。

頂点Kから各ノードへの最短ルートはdfsとかで記録していけばよい。
"""
def main():
    from collections import deque
    import sys
    sys.setrecursionlimit(20000000)
    input = sys.stdin.readline
    N = int(input())
    AB = [[]for _ in range(N+1)]
    for i in range(N-1):
        a,b,c = map(int,input().split())
        AB[a].append((b,c))
        AB[b].append((a,c))

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

    path = {K:""}
    dp = [0]*(N+1)
    que = deque()
    for n,c in AB[K]:
        que.append((n,c))
    while que:
        now,cost = que.pop()
        path[now]=""
        dp[now]=cost
        for n,c in AB[now]:
            if n not in path:
                que.append((n,cost+c))
    for i in range(Q):
        x,y=map(int,input().split())
        print(dp[x]+dp[y])
main()

Measured memory_bytes: 82736
import java.util.*;
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.input();
    }
 
    public void input(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Long> numList = new ArrayList<Long>();
        for(int i = 0; i < n; i++){
            numList.add(sc.nextLong());
        }
        Collections.sort(numList);
        sc.close();
        long num = numList.get(n - 1) / 2;
        long min = binsearch(numList,numList.size(),num);
        long max = numList.get(n - 1);
        System.out.println(max + " " + min);
    }

    static long binsearch(ArrayList<Long> list, int n, long key){
        if(list.size () == 2){
             return list.get(0);
        }
        int pl = 0;
        int pr = n - 1;
        while(pl <= pr){
            int pc = (pl + pr) / 2;
            if(key == list.get(pc) || key == list.get(pc + 1)){
                return key;
            }else if(key > list.get(pc) && key < list.get(pc + 1)){
                if((key * 2 + 1) - list.get(pc) * 2 <= Math.abs((key * 2 + 1) - list.get(pc + 1) * 2) || list.get(pc + 1) == list.get(n - 1)){
                    return list.get(pc);
                }else{
                    return list.get(pc + 1);
                }
            }else if(key < (list.get(pc))){
                pr = pc - 1;
            }else{
                pl = pc  + 1;
            }
        }
        return list.get(pl);
    }
}

Measured memory_bytes: 61120
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		while (in.hasNext()) {
			int d = in.nextInt();
			int ans = 0;
			for (int i=d; i<600; i+=d) {
				ans += i*i*d;
			}
			out.println(ans);
			out.flush();
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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

namespace Volume0017
{
    class Program
    {
        static void Main(string[] args)
        {
            string sentence = "";
            while ((sentence = Console.ReadLine()) != null)
            {
                string[] words = sentence.Split(' ');
                string[] AnalysisResult = Decryption.Decrypte(words);
                Console.Write(AnalysisResult[0]);
                for (int i = 1; i < AnalysisResult.Length; ++i)
                {
                    Console.Write(" " + AnalysisResult[i]);
                }
                Console.WriteLine();
            }
        }
    }
    class Decryption
    {
        internal static string[] Decrypte(string[] words)
        {
            string[] AnalysisResult = new string[words.Length];
            char[][] sentence = StringConversion(words);
            while (!EndJudge(sentence))
            {
                sentence = SentenceShift(sentence);
            }
            for (int i = 0; i < sentence.Length; ++i)
            {
                AnalysisResult[i] = new string(sentence[i]);
            }
            return AnalysisResult;
        }
        internal static char[][] StringConversion(string[] words)
        {
            char[][] character = new char[words.Length][];
            for (int i = 0; i < words.Length; ++i)
            {
                character[i] = words[i].ToCharArray();
            }
            return character;
        }
        internal static bool EndJudge(char[][] sentence)
        {
            for (int i = 0; i < sentence.Length; ++i)
            {
                string keyword = new string(sentence[i]);
                if (keyword == "the" || keyword == "this" || keyword == "that")
                    return true;
            }
            return false;
        }

        internal static char CharacterShift(char s)
        {
            if ((int)s == 122)
            {
                s = (char)97;
            }
            else if (!(97 <= (int)s && (int)s <= 122))
            {
            }
            else
            {
                s = (char)((int)s + 1);
            }
            return s;
        }
        internal static char[] WordShift(char[] word)
        {
            for (int i = 0; i < word.Length; ++i)
            {
                word[i] = CharacterShift(word[i]);
            }
            return word;
        }
        internal static char[][] SentenceShift(char[][] sentence)
        {
            for (int i = 0; i < sentence.Length; ++i)
            {
                sentence[i] = WordShift(sentence[i]);
            }
            return sentence;
        }
    }
}



Measured memory_bytes: 13748
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

long n, s;

void main() {
    scan(n);
    scan(s);

    if (n == s) {
        writeln(n + 1);
        return;
    }

    for (long b = 2; b*b <= n; b++) {
        if (f(b, n) == s) {
            writeln(b);
            return;
        }
    }

    long ans = n + 1;

    for (long p = 1; p*p < n; p++) {
        long b = (n - s) / p + 1;

        if (f(b, n) == s) {
            ans = b;
        }
    }

    writeln(ans == n + 1 ? -1 : ans);
}

long f(long b, long n) {
    if (b < 2) return 0;
    return n < b ? n : f(b, n / b) + (n % b);
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int DN=1e5+5;
int n,a[DN],dp[DN],k;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=2;i<=n;i++)
    {
        dp[i]=1e9;
        for(int j=i-1;j>=max(1,i-k);j--)
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
    cout<<dp[n];
}


Measured memory_bytes: 1024
N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp=[[10**9 for i in range(N*max(v)+1)] for j in range(N+1)]
dp[0][0]=0
for i in range(N):
    for sumv in range(N*max(v)+1):
        if (sumv-v[i])>=0:
            m=dp[i][sumv-v[i]]+w[i]
            dp[i+1][sumv]=min(dp[i+1][sumv],m)
        dp[i+1][sumv]=min(dp[i+1][sumv],dp[i][sumv])
ans=10**9
for i in range(N*max(v)+1):
    if (dp[-1][i]<=W):
        ans=i
print(ans)

Measured memory_bytes: 171812
#include<stdio.h>
#include<stdlib.h>
int a[10010];
int main(void){
    int n,m;
    int sum =0;
    scanf("%d %d",&n,&m);
    for (int i=0;i<m;i++){
        scanf("%d",&a[i]);
    }
    for(int k=0;k<m;k++){
        sum = sum + a[k];
    }
    int ans = n - sum;
    if(ans>=0){
        printf("%d\n",ans);
    }else{
        printf("-1\n");
    }
    return 0;
}

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

//input
string s;
ll x,y;

bool dp_tate[20000];
bool dp_yoko[20000];

void solve_tate(int t){
    vector<bool>tmp(20000,false);
    rep(i,20000){
        if(dp_tate[i]){
            if(i-t>0)tmp[i-t]=true;
            if(i+t<20000)tmp[i+t]=true;
        }
    }
    rep(i,20000){
        dp_tate[i]=tmp[i];
    }
}

void solve_yoko(int t){
    vector<bool>tmp(20000,false);
    rep(i,20000){
        if(dp_yoko[i]){
            if(i-t>0)tmp[i-t]=true;
            if(i+t<20000)tmp[i+t]=true;
        }
    }
    rep(i,20000){
        dp_yoko[i]=tmp[i];
    }
}

int main(){
    //input
    cin >> s;
    cin >> x >> y;
    x += 10000;
    y += 10000;

    //初期位置の決定
    int fi = 0;
    while(s[fi]=='F'&&fi<s.size()){
        fi++;
    }
    P shoki = {fi+10000,10000};

    //前計算
    vector<ll>tate;
    vector<ll>yoko;
    bool horizon = true;
    ll res = 0;
    for(int i=fi;i<s.size();i++){
        if(s[i]=='T'){
            if(horizon){
                yoko.push_back(res);
            }
            else{
                tate.push_back(res);
            }
            res = 0;
            horizon ^= 1;
        }
        else{
            res++;
        }
    }
    if(horizon){
        yoko.push_back(res);
    }
    else{
        tate.push_back(res);
    }

    //縦横それぞれについてDP
    rep(i,16200){
        dp_tate[i]=dp_yoko[i]=false;
    }
    dp_tate[shoki.second]=true;
    dp_yoko[shoki.first]=true;

    //縦
    rep(i,tate.size()){
        int t = tate[i];
        solve_tate(t);
    }
    rep(i,yoko.size()){
        int t = yoko[i];
        solve_yoko(t);
    }

    if(dp_tate[y]&&dp_yoko[x]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3776
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
H = LI() + [1]
dp = [0] * (n + 1)
ret = pow(2, H[0], mod)
for kk in range(n + 1):
    if H[0] >= H[kk]:
        dp[kk] = pow(2, H[0] - H[kk], mod) * 2
    else:
        dp[kk] = 2


for k in range(1, n):
    new_dp = [0] * (n + 1)
    for i in range(n + 1):
        if H[i] <= H[k]:
            if H[k - 1] <= H[i]:
                new_dp[i] = dp[i] * 2 * pow(2, H[k] - H[i], mod)
            elif H[k - 1] > H[k]:
                new_dp[i] = dp[i] - dp[k] + dp[k] * 2
            else:
                new_dp[i] = (dp[i] - dp[k - 1] + dp[k - 1] * 2) * pow(2, H[k] - H[k - 1], mod)
        else:
            new_dp[i] = dp[k] * 2
        new_dp[i] %= mod
    dp = new_dp


print(dp[-1])


Measured memory_bytes: 83772
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <map>
#include <bitset>
#include <string.h>
#include <cmath>
#include <queue>
#include <algorithm>
#define N 100005
#define P pair<int,int>
#define ll long long
#define mk(a, b) make_pair(a, b)
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
int inf = 0x3f3f3f3f;
int n, m, pre[N];
double sum;
bool vis[N];
double dis[N];
struct ac{
	int v;
	double c;
};
vector<P> a(N);
vector<ac> g[N];
void init() {
	for (int i = 1; i <N; ++i) {
		pre[i] = i;
	}
}
int find(int x) {
	if (x == pre[x])	return x;
	else 	return pre[x] = find(pre[x]);
}
void join(int x, int y) {
	int fx = find(x);
	int fy = find(y);
	if (fx == fy)	return;
	else if (fx < fy)	pre[fy] = fx;
	else 	pre[fx] = fy;
}

// 求最大生成树
void prim(int x) {
	mem(dis, 0);
	mem(vis, false);
	for (int i = 0; i < g[x].size(); ++i) {
		ac t = g[x][i];
		dis[t.v] = t.c;
	}
	vis[x] = true;
	for (int i = 1; i < n; ++i) {
		double MAX = 0;
		int u = -1;
		for (int j = 1; j <= n; ++j) {
			if (vis[j])	continue;
			if (dis[j] > MAX) {
				MAX = dis[j];
				u = j;
			}
		}
		if (u == -1)	return;
		vis[u] = true;
		sum += MAX;
		for (int j = 0; j < g[u].size(); ++j) {
			ac t = g[u][j];
			if (vis[t.v])	continue;
			if (dis[t.v] < t.c ) {
				dis[t.v] = t.c;
			}
		}
	}
}

int main(){
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
// #endif
	ios::sync_with_stdio(false);
	while (cin >> n >> m) {
		init();
		for (int i = 1; i <= n; ++i) {
			cin >> a[i].first >> a[i].second;
		}
		double ans = 0;
		for (int i = 0; i < m; ++i) {
			int u, v;
			cin >> u >> v;
			int dx = a[u].first - a[v].first;
			int dy = a[u].second - a[v].second;
			double temp = sqrt(dx * dx + dy * dy);
			ans += temp;
			// 建图
			g[u].push_back((ac){v, temp});
			g[v].push_back((ac){u, temp});
			join(u, v);
		}
		for (int i = 1; i <= n; ++i) {
			// 求这个并查集的最大生成树
			if (pre[i] == i) {
				sum = 0;
				prim(i);
				ans -= sum;
			}
		}
		printf("%.3lf\n",ans);
		for (int i = 1; i <= n; ++i) {
			g[i].clear();
		}
	}

	return 0;
}



Measured memory_bytes: 8948
//coloful_smiles.cpp
#include<iostream>
#include<vector>
using namespace std;

int main()
{
        int N;
        cin>>N;
        std::vector<int> v(N);
        for(int i=0;i<N;i++){
                cin>>v[i];
        }
        /*      
        for(int i=0;i<N;i++){
                cout<<v[i]<<", ";
        }
        cout<<endl;
        */
        int num=0;
        for(int i=0;i<N-1;i++){
                if(v[i] == v[i+1]){
                        num++;
                        i++;
                }
        }
        cout<<num<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin>>s>>t;
  string res;
  int id=0;
  if(s.length()>t.length())t=t+" ";
  while(1){
    res=res+s[id]+t[id];
    id++;
    if(id==s.length())break;
  }
  cout<<res<<endl;

}


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

int main(){
  int n,k; cin >> n >> k;
  string s; cin >> s;
  s[k-1] = tolower(s[k-1]);
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 16;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

vector <int> Vx;
vector <int> Vy;
int in[55][2];
int main() {
	int N, K, i, j, k, l, m;
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) {
		scanf("%d %d", &in[i][0], &in[i][1]);
		Vx.push_back(in[i][0]);
		Vy.push_back(in[i][1]);
	}
	sort(all(Vx));
	sort(all(Vy));
	Vx.erase(unique(all(Vx)), Vx.end());
	Vy.erase(unique(all(Vy)), Vy.end());

	ll ans = LL_INF;
	for (i = 0; i < Vx.size(); i++) {
		for (j = i; j < Vx.size(); j++) {
			for (k = 0; k < Vy.size(); k++) {
				for (l = k; l < Vy.size(); l++) {
					int sx = Vx[i], ex = Vx[j], sy = Vy[k], ey = Vy[l];
					int c = 0;
					for (m = 1; m <= N; m++) {
						if (sx <= in[m][0] && in[m][0] <= ex && sy <= in[m][1] && in[m][1] <= ey) c++;
					}
					if (c >= K) ans = min(ans, (ll)(ex - sx)*(ey - sy));
				}
			}
		}
	}
	return !printf("%lld\n", ans);
}

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

#define ran 888

const int go[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};

int n, m, k;
char s[ran][ran];
int d[ran][ran];
int q[ran*ran*2], l, r;

void bfs() {
	while(l<r) {
		int a = q[l++], b = q[l++];
		int dist = d[a][b];
		if(dist == k) continue;
		for(int i=0;i<4;i++) {
			int x = a+go[i][0], y = b+go[i][1];
			if(x<0 || x>=n || y<0 || y>=m) continue;
			if(s[x][y]=='#' || d[x][y]!=-1) continue;
			
			q[r++] = x;
			q[r++] = y;
			d[x][y] = dist + 1;
		}
	}
}

int calc(int x, int y) {
	int res = x+y;
	res = min(res, (x+k-1)/k);
	res = min(res, ((n-1-x) + (k-1))/k);
	res = min(res, (y+k-1)/k);
	res = min(res, ((m-1-y) + (k-1))/k);
	return res;
}

int main() {
	scanf("%d%d%d", &n, &m, &k);
	memset(d, -1, sizeof d);
	l=r=0;
	for(int i=0;i<n;i++) {
		scanf("%s", s[i]);
		for(int j=0;j<=m;j++)
			if(s[i][j]=='S') {
				q[r++] = i; q[r++] = j; d[i][j] = 0;
				s[i][j] = '.';
			}
	}
	bfs();
	
	int res = n+m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(d[i][j]!=-1)
				res = min(res, calc(i, j) + 1);
	printf("%d\n", res);
	
	return 0;
}

Measured memory_bytes: 10112
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {

  int n;
  cin >> n;
  int a[n];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[a[i] - 1] == i + 1) {
      ans++;
    }
  }
  cout << ans / 2 << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
int n,m,st,t,s[100005][3];
vector<int> g[100005];
int main()
{
	memset(s,63,sizeof(s));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
	}
	scanf("%d%d",&st,&t);
	queue<int> q;
	q.push(st);
	s[st][0]=0;
	while(!q.empty())
	{
		int u=q.front();
//		cout<<u<<"  ";
		q.pop();
		for(int i=0;i<g[u].size();i++)
		{
			int v=g[u][i],yes=0;
//			cout<<v;
			if(s[u][0]+1<s[v][1])
			{
				yes=1;
				s[v][1]=s[u][0]+1;
			}
			if(s[u][1]+1<s[v][2])
			{
				yes=1;
				s[v][2]=s[u][1]+1;
			}
			if(s[u][2]+1<s[v][0])
			{
				yes=1;
				s[v][0]=s[u][2]+1;
			}
			if(yes==1)
			{
//				cout<<".";
				q.push(v);
			}
//			cout<<' ';
		}
//		cout<<endl;
	}
//	for(int i=1;i<=n;i++)
//	{
//		cout<<s[i][0]<<' '<<s[i][1]<<' '<<s[i][2]<<endl;
//	}
	if(s[t][0]!=s[0][0])
	{
		printf("%d",s[t][0]/3);
	}
	else
	{
		printf("-1");
	}
	return 0;
}


Measured memory_bytes: 9796
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int H, W; cin >> H >> W;
    vs A(H); REP(i, H) cin >> A[i];

    vb row(H, false);
    REP(i,H){
        REP(j,W){
            if (A[i][j]=='#') {
                row[i] = true;
                break;
            }
        }
    }

    vb col(W, false);
    REP(j,W){
        REP(i,H){
            if (A[i][j]=='#') {
                col[j] = true;
                break;
            }
        }
    }

    REP(i,H){
        if (!row[i]) continue;
        REP(j,W){
            if (!col[j]) continue;
            cout << A[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val mod = 1000000007L
//    val (N,D) = readLine()!!.split(" ").map { it.toInt() }
    val N = readLine()!!.toInt()
 
    val A = Array(N) {readLine()!!.toInt()}
    val (m0,m1) = A.sortedDescending().take(2)
    val list = mutableListOf<Int>()
 
    for (a in A)
        list.add(if(m0 != a) m0 else m1)
 
    println(list.joinToString("\n"))
}


Measured memory_bytes: 64776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n;
    cin >> n;
    map<char, ll> m;
    string march = "MARCH";
    for (auto c : march)
        m[c] = 0LL;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (march.find(s[0]) != string::npos) {
            m[s[0]]++;
        }
    }
    ll ans = m['M'] * m['A'] * m['R']
            + m['M'] * m['A'] * m['C']
            + m['M'] * m['A'] * m['H']
            + m['M'] * m['R'] * m['C']
            + m['M'] * m['R'] * m['H']
            + m['M'] * m['C'] * m['H']
            + m['A'] * m['R'] * m['C']
            + m['A'] * m['R'] * m['H']
            + m['A'] * m['C'] * m['H']
            + m['R'] * m['C'] * m['H'];
    cout << ans << "\n";
}

Measured memory_bytes: 256
'use strict'

function main(input) {
  input = input
    .split(' ')
    .map(v => ~~v)
    .sort((a, b) => b - a)
  // .reverse()
  //   console.log(input)

  const ans = input[0] * 10 + input[1] +  input[2]
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7500
// ※※※ 解答不能 ※※※
// tourist氏.
// https://atcoder.jp/contests/cf17-relay-open/submissions/8927539
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    int n;
    scanf("%d", &n);
    vector<LL> x(n);
    vector<int> s(n);
    rep(i, n) scanf("%lld %d", &x[i], &s[i]);
    LL ans = 0, best = (LL) -9e18, sum = 0;
    rep(i, n){
        best = max(best, -sum + x[i]);
        sum += s[i];
        ans = max(ans, sum - x[i] + best);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2560
ans = 0
n, a, b = map(int, input().split())
for i in range(1, n + 1):
  t = 0
  z = i
  while z > 0:
    t = t + z % 10
    z = z // 10
  if t >= a and t <= b:
    ans = ans + i
print(ans)

Measured memory_bytes: 66064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double ara[n], sum = 0;
    int i;
    for(i = 0; i < n; i++)cin>>ara[i];
    for(i = 0; i < n; i++)
    {
        ara[i] = 1.0 / ara[i];
    }
    for(i = 0; i < n; i++)
    {
        sum += ara[i];
    }
    sum = 1.0 / sum;
    printf("%.9lf", sum);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

ll p5 (ll i) { return i*i*i*i*i; }
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    for (ll i = 1; i * i <= x; i++) {
        if (x % i != 0) continue;
        // a - b = i wo tansaku
        ll ng = (i - 1) / 2LL, ok = 1000;
        while (ok - ng > 1) {
            ll med = (ng + ok) / 2;
            if (p5(med) - p5(med - i) >= x) ok = med;
            else ng = med;
        }
        if (i == 3) eprintf("%lld %lld\n", ok, p5(ok) - p5(ok - i));
        if (p5(ok) - p5(ok - i) == x) {
            cout << ok << " " << ok - i << "\n";
            return 0;
        }

        ll j = x / i;
        ng = (j - 1) / 2, ok = 1000;
        while (ok - ng > 1) {
            ll med = (ng + ok) / 2;
            if (p5(med) - p5(med - j) >= x) ok = med;
            else ng = med;
        }
        if (p5(ok) - p5(ok - j) == x) {
            cout << ok << " " << ok - j << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (0 < (n-k))
	{
		cout << k * x + (n - k)*y << endl;
	}
	else
	{
		cout << n * x  << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll v;cin>>v;vec.push_back(v);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
ll inv(ll a)
{
    ll p=mod2;
    ll b=p-2,ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll ncr(ll n,ll m)
{
    ll p=mod2;
    if(m > n)return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<n+1;i++)up*=i,up%=p;
    for(int i=1;i<m+1;i++)down*=i,down%=p;
    return up*inv(down)%p;
}

ll countDigit(ll n)
{   
    return floor(log10(n) + 1); 
}  
ll a_pow_b(ll a,ll b)
{
    ll p=1000000007;
    ll ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll gcd(ll a,ll b) 
{ 
    if (b==0) 
        return a; 
    return gcd(b,a%b);      
} 
ll lcm(ll a, ll b)  
{  
    return (a*b)/gcd(a, b);  
}
bool isPerfectSquare(ll x) 
{   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
}
ll ncr123(ll n, ll k){
    if (k == 1) {
        return n;
    }
    if (k == 2) {
        return n * (n - 1) / 2;
    }
    if (k == 3) {
        return n * (n - 1) * (n - 2) / 6;
    }
}
bool com(const pi &a,const pi &b)   //acc to second element sort for vec of pi
{ 
    if(a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
}



void solve(){

    ll a,b,n;
    cin>>a>>b>>n;

    if(n>=b){
        n=b-1;
    }

    ll l=n/b;

    cout<< (a*n)/b-l*a;



    return ;
}
 
 
int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

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

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

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

	cout << "-1 -1" << endl;

	return 0;
}

Measured memory_bytes: 512
N = int(input())
mod = 10**9+7
x = 1
y = 1
z = 1
for i in range(N):
    x *= 9
    y *= 8
    z *= 10
    x %= mod
    y %= mod
    z %= mod
x *= 2
ans = z - x + y
print(ans%mod)

Measured memory_bytes: 63396
import numpy as np
n, m = map(int, input().split())
ab = np.empty((n, 2), dtype=np.int64)
for i in range(n):
    ab[i, :] = list(map(int, input().split()))

ab = ab[ab[:, 0].argsort(), :]

money = 0
drink = 0
for i in range(n):
    if drink + ab[i, 1] < m:
        money += ab[i, 0] * ab[i, 1]
        drink += ab[i, 1]
    else:
        next_drink = m - drink
        money += ab[i, 0] * next_drink
        break
print(money)


Measured memory_bytes: 20852
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <assert.h>
using namespace std;

#ifdef ONLINE_JUDGE
#define ep(...) ;
#else
#define ep(...) fprintf(stderr, __VA_ARGS__)
#endif

typedef long long i64;

const int MOD = (int) 1e6 + 3;
const int MAXN = 1003;

int gcd(int a, int b) {
	if (! b) return a;
	return gcd(b, a % b);
}

int pow_mod(i64 a, int b, int p) {
	i64 ret = 1;
	for (; b; b >>= 1) {
		if (b & 1) ret = ret * a % p;
		a = a  * a % p;
	}
	return ret;
}

int n, k;
int f[MAXN][2][MAXN];
int sum[MAXN];

inline void addIt(int &a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

void calcf() {
	for (int i = 1; i <= n; i ++)
		for (int num = 0; num < 2; num ++)
			fill(f[i][num], f[i][num] + k + 1, 0);
	f[1][0][1] = 1;
	for (int i = 1; i < n; i ++)
		for (int num = 0; num < 2; num ++)
			for (int len = 1; len <= k; len ++) {
				int &cur = f[i][num][len];
				if (! cur) continue;
				if (len < k) 
					addIt(f[i + 1][num][len + 1], cur);
				addIt(f[i + 1][num ^ 1][1], cur);
			}
	for (int i = 1; i <= n; i ++) {
		int &cur = sum[i];
		cur = 0;
		for (int j = 1; j <= k; j ++)
			addIt(cur, f[i][0][j]);
	}
}

int calc(int m) {
	int ret = 0;
	for (int len = 1, _len = min(m, k); len <= _len; len ++) {
		addIt(ret, (i64) sum[m - len] * len * 2 % MOD);
	}
	if (k >= n) addIt(ret, 2);
	return ret;
}

int main() {
#ifndef ONLINE_JUDGE
#endif
	for (int cases = 1; true; cases ++) {
		scanf("%d%d", &n, &k);
		if (n == 0 && k == 0) break;
		calcf();
		int ans = 0;
		for (int i = 0; i < n; i ++) {
			int d = gcd(n, i);
			addIt(ans, calc(d));
		}
		printf("%d\n", (int) ((i64) ans * pow_mod(n, MOD - 2, MOD) % MOD));
	}

	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() {
	ll d,t,s;
	cin>>d>>t>>s;
	//double time=d/t
if(s*t>=d)
{
	cout<<"Yes\n";
}
else
cout<<"No\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int tc=1; //cin >> tc;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}


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

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e6+ 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 2e5 + 17;

int n, m;
vector< pair<int, int> > g[maxn];
int cl[maxn], d[maxn];

bool read() {
    if (scanf("%d %d", &n, &m) != 2)
        return false;

    forn (i, m) {
        int u, v, x;
        scanf("%d %d %d", &u, &v, &x);
        g[u - 1].push_back(make_pair(v - 1, x));
        g[v - 1].push_back(make_pair(u - 1, -x));
    }

    return true;
}

void dfs(int v) {
    cl[v] = 1;

    for (auto to : g[v])
        if (cl[to.first] == 0) {
            d[to.first] = d[v] + to.second;
            dfs(to.first);
        }
}

void solve() {
    forn (i, n)
        if (cl[i] == 0)
            dfs(i);

    forn (i, n)
        for (auto to : g[i])
            if (d[to.first] - d[i] != to.second) {
                printf("No\n");
                return ;
            }

    printf("Yes\n");
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}

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

int n,id[100005],ans[100005],a[100005],tmp[100005],m;

long long k;

double output[100005];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i),id[i]=ans[i]=i;
	//d[i]记录每只兔子跳一次之后下一次跳的位置，ans[i]记录跳完k轮之后每只兔子的位置
	scanf("%d%lld",&m,&k);
	for(int i=1,x;i<=m;i++){
		scanf("%d",&x);
		swap(id[x],id[x+1]);
	}
	while(k){
		if(k&1){
			for(int i=1;i<=n;i++) tmp[i]=ans[id[i]];
			for(int i=1;i<=n;i++) ans[i]=tmp[i];
		}
		for(int i=1;i<=n;i++) tmp[i]=id[id[i]];
		for(int i=1;i<=n;i++) id[i]=tmp[i];
		k>>=1;
	}
	for(int i=1;i<=n;i++) output[i]=(double)(a[ans[i]]-a[ans[i]-1]);
	for(int i=1;i<=n;i++) printf("%.1f\n",output[i]+=output[i-1]);
}

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

ll a,b;

int main() {
  cin >> a >> b;
  if(a*b<0)
  cout << "Zero" << endl;
  else if(a>0)
  cout << "Positive" << endl;
  else if((b-a+1)%2==1)
  cout << "Negative" << endl;
  else 
  cout << "Positive" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    int a[5],k;
    for(int i=0;i<5;i++)cin>>a[i];
    cin>>k;
    int f=0;
    sort(a,a+5);
    if(a[4]-a[0]>k)cout<<":(";
    else cout<<"Yay!";
	return 0;
}

Measured memory_bytes: 256