akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CWalkOnMultiplicationTable solver = new CWalkOnMultiplicationTable();
        solver.solve(1, in, out);
        out.close();
    }

    static class CWalkOnMultiplicationTable {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long N = in.scanLong();
            long ans = N - 1;
            for (long i = 1; i * i <= N; i++) {
                if (N % i == 0) {
                    ans = Math.min(ans, Math.abs(i - 1) + Math.abs(N / i - 1));
                }
            }
            out.println(ans);

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public long scanLong() {
            long integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

    }
}



Measured memory_bytes: 25556
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;

int main() {
	int n;
	while(cin >> n, n) {
		bool l=false, r=false;
		bool state = false;
		int cnt = 0;
		rep(i, n) {
			string in;
			cin >> in;
			if(in[0]=='l') {
				l = (in[1]=='u');
			} else {
				r = (in[1]=='u');
			}
			if(!state && l && r) {
				cnt++;
				state = true;
			} else if(state && !l && !r) {
				cnt++;
				state = false;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
//CazadorDivino
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<int,int> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}

int main(){
	string s; cin>> s;
	int n = sz(s);
	int ans = inf;
	rep(i,0,n-1){
		if(i+2 <= n-1){
			//~ cout<< i<<" "<<i+2<<endl;
			string x = "";
			rep(j,i,i+2){
				x += conv(s[j]-'0');
			}
			//~ cout<<x <<endl;
			int xi = conv(x);
			int d = abs(xi - 753);
			if(d < ans ){
				ans = d;
			}
		}
		
	}
	cout<<ans;
	return 0;    
}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int a,b;cin>>a>>b;
  if(b==1){
    cout << 0 << endl;
    return 0;
  }
  int z = 1;
  int n = a;
  while(b > n){
    n += a-1;z++;
  }
  cout << z << endl;
  
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m; cin >> n >> m;
  ll k; cin >> k;
  vector<ll> a(n+1);
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    a[i+1] = a[i] + x;
  }

  vector<ll> b(m+1);
  for(int i = 0; i < m; ++i){
    int x; cin >> x;
    b[i+1] = b[i] + x;
  }

  ll ans = 0;

  for(int i = 0; i < n+1; ++i){
    ll a_val = a[i];
    if(a_val > k) continue;
    auto it = upper_bound(b.begin(),b.end(),k-a_val);
    if(it != b.begin())it--;
    ChangeMax(ans,i + ll(it - b.begin()));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
    cin>>s;
    vector<int> check(2, 0);
    for(int i=0;i<3;i++){
        if(s[i] == 'A') check[0] += 1;
        else check[1] += 1;
    }
    if(check[0] == 0 || check[1] == 0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int input;
  long long sum = 0;
  scanf("%d", &input);
 
  for (int i = 1; i <= input; i++){
    if (i % 3 == 0 && i % 5 == 0){
      continue;
    }
    else if (i % 3 == 0){
      continue;
    }
    else if (i % 5 == 0){
      continue;
    }
    else{
      sum += i;
    }
  }
  printf("%lld\n", sum);
  return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<char>>imaA(n,vector<char>(n));
  vector<vector<char>>imaB(m,vector<char>(m));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
      cin >> imaA.at(i).at(j);
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++)
      cin >> imaB.at(i).at(j);
  }
  bool ans=false;
  for(int i=0,l=n-m+1;i<l;i++){
    for(int j=0;j<l;j++){
      if(imaA.at(i).at(j)==imaB.at(0).at(0)){
        bool br=false;
        for(int x=0;x<m;x++){
          for(int y=0;y<m;y++){
            if(imaA.at(i+x).at(j+y)!=imaB.at(x).at(y)){
              br=true;
              break;
            }
          }
          if(br)
            break;
        }
        if(!br){
          ans=true;
        }
      }
      if(ans)
        break;
    }
    if(ans)
      break;
  }
  cout << (ans ? "Yes":"No") << endl;
}

Measured memory_bytes: 3584
import sys

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

def main():
    md=10**9+7
    n=II()
    ans=1
    for i in range(1,n+1):
        ans=ans*i%md
    print(ans)

main()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC121A
{
    static class Program
    {
        static void Main(string[] args)
        {
            var line1 = ReadLine().SplitTryParseToList<int>();
            var line2 = ReadLine().SplitTryParseToList<int>();

            WriteLine((line1[0] - line2[0]) * (line1[1] - line2[1]));
        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  int r, g;
  cin >> r >> g;
  cout << 2 * g - r << '\n';
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0])*100 + int.Parse(str[1])*10 + int.Parse(str[2]);
        sb.Append(n % 4 == 0 ? "YES\n" : "NO\n");
    }
}

Measured memory_bytes: 11092
let [| n; d |] =
    stdin.ReadLine().Split(" ") |> Array.map int64

[ for i in int64 (1) .. n do
    stdin.ReadLine().Split(" ")
    |> Array.map int64
    |> (fun [| x; y |] -> x * x + y * y) ]
|> List.filter (fun x -> x <= (d * d))
|> List.length
|> printfn "%d"


Measured memory_bytes: 49484
#include <iostream>
#include <string.h>
using namespace std;

int a[201][201][201];

int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}

int gcd(int a,int b,int c)
{
    int x=0;
    x=gcd(a,b);
    return gcd(x,c);
}

int main()
{
    int k;
    memset(a,0,sizeof(a));
    cin>>k;

    long long int ans=0;
    //cout<<gcd(2,2,4);
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int l=1;l<=k;l++)
            {
                if(a[i][j][l]!=0)
                {
                    ans+=a[i][j][l];
                }
                else
                {
                    a[i][j][l]=gcd(i,j,l);
                    ans+=a[i][j][l];
                }

            }
        }
    }
    cout<<ans;
}


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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

const int maxn=1000001;
int isprime[maxn];

int main() {
    IOS;
    int i;
    REP(i,1,maxn-1) isprime[i]=i;
    for(i=2;i*i<maxn;i++)
        if(isprime[i])
            for(int j=i*i;j<maxn;j+=i)
                isprime[j]=min(i,isprime[j]);
    int n;
    cin>>n;
    int a[n],flag=0,g;
    REP(i,0,n-1){
        cin>>a[i];
        if(!i) g=a[i];
        else g=__gcd(g,a[i]);
    }
    set<int> s1;
    REP(i,0,n-1){
        set<int> s2;
        while(a[i]>1){
            if(s1.find(isprime[a[i]])!=s1.end()){
                flag=1;
                break;
            }
            s2.insert(isprime[a[i]]);
            a[i]/=isprime[a[i]];
        }
        if(flag) break;
        for(auto u:s2) s1.insert(u);
    }
    if(!flag) cout<<"pairwise coprime";
    else if(g==1) cout<<"setwise coprime";
    else cout<<"not coprime";
    return 0;   
}

Measured memory_bytes: 11508
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	int n, m; cin >> n >> m;
	vector<int> a(n, 0);
	rep(i, 0, m) {
		int l, r; cin >> l >> r;
		l--; r--;
		a[l]++; if(r+1<n)a[r + 1]--;
	}
	rep(i, 0, n - 1) a[i + 1] += a[i];
	int ans = 0;
	rep(i, 0, n) {
		if (a[i] == m) ans++;
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1e9 + 7;

vector<int> g[100100];

int k;
ll ans;
void dfs(int v=0, int p=-1, int root=0) {
    int num;
    if (v == root) num = k-1;
    else num = k-2; 
    for (int nv: g[v]) {
        if (nv == p) continue;
        ans *= num;
        ans %= mod;
        dfs(nv, v, root);
        num -= 1;
    }
}

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

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ans = k;
    dfs();

    cout << ans << endl;


    return 0;

}


Measured memory_bytes: 10368
import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# sys.setrecursionlimit(500000)
def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(arr, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if arr[mid] == val:return mid
        elif arr[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,arr):
    for i in range(1,n):arr[i]+=arr[i-1]
    return arr;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;
# code start from here-
# for i in range(10):
x,k,d=iia()

xx=abs(x)

if k*d<=xx:
    ans1=abs(xx-k*d )
    print(ans1)
else:
    ans1,ans2=0,0
    step=xx//d
    rs=k-step

    f=abs(xx-step*d)
    s=abs(xx-step*d-d)
    if rs%2==0:
        a=f
    else:
        a=s
    print(a)


Measured memory_bytes: 77376
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = str(input())
t += "e"*k
lst = ["r","s","p"]
lst2 = [p,r,s]
score  = 0
for i in range(k):
    now = i
    s = ""
    while now < n:
        s += t[now]
        now += k
    l = []
    count = 1
    for j in range(len(s)-1):
        if s[j] != s[j+1]:
            l.append([s[j],count])
            count = 1
        else:
            count += 1
    l.append([s[len(s)-1],count])
    for arr in l:
        score += lst2[lst.index(arr[0])]*((arr[1]+1)//2)
print(score)

Measured memory_bytes: 9972
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    s = s_input()

    len_s = len(s)

    for i in range(len_s):
        if s[i] == '?':
            print('D',end='')
        else:
            print(s[i],end='')

    print()
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 81756
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	map<string,int> mci;
	set<int> st;
	int num;
	char bd[3];
	while(~scanf("%d,%s ",&num,bd)){
		if( st.find(num) != st.end() ) continue;
		mci[string(bd)]++;
		st.insert(num);
	}
	int step = 0;
	map<string,int>::iterator it;
	for(it=mci.begin(); it!=mci.end();){
		if( step==0 && it->first=="A" ){
			printf("%d\n",it->second);
			it = mci.begin();
			step = 1;
		}else if( step==1 && it->first=="B" ){
			printf("%d\n",it->second);
			it = mci.begin();
			step = 2;
		}else if( step==2 && it->first=="AB" ){
			printf("%d\n",it->second);
			it = mci.begin();
			step = 3;
		}else if( step==3 && it->first=="O" ){
			printf("%d\n",it->second);
			step = 4;
			break;
		}else{
			it++;
		}
	}
	for(int i=step; i<4; i++)printf("0\n");
	return 0;
}

Measured memory_bytes: 0
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
const int N = 300100;
int n, a[N];
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	for (int i = 1; i <= n; i++)
		if (a[i] % 2 != i % 2){
			printf("No\n");
			return 0;
		}
	for (int i = n; i > 2; i--)
		if (a[i] < a[i - 1] && a[i - 1] < a[i - 2])
			swap(a[i], a[i - 2]); 
	for (int i = n; i > 2; i--)
		if (a[i] < a[i - 2] && (a[i] > a[i - 1] || a[i - 1] > a[i - 2])){
			printf("No\n");
			return 0;
		}
	printf("Yes\n"); 
	return 0;
}


Measured memory_bytes: 1408
import itertools
n=int(input())
p = list(map(int,input().split()))	
q = list(map(int,input().split()))
i=1
for lis in list(itertools.permutations(list(range(1,n+1)))):
  if list(lis)==p:
    pin=i
  if list(lis)==q:
    qin=i
  i+=1

print(abs(pin-qin))

Measured memory_bytes: 8052
#include<bits/stdc++.h>
 
using namespace std;
const int maxn=1000005;
int n,m,dp[maxn],best,path[maxn],root;
vector<pair<int,int > > g[maxn];
 
int dfs_With_dp(int u)
{
    if(dp[u]) return dp[u];
    dp[u]=1;
    for(int O=0;O<g[u].size();O++) {
    	pair<int,int>v=g[u][O];
        int c=v.first;
        if(dp[u]<dfs_With_dp(c)+1) {
            dp[u]=dp[c]+1;
            path[u+1]=c+1;
        }
    }
    return dp[u];
}
 
int main()
{
    int x,y;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++) {
        scanf("%d%d",&x,&y);
        x-=1;
        y-=1;
        g[x].push_back(make_pair(y,i+1));
    }
    for(int i=0;i<n;i++) {
        int path_len=dfs_With_dp(i);
        if(best<path_len) {
            root=i;
            best=path_len;
        }
    }
//    cout<<"longest path length : "<<best-1<<endl;
    int u=root+1;
 /*   cout<<"path Sequence: ";
    while(path[u]!=0) {
        cout<<u<<" ";
        u=path[u];
    }
    cout<<u<<endl;
   */
   cout<<best-1<<endl;
    return 0;
}


Measured memory_bytes: 32768
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
  static void Main(string[] args)
  {
    var s = Console.ReadLine();
    long count = 0;
    long countB = 0;
    for(int i=0;i<s.Length;i++){
      if(s[i]=='W'){
        count+=countB;
      }else{
        countB++;
      }
    }
    
    Console.WriteLine(count);
  }  
}

Measured memory_bytes: 11616
if true then
  fh = STDIN
else
  fh=open("in1_0136.txt")
end
f=[]
n=fh.gets.chomp.to_i
0.upto(n-1){|i|
  f.push(fh.gets.chomp.to_f)
}

hlimit=[165.0, 170.0, 175.0, 180.0, 185.0, 999999.9]
hist=Array.new(6,0)
0.upto(n-1){|i|
  0.upto(hist.length-1){|j|
    if f[i] < hlimit[j] then
      hist[j] += 1
      break
    end
  }
}
0.upto(hist.length-1){|j|
  printf("%d:%s\n", j+1, "*" * hist[j])
}

fh.close

Measured memory_bytes: 8576
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>

using namespace std;
int main(void)
{
  int n;
  int i,j,k;
  int sum[112345]={};
  pair<string,int> a[112345];
  int ans[112345]={};
  int len;
  int up,low;
  int before=0;
  cin>>n;
  for(i=0;i<n;i++)
    {
      cin>>a[i].first;
      a[i].second=i;
    }
  sort(a,a+n);
  for(i=0;i<n;i++)
    {
      up=upper_bound(a+i,a+n,make_pair(a[i].first,n))-a;
      low=lower_bound(a+i,a+n,make_pair(a[i].first,0))-a;
      len=up-low;
      for(j=0;j<len;j++)
	sum[i+j+1]=low*3+len-1;
      i+=len-1;
    }
  for(i=0;i<n;i++)
    ans[a[i].second]=sum[i+1];
  for(i=0;i<n;i++)
    cout<<ans[i]<<endl;
 
}

Measured memory_bytes: 10004
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n,t,a,i,ans=0;
    scanf("%d",&n);
    scanf("%d %d",&t,&a);
    int h[n];
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
        h[i]=abs(500*(t-a)-3*h[i]);
        if(h[ans]>h[i]){
            ans=i;
        }
    }
    printf("%d\n", ans+1);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}

	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int r,d,x;
			int index, result;
			r = sc.nextInt();
			d = sc.nextInt();
			x = sc.nextInt();
			sc.close();
			result=x;
			for(index=0;index<10;index++) {
				result = result * r - d;
				System.out.println(result);
			}

			// 出力

	}
}

Measured memory_bytes: 20564
n = int(input())
w = [int(i) for i in input().split()]
ans = 999999999
for i in range(1,n):
    g1 = w[0:i]
    g2 = w[i:n]
    d = abs(sum(g1)-sum(g2))
    if d <= ans:
        ans = d
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pob pop_back
#define ff first
#define ss second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define debug(x) cout << x << endl;
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace __gnu_pbds;
using namespace std;
using LD = long double;

const int N = 1e7+1;
const int mod = 1e9+7;
const int INF = 1e18;

int a[N];

void solve() {
	int n,k;
	cin >> n >> k;
	int v[n+1];
	for(int i=1;i<=n;i++)
		cin >> v[i];
	while(k--) {
		for(int i=1;i<=n;i++) {
			int l = i - v[i];
			int r = i + v[i] + 1;
			if(l < 1) l = 1;
			a[l]++;
			a[r]--;
		}
		for(int i=1;i<=n;i++)
			a[i] += a[i-1];
		//cout << p << ": " << endl;
		for(int i=1;i<=n;i++) {
			v[i] = a[i];
			a[i] = 0;
		}
		if(count(v+1,v+n+1,n) == n)
			break;
		//cout << endl;
	}
	for(int i=1;i<=n;i++)
		cout << v[i] << " ";
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1,i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 8348
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
  
N,K=list(map(int,input().split()))
print(len(Base_10_to_n(N,K)))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)

int main() {
  string s;
  cin>>s;
  int n=s.size();
  bool ans=true;
  if (n%2==1) ans=false;
  else {
    rep(i,n/2) {
      if (s[i*2]!='h'||s[i*2+1]!='i') ans=false;
    }
  }
  cout<<(ans ? "Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int K;
  cin >> K;
  vector<int> math(N);
 
  for (int i = 0; i < N; i++) {
    cin >> math.at(i);
  }
  int q = 0;
  for(int i = 0; i < N; i++) {
    if(K <= math.at(i)) {
      q++;
    }
  }
  cout << q << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int l;
pi dist[305][305];
vector<pi> g[305];

bool lss(pi a, pi b){
	if(a.fi != b.fi) return a.fi < b.fi;
	return a.se > b.se;
}

struct cmp{
	bool operator() (pair<pi, int> a, pair<pi, int> b){
		if(a.fi.fi != b.fi.fi) return a.fi.fi < b.fi.fi;
		return a.fi.se > b.fi.se;
	}
};

void dijkstra(int source){
	dist[source][source] = {0, l};
	multiset<pair<pi, int>, cmp> q;
	q.insert(mp(dist[source][source], source));
	while(!q.empty()){
		/*
		for(pair<pi, int> emmm : q){
			cout << emmm.fi.fi << " " << emmm.fi.se << " " << emmm.se << endl;
		}
		cout << "-----" << endl;
		*/
		pair<pi, int> cur = *q.begin();
		q.erase(q.begin());
		for(pi x : g[cur.se]) if(x.se <= l){
			pi nw = cur.fi;
			if(x.se <= nw.se) nw.se -= x.se;
			else{
				nw.fi++;
				nw.se = l - x.se;
			}
			if(lss(nw, dist[source][x.fi])){
				q.erase(mp(dist[source][x.fi], x.fi));
				dist[source][x.fi] = nw;
				q.insert(mp(dist[source][x.fi], x.fi));
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m >> l;
	rep(i, 305) rep(j, 305) dist[i][j] = {1e9, 0};
	rep(i, m){
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
        	g[a].pb(mp(b, c));
        	g[b].pb(mp(a, c));
	}
	rep(i, n) dijkstra(i);
	int q;
	cin >> q;
	rep(i, q){
		int s, t;
        	cin >> s >> t;
		//assert(dist[s - 1][t - 1].fi == dist[t - 1][s - 1].fi);
        	if(dist[s - 1][t - 1].fi == 1e9) cout << -1 << endl;
        	else cout << dist[s - 1][t - 1].fi << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 2432
import sys

M = 1044697
H = [None] * M

table = str.maketrans({"A":"1","C":"2","G":"3","T":"4"})


def getChar(ch):
    if ch == "A":
        return 1
    elif ch == "C":
        return 2
    elif ch == "G":
        return 3
    elif ch == "T":
        return 4
    else:
        return 0

def getKey(string):
    sum = 0
    p = 1
    for i in range(len(string)):
        sum += p*(getChar(string[i]))
        p *= 5
    return sum

#print(getKey(string))

def h1(key):
    return key % M

def h2(key):
    return 1 + (key % (M-1))

# 関数の中のwhile文はreturnで抜け出せる
def find(string):
    i = 0
    key = getKey(string)
    while True:
        h = (h1(key) + i * h2(key)) % M
        if H[h] == string:
            return 1
        elif H[h] is None:
            return 0
        else:
            i += 1

def insert(string):
    i = 0
    key = getKey(string)
    while True:
        h = (h1(key) + i * h2(key)) % M
        if H[h] is None:
            H[h] = string
            break
        else:
            i += 1


input = sys.stdin.readline
n = int(input())

for _ in range(n):
    com,string = input().split()
    if com == "insert":
        insert(string)
    elif com == "find":
        if find(string):
            print("yes")
        else:
            print("no")


Measured memory_bytes: 48564
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

int main() {
  int N;
  in(N);
  if(N/100==7 || (N%100)/10 ==7 || (N%10) ==7)out("Yes");
  else out("No");
}


Measured memory_bytes: 3632
N,C=map(int, input().split())
IA=[[int(i) for i in input().split()] for _ in range(N)]
MS=[[0]*(N+1),[0]*(N+1)]
CS=[0]*(N+1)
cum = 0
for i,[a,v] in enumerate(IA):
    cum += v
    MS[0][i+1]=cum-a if(cum-a)>MS[0][i]else MS[0][i]
    MS[1][i+1]=cum-2*a if(cum-2*a)>MS[1][i]else MS[1][i]
    CS[i+1]=cum
res = 0
for i in range(N):
    ob=CS[N]-CS[i]
    res=max(res,ob+MS[0][i]-2*(C-IA[i][0]),ob+MS[1][i]-(C-IA[i][0]))
print(max(res, MS[0][N], 0))


Measured memory_bytes: 33792
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define rep(i, a, b) for (int i = (a); i < ((int)b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= ((int)a); --i)
#define sz(c) ((int)c.size())

using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

void dump_impl(string s) {}
template <class H, class... T>
void dump_impl(string s, H head, T... tail) {
    int p = 0;
    rep(i, 0, s.size()) {
        char x = s[i];
        if (p == 0 && x == ',') {
            cerr << " = " << head << ", ";
            dump_impl(s.substr(i + 1), tail...);
            return;
        } else {
            cerr << x;
            if (x == '(') p++;
            if (x == ')') p--;
        }
    }
}
#ifdef LOCAL
#define dump(...) do { cerr << "\x1b[33;1m"; dump_impl(#__VA_ARGS__ ",", __VA_ARGS__); cerr << "\x1b[0m" << endl; } while (0)
#else
#define dump(...)
#endif

const int INF = 1e9;

struct Edge {
    int to;
    int lim;
    int len;
};

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

void solve(int N, int M) {
    int S, T;
    cin >> S >> T;
    S--, T--;
    vector<vector<Edge>> G(N);
    rep(i, 0, M) {
        int a, b, d, c;
        cin >> a >> b >> d >> c;
        a--, b--;
        G[a].push_back(Edge {b, c, d});
        G[b].push_back(Edge {a, c, d});
    }

    vector<vector<vector<double>>> dist(N, vector<vector<double>>(N, vector<double>(35, INF)));
    dist[S][S][1] = 0;
    priority_queue<tuple<double, int, int, int>, vector<tuple<double, int, int, int>>, greater<>> pq;
    for (auto e : G[S]) {
        double cost = e.len / (double)1;
        if (chmin(dist[e.to][S][1], cost)) {
            pq.push(make_tuple(dist[e.to][S][1], e.to, S, 1));
        }
    }
    while (sz(pq)) {
        double dist_cur;
        int v, from, sp;
        tie(dist_cur, v, from, sp) = pq.top(); pq.pop();
        if (dist_cur > dist[v][from][sp]) continue;

        rep(dsp, -1, 2) {
            int nsp = sp + dsp;
            if (nsp > 0) {
                for (auto e : G[v]) {
                    if (e.to == from) continue;
                    if (e.lim < nsp) continue;
                    double cost = e.len / (double)nsp;
                    if (chmin(dist[e.to][v][nsp], dist_cur + cost)) {
                        pq.push(make_tuple(dist[e.to][v][nsp], e.to, v, nsp));
                    }
                }
            }
        }
    }

    double ans = INF;
    rep(i, 0, N) {
        chmin(ans, dist[T][i][1]);
    }
    if (ans >= INF) {
        cout << "unreachable" << endl;
    } else {
        cout << ans << endl;
    }
}

signed main() {
    cout << setprecision(20);
    while (1) {
        int N, M;
        cin >> N >> M;
        if (N == 0 && M ==0) break;
        solve(N, M);
    }
}


Measured memory_bytes: 3932
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
 
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//infinity
#define INTINF 2000000000
#define LONGINF 20000000000
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(){
	long long n, k; cin >> n >> k;
	long long ans = 0;
	long long tn = (n > k) ? k+1 : n+1;
	FOR(a, 1, tn){
		long long b = (k-a) == 0 ? k: (k-a);
		long long c = (k-b) == 0 ? k: (k-b);
		if ( (c + a) % k != 0 ) continue;

		long long an = (n - a) / k + 1;
		long long bn = (n - b) / k + 1;
		long long cn = (n - c) / k + 1;
		long long t = an * bn * cn;
		ans += t;
	}
	cout << ans << endl;
	return 0;
}


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

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

  if (s[0]=='1'){++n;}
  if (s[1]=='1'){++n;}
  if (s[2]=='1'){++n;}
  
  cout << n << endl;
}


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

int main() 
{
    string s;
    cin >> s;
    bool y = true;
    if (s[0] != 'A')
        y = false;
    if (count(s.begin()+2, s.end()-1, 'C') != 1)
        y = false;
    if (!y)
    {
        cout << "WA";
        return 0; 
    }
    for (int i = 1; i<s.size(); i++)
    {
        if (s[i] == 'C') continue;
        if (isupper(s[i]))
        {
            y = false;
            break;
        }
    }
    if (s[s.size()-1] == 'C') y = false;
    if (s[1] == 'C') y = false;
    cout << (y?"AC":"WA");
    return 0;
}

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

int main(void) {
    int64_t N,K,R,S,P;
    string T; 
    int64_t point = 0;
    cin >> N >> K >> R >> S >> P >> T;
    vector<char> chk(K,0);
    map<char,int64_t> mp;
    mp['r'] = P;
    mp['s'] = R;
    mp['p'] = S;
    for(int64_t i=0;i<N;i++) {
        if(chk[i%K] != T[i]) {
            point += mp[T[i]];
            chk[i%K] = T[i];
        } else {
            chk[i%K] = 0;
        }
    }
    
    cout << point << "\n";

    return 0;
}


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

using namespace std;

void print_vec(vector<int> &vec) {
    for (int i = 0; i < vec.size(); i++) {
        if (i != 0) cout << " ";
        cout << vec[i];
    }
    cout << endl;
}

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

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

    bool flag = true;
    int cnt = 0;
    while (flag) {
        flag = false;
        for (int i = N-1; i > 0; i--) {
            if (A[i-1] > A[i]) {
                int tmp = A[i];
                A[i] = A[i-1];
                A[i-1] = tmp;
                flag = true;
                cnt++;
            }
        }
    }
    print_vec(A);
    cout << cnt << endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
   
using namespace std;
     
#define PB(x) push_back(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x) make_pair(x);
    
#define debug(x) cerr << #x << '=' << x << endl;
#define debug2(x, y) cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a) for (int x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, n, m) for (int i = 0; i < n; i++, cout << endl)           \
						for (int j = 0; j < m; j++) cout << a[i][j] << ' ';

#define int long long
     
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

int32_t main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	int a[n];
	for (int& x: a) cin >> x;
	
	reverse(a, a+n);
	vi diff;
	for (int i = 1; i < n; i++) {
		diff.push_back(a[i]-a[i-1]);
	}
	int ans = 0;
	int cnt = 0;
	for (int i = 0; i < (int)diff.size(); i++) {
		if (diff[i] < 0) {
			cnt = 0;
		} else {
			cnt++;
		}
		ans = max(cnt, ans);
	}
	cout << ans << endl;
}


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

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

  int alice = 0;
  int bob = 0;
  for(int j=0;j<n;j++){
    int max_temp = 0;
    int max_temp_index = 0;
    for(int k=0;k<n;k++){
      if(vec[k] > max_temp){
        max_temp = vec[k];
        max_temp_index = k;
      }
    }
    if(j%2 == 0){
      alice = alice + max_temp;
    }
    else{
      bob = bob + max_temp;
    }
  vec[max_temp_index] = 0;
  }
  cout << (alice - bob) << endl;
  // cout << alice << endl;                                                       
  // cout << bob << endl;                                                         
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

class SegmentTree{
    int n;
    vector<ll> node;
    bool mx;

    public:
    SegmentTree(vector<ll> v, bool mxmx){
        mx = mxmx;
        int sz = v.size();
        n = 1;
        while(sz > n) n *= 2;
        node.resize(2*n-1);

        for(int i = 0; i < sz; i++)
            node[i+n-1] = v[i];
        for(int i = n-2; i >= 0; i--){
            if(mx)
                node[i] = max(node[2*i+1], node[2*i+2]);
            else
                node[i] = min(node[2*i+1], node[2*i+2]);
        }
    }

    void update(int x, ll val){
        x += n-1;
        node[x] = val;
        while(x > 0){
            x = (x-1) / 2;
            if(mx)
                node[x] = max(node[2*x+1], node[2*x+2]);
            else
                node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }

    ll getval(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)
            r = n;

        if(r <= a || b <= l){
            if(mx) return 0;
            else return 1e12;
        }

        if(a <= l && r <= b)
            return node[k];

        ll lval = getval(a, b, 2*k+1, l, (l+r)/2);
        ll rval = getval(a, b, 2*k+2, (l+r)/2, r);
        if(mx) return max(lval, rval);
        else return min(lval, rval);
    }
};

int main(){
    ll N;
    cin >> N;
    vector<pair<ll, ll>> LR(N);
    vector<ll> L;
    vector<ll> R;
    REP(i,N){
        ll l, r;
        scanf("%lld %lld", &l, &r);
        LR[i] = mp(l, -r);
    }

    sort(LR.begin(), LR.end());

    for(auto&& p : LR){
        L.push_back(p.first);
        R.push_back(-p.second);
    }

    SegmentTree treeL(L, true);
    SegmentTree treeR(R, false);

    ll maxl1 = -1;
    ll minr1 = 1e10;
    ll ans = 0;
    REP(i,N-1){
        ll tmp = 0;
        auto p = LR[i];
        chmax(maxl1, p.first);
        chmin(minr1, -p.second);

        ll maxl2 = treeL.getval(i+1, N);
        ll minr2 = treeR.getval(i+1, N);

        tmp = max(0LL, minr1-maxl1+1) + max(0LL, minr2-maxl2+1);
        chmax(ans, tmp);
    }

    REP(i,N){
        ll tmp = 0;
        auto p = LR[i];
        ll maxl1 = p.first;
        ll minr1 = -p.second;

        ll maxl2, minr2;
        maxl2 = treeL.getval(0, i);
        chmax(maxl2, treeL.getval(i+1, N));

        minr2 = treeR.getval(0, i);
        chmin(minr2, treeR.getval(i+1, N));

        tmp = max(0LL, minr1-maxl1+1) + max(0LL, minr2-maxl2+1);
        chmax(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8284
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include<cstring>
#include<cmath>
using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;

int ans=0;

int main()
{
	ll i,n,m;
	cin>>n>>m;
	ll x[n],y[n],z[n];
	for (i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i];
	ll sum=0,tmp[n],ans=0;
	for(i=0;i<n;++i)
	{
		tmp[i]=x[i]+y[i]+z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i) sum+=tmp[i];
  	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i)
	{
		tmp[i]=x[i]+y[i]-z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i) sum+=tmp[i];
	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i)
	{
		tmp[i]=x[i]-y[i]+z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i) sum+=tmp[i];
	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i)
	{
		tmp[i]=x[i]-y[i]-z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i) sum+=tmp[i];
	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i)
	{
		tmp[i]=-x[i]+y[i]+z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i) sum+=tmp[i];
	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i)
	{
		tmp[i]=-x[i]+y[i]-z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i) sum+=tmp[i];
	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i) 
	{
		tmp[i]=-x[i]-y[i]-z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i) sum+=tmp[i];
	ans=max(ans,sum);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256