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


int comp(const void* a, const void* b)
{ return *(int*)a > *(int*)b ; }


int findNumberOfTriangles(int arr[], int n)
{

    qsort(arr, n, sizeof( arr[0] ), comp);

    int count = 0;



    for (int i = 0; i < n - 2; ++i)
    {

        int k = i + 2;


        for (int j = i + 1; j < n; ++j)
        {

            while (k < n && arr[i] + arr[j] > arr[k])
            ++k;


            if(k > j)
            count += k - j - 1;
        }
    }

    return count;
}

int main(){

int n;
int arr[2002];

cin>>n;
for(int i=0;i<n;i++)cin>>arr[i];

cout<<findNumberOfTriangles(arr,n)<<endl;



return 0;}


Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
b=dict()
for i in a:
    b[i//400]=b.get(i//400,0)+1
count=0
count2=0
for i in b:
    if i>7:count2+=b[i]
    else:count+=1
print(max(count,1),count+count2)

Measured memory_bytes: 3064
n, x = map(int, input().split())
a, p = [1], [1]
for i in range(n):
 a += [a[i] * 2 + 3]
 p += [p[i] * 2 + 1]

def f(n, x):
 if n == 0:
  return 1 - (x <= 0)
 elif x <= 1 + a[n-1]:
  return f(n-1, x-1)
 else:
  return p[n-1] + 1 + f(n-1, x-2-a[n-1])

print(f(n, x))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

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

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int a = in.nextInt();
			int b = in.nextInt();

			out.println((a+b)%24);

		}

	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
N = int(input())
A = [[int(i) for i in reversed(input().split())] for n in range(N)]
B = [[int(i) for i in input().split()] for n in range(N)]
A.sort(); A.reverse(); B.sort()
C = 0
i = 0
for b in B:
  found = False
  while not found:
    a = A[i]
    if a[1] < b[0] and a[0] < b[1]:
      found = True
      C += 1
      A.pop(i)
      i = 0
    elif i+1 == len(A):
      found = True
      i = 0
    else:
      i += 1
print(C)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

ll n,w;
ll v[MAXN],c[MAXN];
ll dp[MAXN];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> w;
    REP (i,n) {
        cin >> c[i] >> v[i];
    }

    MEM(dp,INF);
    dp[0] = 0;
    REP (i,n) {
        for (ll j=MAXN-1;j>=0;j--) {
            if (j-v[i] >= 0) {
                dp[j] = min(dp[j],dp[j-v[i]]+c[i]);
            }
        }
    }

    ll ans = 0;
    REP (i,MAXN) {
        if (dp[i] <= w) {
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if(a<b) {
    if(abs(b+w*t) <= abs(a+v*t)) cout << "YES" << endl;
    else cout << "NO" << endl;
  } else {
    if(abs(b-w*t) <= abs(a-v*t)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int N;
vector<int> A(200010), v(200010);

int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> A[i];
  
  if (A[N] % 2 == 1) v[N] = 1;
  for (int i = N; i >= 1; --i) {
    int cnt = 0;
    for (int j = 2; i * j <= N; ++j) cnt += v[i * j];
    if (abs(cnt - A[i]) % 2 == 1) v[i] = 1;
  }
  
  int ans = 0;
  for (int i = 1; i <= N; ++i) ans += v[i];
  cout << ans << endl;
  int cnt = 0;
  for (int i = 1; i <= N; ++i) {
    if (v[i] == 1) {
      ++cnt;
      cout << i;
      if (cnt != ans) cout << " ";
    }
  }
  return 0;
}

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

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

int main(){
  long long int h,w;
  cin >> h >> w;
  long long int ans = 0;
  ans = h*w/2;
  if(h*w % 2)
    ans++;

  if(h == 1 || w == 1)
    ans = 1;

  cout << ans << endl;
}


Measured memory_bytes: 256
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func genAry(a []int, i int, j2 int, N int, M int, fn func([]int)) {
	if i >= N {
		fn(a)
		return
	}
	for j := j2; j <= M; j++ {
		a[i] = j
		genAry(a, i+1, j, N, M, fn)
	}
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	N := sc.nextInt()
	M := sc.nextInt()
	Q := sc.nextInt()
	q := make([]map[string]int, Q)
	for i := 0; i < Q; i++ {
		q[i] = make(map[string]int)
		q[i]["a"] = sc.nextInt()
		q[i]["b"] = sc.nextInt()
		q[i]["c"] = sc.nextInt()
		q[i]["d"] = sc.nextInt()
	}

	A := make([]int, N)
	max := 0
	genAry(A, 0, 1, N, M, func(B []int) {
		tmp := 0
		for i := 0; i < Q; i++ {
			a := q[i]["a"]
			b := q[i]["b"]
			c := q[i]["c"]
			d := q[i]["d"]
			if A[b-1]-A[a-1] == c {
				tmp += d
			}
		}
		if max < tmp {
			max = tmp
		}
	})

	fmt.Println(max)

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 1796
import sys


l = raw_input().split()
N = int(l[0])
l = raw_input().split()
S = l[0]
l = raw_input().split()
K = int(l[0])

c = S[K - 1]
ret = ''
for s in S:
    if s != c:
        ret += '*'
    else:
        ret += s
print(ret)


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#include <iostream>
// #include <unordered_map>
#define vi vector <ull>
#define ii pair<ull,ull>
#define vii vector<ii>
 
#define seti set<ull>
#define mii map<ull,ull>
#define um unordered_map
#define ll long long
#define ull  long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 100100
#define _ << " " <<
 
using namespace std;
 
string s,t;
int dp[3001][3001];

int get(int i, int j){
	if(i < 0 || j < 0) return 0;
	if(dp[i][j] != -1) return dp[i][j];
	if(s[i] == t[j]) return dp[i][j] = max(get(i-1,j-1)+1, max(get(i-1, j), get(i, j-1)));
	return dp[i][j] = max(get(i-1, j), get(i, j-1));
}

string ans;

void getAns(int i, int j){
	if(i < 0 || j < 0) return;
	if(s[i] == t[j]){
		ans+=s[i];
		// cout << s[i];
		if(dp[i][j] == get(i-1, j-1)+1){
			getAns(i-1, j-1);
		}else if(dp[i][j] == get(i-1, j)){
			getAns(i-1, j);
		}else if(dp[i][j] == get(i, j-1)){
			getAns(i, j-1);
		}
	}else{
		if(dp[i][j] == get(i-1, j)){
			getAns(i-1, j);
		}else if(dp[i][j] == get(i, j-1)){
			getAns(i, j-1);
		}
	}
}
 
 
void solve(){
	cin >> s >> t;

	for(int i = 0 ; i < 3001; i++){
		for(int j = 0; j < 3001; j++){
			dp[i][j] = -1;
		}
	}

	ans = "";

	dp[s.size()-1][t.size()-1] = get(s.size()-1, t.size()-1);
	getAns(s.size()-1, t.size()-1);

	reverse(ans.begin(), ans.end());
	// cout << "asdfn";
	// cout << dp[s.size()-1][t.size()-1];
	cout << ans;
}
 
 
int main(){
	// freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ull q;
	// cin >> q;
	q = 1;
	for(ull i = 0; i < q; i++){
		// cout << "Case #" << i+1 << ":" << endl;
 
		solve();
		// cout << endl;
	}
 
	
 
	return 0;
}

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

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++)
 
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; }

const long long INF = 1LL << 60;

bool dp[100100];

int main () {
    int N, A;
    cin >> N >> A;

    cout << N*N-A << endl;


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long k = scan.nextLong();
		scan.close();
		long base = 7;
		boolean fg=false;

		for(int i=1;i<=k;i++) {

			if(base%k == 0) {
				fg = true;
				System.out.println(i);
				break;
			}
			base = (base*10 + 7)%k;
		}
		if(!fg) {
			System.out.println(-1);
		}
	}
}

Measured memory_bytes: 35744
## ABC 043 b

s = list(input())

ans = []
for i in s:
    if(i == '0' or i == '1'):
        ans.append(i)
    elif(i == 'B'):
        if(len(ans) == 0):
            continue
        else:
            ans.pop()
        
print(''.join(ans))

Measured memory_bytes: 2940
def resolve():
  base = 10**9+7
  S = int(input())
  dp = [0] * (S+1)
  dp[0] = 1

  for i in range(3, S+1):
    dp[i] = dp[i-1] + dp[i-3]
  # print(dp)
  print(dp[S]%base)

if __name__ == "__main__":
  resolve()

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define P pair<int,int>
typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//s.find(w[i])==string::npos
//findの使い方

long long int n,cnt=0,ans=0,a[100000],b[100000],c,cmp[100000],data[100000],m,h,x,y;

string s,w;

int main(void){
      cin >> n;
      rep(i,n){
          cin >> a[i] >> b[i];
      }
      rrrep(i,n-1,0){
          ans+=(b[i]-((a[i]+ans)%b[i]))%b[i];
      }
      cout << ans << endl;
return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var ans = 0;
        for (int i = 1; i <= N; i += 2)
        {
            var divisor = Divisor(i);
            if (divisor.Count() == 8) ans++;
        }
        Console.WriteLine(ans);
    }
    static long[] Divisor(long n)
    {
        var res = new List<long>();
        for (int i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                res.Add(i);
                if (i * i != n) res.Add(n / i);
            }
        }
        return res.ToArray();
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


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

using namespace std;

typedef long long ll;

int main(){

    ll n, m, a, b, c, d;
    cin >> n >> m;
    vector<ll> res((1<<n), INT_MAX);
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        d = 0;
        for(int j = 0; j < b; j++){
            cin >> c;
            c--;
            d = d | (1<<c);
        }
        res[d] = min(res[d], a);
    }

    for(int i = 0; i < res.size(); i++){
        if( res[i] == INT_MAX )
            continue;
        for(int j = 0; j < res.size(); j++){
            if( res[j] == INT_MAX )
                continue;
            res[i|j] = min(res[i|j], res[i]+res[j]);
        }
    }

    if( res[(1<<n)-1] == INT_MAX )
        cout << -1 << endl;
    else
        cout << res[(1<<n)-1] << endl;
    return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    string s, t;
    cin >> s >> t;
    vector<string> v;
    for(int i = 0; i < sz(s) - sz(t) + 1; i++) {
        v.pb(s.substr(i, sz(t)));
    }
    int ans = sz(s);
    for(auto x : v) {
        int cnt = 0;
        forn(i, sz(x)) {
            if(x[i] != t[i])cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3884
using System;

namespace MyProgram{
    class AtCoder{
        static void Main(string[] args){
            long[] input = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            long L = input[0];
            long R = input[1];
            long temp=2000000000;
            for(var i=L;i<R;i++){
                for(var j=i+1;j<=R;j++){
                    long mod = (i*j)%2019;
                    if(mod<temp){
                        temp = mod;
                    }
                    if(temp==0){
                        goto END;
                    }
                }
            }
            END:
            Console.WriteLine(temp);
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
const int N = 2e3+100;
const int K = 1e4+100;
typedef pair<int,int> pii;
#define fr(i,low,up,st) for(int i = low;i <= (int)up; i += st)
#define nfr(i,low,up,st) for(int i = low;i >= (int)up; i -= st)
#define SZ(a) (int)a.size()
#define fill(a,b) memset(a,b,sizeof a)
#define cpy(a,b) memcpy(a,b,sizeof a)
#define pb push_back

string str[N];
string a[N];
int isc[K];

string curs;
int z[K*2],exk[K*2];
vector<int> q1;

void z_algo(int stp,string s1){
   fill(z,0); fill(exk,0);
   z[1] = stp-1;
   int R = 0,mx = 0;
   fr(i,2,SZ(s1)-1,1){
      z[i] = (i < R)?min(R-i,z[i-mx+1]):0;
      while(i+z[i] < SZ(s1) && s1[z[i]+1] == s1[z[i]+i])++z[i];
      if(i+z[i] > R)R = i+z[i],mx = i;
   }
   fr(i,stp+1,SZ(s1)-1,1){
      exk[i-stp] = z[i];
   }
}

int f[N][K];
int n,k,cut[K*2];
bool flag;

int main(){
   scanf("%d%d",&n,&k);
   fr(i,1,n,1){
      cin >> str[i];
   }
   fill(f,0); f[n+1][k] = 1;
   nfr(i,n,1,1){
      nfr(j,k,0,1){
         f[i][j] |= f[i+1][j];
         if(j+SZ(str[i]) <= k)f[i][j] |= f[i+1][j+SZ(str[i])];
      }
   }

   cut[0] = 1;
   int curp;
   fr(i,1,n,1){
      q1.clear();
      string qry = " "+str[i]+" "+curs;
      int cz = SZ(curs);
      int sz = SZ(str[i]);
      z_algo(str[i].size()+1,qry);
      curp = -1; flag = false;
      nfr(j,k,0,1){
         if(j+sz > k || !cut[j] || !f[i+1][j+SZ(str[i])])continue ;
         if(curp == -1){
            if(exk[j+1] == sz)q1.pb(j+sz);
            else if(exk[j+1] == cz-j)q1.pb(j+sz),curp = j;
            else {
               if(str[i][exk[j+1]] < curs[j+exk[j+1]]){
                  q1.clear(); curp = j; flag = true;
               }
            }
         } else {
            if(exk[j+1] >= curp-j){
               if(z[curp-j+1] == (sz-curp+j))q1.pb(j+sz);
               else {
                  if(str[i][curp-j+z[curp-j+1]] < str[i][z[curp-j+1]]){
                     q1.clear(); curp = j; flag = true;
                  }
               }
            } else if(exk[j+1] == sz)q1.pb(j+sz);
            else {
               if(str[i][exk[j+1]] < curs[j+exk[j+1]]){
                  q1.clear(); curp = j; flag = true;
               }
            }
         }
      }

      if(curp > -1 && flag){
         fr(j,curp+1,k,1){
            if(j > curp+SZ(str[i]))cut[j] = 0;
            if(!cut[j])continue ;
            if(exk[curp+1] < j-curp)cut[j] = 0;
         }
      }
      fr(j,0,SZ(q1)-1,1)cut[q1[j]] = 1;
      q1.clear();
      if(curp > -1)curs = curs.substr(0,curp)+str[i];
      cut[SZ(curs)] = 1;
   }
   cout << curs << endl;
   return 0;
}


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

int main() {
  int A, B, ans1, ans2, ans3;
  cin >> A >> B;
  ans1 = A + B;
  ans2 = A - B;
  ans3 = A * B;
  if (ans1 >= ans2 && ans1 >= ans3){
    cout << ans1;
  }else if (ans2 >= ans1 && ans2 >= ans3) {
    cout << ans2;
  }else{
    cout << ans3;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int a[10];

int main(void) {
    string input;
    cin >> input;
    for (int i = 0; i < 4; i++) a[i] = input[i] - '0';

    for (int x = 0; x < 8; x++) {
        int sum = a[0];
        string s;
        s += (char)('0' + a[0]);
        for (int i = 0; i < 3; i++) {
            if (x & (1 << i)) {
                sum += a[i + 1];
                s += '+';
                s += (char)('0' + a[i + 1]);
            } else {
                sum -= a[i + 1];
                s += '-';
                s += (char)('0' + a[i + 1]);
            }
        }
        if (sum == 7) {
            s += '=';
            s += '7';
            cout << s << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=8e18;
const int32_t LOG=21;
const int MOD=MOD2;


int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
          int x;
          cin>>x;
          int val=100;
          int cnt=0;
          while(val<x)
          {
               cnt++;
               val=(val)+(val/100);
          }
          cout<<cnt<<endl;
      }

      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int partition(vector<pair<char, pair<int, int> > >& v, int p, int r)
{
  int val = v[r].second.first;
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if (v[j].second.first <= val) {
      ++i;
      swap(v[i], v[j]);
    }
  }
  swap(v[i + 1], v[r]);
  return i + 1;
}

void quickSort(vector<pair<char, pair<int, int> > >& v, int l, int r)
{
  if (l >= r) { return; }
  int q = partition(v, l, r);
  quickSort(v, l, q - 1);
  quickSort(v, q + 1, r);
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<pair<char, pair<int, int> > > v(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, " %c %d", &v[i].first, &v[i].second.first);
    v[i].second.second = i;
  }
  quickSort(v, 0, n - 1);
  bool stbl = true;
  for (int i = 0; i + 1 < n; ++i) {
    if (v[i].second.first == v[i + 1].second.first) {
      if (v[i].second.second > v[i + 1].second.second) {
        stbl = false;
        break;
      }
    }
  }
  fprintf(stdout, "%s\n", stbl ? "Stable" : "Not stable");
  for (int i = 0; i < n; ++i) {
    fprintf(stdout, "%c %d\n", v[i].first, v[i].second.first);
  }
  return 0;
}

Measured memory_bytes: 2320
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
int i[1111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e,f;
  string s;
  cin >>a>>b;
  cin >>s;
  s[b-1]=s[b-1]+32;
  cout <<s<<'\n';
  return (0);
}


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

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    vector<int> a(3 * n);
    rep(i, 3 * n) cin >> a[i];
    sort(ALL(a), greater<int>());
    ll ans = 0;
    rep(i, n) ans += a[2 * i + 1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
while True:
    line = input().split()
    a = int(line[0])
    b = int(line[2])
    op = line[1]

    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    else:
        break

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

vector<int>G[1024];
set<int>s;
int vis[1024];

void dfs(int cur){
  //  cout << cur << endl;
  if(vis[cur]) return;
  vis[cur] = 1;
  if(G[cur].size() == 0){
    s.insert(cur);
    return;
  }

  rep(i,G[cur].size()) dfs(G[cur][i]);
}

int main(){
  int N;
  while(cin>>N && N){
    rep(i,1024)G[i].clear();
    map<string,int>m;
    rep(i,N){
      string s; cin >> s;
      replace(s.begin(), s.end(), ',',' ');
      replace(s.begin(), s.end(), '.',' ');
      replace(s.begin(), s.end(), ':',' ');
      stringstream buf(s);
      string cur, tar; buf >> cur;
      if(m.find(cur) == m.end()) m[cur] = m.size();
      while(!buf.eof()){
	buf >> tar;
	if(m.find(tar) == m.end()) m[tar] = m.size();
	G[m[cur]].push_back(m[tar]);
      }
    }
    //    for(map<string,int>::iterator it = m.begin();it!=m.end();it++) cout << it->first << " " << it->second << endl;
    memset(vis, 0, sizeof(vis));
    s.clear();
    dfs(1);
    cout << s.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c=0;
    while(1){
        cin>>a>>b;
        if(a==0&&b==0) break;
        for(int x=1;x<a-1;x++){
            for(int y=x+1;y<a;y++){
                for(int z=y+1;z<a+1;z++){
                    if(x+y+z==b){
                        c++;
                    }
                    
                }
            }
        }
        cout<<c<<endl;
        c=0;
    }
}


Measured memory_bytes: 3076
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d\n",&a,&b,&c);
    if((a<b)&&(b<c)){
        printf("%d %d %d\n",a,b,c);
    }
    else if((b<c)&&(c<a)){
        printf("%d %d %d\n",b,c,a);
    }
    else if((c<a)&&(a<b)){
        printf("%d %d %d\n",c,a,b);
    }
    else if((a<c)&&(c<b)){
        printf("%d %d %d\n",a,c,b);
    }
    else if((b<a)&&(a<c)){
        printf("%d %d %d\n",b,a,c);
    }
    else if((c<b)&&(b<a)){
        printf("%d %d %d\n",c,b,a);
    }
    else if((a==b)&&(b<c)){
        printf("%d %d %d\n",a,b,c);
    }
    else if((b==c)&&(c<a)){
        printf("%d %d %d\n",b,c,a);
    }
    else{
        printf("%d %d %d\n",c,a,b);
    }
    return 0;
}


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


using namespace std;

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

string LCS(string& s1,string& s2){
    int m=s1.size();
    int n=s2.size();
    string res="";
    if(m==0||n==0)return 0;
    int dp[m+1][n+1];
    fo(i,m){
        fo(j,n){
            if(i==0||j==0)dp[i][j]=0;
            else{
            if(s1[i-1]==s2[j-1]){dp[i][j]=1+dp[i-1][j-1];}
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    
    //Printing LCS
    int l=dp[m][n];
    int i=m;
    int j=n;
    while(i>0&&j>0){
        if(s1[i-1]==s2[j-1]){
            res+=s1[i-1];
            i--;
            j--;}
        else{
            if(dp[i-1][j]>dp[i][j-1])i--;
            else j--;
        }
    }
    
    reverse(res.begin(),res.end());
    return res;
}


int main()
{
    string s1,s2;
    std::cin >> s1;
    cin>>s2;
    string ans=LCS(s1,s2);
    cout<<ans;

    return 0;
}


Measured memory_bytes: 38776
#include<iostream>
using namespace std;
int a[1000];
int main()
{
	long long n,m,p,s=0;
	cin>>n>>m>>p;
	a[n]=1;
	a[m]=1;
	a[p]=1;
	for(int i=0;i<=1000;i++)
	s+=a[i];
	cout<<s<<endl;
	return 0;
}

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

int n;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n; int pre = 0, mx = 0;
    for(int i = 1; i <= n; i++) {
        int u, v; cin >> u >> v;
        if(u == v) pre++;
        else pre = 0;
        mx = max(mx, pre);
    }
    cout << (mx >= 3 ? "Yes" : "No") << '\n';
    return 0;
}


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

typedef long double ld;

int main()
{
	int m, n;
	while (true) {
		std::cin >> m;
		if (m==0) break;
		int deg_total = 0;
		ld area1 = 0.0;
		for (int i=0; i<m-1; i++) {
			int d; std::cin >> d;
			deg_total += d;
			area1 += std::sin((ld)d * M_PI / 180.0);
		}
		area1 += std::sin((ld)(360-deg_total) * M_PI / 180.0);
		std::cin >> n;
		deg_total = 0;
		ld area2 = 0.0;
		for (int i=0; i<n-1; i++) {
			int d; std::cin >> d;
			deg_total += d;
			area2 += std::sin((ld)d * M_PI / 180.0);
		}
		area2 += std::sin((ld)(360-deg_total) * M_PI / 180.0);
		if (area1 > area2) std::cout << 1 << std::endl;
		else if (area1 < area2) std::cout << 2 << std::endl;
		else std::cout << 0 << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	sort(all(v));
	ll ans=0;
	rep(i,n-2){
		range(j,i+1,n-1){
			ans+=(max(0ll,lower_bound(all(v),v[i]+v[j])-v.begin()-j-1));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INFL = 1e18;
const int INF = 1000000007;
const ld PI = acos(-1);
const ld EPS = 1e-13;
const ll MOD = 1000000007;

void add(ll& a, ll b) {
    a += b;
    while (a >= MOD) {
        a -= MOD;
    }
}

void mul(ll& a, ll b) {
    a = (a * b) % MOD;
}

ll todeg(ll x, ll d) {
    if (d < 0LL) {
        d += MOD - 1;
    }
    if (d == 0LL) {
        return 1LL;
    }
    ll ans = todeg(x, d / 2LL);
    mul(ans, ans);
    if (d % 2 == 1) {
        mul(ans, x);
    }
    return ans;
}

vector<ll> fact;
vector<ll> rfact;

void prep(int n) {
    fact.assign(n + 1, 1);
    rfact.resize(n + 1);
    for (int i = 1; i <= n; ++i) {
        fact[i] = fact[i - 1];
        mul(fact[i], i);
    }
    rfact[n] = todeg(fact[n], -1);
    for (int i = n - 1; i >= 0; --i) {
        rfact[i] = rfact[i + 1];
        mul(rfact[i], i + 1);
    }
}

ll C(int n, int k) {
    ll ans = fact[n];
    mul(ans, rfact[k]);
    mul(ans, rfact[n - k]);
    return ans;
}

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

    int n;
    cin >> n;
    vector<int> a(n), b(n, 0), ca(n + 1, 0), cb(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ++ca[a[i]];
    }
    for (int i = 0; i < n; ++i) {
        int vb;
        cin >> vb;
        ++cb[vb];
    }

    for (int i = 1; i <= n; ++i) {
        if (ca[i] + cb[i] > n) {
            cout << "No\n";
            return 0;
        }
    }

    priority_queue<int> inds, sind, used, ucur;
    for (int i = 0; i < n; ++i) {
        inds.push(i);
    }

    for (int v = 1; v <= n; ++v) {
        int cv = cb[v];
        while (cv > 0 && !inds.empty()) {
            if (a[inds.top()] != v) {
                b[inds.top()] = v;
                --cv;
                ucur.push(inds.top());
                inds.pop();
            }
            else {
                sind.push(inds.top());
                inds.pop();
            }
        }
        while (cv > 0) {
            b[sind.top()] = b[used.top()];
            b[used.top()] = v;
            ucur.push(used.top());
            ucur.push(sind.top());
            used.pop();
            sind.pop();
            --cv;
        }
        while (!sind.empty()) {
            inds.push(sind.top());
            sind.pop();
        }
        while (!ucur.empty()) {
            used.push(ucur.top());
            ucur.pop();
        }
    }

    cout << "Yes\n";
    for (int i = 0; i < n; ++i) {
        cout << b[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 9500
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
using namespace std;
int N,L;
int len[100000];
int life[100000];
int dfs(int idx){
    if(life[idx]!=-1)return life[idx];
    int dif=L-len[idx];
    int res;
    if(idx==0)
        res=(len[idx]>len[idx+1])?dif:dif+dfs(idx+1);

    else if(idx==N-1)
        res=(len[idx]>len[idx-1])?dif:dif+dfs(idx-1);

    else if(len[idx]>len[idx+1]&&len[idx]>len[idx-1])
        res=dif;

    else if(len[idx]>len[idx+1])
        res=dif+dfs(idx-1);

    else if(len[idx]>len[idx-1])
        res=dif+dfs(idx+1);

    else res=dif+max(dfs(idx+1),dfs(idx-1));

    return life[idx]=res;
}
int main(){
    cin>>N>>L;
    for(int i=0;i<N;i++)cin>>len[i];
    fill(life,life+100000,-1);

    int Max=-1;
    for(int i=0;i<N;i++)
        Max=max(Max,dfs(i));
    
    cout<<Max<<endl;
}

Measured memory_bytes: 4088
MOD = 10**9 + 7
N, M = [int(s) for s in input().split()]
#行ってはいけないところには0がはいる
ls = [1 for _ in range(N + 1)]
for i in range(M):
    ls[int(input())] = 0

for n in range(2, N + 1):
    if ls[n] != 0:
        #(n*m)mod k ==(n(mod k)*m(mod k))
        ls[n] = (ls[n - 1] + ls[n - 2]) % MOD
print(ls[N])

Measured memory_bytes: 7064
package main

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

func main() {
	S := nextString()
	S = S[:len(S)-2]
	for {
		S1 := S[:len(S)/2]
		S2 := S[len(S)/2:]
		isSame := true
		for i := 0; i < len(S1); i++ {
			if S1[i] != S2[i] {
				isSame = false
				break
			}
		}
		if isSame {
			break
		}
		S = S[:len(S)-2]
	}
	fmt.Println(len(S))
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
dishlist = []
for i in range(5):
    dishlist.append(int(input()))

mind = 124
mini = 0
for i in range(len(dishlist)):
    d = (dishlist[i]-1) % 10
    if (d < mind):
        mind = d
        mini = i

dishlist[mini], dishlist[-1] = dishlist[-1], dishlist[mini]

ans = 0
for i in range(len(dishlist)):
    p = 0
    if (i < len(dishlist)-1):
        if (dishlist[i] % 10 != 0):
            p = 10 - (dishlist[i] % 10)
    ans += dishlist[i] + p 

print(ans)


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int x, a; cin >> x >> a;
    if( x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;
}


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

a = list(map(int,input().split()))

b = []

for i in range(n):
    b.append(a[i]-i)
    
b.sort()

kb = [b[n//2],b[n//2]]

ans = []

for i in kb:
    x = 0
    for s in range(len(a)):
        x += abs(a[s]-i-s)
    ans.append(x)
    
print(min(ans))

Measured memory_bytes: 25196
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod    998244353
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 500000
int dirx[] = {1, -1,0, 0, 1, 1, -1, -1}, diry[] = {0, 0, 1, -1, 1, -1, 1, -1};



//=============================================ASIFAZAD==============================================//

ll fun(ll x)
{
    return x*(x+1)/2;
}

int32_t main()
{
    io;
    ll n, x, m, cx;
    cin>>n>>x>>m;
    ll ans = 0, i = 0;
    cx = x;
    int cnt[m+5] = {};
    for(; i < n; i++)
    {
        if(cnt[x] || !x)
            break;
        cnt[x] = i;
        ans += x;
        x = (x*x)%m;
    }
    if(!x || i >= n)
        return cout<<ans, 0;
    ll first = 0;
    for(int a = 0;  a< cnt[x]; a++)
    {
        first +=  cx;
        cx = (cx*cx)%m;
    }

    ans -= first;
    n -= cnt[x];
    i -= cnt[x];


    ans = ans*(n/i);


    for(int j = 0; j < n%i; j++)
    {
        ans += x;
        x = (x*x)%m;
    }

    cout<<ans+first;
    return 0;
}


Measured memory_bytes: 4040
#include<iostream>
using namespace std;
int a[200020];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    long long ans=0;
    for(int i=2;i<=n;i++)
        if(a[i]<a[i-1])
        {
            ans+=(a[i-1]-a[i]),a[i]+=(a[i-1]-a[i]);
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MM 1e9

struct _shop {
string name;
int score;
int index;
};

class shop_cmp {
public:
bool operator()(const _shop& left, const _shop& right) const {
if(left.name==right.name) return left.score>right.score;
return left.name<right.name;
}
};

int N;
vector<_shop> vec;

void input() {
    cin >> N;
    _shop s;
    rep (i,0,N) {
        cin >> s.name >> s.score;
        s.index = i+1;
        vec.push_back(s);
    }
}

void solve(){
    sort(vec.begin(),vec.end(),shop_cmp());
    for(auto x:vec){
		//cout << x.index << " " << x.name << " " << x.score << endl;
        cout << x.index << endl;
	}
}

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



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

using namespace std;

int n, k, w[100000];
bool a(int q) {
	int ka=1,qa=0;
	for (int i = 0; i < n; i++) {
		qa += w[i];
		if (qa <= q) continue;
		else {
			ka++;
			qa = w[i];
			if (qa > q)return false;
		}
	}
	if (ka <= k)return true;
	else return false;
}
int binary_search() {
	long long int l = 0, r = 1000000000;
	while (r - l > 1) {
		int m = (r + l) / 2;
		if (a(m)) {
			r = m;
		}
		else {
			l = m + 1;
		}
	}
	if(a(l))return l;
	else return r;
}
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	int ans;
	ans = binary_search();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100005

int dp[3][MAXN];

int main() 
{
	int n;
	cin >> n;
	int hei[3][MAXN];
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= 2; j++)
		{
			if (i==0) cin >> dp[j][i];
			else cin >> hei[j][i];
		}
	}
	
	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (j==0) dp[j][i] = max(dp[1][i-1], dp[2][i-1]) + hei[0][i];
			if (j==1) dp[j][i] = max(dp[2][i-1], dp[0][i-1]) + hei[1][i];
			if (j==2) dp[j][i] = max(dp[1][i-1], dp[0][i-1]) + hei[2][i];
		}
	}
	
	cout << max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1])) << "\n";
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define INF (1LL<<50)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<double,P> PP;

int n;
PP p[205];
P sum[205];

int main(void){
	scanf("%d",&n);
	int cur=0,nxt=1;
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&p[i].second.first,&p[i].second.second);
		p[i].first=atan2(p[i].second.second,p[i].second.first);
	}
	sort(p,p+n);
	for(int i=0;i<n;i++){
		p[i+n]=p[i];
	}
	for(int i=0;i<n*2;i++){
		sum[i+1].first=sum[i].first+p[i].second.first;
		sum[i+1].second=sum[i].second+p[i].second.second;
	}
	ll ans=0;
	int pos=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=n;j++){
			ll val=sum[i+j].first-sum[i].first;
			ll val2=sum[i+j].second-sum[i].second;
			ans=max(ans,val*val+val2*val2);
		}
	}
	printf("%.10f\n",sqrt((double)ans));
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  string S0, S1, S2, C0, C1, C2;
  S0 = S1 = "                                                  ";
  
  for(int i=0;i<H+1;i++){
    S2 = S1;S1 = S0; cin >> S0;
    if (i== H){S0 = "                                                  ";}
    C0 = ' ' + S0 + ' ';
    C1 = ' ' + S1 + ' ';
    C2 = ' ' + S2 + ' ';
    
    for(int j=0;j<W;j++){
      if(S1.at(j) == '.'){
        int count = 0;
        
        for(int J=j;J<j+3;J++){
          if(C0.at(J)=='#'){count++;}
          if(C1.at(J)=='#'){count++;}
          if(C2.at(J)=='#'){count++;}
        }
        
        if(count == 0){S1.at(j) = '0';}
        if(count == 1){S1.at(j) = '1';}
        if(count == 2){S1.at(j) = '2';}
        if(count == 3){S1.at(j) = '3';}
        if(count == 4){S1.at(j) = '4';}
        if(count == 5){S1.at(j) = '5';}
        if(count == 6){S1.at(j) = '6';}
        if(count == 7){S1.at(j) = '7';}
        if(count == 8){S1.at(j) = '8';}
      }
    }
    
    cout << S1 << endl;
  }
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	b := 0
	c := 0
	for i := 0; i < n; i++ {
		if b <= a[i] {
			b = a[i]
			c++
		}
	}
	_, _ = fmt.Fprintf(writer, "%d\n", c)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int i;
  int a[3][3];
  char s[10];
  while(scanf("%s",s)!=-1){
    for(i=0;i<9;i++){
      if(s[i]=='o')
	a[i%3][i/3]='o';
      else if(s[i]=='s')
	a[i%3][i/3]=0;
      else if(s[i]=='x')
	a[i%3][i/3]='x';
    }
    for(i=0;i<3;i++){
      if(a[i][0]&&a[i][0]==a[i][1]&&a[i][1]==a[i][2]){
	printf("%c\n",a[i][0]);
	break;
      }
      if(a[0][i]&&a[0][i]==a[1][i]&&a[1][i]==a[2][i]){
	printf("%c\n",a[0][i]);
	break;
      }
    }
    if(i==3){
      if(a[0][0]&&a[0][0]==a[1][1]&&a[1][1]==a[2][2]){
	printf("%c\n",a[0][0]);
	continue;
      }
      if(a[2][0]&&a[2][0]==a[1][1]&&a[1][1]==a[0][2]){
	printf("%c\n",a[2][0]);
	continue;
      }
    }else
      continue;
    puts("d");
  }
  return 0;
}

Measured memory_bytes: 0