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

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		long N=sc.nextLong();
		for(long i=3500; i>=1; i--) {
			if(4*i-N>0) {
				long a=4*i-N;
				long b=N*i;
				for(int j=3500; j>=1; j--) {
					if(a*j-b>0) {
						if((b*j)%(a*j-b)==0) {
							pl(i+" "+j+" "+((b*j)/(a*j-b)));
							System.exit(0);
						}
					}
				}
			}
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 23380
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	ll ans = 0 ;
	for(ll i=1;i*i<=m;i++){
		if(m%i==0){
			if(m/i*n<=m){
				cout << m/i << endl ;
				return 0 ;
			}else{
				if(i*n>m){
					cout << ans << endl ;
					return 0 ;
				}else{
					ans = i ;
				}
			}
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
#include <cstdio>

char s[10010];

int main() {
	int i;
	int n;
	
	scanf("%d %s", &n, s+1);
	for(i=1; s[i]; i++)
		putchar('A' + (s[i] - 'A' + n) % 26);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define adrep(i,s,n) for (int i=(s);i<(n);i++)
using namespace std;
typedef long long ll;
const unsigned long long BIG=1000000000000000000;

int main(){

  int N;
  cin>>N;
  vector<long long> a;

  a.resize(N);
  
  rep(i,N)cin>>a[i];
  

  sort(a.begin(),a.end());
  if(a[0]==0){cout<<0<<endl;return 0;}
  
  unsigned long long prod=1;
  rep(i,N){

    if(a[i]<=(BIG/prod) )prod*=a[i];
    else {cout<<-1<<endl;return 0;}
    
  }
  
  cout<<prod<<endl;
  
}


Measured memory_bytes: 3964
// Vicfred
// https://atcoder.jp/contests/abc174/tasks/abc174_c
// math

import std.bigint;
import std.stdio;

void main() {
    int k;
    readf("%s\n", &k);

    int kkk = 7;
    int steps = 1;

    while(kkk%k != 0) {
        if(steps >= 10^^6+5) {
            steps = -1;
            break;
        }

        steps += 1;
        kkk = kkk * 10 + 7;
        kkk %= k;
    }

    steps.writeln;
}



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

Measured memory_bytes: 256
n = gets.to_i
s = gets.split(" ").map &:to_i
q = gets
ta = gets.split(" ").map &:to_i

c = 0
ta.each { |t|
	s_start = 0
	s_end = n-1
	while true
		i = (s_start + s_end) / 2
		if t == s[i]
			c += 1
			break
		elsif t < s[i]
			s_end = i - 1
		elsif s[i] < t
			s_start = i + 1
		end
		break if s_end < s_start
	end
}
puts c

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s.at(0) == s.at(1) && s.at(1) != s.at(2) && s.at(2) == s.at(3)) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
s = str(input())
L = []
R = []

if s == "L"*n or s == "R"*n:
    print(n-1)
    exit()
now = "E"
ss = 0
for i in range(n):
    if s[i] != now:
        if s[i] == "R" and ss:
            L.append(ss)
        elif s[i] == "L" and ss:
            R.append(ss)
        ss = 1
        now = s[i]
    else:
        ss += 1
    if i == n-1:
        if s[i] == "R" and ss:
            R.append(ss)
        elif s[i] == "L" and ss:
            L.append(ss)
lis = []
ri = 0
li = 0
if s[0] == "R":
    key = 0
else:
    key = 1
for i in range(len(R)+len(L)):
    if key == 0:
        lis.append(R[ri])
        ri += 1
        key = 1
    else:
        lis.append(L[li])
        li += 1
        key = 0


if len(lis) == 2:
    print(sum(lis)-1)
    exit()

m-=1
ans = 0

for i in range(3):
    ans += lis.pop(0)
for i in range(m):
    try:
        ans += lis.pop(0)
    except:
        continue
    try:
        ans += lis.pop(0)
    except:
        continue
ans -= 1
for nu in lis:
    ans += nu-1
print(ans)

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

int bubbleSort(int* a,int n){
	bool isTraded = true;
	int trade = 0;
	while(isTraded){
		isTraded = false;
		for(int i = n - 1; i >= 1;i--){
			if(a[i - 1] > a[i]){
				int v = a[i];
				a[i] = a[i - 1];
				a[i - 1] = v;
			       isTraded = true;
			       trade++;
			}
		}
	}
	for(int i = 0;i < n;i++){
		cout << a[i] << flush;
		if(i != n - 1){
			cout << " " << flush;
		}else{
			cout << endl;
		}
	}
	return trade;

}

int main(){
	int n;
	cin >> n;
	int* a = new int[n];
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	int trade = bubbleSort(a,n);
	cout << trade << endl;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

int main() {
    ll N,K;
    cin >> N >> K;
    vl A(N);
    rep(i,N){
        cin >> A[i];
    }
    vP sum(N+1,{0,0});
    rep(i,N){
        sum[i+1].first=sum[i].first+A[i];
        sum[i+1].second=i+1;
    }
    rep(i,N+1){
        sum[i].first-=i;
        sum[i].first%=K;
    }
    sort(sum.begin(),sum.end());
    ll ans=0;
    rep(i,N+1){
        ll ok=N+1,ng=-1;
        P p={sum[i].first,sum[i].second+K};
        while(abs(ok-ng)>1){
            ll mid=(ok+ng)/2;
            if(sum[mid]>=p){
                ok=mid;
            }
            else{
                ng=mid;
            }
        }
        ans+=ng-i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8008
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

void solve()
{
	int n;
	scanf("%d\n", &n);
	for(int i = 0; i < n; ++i)
	{
		string str;
		getline(cin, str);
		string temp = str;
		bool flag = true;
		int count = 0;
		while(flag)
		{
			for(int i = 0; i <= 26; ++i)
			{
				if(temp.find("this") != temp.npos || temp.find("that") != temp.npos)
				{
					cout << temp << endl;
					flag = false;
					break;
				}
				else
				{
					for(int j = 0; j < str.size(); ++j)
					{
						if('a' <= str[j] && str[j] <= 'z')
						{
							temp[j] = ((str[j] - 'a') * count + i) % 26 + 'a';
						}
					}
				}
			}
			++count;
		}
	}
}

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

Measured memory_bytes: 1240
// A - Security
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	string s;
	cin >> s;

	bool bad = false;
	for (int i = 1; i < s.size(); i++)
		if (s[i] == s[i - 1]) bad = true;
	cout << (bad ? "Bad" : "Good") << endl;

	return 0;
}


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

int main(){
	int a, b;
	cin >> a >> b;
	if(a!=1 && b!=1){
		if(a>b) cout << "Alice" << endl;
		if(a==b) cout << "Draw" << endl;
		if(a<b) cout << "Bob" << endl;
	}
	if(a==1 && b!=1) cout << "Alice" << endl;
	if(a!=1 && b==1) cout << "Bob" << endl;
	if(a==1 && b==1) cout << "Draw" << endl;
}


Measured memory_bytes: 3588
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(A: int, B: int):
    ret = A - B * 2
    ret = max(ret, 0)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
//50
#include<iostream>

#define S(X) ((X)*(X))

using namespace std;

int main(){
  for(int d;cin>>d;){
    int ans=0;
    for(int i=0;i<600/d;i++){
      ans+=d*d*d*i*i;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
    long long int n,p,k,i;
    cin>>n>>k;
    if(k>=n)
    {
        for(i=n; i>=0; i=abs(i-k))
        {
            if(abs(i-k)>i)
            {
                break;
            }

        }
        cout<<i;
    }
    else if(k<n)
    {
        while(1)
        {
            p=n%k;
            if(k-p>p){
                break;
            }
            else if(k-p<p){
                 n=k;
                k=p;

            }
        }
      cout<<p;
    }

}


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

using namespace std;

const int max_n = 111111, inf = 1011111111;

int n, a[max_n], x[max_n];
long long sum;

void wa() {
    printf("NO\n");
    exit(0);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    long long pl = (1LL * n * (n + 1)) / 2;
    if (sum % pl) {
        wa();
    }
    long long cnt = sum / pl;
    if (n > 1) {
        long long bef = 0;
        for (int i = 1; i < n; ++i) {
            if ((a[i] - a[0] - (cnt - bef) * i - bef * (i - n)) % (-n)) {
                wa();
            }
            x[i] = (a[i] - a[0] - (cnt - bef) * i - bef * (i - n)) / (-n);
            bef += x[i];
        }
        x[0] = cnt - bef;
        for (int i = 0; i < n; ++i) {
            if (x[i] < 0) {
                wa();
            }
            //cout << x[i] << " ";
        }
        long long a0 = x[0], pl = n;
        for (int i = 1; i < n; ++i) {
            a0 += pl * x[i];
            --pl;
        }
        if (a0 != a[0]) {
            wa();
        }
    }
    printf("YES\n");
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int m1 = in.nextInt();
		int d1 = in.nextInt();
		int m2 = in.nextInt();
		int d2 = in.nextInt();

		if (m1 != m2)
			System.out.println(1);
		else
			System.out.println(0);
	}
}

Measured memory_bytes: 23252
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-23 20:15:11
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int h, w, k; cin >> h >> w >> k;
  vector<string> s(h);
  for (int i = 0; i < h; ++i) cin >> s[i];

  vector<vector<int>> ans(h, vector<int>(w, -1));

  int num = 1;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (s[i][j] == '#') {
        int beg = i, end = i;
        while (beg - 1 >= 0 && s[beg - 1][j] == '.' && ans[beg - 1][j] == -1) --beg;
        while (end + 1 < h && s[end + 1][j] == '.' && ans[end + 1][j] == -1) ++end;
        for (int p = beg; p <= end; ++p) {
          ans[p][j] = num;
        }
        s[i][j] = '!';
        ++num;
      }
    }
  }

  int beg = 0;
  while (ans[0][beg] == -1) ++beg;
  //int end = 0;

  for (int i = 0; i < h; ++i) {
    for (int j = beg - 1; j >= 0; --j) {
      ans[i][j] = ans[i][j + 1];
    }
  }
  

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (ans[i][j] == -1) {
        ans[i][j] = ans[i][j - 1];
      }
    }
  }

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cout << ans[i][j] << " ";
    }
    cout << '\n';
  }

  return 0;
}

Measured memory_bytes: 1280
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	s := readString()
	max := 0
	acc := 0
	for _, r := range s {
		switch r {
		case 'A', 'C', 'G', 'T':
			acc++
			if max < acc {
				max = acc
			}
		default:
			acc = 0
		}
	}
	println(max)
}

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


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

// 素数判定
bool prime (int i) {
  bool can = true;
  for (int j=2; j<=sqrt(i); j++) {
    if (i%j==0) {
      can = false;
      break;
    }
  }
  return can;
}

int main() {
  int N;
  cin >> N;
  vector<int> a;
  for (int i=2; i<=55555; i++) {
    if (prime(i)&&i%5==1) a.push_back(i);
  }
  for (int i=0; i<N; i++) {
    if (i==N-1) cout << a[i] << endl;
    else cout << a[i] << " ";
  }
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

def count(num, counter_list):
    if len(counter_list) == 0:
        counter_list.append([num, 0])
    current = counter_list[-1]     
    if current[0] == num:
        current[1] += 1
    else:
        counter_list.append([num, 1])

def calc(list):
    result = 0
    for item in list:
        cmp_count = item[1] - item[0]
        result += cmp_count if cmp_count >= 0 else item[1]
    return result

def main():
    A.sort()
    counter_list = []
    for i in range(N):
        count(A[i], counter_list)
    ans = calc(counter_list)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, k;
    cin >> n >> k;

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

    cout << (n - 1 + (k - 1 - 1)) / (k - 1) << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll n, sa = 0, sb = 0;
	cin >> n;
	vector<P> ba(n);
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		sa += a; sb += b;
		ba.at(i) = make_pair(b, a);
	}
	if (sa > sb) {
		cout << "No";
		return 0;
	}
	sort(all(ba));
	ll t = 0;
	rep(i, n) {
		t += ba.at(i).second;
		if (t > ba.at(i).first) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

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

using namespace std;

#define LL long long

int main() {
    int n;
    cin >> n;

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

    // 部分和を1,-1,1,-1,...にする場合
    LL tmp = 0;
    LL ans1 = 0;
    for (int i = 0; i < n; ++i) {
        tmp += vt[i];
        if (i % 2 == 0) {
            if (tmp <= 0) {
                ans1 += 1LL - tmp;
                tmp = 1;
            }
        } else {
            if (tmp >= 0) {
                ans1 += 1LL + tmp;
                tmp = -1;
            }
        }
    }

    // 部分和を-1,1,-1,1,...にする場合
    LL ans2 = 0;
    tmp = 0;
    for (int i = 0; i < n; ++i) {
        tmp += vt[i];
        if (i % 2 == 0) {
            if (tmp >= 0) {
                ans2 += 1LL + tmp;
                tmp = -1;
            }
        } else {
            if (tmp <= 0) {
                ans2 += 1LL - tmp;
                tmp = 1;
            }
        }
    }

    cout << min(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 640
a_code = ord("a")

s = [ord(c) - a_code for c in input().strip()]
t = [ord(c) - a_code for c in input().strip()]

tl = len(t)
sl = len(s)

s_table = [None] * sl
index_table = [None] * 26
for i in range(sl - 1, -1, -1):
	c = s[i]
	index_table[c] = i
	s_table[i] = list(index_table)

ti = 0
si = 0
count = 0
found = False
while ti < tl:
	c = t[ti]
	index = s_table[si][c]
	if index != None:
		ti += 1
		count += index + 1 - si
		si = index + 1
		found = True
		if si >= sl:
			if not found:
				count = -1
				break
			found = False
			si = 0
	else:
		if not found:
			count = -1
			break
		found = False
		count += sl - si
		si = 0
print(count)


Measured memory_bytes: 45008
//dont try to understand my code i really dont understand it 
#include<iostream>
#include<fstream>
#include<cmath>
#include<string>
#include<set>
#include <map>
#include<vector>
#include <queue>
#include <stack>
#include<algorithm>
#include<memory.h>
using namespace std;
typedef long long ll;
#define f( i , x , n ) for(int i = x; i < (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef pair<int, int> ii;
const double PI = acos(-1.0);
//const ll oo = 1000000000000030200;
//const ll F = LLONG_MIN;	
const int A = 1234567;
typedef long long ll;
// write what you need here : ... 

map<char, char> c;
map<string, int > out;
map<string, int> ::iterator it;
vector<pair<string, int>>v;
int main()
{
	int arr[8] = {1 , 2 , 4 ,8 ,16 ,32 , 64 , 101};
	int a;
	cin >> a;
	for (int i = 1;i < 8;i++)
		if (a < arr[i]) {
			cout << arr[i - 1];
			break;
		}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

// https://atcoder.jp/contests/agc009/tasks/agc009_b

int n;
vector<int> v[100000];

int dfs(int now) {
    vector<int> dep;
    for (auto vi : v[now]) {
        dep.eb(dfs(vi)); // 下の層から決まってく
    }
    sort(all(dep), greater<int>());
    
    int ret = 0; // leafは0をreturn
    rep(i, SZ(dep)) {
        chmax(ret, (i + 1) + dep[i]);
    }
    return ret;
}

int main() {
    
    cin >> n;
    
    rep3(i, 1, n) {
        int a;
        cin >> a;
        v[a - 1].eb(i); // v[win].eb[lose]
    }
    
    out(dfs(0));
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int A,B; cin>>A>>B;

  cout<< max({A+B,A-B,A*B})<<"\n";


}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P2;
typedef pair<double,P2> PP;
struct P {double x,y,z,r;};
double D3(P a,P b) {
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
}

int p[10001],r[10001];
void init() {rep(i,10001) p[i]=i,r[i]=0;}
int find(int x) {return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y) return;
  if(r[x]<r[y]) p[x]=y;
  else {p[y]=x;if(r[x]==r[y]) r[x]++;}
}
bool same(int x, int y) {return find(x)==find(y);}

void Main() {
  int n;
  while(R n && n) {
    init();
    P a[n];
    rep(i,n) {
      double x,y,z,r;
      cin >> x >> y >> z >> r;
      a[i]=(P){x,y,z,r};
    }
    priority_queue<PP,vector<PP>,greater<PP> > que;
    rep(i,n) {
      REP(j,i+1,n) que.push(PP(max(0.0,D3(a[i],a[j])-a[i].r-a[j].r),P2(i,j)));
    }
    double ans=0;
    while(!que.empty()) {
      PP q=que.top();que.pop();
      int i=q.S.F,j=q.S.S;
      if(same(i,j)) continue;
      unite(i,j);
      ans+=q.F;
    }
    printf("%.3f\n",ans);
  }
}

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


Measured memory_bytes: 1536
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

n = getN()
if n == 3 or n == 5 or n== 7:
    print("YES")

else:
    print("NO")

Measured memory_bytes: 3316
S = input()
T = input()
ans = len(T)
for i in range(len(S)-len(T)+1):
    cnt = 0
    for j in range(len(T)):
        # print(i, j, S[i+j], T[j])
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 5, mod = 1e9 + 7;

string s;
int n, dp[N][2];


int solve(int idx, bool b){
    if(idx == n) return b;
    if(~dp[idx][b]) return dp[idx][b];
    int op1 = solve(idx + 1, 0) + s[idx] - '0' + b;
    int op2 = 10 - b - (s[idx] - '0') + solve(idx + 1, 1);
    return dp[idx][b] = min(op1, op2);
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> s;
    reverse(s.begin(), s.end());
    n = s.size();
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0);

    return 0;
}


Measured memory_bytes: 74680
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();

    let ans = if c - a - b >= 0 {
        if 4 * a * b < (c - a - b).pow(2) {
            "Yes"
        } else {
            "No"
        }
    } else {
        "No"
    };
 
    println!("{}", ans);  
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dfs(vvi &v, vi &dp, int i) {
	if (dp[i] != -1)return dp[i];
	int ret = 0;
	REP(j, v[i].size()) {
		ret = max(ret, dfs(v, dp, v[i][j])+1);
	}
	return dp[i] = ret;

}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vvi v(n);
	REP(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		v[x].push_back(y);
	}
	vi dp(n, -1);
	REP(i, n) {
		if (dp[i] == -1)dfs(v, dp, i);
	}
	cout << *max_element(ALL(dp)) << endl;
}

Measured memory_bytes: 8832
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	p := sc.NextIntArray()

	count := 0

	for i := 0; i < N-1; i++ {
		if p[i] == i+1 {
			p[i], p[i+1] = p[i+1], p[i]
			count++
		}
	}
	if p[N-1] == N {
		count++
	}
	fmt.Println(count)

}

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

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

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

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

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

	return mp
}

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


Measured memory_bytes: 6272
#define r(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#include <cmath>
#include <fstream>
#define f first
#define endl "\n"
#define s second
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a))
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
char _;

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin>>x;
	if(x>=30) cout << "Yes" << endl;
	else cout << "No" << endl;
		
	return 0;
}


Measured memory_bytes: 3568
from math import factorial

n,m = map(int,input().split())

if abs(n-m) > 1:
    print(0)
elif abs(n-m) == 1:
    print((factorial(n) * factorial(m)) % (10**9+7))
    
else:
    print((2 * factorial(n)**2) % (10**9+7))

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

int main() {
   char moji;
   cin >> moji;
  if ( moji == 'a' || moji == 'i' || moji == 'u' || moji == 'e' || moji == 'o'){
      cout << "vowel" << endl;
}
 else {
     cout << "consonant"<< endl;
}
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    make_heap(a.begin(), a.end());

    for (int i = 0; i < m; i++) {
        long head = a.front();
        head /= 2;

        pop_heap(a.begin(), a.end());
        a.pop_back();

        a.push_back(head);
        push_heap(a.begin(), a.end());
    }

    long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    vector<int> a(n);
    {
        int fst;
        cin, fst;
        if (n == 0) {
            if (fst == 1) {
                print(1);
            } else {
                print(-1);
            }
            return 0;
        }
        if (fst != 0) {
            print(-1);
            return 0;
        }
    }
    vector<ll> child(n, 0);
    {
        ll t = 1;
        REP(i, 0, n) {
            cin, a[i];
            t *= 2;
            chmin(t, 1LL << 60);
            t -= a[i];
            if (t < 0) {
                print(-1);
                return 0;
            }
            child[i] = t;
        }
    }
    ll ans = 1;
    ll cnt = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (cnt < child[i]) {
            cnt += a[i];
            ans += cnt;
        } else if (cnt > 2 * child[i]) {
            print(-1);
            return 0;
        } else {
            cnt = child[i] + a[i];
            ans += cnt;
        }
        dump(ans, cnt);
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 4520
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);
 
#define int LL
 
const int MAX_V = 202;
int d[MAX_V][MAX_V];
int V;
 
void warshall_floyd() {
	for (int k = 0; k<V; k++) {
		for (int i = 0; i<V; i++) {
			for (int j = 0; j<V; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}
void first() {
	for (int i = 0; i < MAX_V; i++) {
		for (int j = 0; j < MAX_V; j++) {
			if (i == j)d[i][j] = 0;
			else d[i][j] = INF;
		}
	}
}
signed main() {
	first();
	int N, M, R;
	cin >> N >> M >> R;
	int a, b, c;
	vector<int> v;
	V = N;
	int r;
	for (int i = 0; i < R; i++) {
		cin >> r;
		v.emplace_back(r - 1);
	}
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--, b--;
		if (d[a][b] < c) continue;
		d[a][b] = c;
		d[b][a] = c;
	}
	warshall_floyd();
	sort(v.begin(), v.end());
	LL ans = INF;
	do {
		LL sum = 0;
		for (int i = 0; i < R - 1; i++) {
			sum += d[v[i]][v[i + 1]];
		}
		ans = min(sum, ans);
	} while (next_permutation(v.begin(), v.end()));
	cout << ans << endl;
}

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

int main(){
    int n ; cin >> n ;
    vector<int> cnt(100010,0) ;
    for(int i=0;i<n;i++){
        int a ; cin >> a ;
        cnt.at(a+1)++ ;
        cnt.at(a)++ ;
        cnt.at(a+2)++ ;
    }
    sort(cnt.begin(),cnt.end()) ;
    reverse(cnt.begin(),cnt.end()) ;
    cout << cnt.at(0) << endl ;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
class STACK{
public:
    STACK(){
        index = 0;
    }
 
    void push(int data){
        array[index] = data;
        index++;
    }
    int pop(){
        index--;
        return array[index];
    }
    bool isEmpty(){
        return index == 0;
    }
 
private:
    int array[100];
    int index;
};
 
int main(){
 
    STACK stack;
    int tmp;
    while(scanf("%d",&tmp) != EOF){
        if(tmp == 0){
            printf("%d\n",stack.pop());
        }else{
            stack.push(tmp);
        }
    }
    return 0;
}




Measured memory_bytes: 2600
#include <stdio.h>

int main()
{
	int x1, y1, x2, y2, sidex, sidey;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	
	sidex = x1 - x2, sidey = y1 - y2;
	printf("%d %d %d %d\n", x2 + sidey, y2 - sidex, x1 + sidey, y1 - sidex);

	return 0;
}

Measured memory_bytes: 128
fn read_ls<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main(){
    let l:Vec<i32> = read_ls();
    let (a, b) = (l[0], l[1]);
    println!("{} {} {}", a / b, a % b, (a as f64) / (b as f64) )
}



Measured memory_bytes: 5048
import sys
n = int(input())
h = list(map(int, input().split()))
dp = [-1] * n

sys.setrecursionlimit(n + 2)
def dfs(i):
    if dp[i] != -1:
        return dp[i]
    if i == n - 1:
        return 0
    cost = 0
    if i == n - 2:
        cost = dfs(i + 1) + abs(h[i] - h[i + 1])
    else:
        cost = min(dfs(i + 1) + abs(h[i] - h[i + 1]), dfs(i + 2) + abs(h[i] - h[i + 2]))
    dp[i] = cost
    return cost

print(dfs(0))

Measured memory_bytes: 93740
//#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

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

const int N = 2e5 + 123;	
int n , m , k;
int a[N];
string s;
map < int , int > dp;
int DP(int x){
	if(x == 1)
		return 1;
	else return 2ll * DP(x / 2) + 1;
}
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n;
	cout << DP(n);
}
	                             


Measured memory_bytes: 256
/**
 *   author: sahushivam
 *   created: 12 April 2020 (Sunday)  17:28:40
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long
#define ll long long

ll findSum(int n) 
{ 
  
    ll s = (n*(n+1))/2;
    ll sum2, sum5, sum10; 
  
    // sum2 is sum of numbers divisible by 2 
    sum2 = ((n / 3) * (6 + (n / 3 - 1) * 3)) / 2; 
  
    // sum5 is sum of number divisible by 5 
    sum5 = ((n / 5) * (10 + (n / 5 - 1) * 5)) / 2; 
  
    // sum10 of numbers divisible by 2 and 5 
    sum10 = ((n / 15) * (30 + (n / 15 - 1) * 15)) / 2; 
  
    return s - (sum2 + sum5 - sum10); 
} 
void solve(){
    int n; cin>>n;
    cout<<findSum(n);
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}

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

int main(){
    int N;
    int d[110];
    cin >> N;
    for(int i=0;i<N;++i) cin >> d[i];

    int num[110]={0};
    for (int i=0; i<N; ++i){
        num[d[i]]++;
    }

    int res=0;
    for (int i=1; i<=100;++i){
        if (num[i]){
            ++res;
        }
    }

    cout << res << endl;
}

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

int main(void)
{
	int N, K;
	cin >> N >> K;

	long long ret = 0;
	long long cnt = N / K;
	ret = cnt * cnt * cnt;
	if(K%2 == 0){
		cnt = N/K + ((N%K) >= K/2);
		ret += cnt * cnt * cnt;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b, c, temp;
	scanf("%d %d %d", &a, &b, &c);
	if(a>b){
		temp = a;
		a = b;
		b = temp;
	}
	if(b>c){
		temp = b;
		b = c;
		c = temp;
	}
	if(a>b){
		temp = a;
		a = b;
		b = temp;	
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2084
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N;
  get(N);
  vector<int> p(N);
  getv(p);
  int err = 0;
  FOR(i, N) {
    if (p[i] != i + 1)
      err++;
  }
  if (err <= 2) {
    print("YES");
  } else {
    print("NO");
  }
  return 0;
}

Measured memory_bytes: 256
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
if N<=2:
  print('No')
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if b==A[j][k]:
        A[j][k]=101
        
judge = False
for i in range(3):
  if sum(A[i])==303:
    judge = True
    
for i in range(3):
  if (A[0][i]+A[1][i]+A[2][i])==303:
    judge = True

if (A[0][0]+A[1][1]+A[2][2])==303:
  judge = True

if (A[0][2]+A[1][1]+A[2][0])==303:
  judge = True
  
if judge:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 39856
S = list(input())
n = len(S)

for i in range(n, 0, -1):
    del S[len(S)-1]
    if len(S)%2 == 0:
        str1=""
        str2=""
        for j in range(int(len(S)/2)):
            str1 = str1 + S[j]
        for j in range(int(len(S)/2), len(S)):
            str2 = str2 + S[j]
        if str1 == str2:
            print(len(S))
            break


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 2000005;
const int K = 1000000;
int f[N], q[N], cnt[N];
int binpow(ll x, ll y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    ll z = binpow(x, y / 2);
    return z * z % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    vector < int > pr;
    f[1] = 1;
    int s = 0;
    for (int i = 2; i <= K; i++){
        if (f[i] == 0){
            pr.pb(i);
            f[i] = i - i * i;
        }
        for (int j = 0; j < pr.size() && i * pr[j] <= K; j++){
            if (i % pr[j] == 0){
                f[i * pr[j]] = f[i] * pr[j];
            } else{
                f[i * pr[j]] = f[pr[j]] * f[i];
            }
        }
    }
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        s += x;
        cnt[x]++;
    }
    for (int i = 1; i <= K; i++){
        for (int j = i; j <= K; j += i){
            q[i] = (q[i] + cnt[j] * j / i) % mod;
        }
    }
    int ans = 0;
    for (int i = 1; i <= K; i++){
        ans = (ans + f[i] * q[i] % mod * q[i] + mod) % mod;
    }
    ans = (ans - s % mod + mod) % mod;
    cout << ans * binpow(2, mod - 2) % mod;
}


Measured memory_bytes: 29684
import sys
import numpy as np

# N 対象の整数
n = int(input())

# N の平方根
n_sqrt = np.sqrt(n)

# 約数を求める
divisors_a = []
divisors_b = []
for i in np.arange(1, n_sqrt + 1):
    if n % i == 0:
        # 約数
        divisors_a.append(int(i))
        divisors_b.append(int(n / i))

# divisors_b の一番最後の要素が桁数が小さい
print(len(str(divisors_b[-1])))

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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  int ans = min((N + A - 1) / A * B, (N + C - 1) / C * D);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3188
# from sys import exit

while(True):
    S0 = str(input())
    if S0 == ".":
        exit()
    S1 = str(input())
    if S0 == S1:
        print("IDENTICAL")
        continue
    S0else = list(S0.split('"')[0::2])
    S1else = list(S1.split('"')[0::2])
    if S0else != S1else:
        print("DIFFERENT")
        continue
    S0str = list(S0.split('"')[1::2])
    S1str = list(S1.split('"')[1::2])
    if len(S0str) != len(S1str):
        print(S0str, S1str)
        print("DIFFERENT")
        continue
    OK = 1
    for i in range(len(S0str)):
        if S0str[i] != S1str[i]:
            OK -= 1
    if OK < 0:
        print("DIFFERENT")
    elif OK >= 0:
        print("CLOSE")



Measured memory_bytes: 5576