akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<long long> a(n),b(n);
    vector<bool> bb(n,false);
    priority_queue<pair<long long,int>> bq;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin>>b[i];
        if(b[i]!=a[i])bq.push(make_pair(b[i],i));
        else bb[i]=true;
    }
    long long ans=0;
    while(!bq.empty()){
        auto tp=bq.top();
        bq.pop();

        int bi=tp.second-1,fi=tp.second+1,ti=tp.second;
        if(bi<0)bi=n-1;
        if(fi>=n)fi=0;
        int nm;
        if(!bq.empty())nm=bq.top().first;
        else nm=0;

        ++ans;
        b[ti]-=(b[bi]+b[fi]);

        if(b[ti]<=0){
            cout<<"-1"<<endl;
            return 0;
        }

        if(bq.top().second!=bi&&bq.top().second!=fi){
            long long rem=(b[ti]-a[ti])/(b[bi] + b[fi]);
            b[ti]-=(b[bi] + b[fi])*rem;
            ans+=rem;
        }
        else{
            long long rem = b[ti] - nm;

            rem = rem / (b[bi] + b[fi]);
            ans += rem;
            b[ti] -= (b[bi] + b[fi]) * rem;
        }

        if(b[ti]<=0){
            cout<<"-1"<<endl;
            return 0;
        }
        if(b[ti]==a[ti])bb[ti]=true;
        else bq.push(make_pair(b[ti],ti));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9716
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"

using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)

const int INF = 100000000;

typedef vector<vector<int> > Matrix;
Matrix d;
//4

void warshall_floyd(int n) {
	for (int p = 0; p < n; p++) {
		for (int q = 0; q < n; q++) {
			for (int r = 0; r < n; r++) {
				d[q][r] = min(d[q][r], d[q][p] + d[p][r]);
			}
		}
	}
}

int main(void) {
	int h, w;
	cin >> h >> w;
	const int LIM = 10;
	d = Matrix(10, vector<int>(LIM, INF));
	rep(0, LIM) d[i][i] = 0;
	for (int p = 0; p < LIM; p++) {
		for (int q = 0; q < LIM; q++) {
			int c = 0;
			cin >> c;
			d[p][q] = c;
		}
	}
	warshall_floyd(LIM);
	int ans = 0;
	for (int p = 0; p < h; p++) {
		for (int q = 0; q < w; q++) {
			int a = 0;
			cin >> a;
			if (a == -1 || a == 1) continue;
			else {
				ans += d[a][1];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int x;
    cin >> x;
    if(x < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
    return 0;
}

Measured memory_bytes: 256
def dfs(i,Str):
    if i==n-1:
        return sum(map(int,Str.split("+")))
    return dfs(i+1,Str+S[i+1])+dfs(i+1,Str+"+"+S[i+1])
S=input()
n=len(S)
print(dfs(0,S[0]))

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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  char a = toupper(s1[0]);
  char b = toupper(s2[0]);
  char c = toupper(s3[0]);

  cout << a << b << c << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		int a[];

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			if (n <= 3) {
				System.out.println(1);
			} else {
				a = new int[n + 1];
				a[1] = 1;
				a[2] = 2;
				a[3] = 4;
				for (int i = 4; i <= n; i++) {
					a[i] = a[i - 1] + a[i - 2] + a[i - 3];
				}
				int day = a[n] / 10;
				if (a[n] % 10 != 0) {
					day++;
				}
				System.out.println(((day - 1) / 365) + 1);
			}
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(){
  int S[101],top=0;
  string s;
  while(cin>>s){
    if(s=="+") S[--top]+=S[top+1];
    else if(s=="-") S[--top]-=S[top+1];
    else if(s=="*") S[--top]*=S[top+1];
    else S[++top]=atoi(s.c_str());
  }
  cout<<S[top]<<endl;
  return 0;
}

Measured memory_bytes: 3164
n=int(input())
H=map(int,input().split())
h=list(H)
s=9

for i in range(1,n):
    if h[n-i]>=h[n-i-1]:
        continue
    elif h[n-i-1]-h[n-i]==1:
        h[n-i-1]=h[n-i-1]-1

    else:
        s=0
        break


if s==0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 63856
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, k] <- getInts
  as <- replicateM n $ do
    [i, j] <- getInts
    return (i, j)
  print $ solve k $ sort as
  
getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: Int -> [(Int, Int)] -> Int
solve 0 ((a, b):ns) = a
solve k ((a, b):ns) = if k <= b
                      then a
                      else solve (k - b) ns


Measured memory_bytes: 89468
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 2000000000LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll x;
ll a[2001][2001];

int main(void){
	scanf("%d%lld",&n,&x);
	ll res=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i][0]);
		for(int j=1;j<n;j++){
			a[i][j]=a[i][0];
		}
		res+=a[i][0];
	}
	for(int i=0;i<n;i++){
		for(ll j=1;j<n;j++){
			a[i][j]=min(a[i][j],a[(i-j+n)%n][0]);
		}
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<n;j++){
			a[i][j]=min(a[i][j],a[i][j-1]);
		}
	}
	for(ll i=1;i<n;i++){
		ll sum=0;
		for(int j=0;j<n;j++){
			sum+=a[j][i];
		}
		res=min(res,(ll)sum+i*x);
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) (i64)(a / (f64)__gcd(a, b) * b) /* 最小公倍数 */

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

void Main() {
    i32 N;
    cin >> N;
    Vec<i32> h(N);
    i32 i = 0;
    for (i = 0; i < N; i++) cin >> h[i];
    Vec<i32> a(N, 0);
    i32 ans = 0;
    i = 0;
    while (i != N) {
        if (a[i] == h[i]) {
            i++;
            continue;
        }
        i32 j;
        for (j = i + 1; j < N; j++) {
            if (a[j] == h[j]) break;
        }
        for (i32 k = i; k < j; k++) {
            a[k]++;
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main()
{
	cin>>n>>m;
    if(n==1&&m==1)cout<<1;
	else if(n==1)cout<<m-2<<endl;
	else if(m==1)cout<<n-2<<endl;
	else cout<<n*m-(n+n+m+m-4)<<endl;
	return 0;
}

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

int main(){
	string A,B,C;
  cin>>A>>B>>C;
  int asize=A.size();
  int bsize=B.size();
  int csize=C.size();
  vector<char> vec(asize+bsize+csize);
  vec.at(0)=A.at(0);
  asize--;
  
  for(int i=1;i<vec.size();i++){
  	if(vec.at(i-1)=='a'){
      	if(asize>0){
    		vec.at(i)=A.at(A.size()-asize);
      		asize--;
        }
      else{
        cout<<"A"<<endl;
        break;
    	}
    }
    if(vec.at(i-1)=='b'){
      	if(bsize>0){
    		vec.at(i)=B.at(B.size()-bsize);
      		bsize--;
        }
      else{
        cout<<"B"<<endl;
        break;
    	}
    }
    if(vec.at(i-1)=='c'){
      	if(csize>0){
    		vec.at(i)=C.at(C.size()-csize);
      		csize--;
        }
      else{
        cout<<"C"<<endl;
        break;
    	}
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    boolean[] b = new boolean[n];
    int ans = 0;
    int pre = 0;

    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if (pre == (a - 1)) {
        b[pre] = true;
      }
      pre = a;
    }

    for (int i = 0; i < n; i++) {
      ans += sc.nextInt();
    }

    for (int i = 1; i < n; i++) {
      int c = sc.nextInt();
      if (b[i]) {
        ans += c;
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 35784
import Control.Monad
import Data.Maybe
import Data.List
import Text.Printf
import qualified Data.IntSet as S
import qualified Data.ByteString.Char8 as C

parseInt :: C.ByteString -> Int
parseInt = fst . fromJust . C.readInt

main :: IO ()
main = do
  [n, k] <- map parseInt . C.words <$> C.getLine
  ds <- replicateM k $ do
    _ <- C.getLine
    map parseInt . C.words <$> C.getLine
  let removeAll = foldl' (\s d -> S.delete d s)
      rest = foldl' removeAll (S.fromList [1..n]) ds
  printf "%d\n" (S.size rest)

Measured memory_bytes: 5072
#include "bits/stdc++.h"
using namespace std;
 
int main(){
  char X, Y;

	cin >> X >> Y;

	if (X<Y) {
		cout << "<" << endl;
	}
	else if (X>Y) {
		cout << ">" << endl;
	}
	else if (X==Y) {
		cout << "=" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ac,wa,re,tle;
int main(){
	int n;
	char s[8];
	scanf("%d",&n);
	while(n--){
		scanf("%s",s);
		if(s[0]=='A') ac++;
		if(s[0]=='W') wa++;
		if(s[0]=='T') tle++;
		if(s[0]=='R') re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	
	return 0;
}

Measured memory_bytes: 3736
""" B
    https://atcoder.jp/contests/abc173/tasks/abc173_b
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return [readIntegerSet(m) for _ in range(0, n)]

def main(N, D, XY):
    count = 0

    D2 = math.pow(D, 2)

    for xy in XY:
        if math.pow(xy[0], 2) + math.pow(xy[1], 2) <= D2:
            count += 1

    return count

if __name__ == "__main__":
    _N, _D = readIntegerSet(2)
    _XY = readIntegerMatrix(_N, 2)

    print(main(_N, _D, _XY))


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

c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
  s = input()
  if s == 'AC':
    c0 += 1
  elif s == 'WA':
    c1 += 1
  elif s == 'TLE':
    c2 += 1
  elif s == 'RE':
    c3 += 1

print('AC x {}'.format(c0))
print('WA x {}'.format(c1))
print('TLE x {}'.format(c2))
print('RE x {}'.format(c3))


Measured memory_bytes: 9204
X = int(input())

if X >= 400 and X < 600:
    print('8')
elif X >= 600 and X < 800:
    print('7')
elif X >= 800 and X < 1000:
    print('6')
elif X >= 1000 and X < 1200:
    print('5')
elif X >= 1200 and X < 1400:
    print('4')
elif X >= 1400 and X < 1600:
    print('3')
elif X >= 1600 and X < 1800:
    print('2')
elif X >= 1800 and X < 2000:
    print('1')

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int vis[3];

int main() {
	int n;
	cin >> n;
	long long sum = 1;
	for(int i = 1; i <= n; i++){
		int t;
		cin >> t;
		int k = 0;
		for(int i = 0; i < 3; i++){
				if(vis[i] == t)
					k++;
			}
			for(int i = 0; i < 3; i++){
				if(vis[i] == t){
					vis[i]++;
					break;					
				}
			}
			sum = (sum * k) % mod;	
		}
		cout << sum << endl;
		
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,cnt[4];
bool vis[305][305][305];
double dp[305][305][305];
double solve(int i,int j,int k)
{
	double tot=i+j+k;
	if (i<0 || j<0 || k<0 || !tot)
	return 0;
	if (vis[i][j][k])
	return dp[i][j][k];
	vis[i][j][k]=1;
	return dp[i][j][k]=(n+i*solve(i-1,j,k)+j*solve(i+1,j-1,k)+k*solve(i,j+1,k-1))/tot;
}
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		cnt[a]++;
	}
	printf("%.12lf",solve(cnt[1],cnt[2],cnt[3]));
}

Measured memory_bytes: 246144
#pragma region Header
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
#pragma endregion

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

    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u == s)
    {
        --a;
    }
    else
    {
        --b;
    }
    cout << a << ' ' << b << endl;

    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int a,b,c; cin>>a>>b>>c;
    if(b*c>=a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 3640
import numpy as np
import math
import subprocess
import random
import os
import sys


s=input()

nums=len(s)

count=0
for i in range(nums):
	if i%2==0:
		if s[i]=='R'or s[i]=='U'or s[i]=='D':
			pass
		else:
			count+=1
	if i%2==1:
		if s[i]=='L'or s[i]=='U'or s[i]=='D':
			pass
		else:
			count+=1

if count==0:
	print('Yes')
else:
	print("No")

Measured memory_bytes: 22912
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var L = parseInt(tmp[0], 10);
	var R = parseInt(tmp[1], 10);

	if((L-R)>=2019){
		console.log('%d',0);
	}
	else{
		var ans = Infinity;
		var endFlag = false;
		for(var i=L; i<R; i++){
			var iTmp = i%2019;
			if(iTmp === 0){
				ans=0;
				endFlag=true;
				break;
			}
			for(var j=i+1; j<=R; j++){
				var jTmp = j%2019;
				if(jTmp === 0){
					ans=0;
					endFlag=true;
					break;
				}
				var rTmp = (iTmp*jTmp)%2019;
				if(rTmp<ans) ans=rTmp;
			}
			if(endFlag === true) break;
		}
		//出力
		console.log('%d',ans);
	}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<stdio.h>
int main(void)
{
	int a[21],b[21],c[21],n,j,i,w;
	scanf("%d",&n);
	w=0;
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	for(i=0;i<n;i++){
		scanf("%d",&b[i]);
		w+=b[i];
		// printf("%d\n",w);
	}
	for(i=1;i<=n-1;i++)	scanf("%d",&c[i]);
	for(i=1;i<n;i++){
		if(a[i]-a[i-1]==1){
			w=c[a[i-1]]+w;
			// printf("%d\n",w);
		}
	}
	printf("%d\n",w);
	return 0;
}

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

const int N = 500005;

int n, q;
int nxt[N][30];
int rmq[N][20];
string s;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> s >> q;
	n = s.size();

	for (int j = 0; j <= 26; ++j) nxt[n][j] = nxt[n + 1][j] = n + 1;

	for (int i = n - 1; i >= 0; --i) {
		nxt[i][s[i] - 'a' + 1] = i + 1;
		for (int j = s[i] - 'a' + 2; j <= 26; ++j) {
			nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
			// the remaining string contains only one character: j
		}
		nxt[i][0] = nxt[nxt[i][26]][26]; // empty string

		for (int j = 1; j < s[i] - 'a' + 1; ++j) {
			nxt[i][j] = nxt[nxt[i][0]][j];
		}
	}

	for (int i = 0; i <= n + 1; ++i) rmq[i][0] = nxt[i][0];
	for (int j = 1; j <= 19; ++j) {
		for (int i = 0; i <= n + 1; ++i) rmq[i][j] = rmq[rmq[i][j - 1]][j - 1];
	}

	while(q--) {
		int l, r; cin >> l >> r;
		--l;
		// r = nxt[l], nxt[nxt[l]], ...
		for (int i = 19; i >= 0; --i) {
			if (rmq[l][i] <= r) l = rmq[l][i];
		}
		printf("%s\n", (l == r) ? "Yes" : "No");
	}
}

Measured memory_bytes: 98844
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

ll dp[20200];

ll N, M, K;

ll rec(ll i, vector<ll> &A) {
    if(dp[i] != LINF) {
        return dp[i];
    }
    ll ret = LINF;
    ll ma = -LINF;
    ll mi = LINF;
    for(ll j = i - 1; j >= max(0LL, i - M); j--) {
        ma = max(ma, A[j]);
        mi = min(mi, A[j]);
        ret = min(ret, rec(j, A) + K + (i - j) * (ma - mi));
    }
    return dp[i] = ret;
}

int main() {
    cin >> N >> M >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    rep(i, 20200) dp[i] = LINF;
    dp[0] = 0;
    cout << rec(N, A) << endl;
    return 0;
}


Measured memory_bytes: 5124
import bisect

N = int(input())
L = sorted(map(int, input().split()))

ans = 0
for a in range(N):
    for b in range(a+1, N):
        ab = L[a] + L[b]
        left = b + 1
        right = bisect.bisect_left(L, ab)
        ans += right - left

print(ans)


Measured memory_bytes: 42972
#include <bits/stdc++.h>
#define REP(a, b) for(int a = 0; a < b; a++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
using namespace std;

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const int MAXN = 1005;

int h, w;
int DP[MAXN][MAXN];
char A[MAXN][MAXN];

int rek(int a, int b) {
	if (a == h - 1 && b == w - 1) return 1;
	int &ret = DP[a][b];
	if (ret != -1) return ret;
	ret = 0;
	if (b + 1 < w && A[a][b + 1] == '.') ret = (ret + rek(a, b + 1)) % MOD;
	if (a + 1 < h && A[a + 1][b] == '.') ret = (ret + rek(a + 1, b)) % MOD;
	return ret;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	memset(DP, -1, sizeof DP);
	cin >> h >> w;
	REP(i, h) REP(j, w) cin >> A[i][j];
	cout << rek(0, 0) << '\n';
}

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

# define C continue;
# define D double
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vii vector < pii >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(-1,1);
const D tpie = 2*pie;

void solve ( int test_case )
{
    int a,b,t;
    cin>>a>>b>>t;
    
    cout<<(t/a)*b;
    
}

int main()
{
    int t = 1;
    //cin>>t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}



Measured memory_bytes: 256
def poll(n , s):

    ss = {}
    maxint = 0
    ans = []

    for i in range(n):
        if s[i] in ss:
            ss[s[i]] += 1
        else:
            ss[s[i]] = 1

    maxint = max(ss.values())

    ans = [k for k, v in ss.items() if v == maxint]

    ans.sort()
    return ans

def main():
    n = int(input())
    s =[str(input()) for i in range(n)]
    ans = poll(n , s)

    for i in range(len(ans)):
        print(ans[i])

if __name__ == '__main__':
    main()

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

int main(){

	float n;
	float temp_1[8] = { 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0, 1.0 };
	float temp_2[4] = { 0.5, 0.25, 0.125, 0.0625 };

	while (cin >> n && n >= 0.0){

		int temp_a[8], temp_b[4];

		for (int i = 0; i < 8; i++){

			if (n >= temp_1[i]){

				temp_a[i] = 1;
				n -= temp_1[i];
			}
			else temp_a[i] = 0;
		}

		if (n >= 1.0){

			cout << "NA" << endl;
			continue;
		}

		for (int i = 0; i < 4; i++){

			if (n >= temp_2[i]){

				temp_b[i] = 1;
				n -= temp_2[i];
			}
			else temp_b[i] = 0;
		}

		if (n != 0.0){

			cout << "NA" << endl;
			continue;
		}

		for (int i = 0; i < 8; i++)
			cout << temp_a[i];
		cout << '.';
		for (int i = 0; i < 4; i++)
			cout << temp_b[i];

		cout << endl;
	}
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b))<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3660
import Control.Monad
import Data.Array.Unboxed

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  kss <- replicateM m $ map read . words <$> getLine :: IO [[Int]]
  ps <- map read . words <$> getLine :: IO [Int]

--  let ios = map (listArray (0,n-1)) $ (!!n) $ iterate ([(0:),(1:)] <*>) [[]]
  let ios = (!!n) $ iterate ([(0:),(1:)] <*>) [[]]

  print $ solve ios kss ps m

-- solve :: [UArray Int Int] -> [[Int]] -> [Int] -> Int -> Int
solve :: [[Int]] -> [[Int]] -> [Int] -> Int -> Int
solve ios kss ps m = go ios kss ps 0 0
--  where go :: [UArray Int Int] -> [[Int]] -> [Int] -> Int -> Int -> Int
  where
        go [] _ _ _ b = b
        go (io:ios') ((_:s):kss') (p:ps') acc bcc = let l = (`mod`2) $ sum $ map ((io!!) . subtract 1) s
                                                    in if l == p
                                                       then go (io:ios') kss' ps' (acc+1) bcc
                                                       else go (io:ios') kss' ps' acc     bcc
        go (io:ios') [] [] acc bcc = if acc == m then go ios' kss ps 0 (bcc+1) else go ios' kss ps 0 bcc


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll S, W;
    cin >> S >> W;
    if (W >= S ) {
        cout << "unsafe" << '\n';
    } else {
        cout << "safe" << '\n';
    }

}

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


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

int N, M;
vector<int> G[100];
bool visited[100];

int dfs(int from, int cnt) {
   if (cnt >= N-1) {
      return 1;
   }

   visited[from] = true;
   int ret = 0;
   for (int to : G[from]) {
      if (visited[to]) continue;
      ret += dfs(to, cnt+1);
   }
   visited[from] = false;

   return ret;
}

int main() {
   cin >> N >> M;
   for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      G[a].push_back(b);
      G[b].push_back(a);
   }

   cout << dfs(0, 0) << endl;

   return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<vector<int>> x(n+1, vector<int>(n));
    vector<vector<int>> y(n+1, vector<int>(n));

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        for (int j = 1; j <= a[i]; j++) cin >> x[i][j] >> y[i][j];
    }

    int ans = 0;
    for (int is = (1<<n)-1; is >=0 ; is--) {
        int tmp = 0;

        bool okflag = true;
        for (int i=1; i<=n; i++) {
            if(is>>(i-1)&1) {
                for (int j = 1; j <= a[i]; j++) {
                    if ((is>>(x[i][j]-1)&1) != (y[i][j])) {
                        okflag = false;
                        break;
                    }
                }
            }
            if(!okflag) break;
        }
        if(!okflag) continue;
        rep(k, n) if (is>>k&1) tmp++;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;

int main(void) {
	ll ans;
	vector<int> X;

	X.resize(3);
	cin >> X[0] >> X[1] >> X[2];

	if (X[0] % 2 == 0 || X[1] % 2 == 0 || X[2] % 2 == 0)
		ans = 0;
	else {
		sort(X.begin(), X.end());
		ans = (ll)X[0] * X[1];
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
h,w,k = map(int,input().split())
a = [list(input()) for i in range(h)]
t = 0
s = set()
las = -1
for i in range(h):
    cur = a[i].count("#")
    if not cur:
        s.add(i)
        continue
    f = 1
    for j in range(w):
        if a[i][j] == "#" and f < cur:
            a[i][j] = t+f
            f += 1
        else:
            a[i][j] = t+f
    if len(s):
        for x in s:
            a[x] = a[i]
        s = set()
    t += f
    las = i
for x in s:
    a[x] = a[las]
for x in a:
    print(" ".join(map(str,x)))

Measured memory_bytes: 7156
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
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);}

template<typename Num>
constexpr Num mypow(Num a, unsigned long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll n,k;
  std::cin>>n>>k;

  ll mod=n%k;

  std::cout<<std::min(mod,k-mod)<<"\n";

  return 0;
}

Measured memory_bytes: 3556
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, i;
	ll L, a = 2, b = 1;

	cin >> n;

	if (n == 1) {
		cout << b << endl;
		return 0;
	}

	for (i = 2; i <= n; i++) {
		L = a + b;
		a = b;
		b = L;
	}

	cout << L << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
#define rg register
using namespace std;
typedef long long LL;
const LL m_63=1061109567;
const LL m_127=2139062143;
const LL inf=2147483647;
const LL llf=9223372036854775807;
const LL N=1e5+7;
const LL M=2e5+7;
LL n,a[M],id,ans[M],sum[M];
il LL read(){
	LL x(0),ff(1);char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
il void write(LL x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
il void fre(){
	freopen("mid.in","r",stdin);
	freopen("mid.out","w",stdout);
}
il int check(int k){
	for(rg int i=0;i<n-1;++i){
		int x1=a[n+i],x2=a[n+i+1],y1=a[n-i],y2=a[n-i-1];
		if((x1<=k&&x2<=k)||(y1<=k&&y2<=k))return 1;
		if((x1>k&&x2>k)||(y1>k&&y2>k))return 0;
	}
	if(a[1]<=k)return 1;
	else if(a[1]>k)return 0;
}
int main(){
//	fre();
	n=read();
	for(rg LL i=1;i<2*n;++i)a[i]=read();
	int left=1,right=2*n-1,ans;
	while(left<right){
		int mid((left+right)>>1);
		if(check(mid))right=mid;
		else left=mid+1;
	}
	printf("%d",right);
	return 0;
}
/*
4
1 6 3 7 4 5 2
1 2 3 4 5 6 7
3 6 4
4 6 4
4 6 4 5
4 5 4 5
4 5 4 5 4
4 5 4 5 4


2 1 2 3
*/ 

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1], X = l[2];

            if (A + B < X || X < A) Console.WriteLine("NO");
            else Console.WriteLine("YES");
        }
    }
}



Measured memory_bytes: 13268
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
const int N=5005,mod=1e9+7;
int n,A,B,f[N][N][2],sum1[N][N][2],sum2[N][N][2],ans;
//sum1[i][j][o] = sigma f[i][s][o] (s<=j)
//sum2[i][j][o] = sigma f[i+s][s][o] (s<=j)
int qpow(int x,int y) {
	int res=1;
	while(y) {
		if(y&1) res=(LL)res*x%mod;
		x=(LL)x*x%mod, y>>=1;
	}
	return res;
}
int main() {
	scanf("%d%d%d",&n,&A,&B);
	if(A>B) swap(A,B);
	f[0][0][0]=1, f[0][0][1]=1;
	for(int i=0;i<=n;++i) {
		if(i) {
			for(int j=1;j <= i && j < B;++j) {
				if(j < A) f[i][j][0]=sum1[i-j][i-j][1];
				if(j >= A) f[i][j][0]=sum2[i-j][j-A][1];
				f[i][j][1]=sum1[i-j][min(A-1,i-j)][0];
				if(j >= A)
					f[i][j][1]=((LL)f[i][j][1]+sum2[i-j][j-1][0]+mod-sum2[i-j][A-1][0])%mod;
			}
		}
		for(int j=0;j<=i;++j) for(int o=0;o<2;++o) {
			sum1[i][j][o]=(sum1[i][j-1][o]+f[i][j][o])%mod;
			sum2[i-j][j][o]=(sum2[i-j][j-1][o]+f[i][j][o])%mod;
		}
	}
	for(int i=1;i<=n;++i) ans=(ans+f[n][i][0])%mod, ans=(ans+f[n][i][1])%mod;
	ans=(qpow(2,n)+mod-ans)%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 353880
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	S = sys.stdin.readline()
	ans = ''
	for i in range(len(S)-1):
		if ord(S[i])+N > 90:
			ans += chr((ord(S[i])+N)%91 + 65)
		else:
			ans += chr((ord(S[i])+N))
	print(ans)

main()

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int n;
ll a[220000];
int lb[220000];
int rb[220000];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	vector<int> st;
	for (int i = 0; i < n; ++i) {
		while (!st.empty() && a[st.back()] > a[i])
			st.pop_back();
		if (st.empty())
			lb[i] = 0;
		else
			lb[i] = st.back() + 1;
		st.push_back(i);
	}
	st.clear();
	for (int i = n - 1; i >= 0; --i) {
		while (!st.empty() && a[st.back()] > a[i])
			st.pop_back();
		if (st.empty())
			rb[i] = n - 1;
		else
			rb[i] = st.back() - 1;
		st.push_back(i);
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += (ll)a[i] * (ll)(rb[i] - i + 1) * (i - lb[i] + 1);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 4340
#ABC073C
N=int(input())
A=[]
for n in range(N):
	A.append(int(input()))
A.sort()
x=A[0]
i=1
ans=N
while i<N:
	if A[i]==x:
		ans-=2
		i+=1
		if i<N:
			x=A[i]
		i+=1
	else:
		x=A[i]
		i+=1
print(ans)

Measured memory_bytes: 7388
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int k;
    cin >> k;
    int mod = 7%k,now = 1;
    if(mod == 0) {
        cout << 1 << endl;
        return 0;
    }
    while(true) {
        mod = mod*10+7;
        mod %= k;
        now++;
        if(mod == 0) {
            cout << now << endl;
            return 0;
        }
        if(now >= 10000000) {
            cout << -1 << endl;
            return 0;
        }
    }
}


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

int main(){
  int n, i, count=1;
  cin >> n;
  vector<int> d(n);  
  for(i=0; i<n; i++) cin >> d[i];
  sort(d.begin(), d.end());
  //reverse(d.begin(), d.end());
  for(i=0; i<n-1; i++){
    if(d[i] == d[i+1]) count = count;
    else count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[100001],b[100001];
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%lld",&a[i]);
	for(int i=1; i<=n; i++) {
		if(i%2)b[1]+=a[i];
		else b[1]-=a[i];
	}
	for(int i=2; i<=n; i++) {
		b[i]=2*a[i-1]-b[i-1];
	}
	for(int i=1; i<=n; i++)printf("%lld ",b[i]);
}

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

int main(){
  int a, b;
  cin >> a >> b;
  bool check = true;
  
  for(int x = 0; x < 11000; x++){
    if(x*8/100 == a && x/10 == b){
      cout << x << endl;
      check = false;
      break;
    }
  }
  
  if(check)
    cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf=8000000000000000000;

int n,tim,dis,ans=inf;

signed main()
{
	cin>>n>>tim>>dis;
	if (n<=0)  n=-n;
	if (n==0)
	{
		if (tim%2==1)  cout<<dis<<endl;
		else cout<<0<<endl;
		return 0;
	}
	int now=n%dis,now2=now-dis;
	
	if (tim<=n/dis)  return cout<<n-tim*dis<<endl,0;
	if (abs(now)<=abs(now2))
	{
		tim=tim-(n/dis);
		if (tim%2==1)  ans=min(ans,abs(now2));
		else ans=min(ans,now);
	}
	else if (abs(now)>=abs(now2))
	{
		tim=tim-((n/dis)+1);
		if (tim%2==1)  ans=min(ans,now);
		else ans=min(ans,abs(now2));
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3648
import math

def read_input():
    x = int(input())
    return x


def submit():
    x = read_input()
    max_root = int(math.floor(math.sqrt(x)))

    max_square = 1
    for i in range(2, max_root + 1):
        test = i
        while test <= x:
            if test > max_square:
                max_square = test
            test *= i

    print(max_square)


if __name__ == '__main__':
    submit()


Measured memory_bytes: 2940
def binarySearch(x, S):
    left = 0
    right = len(S)
    while left < right:
        mid = (left + right) / 2
        if x == S[mid]:
            return mid
        elif x < S[mid]:
            right = mid
        else:
            left = mid + 1
    return -1

n = int(raw_input())
S = map(int, raw_input().split())
q = int(raw_input())
T = map(int, raw_input().split())
count = 0
for x in T:
    if binarySearch(x, S) >= 0:
        count += 1
print count

Measured memory_bytes: 12876
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main() {
  int n;
  cin >> n;
  vector<string> maze(2);
  rep(i,2) cin >> maze.at(i);
  
  vector<ll> dp(n);
  int i;
  if(maze.at(0).at(0) == maze.at(1).at(0)) { dp.at(0) = 3; i = 1;}
  else { dp.at(0) = dp.at(1) = 6; i = 2;}
  
  while(i < n){
    if(maze.at(0).at(i) == maze.at(1).at(i)){
      if(maze.at(0).at(i-1) == maze.at(1).at(i-1)){
        dp.at(i) = (2*dp.at(i-1))%MOD;
        i++;
      }else{
        dp.at(i) = dp.at(i-1);
        i ++;
      }
    }else{
      if(maze.at(0).at(i-1) == maze.at(1).at(i-1)){
        dp.at(i+1) = (2 * dp.at(i-1))%MOD;
        i += 2;
      }else{
        dp.at(i+1) = (3 * dp.at(i-1))%MOD;
        i += 2;
      }
    }
  }
  
  cout << dp.at(n-1) << endl;  
    
  return 0;
}



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

int main() {
  long long n;
  cin>>n;
  string ans = "";
  while (n > 0) {
    int tmp = (n - 1) % 26;
    char c = 'a' + tmp;
    ans = ans + c;
    n = (n - 1) / 26;
  }
  reverse(ans.begin(), ans.end());
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e3+5;
const ll mod =   1e9+7;
int n,t;int a[N],b[N];int dp[N][7000];vector<pair<int,int> > vp;
int main()
{  fast
cin>>n>>t;
for(int i=0;i<n;i++)
{
	int x,y;
	cin>>x>>y;
	vp.emplace_back(x,y);
}
sort(vp.begin(),vp.end());
for(int i=0;i<n;i++){
	for(int j=7000;j>=0;j--){dp[i+1][j]=dp[i][j];
		if(j<t&&dp[i+1][j+vp[i].fi]<dp[i][j]+vp[i].se)
		dp[i+1][j+vp[i].fi]=dp[i][j]+vp[i].se;
	}
}
int ans=0;
for(int i=0;i<7000;i++)
ans=max(ans,dp[n][i]);
cout<<ans;
}


Measured memory_bytes: 85680
N = int(input())
l = []
for _ in range(N):
    a, b = map(int, input().split())
    l.append((a, b))

cnt = 0
for t in l:
    if t[0] == t[1]:
        cnt += 1
        if cnt >= 3:
            break
    else:
        cnt = 0
if cnt >= 3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9176
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
void fx(vector<int> &a,int n, int m){

}

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

int arr[3000000];
void input(int n){
	for(int i=0;i<n;++i)
	cin>>arr[i];
}

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



void q1(){
	int n;
	n*=(n+1);
	n/=2;
	cout<<n;
}
// -----------------------------------------------------------------------


void q2(){
	string s,t;
	cin>>s;
	t="";
	int skip=0;
	for(int i=(int)s.size()-1;i>=0;i--){
		if(s[i]=='B'){
			skip++;
		} else{
			if(skip>0){
				skip--;
			} else{
				t+=s[i];
			}
		}
	}
	cout<<t.size();
}

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

void q3(){
	int n;
	input(n);
	ld sum=0;
	for(int i=0;i<n;++i){
		sum+=arr[i];
	}
	sum/=n;
	int l=sum;
	sum+=1;
	int u=sum;
	int pp,p;
	pp=0;
	for(int i=0;i<n;++i){
		pp+=((arr[i]-sum)*(arr[i]-sum));
	}p=0;
	for(int i=0;i<n;++i){
		p+=((arr[i]-sum)*(arr[i]-sum));
	}
	cout<<min(p,pp);
}


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

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

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


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	q4();
	return 0;
}


Measured memory_bytes: 512
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map> 
#include <set>
#include <ctime> 
#include <queue> 

#define LL long long

using namespace std;

const int N = 200000+10;

int n;
int a[N];
struct node{
	int v;
	bool mk;
	node* next, *prev;	
	node() {mk = false;}
}*st, *ed, em;

int main()
{

	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	st = ed = &em; em.mk = true;
	bool d = 1;
	for(int i = 1; i <= n; i++)
	{
		node *x = new node(); x->v = a[i];
		if(d)
		{
			x->next = NULL; x->prev = ed;
			ed->next = x;
			ed = x;
		}else
		{
			x->prev = NULL; x->next = st;
			st->prev = x;
			st = x;
		}
		d = !d;
	}
	if(n%2==0)
	{
		while(st) 
		{
			if(!st->mk)
				if(st->next)
					printf("%d ", st->v);
				else
					printf("%d\n", st->v);
			st = st->next;
		}
	}
	else
		while(ed)
		{
			if(!ed->mk)
				if(ed->prev)
					printf("%d ", ed->v);
				else
					printf("%d\n", ed->v);
			ed = ed->prev;
		}
}

Measured memory_bytes: 9216
n = int(input())
Arr = [0] * (n + 1)
for num in range(1, n+1):
    for i in range(1, n // num + 1):
        Arr[i * num] += 1
ans = 0
for i in range(1, n+1):
    ans += Arr[i] * i
print(ans)


Measured memory_bytes: 151472
#include <bits/stdc++.h>
using namespace std;
const int MXN = 100005;
using LL = long long;
LL a[MXN], dp[MXN][2];

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    if(a[2] >= 0)
    {
        dp[2][0] = (a[1] + a[2]);
        dp[2][1] = -(a[1] + a[2]);
    }
    else
    {
        dp[2][0] = -(a[1] + a[2]);
        dp[2][1] = (a[1] + a[2]);
    }
    for(int i = 3; i <= n; ++i)
    {
        if(a[i] >= 0)
        {
            dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i];
            dp[i][1] = max(dp[i - 1][0] - 2 * abs(a[i - 1]), dp[i - 1][1] + 2 * abs(a[i - 1])) - a[i];
        }
        else
        {
            dp[i][0] = max(dp[i - 1][0] - 2 * abs(a[i - 1]), dp[i - 1][1] + 2 * abs(a[i - 1])) - a[i];
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) + a[i];
        }
    }
    cout << max(dp[n][0], dp[n][1]) << '\n';
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int N, D, X; cin >> N >> D >> X;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	int ans = N + X;
	--D;
	rep(i, N) {
		ans += D / A[i];
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    int n;
    cin>>n;
    vector<int>x(n);
    rep(i,n)cin>>x[i];
    ll mini = INF;
    rep(i,100){
        ll cmp = 0;
        rep(j,n)cmp += pow(x[j] - (i + 1),2);
        mini = min(mini,cmp);
    }
    cout<<mini<<endl;
}

Measured memory_bytes: 256