akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	int n; std::cin >> n;
	string s; std::cin >> s;
	int ans = 0;
	rep(i, n) {
		ans++;
		while(i < n && s[i] == s[i+1])
			i++;
	}
	std::cout << ans << "\n";
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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;
typedef pair<int,int> P;

int dp[5005][5005];

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  dp[0][0]=0;
  rrep(i,n){
    rrep(j,n){
      if(i<=j)continue;
      if(s[i-1]==s[j-1])dp[i][j]=dp[i-1][j-1]+1;
    }
  }
  int ans = 0;
  rrep(i,n){
    rrep(j,n){
      if(i<=j)continue;
      chmax(ans,min(dp[i][j],i-j));
    }
  }
  cout << ans << endl;
}

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

int main(){
    int k, i = 0; 
    string s;
    cin >> s >> k;
    while(s[i] == '1' && i < s.size()-1){
        i++;
    }
    if(i < k){
        cout << s[i];
    }else{
        cout << 1;
    }
    return 0;
}

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

class Main {
	static boolean[] isExist = new boolean[2001];
	static int n;
	static int[] A;
    public static void main( String[] args ) {
        try {
	      	BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
			n = Integer.parseInt( kb.readLine() );
			String[] buf = kb.readLine( ).split( " " );
			A = new int[n];
			int num;
			int sum = 0;
			for( int i=0; i<n; i++ ) {
				num = Integer.parseInt( buf[i] );
				for( int j=2000-num; 0<j; j-- ) {
					if( isExist[j] ) {
						isExist[ j+num ] = true;
					}
				}
				isExist[ num ] = true;
				A[i] = num;
			}
			
			StringBuilder output = new  StringBuilder( );
			int q = Integer.parseInt( kb.readLine() );
			buf = kb.readLine( ).split( " " );
			for( int i=0; i<q; i++ ) {
				if( isExist[ Integer.parseInt( buf[i] ) ] ) {
					output.append( "yes" ).append( "\n" );			
				} else {
					output.append( "no" ).append( "\n" );
				}
			}
			System.out.print( output );            
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}

Measured memory_bytes: 18156
fn input() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn main() {
    let mut count = 0;
    let mut val = vec![];

    while {
        let seg: Vec<i32> = input()
            .split_whitespace()
            .map(|s| s.parse::<i32>().unwrap())
            .collect();
        if seg[0] != 0 {
            val.push(seg[0]);
            count += 1;
        }
        seg[0] != 0
    } {}
    for i in 0..count {
        println!("Case {}: {}", i + 1, val[i]);
    }
}


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

using namespace std;

const int mod = 1e9 + 7;

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }

    vector<int> suffix(n);
    suffix[n-1] = v[n-1];
    for(int i = n-2;i>=0;i--)
    {
        suffix[i] = (v[i] + suffix[i+1]) % mod;
    }

    int total = 0;
    for(int i = 0;i<n-1;i++)
    {
        int t = (long long) suffix[i+1] * v[i] % mod;
        total = (total + t) % mod;
    }

    cout<<total<<"\n";

    return 0;
}

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

class dice{
    private:
        int order[6];
    public:
        void roll_N();
        void roll_S();
        void roll_W();
        void roll_E();
        void setOrder(int i, int ord){order[i] = ord;}
        int getOrder(int i){return order[i];}
};
void dice::roll_N(){
    int tmp;
    tmp = order[0];
    order[0] = order[1];
    order[1] = order[5];
    order[5] = order[4];
    order[4] = tmp;
}
void dice::roll_S(){
    int tmp;
    tmp = order[0];
    order[0] = order[4];
    order[4] = order[5];
    order[5] = order[1];
    order[1] = tmp;
}
void dice::roll_W(){
    int tmp;
    tmp = order[0];
    order[0] = order[2];
    order[2] = order[5];
    order[5] = order[3];
    order[3] = tmp;
}
void dice::roll_E(){
    int tmp;
    tmp = order[0];
    order[0] = order[3];
    order[3] = order[5];
    order[5] = order[2];
    order[2] = tmp;
}

int main(void){

    int d[6];
    cin >> d[0] >> d[1] >> d[2] >> d[3] >> d[4] >> d[5];
    dice a;
    for( int i=0;i<6;i++){
        a.setOrder(i,d[i]);
    }

    string st;
    cin >> st;
    for(int i=0;i<st.size();i++){
        if(st[i]=='N') a.roll_N();
        if(st[i]=='S') a.roll_S();
        if(st[i]=='W') a.roll_W();
        if(st[i]=='E') a.roll_E();
    }
    cout << a.getOrder(0) << endl;
}



Measured memory_bytes: 3188
import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B

main = do
    n<-readLn::IO Int
    as<-replicateM n $ fst.fromJust.B.readInt <$> B.getLine ::IO[Int]
    print $ sol n $ sort as
--
sol n as
    | n==2 = a2-a1
    | n==3 = max (b3*2-b2-b1) (b3+b2-b1*2)
    | even n = sum e4*2+e3-e2-sum e1*2
    | odd n = max (sum oa4*2+oa3+oa2-sum oa1*2) (sum ob4*2-ob3-ob2-sum ob1*2)
    where
        [a1,a2] = as
        [b1,b2,b3] = as
        (e1,e2:e3:e4) = splitAt ((n-2)`div`2) as
        (oa1,oa2:oa3:oa4) = splitAt ((n-1)`div`2) as
        (ob1,ob2:ob3:ob4) = splitAt ((n-2)`div`2) as

Measured memory_bytes: 30972
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    m=n+1-m;
    int a[n],i,b[n+1];
    for(i=0;i<=n;i++)
    b[i]=0;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
        int k=a[i];
        b[k]++;
    }
    sort(b,b+n+1);
    for(i=0;i<m;i++)
   sum=sum+b[i];

    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 1792
using System;


	public class SelectionSort
	{
		public static void Main(string[] args)
		{
			int count=int.Parse(Console.ReadLine());			
			string data=Console.ReadLine();
			string[] num=data.Split();
			int[] target=new int[count];
			int temp;
			int sortCount=0;//?????????????????°???
			for(int d=0;d<num.Length;d++)
			{
				target[d]=int.Parse(num[d]);
			}
			
			for(int i=0;i<count-1;i++)
			{   int mini=i;
				for(int j=i+1;j<count;j++)
				{
					
					if(target[j]<target[mini])
					{
						mini=j;
						
					}
					
				}
				if(i!=mini)
				{
					temp=target[i];
					target[i]=target[mini];
					target[mini]=temp;
					sortCount++;
				}
			}
			Console.Write(target[0]);
			for(int k=1;k<target.Length;k++)
			{
				Console.Write(" "+target[k]);
			}
			Console.Write("\r\n");
			Console.WriteLine(sortCount);
		}
	}

Measured memory_bytes: 9164
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,k,s;
  cin>>n>>k>>s;
  vector<int>ans;
  for(int i=0;i<k;i++)ans.push_back(s);
  if(s<mod-7){
    for(int i=0;i<n-k;i++)ans.push_back(mod-7);
  } else {
    for(int i=0;i<n-k;i++)ans.push_back(1);
  }
  for(int i=0;i<n-1;i++)cout<<ans[i]<<" ";
  cout<<ans[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1784
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod=1000000007
def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y: x*y%mod, range(n, n - r, -1), 1)
    denom = pow( reduce(lambda x,y: x*y%mod, range(1, r + 1), 1) , mod-2, mod)
    return numer * denom % mod


def main():
    h1,m1,h2,m2,k = map(int,input().strip().split())
    print( max(60*(h2-h1) + (m2-m1) - k, 0))



if __name__ == '__main__':
    main()

Measured memory_bytes: 78292
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Main main = new Main();
		main.solve();
	}

	private void solve() {

		Scanner sc = new Scanner (System.in);

		String s = sc.next();

		String[] list = new String[s.length()];

		list=s.split("");

		int nowCount=0;
		int maximumCount=0;

		for (int index=0; index<s.length(); index++) {
			if (list[index].equals("A")||list[index].equals("T")||list[index].equals("C")||list[index].equals("G")) {
				nowCount++;
			} else {
				if (nowCount>maximumCount) {
					maximumCount=nowCount;
				}
				nowCount=0;
			}
		}
		if (nowCount>maximumCount) {
			maximumCount=nowCount;
		}

		System.out.println(maximumCount);
	}
}

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

signed main(){

  int d;
  vector<int> c(26);
  cin>>d;
  for(auto& ci:c)cin>>ci;
  vector<vector<int>> s(d,vector<int>(26));
  for(auto& si:s)for(auto& sij:si)cin>>sij;

  vector<int> last(26,0);

  auto calc_satisfaction_level = [&](int d,int i){
    int res = s[d][i];
    for(int j=0;j<26;++j){
      if(i==j)continue;
      res -= c[j]*(d-last[j]+1);
    }
    return res;
  };

  vector<int> ans(d);

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

  auto test_all_get_max = [&](int di)->pair<int,int>{
    // 日付を引数にして全てのコンテストタイプを試してmaxscoreになるタイプを返す
    int val_max = 0,type_max = 0;
    auto chmax = [](auto& a,auto b){if(a<b){a=b;return true;}return false;};
    for(int type=0;type<26;++type){
      if(chmax(val_max,calc_satisfaction_level(di,type)))type_max=type;
    }
    return {val_max,type_max};
  };

  for(int di=0;di<d;++di){
    auto [vi,type] = test_all_get_max(di);
    ans[di] = type;
    last[type] = di+1;
  }

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

  for(auto x:ans)cout<< x+1 <<endl;


}

Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (ll)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    string S;
    cin >> S;
    vector<int> cnt(26, 0);
    ll ans = SZ(S) * (SZ(S) - 1) / 2 + 1;
    REP(i, SZ(S)) ans -= cnt[S[i] - 'a']++;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3688
n,a=map(int,input().split())
x=list(map(int,input().split()))
y=[]
for i in x:
  y.append(i-a)
s=2*n*a
dp=[[0 for i in range(s+1)] for j in range(n+1)]
dp[0][n*a]=1
for i in range(n):
  for j in range(s+1):
    x=j-y[i]
    if(0<=x and x<=2*n*a):
      dp[i+1][j]=dp[i][j-y[i]]+dp[i][j]
    else:
      dp[i+1][j]=dp[i][j]

print(dp[n][n*a]-1)

Measured memory_bytes: 5236
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        int M = cin.nextint;
        int Q = cin.nextint;
        var dp = new int[N][];
        for (int i = 0; i < N; i++)
        {
            dp[i] = new int[N];
        }
        for (int i = 0; i < M; i++)
        {
            dp[cin.nextint - 1][cin.nextint - 1]++;
        }
        for (int i = 1; i < N; i++)
        {
            for (int j = 0; j + i < N; j++)
            {
                if (i == 1) dp[j][j + 1] += dp[j][j] + dp[j + 1][j + 1];
                else dp[j][j + i] += dp[j][j + i - 1] + dp[j + 1][j + i] - dp[j + 1][j + i - 1];
            }
        }

        for (int i = 0; i < Q; i++)
        {
            WriteLine(dp[cin.nextint - 1][cin.nextint - 1]);
        }

    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 17172
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
	int n;
	scanf("%d", &n);
	vector<int> p(n);
	vector<int> q(n);
	for (int i = 0; i < n; i++) scanf("%d", &p[i]);
	for (int i = 0; i < n; i++) scanf("%d", &q[i]);
	if (p > q) swap(p, q);
	int ans = 0;
	while (p != q) {
		next_permutation(p.begin(), p.end());
		ans++;
	}
	printf("%d\n", ans);
}



Measured memory_bytes: 256
# ABC126E - 1 or 2
import sys

sys.setrecursionlimit(10 ** 9)


def dfs(v: int) -> None:
    for u in G[v]:
        if not visited[u]:
            visited[u] = color
            dfs(u)


def main():
    global G, visited, color
    N, M, *X = map(int, open(0).read().split())
    G = [[] for _ in range(N + 1)]
    for v, u in zip(X[::3], X[1::3]):
        G[v].append(u), G[u].append(v)
    visited, color = [0] * (N + 1), 1
    for v in range(1, N + 1):
        if not visited[v]:
            visited[v] = color
            dfs(v)
            color += 1
    ans = color - 1
    print(ans)


if __name__ == "__main__":
    main()

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

#define ll long long

using namespace std;

ll p;

ll calc(ll n) {
    ll res = (1 + n) * n / 2;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    ll ans = 0;
    cin >> p;
    vector< pair<int, int> > pref;
    for (ll i = 2; i*i <= p; ++i) {
        if (p%i == 0) {
            int cnt = 0;
            while (p%i == 0) {
                p /= i;
                ++cnt;
            }
            pref.push_back(make_pair(i, cnt));
            ll l = 1, r = 10, res;
            while (l <= r) {
                ll mid = (l + r) >> 1;
                if (calc(mid) <= cnt) {
                    res = mid;
                    l = mid + 1;
                } else {
                    r = mid - 1;
                }
            }
                ans += res;
        }
    }
    if (p > 1) {
        pref.push_back(make_pair(p, 1));
        ++ans;
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define eb push_back
#define mp make_pair
#define hello cout<<"hello"<<"\n"
#define forr(i,a,b) for(int i=a;i<b;i++)
#define it(s)	for(auto itr:s)
#define dvg(s) 	for(auto itr:s)	cout<<itr<<" ";cout<<endl;
#define dbg(s)	cout<<#s<<"= "<<s<<endl;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF=(lli)1e18+5;
const ulli MOD=1e9+7;


	

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::cout.precision(30);
	
	int n,W;
	cin>>n>>W;
	vector<lli> val(n,0);
	vector<lli> w(n,0);
	
	lli vals=0;
	forr(i,0,n)
	{
		cin>>w[i]>>val[i];
		vals+=val[i];
		//~ dp[val[i]]=w[i];
	}
	vector<lli> dp(vals+1,INF);
	dp[0]=0;
	
	forr(i,0,n)
	{
		for(int j=vals-val[i];j>=0;j--)
		{
			dp[j+val[i]]=min(dp[j+val[i]],dp[j]+w[i]);
		}
	}
	
	lli maxi=INT_MIN;
	
	//~ dvg(dp);
	for(int i=0;i<dp.size();i++)
	{
		if(dp[i]<=W)
		{
			maxi=max(maxi,(lli)i);
		}
	}
	cout<<maxi<<"\n";
	
	
		
	return 0;
	
}













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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, K;
  cin >> N >> K;
  int R, S, P;
  cin >> R >> S >> P;

  map<char, int> mp;
  mp['r'] = P;
  mp['s'] = R;
  mp['p'] = S;

  string T;
  cin >> T;

  ll ans = 0;
  for(int i = 0; i < K; i++){
    int now = i;
    char pre = 'a';
    while(now < T.length()){
      if(T[now] != pre){
        ans += mp[T[now]];
        pre = T[now];
      }else{
        pre = 'a';
      }
      now += K;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// IN THE NAME OF GOD
#include <bits/stdc++.h>

#define ff first
#define endl '\n'
#define ss second
#define ll long long
#define pb push_back
#define ld long double
#define pii pair <int, int>
#define pll pair <long long, long long>

using namespace std;
int pre = 1;
string s;
vector <pii> ans;
bool pal(string str){
  for(int i = 1; i < s.size() - 1; i++){
    if(s[i] != s[s.size() - i - 2]) return false;
  }
  return true;
}
int main(){
  //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> s;
  if(s[s.size() - 1] == '1' || s[0] == '0' || !pal(s)) return cout << -1, 0;
  for(int i = 0; i < s.size() - 1; i++){
    if(s[i] == '1') ans.pb({pre, i + 2}), pre = i + 2;
    else ans.pb({pre, i + 2});
  }
  for(int i = 0; i < ans.size(); i++) cout << ans[i].ff << ' ' << ans[i].ss << endl;
}
//programmer: a_h_k_81
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //


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

using namespace std;
long long x[10000010], y[10000010],z[10000010];
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n) i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9+7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a,b,c,d,n,cnt=0,ans=0;
   string s,w;

   cin>>a>>b;
   cout<<(a-1)*(b-1)<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n, r;
    cin >> n >> r;
    if (n >= 10) {
        cout << r << "\n";
    } else {
        cout << r + 100 * (10 - n) << "\n";
    }
}

Measured memory_bytes: 3560
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t dist(int64_t a, int64_t b)
{
	return a + b - 2;
}

void solve()
{
	int64_t N;
    std::cin >> N;

	// a * b = N
	// 対称性から a <= b とすると a <= sqrt(N)

	int64_t ans = INT64_MAX;

	int64_t sqrtN = (int64_t)sqrt((double_t)N) + 1;
	for (int64_t a = 1; a <= sqrtN; a++) {
		if(N % a != 0) continue;
		int64_t b = N / a;
		int64_t tmp = dist(a, b);
		if(tmp < ans) ans = tmp;
	}

	std::cout << ans << std::endl;

}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)998244353
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    set<ll> s;
    for (ll i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            ll one = i;
            ll temp = n;
            while (temp % one == 0)
            {
                temp /= one;
            }
            if (temp == 1 || (temp - 1ll) % one == 0)
            {
                s.insert(one);
            }
            one = n / i;
            temp = n;
            while (temp % one == 0)
            {
                temp /= one;
            }
            if (temp == 1 || (temp - 1ll) % one == 0)
            {
                s.insert(one);
            }
        }
        else if ((n - 1ll) % i == 0)
        {
            s.insert(i);
            s.insert((n - 1ll) / i);
        }
    }
    cout << min((ll)s.size() + 2ll, n - 1ll);
}


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

int main() {
	string now; cin >> now;
  	int n = (int) now.length();
  	
  	for (int i = 0; i < n / 2 - 1; i++) {
    	if (now[i] != now[i + (n / 2 + 1)]) {
        	cout << "No\n";
          	return 0;
        }
      	if (now[i] != now[n - i - 1]) {
         	cout << "No\n";
          	return 0;
        }
    }
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
	int a,b,c,n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&a,&b,&c);
		if(a==sqrt(pow(b,2)+pow(c,2)) || b==sqrt(pow(a,2)+pow(c,2)) || c==sqrt(pow(a,2)+pow(b,2)))printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}



Measured memory_bytes: 2012
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
#define _USE_MATH_DEFINES
using namespace std;
using namespace std::chrono;

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}
const int MAXN = 1000100;
int spf[MAXN];

set<int> sieve_factor(int n){
  set<int> s;
  while(n != 1)
    s.insert(spf[n]), n /= spf[n];
  return s;
}

int h_cnt[300100];
int w_cnt[300100];


signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);

  int h, w, m;
  cin >> h >> w >> m;
  set <pair<int, int>> s;
  int a, b;
  
  for (int i = 0; i < m; i++){
    cin >> a >> b;
    a--, b--;
    h_cnt[a]++, w_cnt[b]++;
    s.insert(MP(a, b));
  }
  set<int> top_h;
  set<int>  top_w;
  int max_h = 0;
  int max_w = 0;
  for (int i = 0; i < h; i++)
    max_h = max (max_h, h_cnt[i]);
  for (int i = 0; i < w; i++)
    max_w = max (max_w, w_cnt[i]);
  for (int i = 0; i < h; i++)
    if ( h_cnt[i] == max_h)
      top_h.insert(i);
  for (int i = 0; i < w; i++)
    if (w_cnt[i] == max_w)
      top_w.insert(i);
  int cnt = 0;
  for (auto item: s)
    if (top_h.find(item.fi) != top_h.end() and top_w.find(item.se) != top_w.end())
      cnt++;
  
  cout << max_h + max_w - (int)(cnt == top_h.size() * top_w.size()) << endl;
  
}


Measured memory_bytes: 55188
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[100005],a1[100005],mx,p[1000005],i,j,b[10000005],ans[1000005],r[10000005],P,c,s,ind,usj,f,pr;
int power(long long u,long long v){
	long long pas=1;
	while(v>0)
	if(v%2==0){
		v/=2; u=u*u%P; u=u%P;
	}
	else {
		pas=(pas%P*u%P)%P; v--;
	}
	return pas%P;
}
int main(){
	ios_base::sync_with_stdio(false);
	P=1000000007;
	scanf("%d",&n);
	for(k=1;k<=n;k++){
		scanf("%d",&a[k]); a1[k]=a[k];
		mx=max(mx,a[k]);
	}
	for(k=2;k<=mx;k++){
		if(p[k]==0){
		
		  j++; b[j]=k;
		for(i=k*k;i<=mx;i+=k){
		p[i]=1;	
		}
	}} //cout<<j<<endl;
	for(k=1;k<=n;k++){
		i=1; 
		
		
		while(a[k]>1){
		if(p[a[k]]==0){
			long long bb=1;
		 ans[a[k]]=max(ans[a[k]],bb); a[k]=1; }
		 else{
		 
			while(a[k]%b[i]==0){ 
			a[k]/=b[i]; ind++; 
			ans[b[i]]=max(ans[b[i]],ind);
		}
		ind=0; i++;}
	} 
}  usj=1; //cout<<1<<endl;
	for(k=1;k<=j;k++){
		c=power(b[k],ans[b[k]]); 
		usj*=c;
		usj%=P;
	} 
	for(k=1;k<=n;k++){
	 
	s+=usj*power(a1[k],P-2)%P;
	s%=P;
	
	}
	printf( "%d",s%P);
	 
	
	
}


Measured memory_bytes: 18816
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
if(n&1)
cout<<0;
else
{
    int count=0;
    int x=5;
    while(n/x!=0)
    {
        count+=((n/x)/2);
        x*=5;
    }
    cout<<count;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A;
void input(){
    fast_io();
    cin >> N;
    A = fetch_vec<ll>(N);
}

int solve(){
    vector<ll> AS(N+1,0);
    for (int i = 0; i < N; i++)
    {
        AS[i+1] = AS[i]+A[i];
    }
    ll ans = LL_INF;
    for (int i = 1; i < N; i++)
    {
        ans = min(ans,abs(AS[N]-AS[i]-AS[i]));
    }
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,k,T,x,d;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int get(){
    if(x==0){
        if(k&1)return d;
        return 0;
    }
    if(x<0){
        int a=(-x)/d;
        if(x%d==0)--a;
        if(a>=k)return abs(x+k*d);
        x+=a*d;k-=a;
        if(k&1)return abs(x+d);
        return abs(x);
    }
    if(x>0){
        int a=x/d;
        if(x%d==0)--a;
        if(a>=k)return abs(x-k*d);
        x-=a*d;k-=a;
        if(k&1)return abs(x-d);
        return abs(x);
    }return 0;
}
signed main(){
    //file(a);
    x=read();k=read();d=abs(read());
    printf("%lld\n",abs(get()));


    return 0;
}


Measured memory_bytes: 3760
// ------------------------------------
// Date:2018/ 3/24
// Problem:Go Home _ b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

int main()
{
  CIN(X);
  ll sum = 0ll;
  int ans = 0;
  FOR(i, 1, 1e8) {
    ans++;
    sum += i;
    // debug(sum);
    // debug(ans);
    if (sum >= X) {
      // debug(sum);
      // debug(ans);
      break;
    }
  }
  cout << ans << endl;

  return 0;
}



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


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



  for(int i=0; i<3; i++){
    if(n[i]=='7')a++;

  }
  if(a>0){cout << "Yes" << endl;}else{


  cout << "No" << endl;
  }
}

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

int main(){
	int N;
	cin >> N;
	vector<string> S(N);
	for(auto &i:S)cin >> i;
	
	int ans=0;
	for(int k=0;k<N;k++){
		bool flag=true;
		for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
			if(S[i][(j-k+N)%N]!=S[j][(i-k+N)%N])flag=false;
		}
		if(flag)ans+=N;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
//ABC132B
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(){
	int n;
	scanf("%d",&n);
	int a[n];
	int i, j;
	int count=0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(j=1;j<n-1;j++){
		if(a[j-1]<a[j] & a[j]<a[j+1]){
			count++;
		}else if(a[j-1]>a[j] & a[j]>a[j+1]){
			count++;
		}else count = count;
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    if (a+b > c+d) {
      System.out.println("Left");
    } else if (a+b < c+d) {
      System.out.println("Right");
    } else {
      System.out.println("Balanced");
    }
  }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int,int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

vector<vector<int> > preki,preki2;
vector<bool> visited,visited2;

void dfs(int now){
    if(visited[now]) return;
    visited[now]=true;
    for(auto x : preki[now]){
        dfs(x);
    }
}

void dfs2(int now){
    if(visited2[now]) return;
    visited2[now]=true;
    for(auto x : preki2[now]){
        dfs2(x);
    }
}

int main(){
    int n,m,p;
    cin >> n >> m >> p;
    map<P,int> cost;
    vector<vector<int> > prekiki(n);
    preki=preki2=prekiki;

    vector<bool> exx(n,false);

    visited=visited2=exx;
    
    vector<T> sidelist;
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        c=-c+p;
        sidelist.emplace_back(a,b,c);
        preki[a].push_back(b);
        preki2[b].push_back(a);
    }
    dfs(0);
    dfs2(n-1);

    vector<P> ki;
    rep(i,n) visited[i]=visited[i]&visited2[i];
/*
    rep(i,m){
        int a=sidelist[i].first;
        int b=sidelist[i].second;
        //cout << visited[a] << visited[b] << visited2[a] << visited2[b] << endl;
        bool check=visited[a]&visited[b]&visited2[a]&visited2[b];
        //bool check2=visited2[a]&visited2[b];
        //check=check&check2;
        if(check) ki.push_back(P(a,b));
    }
*/
    vector<int> ans(n,INF);
    ans[0]=0;

    bool update=true;
    int times=0;

    while(update){
        times++;
        update=false;
        rep(i,m){
            int a,b,c;
            tie(a,b,c) = sidelist[i];
            int newcost=ans[a]+c;
            if(!visited[a]) continue;
            if(!visited[b]) continue;
            if(ans[b]>newcost){
                update=true;
                ans[b]=newcost;
            }
        }
        if(times>n){
            cout << -1 << endl;
            return 0;
        }
    }

    if(ans[n-1]>0) ans[n-1]=0;
    cout << -ans[n-1] << endl;
return 0;
}



Measured memory_bytes: 4112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    map<string, ll> cnt;
    ll ans = 0;
    rep(i, n) {
        sort(all(s[i]));
        ans += cnt[s[i]];
        cnt[s[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////
int board[14][14];
int main() {
	int x, y, s;
	while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
		x += 2;
		y += 2;
		switch (s) {
			case 1: {
				board[x][y]++; board[x+1][y]++; board[x][y+1]++;
				board[x-1][y]++; board[x][y-1]++;
				break;
			}
			case 2: {
				board[x][y]++; board[x][y-1]++; board[x+1][y-1]++;
				board[x+1][y]++; board[x+1][y+1]++; board[x][y+1]++;
				board[x-1][y+1]++; board[x-1][y]++; board[x-1][y-1]++;
				break;
			}
			case 3: {
				board[x][y]++; board[x][y-1]++; board[x+1][y-1]++;
				board[x+1][y]++; board[x+1][y+1]++; board[x][y+1]++;
				board[x-1][y+1]++; board[x-1][y]++; board[x-1][y-1]++;
				board[x][y-2]++; board[x+2][y]++; board[x][y+2]++;
				board[x-2][y]++;
				break;
			}
		}
	}
	int s_max = -1;
	int empty_num = 0;
	for (int i = 2; i < 12; i++) {
		for (int j = 2; j < 12; j++) {
			if (board[i][j] > s_max) {
				s_max = board[i][j];
			}
			if (board[i][j] == 0) {
				empty_num++;
			}
		}
	}
	cout << empty_num << endl << s_max << endl;
}
// END   //////////////////////////////////////////////////////////////

Measured memory_bytes: 1208
N=int(input())

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

    return divsets

divs = make_divsets(N)
#print(divs)

min = 1000000000000019

for (a, b) in divs:
    steps = a-1 + b-1
    if steps < min:
        min = steps
print(min)



Measured memory_bytes: 3464
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    vector<int> a(3);
    int k;
    rep(i,3) cin >> a[i];
    cin >> k;
    sort(a.begin(),a.end(),greater<>());
    rep(i,k) a[0]*=2;
    cout << a[0]+a[1]+a[2] << endl;

    return 0;

}


Measured memory_bytes: 3612
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        c: chars,
    }
    if "aeiou".contains(c[0]) {
        println!("vowel");
    } else {
        println!("consonant");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int main(void){
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.rbegin(),v.rend());
    double base = 1.0/2.0;
    double ans = 0;
    rep(i,n-1) {
        ans += v[i] * base;
        base /= 2.0;
    }ans += v[n-1] * (base*2.0);
    printf("%.10f\n",ans);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  i64 n;
  cin >> n;
  vector<long double> x(n), r(n);
  for(int i = 0;i < n;i++) {
    cin >> x[i] >> r[i];
  }
  long double left = -1e18;
  for(int i = 0;i < n;i++) {
    left = max(left, x[i] - r[i]);
  }
  long double right = 1e18;
  for(int i = 0;i < n;i++) {
    right = min(right, x[i] + r[i]);
  }

  auto f = [&](long double k) -> long double {
    long double MIN = 1e18;
    for(int i = 0;i < n;i++) {
      long double l = abs(k - x[i]);
      MIN = min(MIN, sqrtl(r[i] * r[i] - l * l));
    }
    return MIN;
  } ;

  for(int i = 0;i < 90;i++) {
    long double a = (left * 2 + right) / 3;
    long double b = (left + right * 2) / 3;
    long double fa = f(a);
    long double fb = f(b);
    if(fa < fb) {
      left = a;
    }
    else {
      right = b;
    }
  }
  long double xx = left;
  cout << setprecision(10) << fixed << f(xx) << endl;
}



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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  ll ans = 1;
  ll T;
  for(int i = 0; i < N; i++){
    cin >> T;
    ll gcd_ = gcd(ans, T);
    ans = T / gcd_ * ans;
  }
  cout << ans << endl;
  
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i)
        cin >> v[i];

    sort(v.begin(), v.end());
    double ans = v[0];
    for(int i=1; i<n; ++i){
        ans += v[i];
        ans /= 2.0;
    }
    printf("%.10f\n", ans);

    return 0;
}


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

signed main(){
  
  int n;
  cin>>n;
  
  map<string,int> S;
  
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    S[s]++;
  }
  
  int maxcnt = 0;
  
  for(pair<string,int> t : S ){
    maxcnt = max( maxcnt, t.second );
  }
  
  for(pair<string,int> t : S ){
    if( maxcnt == t.second ) cout<<t.first<<endl;
  }
    
  return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, in[100000], p[100000];
vector<int> g[100000];

int main() {
	cin >> n >> m;
	inc(i, n - 1 + m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
		in[b]++;
	}
	
	queue<int> q;
	inc(i, n) { if(in[i] == 0) { q.push(i); p[i] = -1; } }
	
	while(! q.empty()) {
		int v = q.front(); q.pop();
		for(auto & e: g[v]) {
			in[e]--;
			if(in[e] == 0) { q.push(e); p[e] = v; }
		}
	}
	
	inc(i, n) { cout << p[i] + 1 << "\n"; }
	
	return 0;
}


Measured memory_bytes: 7040