akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    BLACK = '#'
    WHITE = '.'
    H, W = MI()
    graph = [[0 for i in range(W)] for i in range(H)]
    ans = 0
    options = [(-1, 0), (0, 1), (1, 0), (0, -1)]

    for i in range(H):
        S = input()

        for j in range(W):
            graph[i][j] = S[j]

    if H == 1 and W == 1:
        print(0)
        return

    if (H == 2 and W == 1) or (H == 1 and W == 2):
        print(1)
        return

    # H = 2
    # W = 2
    # graph = [['.' for i in range(W)] for i in range(H)]

    ans = 0
    for h in range(H):
        for w in range(W):
            if graph[h][w] == BLACK:
                continue

            visited = [[False for i in range(W)] for i in range(H)]
            q = deque()
            q.append(((h, w), 0))
            arr = []
            while len(q) != 0:
                p, c = q.popleft()
                # print(ans, n)

                for d in options:
                    i = p[0] + d[0]
                    j = p[1] + d[1]

                    if i >= 0 and i < H and j >= 0 and j < W and not visited[i][j] and graph[i][j] == WHITE:
                        visited[i][j] = True
                        q.append(((i, j), c+1))
                        # print((i, j), c+1)
                    else:
                        arr.append(c)
            # print(h, w, arr, max(arr))
            ans = max(ans, max(arr))

    print(ans)



if __name__ == '__main__':
    main()


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

int main() {
    string S;cin >> S;
    int N = S.size();
    int ans = 0;int cur = 0;
    for (int i = 0;i < N;i++){
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            cur += 1;
        }
        else cur = 0;
        ans = max(ans,cur);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;


namespace AtCoderDotNetCore
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			int n = int.Parse(Console.ReadLine());
			var a = new List<int>();
			for (var i = 0; i < n; ++i) {
				a.Add(int.Parse(Console.ReadLine()));
			}

			bool isOK = false;
			int count = 1;

			int index = a[0];
			if (index == 2) {
				isOK = true;
			} else {
				for (var i = 0; i < n; ++i) {
					if (index > a.Count) {
						break;
					}

					++count;

					index = a[index - 1];
					if (index == 2) {
						isOK = true;
						break;
					}
				}
			}

			if (isOK == false) {
				Console.WriteLine($"-1");
			} else {
				Console.WriteLine($"{count}");
			}
		}
	}
}

Measured memory_bytes: 31872
#include <iostream>
#include <vector>

using namespace std;

int main() {
	//std::cout << "Hello World!\n";
	int n;
	cin >> n;
	int* A=new int[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	int q;
	cin >> q;
	int* m = new int[q];
	for (int i = 0; i < q; i++) {
		cin >> m[i];
	}
	//入力ここまで
	//n, A[], q, m[]
	vector<int> ans = { 0 };
	for (int i = 0; i < n; i++) {
		int ansSize = ans.size();
		for (int j = 0; j < ansSize; j++) {
			ans.push_back(ans[j] + A[i]);
		}
	}
	for (int i = 0; i < q; i++) {
		bool found = false;
		for (int j = 0; j < ans.size(); j++) {
			if (ans[j] == m[i]) {
				found = true;
			}
		}
		cout << (found ? "yes" : "no") << "\n";
		/*
		if (found) {
			cout << "yes\n";
		} else {
			cout << "no\n";
		}
		*/
	}
}



Measured memory_bytes: 7056
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

ll calc(const ll& x)
{
    return x * (x - 1) / 2;
}
void solve()
{
    int n; cin >> n;
    vector<int> v(n);
    map<ll, ll> mp;
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
        ll x = v[i];
        mp[x]++;
    }
    ll sum = 0;
    for(auto& x : mp)
    {
        sum += calc(x.second);
    }
    for(int i = 0; i < n; i++)
    {
        ll tmp = sum;
        ll a = mp[v[i]];
        ll b = mp[v[i]] - 1;
        tmp -= calc(a) - calc(b);
        cout << tmp << endl;
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 10368
import itertools
n,m,x = map(int,input().split())

c_li = [0]*n
a_li = [[] for i in range(n)]
for i in range(n):
    c_li[i],*a_li[i] = map(int,input().split())

m_li = [0]*m
ans=float('inf')
for i in range(1,n+1):
    for l in itertools.combinations([i for i in range(n)],i):
        cost = 0
        m_tmp = [0]*m
        for j in l:
            cost+=c_li[j]
            m_tmp = [a+b for a,b in zip(a_li[j],m_tmp)]
        #print(l,cost,m_tmp)
        if all(x<=m for m in m_tmp):
            if ans>cost:
                ans=cost
if ans==float('inf'):
    print(-1)
else:
    print(ans)




Measured memory_bytes: 9244
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)
int main(){
    vector<string> str;
    CIN(H);CIN(W);
    REP(a,H){
        string q;
        REP(b,W){
            char s;cin >> s;
            q.push_back(s);
        }
        str.push_back(q);
    }
    REP(a,W+2)cout<<"#";
    cout<<endl;
    REP(a,H){
        cout<<"#";
        REP(b,W){
            cout<<str.at(a).at(b);
        }
        cout<<"#"<<endl;
    }
    REP(a,W+2)cout<<"#";
    cout<<endl;
    return 0;
}


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


int main() {
  vector<vector<int>> bingo(3,vector<int>(3));
  bool hantei[3][3];
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      cin >> bingo[i][j];
    }
  }
  
  int n;
  cin >> n;
  int b[10];
  for(int i = 0; i < n; i++) {
    cin >> b[i];
  }
  
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      hantei[i][j] = false;
      for(int k = 0; k < n; k++) {
        if(bingo[i][j] == b[k]) {
          hantei[i][j] = true;
        }
      }
    }
  }

  string answer = "No";
  for(int i = 0; i < 3; i++) {
    if(hantei[0][i] && hantei[1][i] && hantei[2][i]) {
      answer = "Yes";
    }
  }
  for(int i = 0; i < 3; i++) {
    if(hantei[i][0] && hantei[i][1] && hantei[i][2]) {
      answer = "Yes";
    }
  }
  if(hantei[0][0] && hantei[1][1] && hantei[2][2]) {
      answer = "Yes";
  }
  if(hantei[0][2] && hantei[1][1] && hantei[2][0]) {
    answer = "Yes";
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AC = [0] * N
WA = [0] * N

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == 'AC':
        AC[p] = 1
    elif AC[p] == 0:
        WA[p] += 1

print(sum(AC), sum( [AC[i] * WA[i] for i in range(N)] ) )


Measured memory_bytes: 5528
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define N_MAX 1000010

int getgcd(int m, int n)
{
    if (n == 0)
        return m;
    return getgcd(n, m % n);
}

bool isPairwiseCoprime(multiset<int> &s)
{
    vector<int> ischecked(N_MAX + 1, false);
    for (int i = 2; i <= N_MAX; i++)
    {
        if (ischecked[i])
            continue;
        int cnt = 0;
        for (int j = i; j <= N_MAX; j += i)
        {
            ischecked[j] = true;
            cnt += s.count(j);
        }
        if (cnt > 1)
        {
            return false;
        }
    }
    return true;
}

bool isSetwiseCoprime(multiset<int> s)
{
    int gcd = *(s.begin());
    for (auto itr = s.begin(); itr != s.end(); itr++)
    {
        gcd = getgcd(gcd, *itr);
    }
    return gcd == 1;
}

int main()
{
    int n;
    cin >> n;
    multiset<int> s;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        s.insert(a);
    }
    if (isPairwiseCoprime(s))
    {
        cout << "pairwise coprime" << endl;
    }
    else if (isSetwiseCoprime(s))
    {
        cout << "setwise coprime" << endl;
    }
    else
    {
        cout << "not coprime" << endl;
    }
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	map<char, vector<pair<int, int>>> mp;
	char z;
	for (int i = 0, x, y; i < n; ++i)
	{
		cin >> x >> y >> z;
		mp[z].push_back({ x, y });
	}

	int mnx = 1e9, mxx = -1e9, mny = 1e9, mxy = -1e9;
	for (auto i : mp['L']) mny = min(mny, i.S), mxy = max(mxy, i.S);
	for (auto i : mp['R']) mny = min(mny, i.S), mxy = max(mxy, i.S);
	for (auto i : mp['U']) mnx = min(mnx, i.F), mxx = max(mxx, i.F);
	for (auto i : mp['D']) mnx = min(mnx, i.F), mxx = max(mxx, i.F);

	auto f1 = [&](ld md)
	{
		ld fmn = mnx, fmx = mxx;
		for (auto i : mp['L'])
		{
			fmn = min(fmn, i.F - md);
			fmx = max(fmx, i.F - md);
		}
		for (auto i : mp['R'])
		{
			fmn = min(fmn, i.F + md);
			fmx = max(fmx, i.F + md);
		}
		fmn = min(fmn, fmx);
		return fmx-fmn;
	};

	auto f2 = [&](ld md)
	{
		ld fmn = mny, fmx = mxy;
		for (auto i : mp['D'])
		{
			fmn = min(fmn, i.S - md);
			fmx = max(fmx, i.S - md);
		}
		for (auto i : mp['U'])
		{
			fmn = min(fmn, i.S + md);
			fmx = max(fmx, i.S + md);
		}
		fmn = min(fmn, fmx);
		return fmx-fmn;
	};

	ld l = 0, r = 1e9+5;
	for (int it = 200; it--; )
	{
		ld md1 = l + (r-l) / 3.0;
		ld md2 = r - (r-l) / 3.0;
		if (f1(md1) * f2(md1) < f1(md2) * f2(md2))
			r = md2;
		else
			l = md1;
	}

	cout << setprecision(20) << fixed << f1(l) * f2(l) << "\n";

	return 0;
}


Measured memory_bytes: 1308
D, G = map(int, input().split())
nums = [list(map(int, input().split())) for i in range(D)]
count = 10000

for i in range(0, 2**(D)):
    binary = "{0:0>{1}b}".format(i, D)
    tmpNum = 0
    tmpCount = 0
    for j in range(D):
        if binary[j] == '1':
            tmpCount += nums[j][0]
            tmpNum += nums[j][0] * (j+1) * 100 + nums[j][1]
        else:
            maxZeroIndex = j

    if tmpNum >= G and count > tmpCount:
        count = tmpCount
    else:
        for j in range(nums[maxZeroIndex][0]):
            tmpNum += (maxZeroIndex+1) * 100
            tmpCount += 1
            if tmpNum >= G and count > tmpCount:
                count = tmpCount

print(count)

Measured memory_bytes: 3064
A_B_list = [int(i) for i in input().split()]
A = A_B_list[0]
B = A_B_list[1]

count = 0
counter = 1
for i in range(20):
    if counter < B:
        counter += (A - 1)
        count += 1
    else:
        break

print(count)

Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize, k: usize,
        ab: [(Usize1, Usize1); n-1],
    }
    let M = 1000000007usize;

    let mut graph = vec![Vec::new(); n];
    for (a, b) in ab {
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut stack = Vec::new();
    let mut ans = 1usize;
    stack.push((0, 0, n));
    while let Some((now, num, prev)) = stack.pop() {
        ans *= k - num;
        ans %= M;
        let base = min(2, num + 1);
        let mut count = 0;
        for &next in &graph[now] {
            if next != prev {
                stack.push((next, base + count, now));
                count += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 13288
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N,count,ans=0;
  cin >> N;
  for(int i=1;i<=N;i++){
    count=1;
    if(i%2!=0){
      for(int j=1;j<i/2;j++){
		if(i%j==0)count++;
      }
    }
    if(count==8)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 
	public static boolean solve(long r, long g, long b, long w) {
		 if((r%2+g%2+b%2+w%2)>1)return false;
		 else return true;
	}
	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		int n = s.nextInt(); 
		long sum=0;
        long[] ar = new long[n];
        for (int i=0; i<n; i++) {
        	ar[i]=s.nextLong();
        	
        }
        for (int i=1; i<n; i++) {
        	if(ar[i-1]>=ar[i]) {
        		sum+=Math.max(ar[i-1]-ar[i],0);
        		ar[i]=Math.max(ar[i-1],ar[i]);
        		
        	}
        }
        System.out.println(sum);
        
      
	}
	
}


Measured memory_bytes: 55408
MOD = 998244353
factorial = None
inverse_factorial = None


def modpow(a, p):
    ans = 1
    while p:
        if p&1 == 1:
            ans = (ans*a)%MOD
        a = (a*a)%MOD
        p >>= 1
    return ans


def nCr(n, r):
    if r == 0 or r == n:
        return 1
    return (((factorial[n]*inverse_factorial[n-r])%MOD)*inverse_factorial[r])%MOD


def init_nCr(max_n):
    global factorial, inverse_factorial
    factorial = [1]*(max_n+1)
    inverse_factorial = [0]*(max_n+1)
    for i in range(1, max_n+1):
        factorial[i] = (factorial[i-1]*i)%MOD
        inverse_factorial[i] = modpow(factorial[i], MOD-2)


init_nCr(2*10**5+1)


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M, K = read_ints()
    answer = 0
    for k in range(0, K+1):
        answer = (answer+M*modpow(M-1, N-1-k)*nCr(N-1, k))%MOD
    return answer


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


Measured memory_bytes: 76888
#include <iostream>

using namespace std;

int main() {
	int num;
	int a,b,c,d,cnt=0;
	while(cin>>num, !cin.eof()){
		cnt=0;
		for(a=0; a<10; a++)
			for(b=0; b<10; b++)
				for(c=0; c<10; c++)
					for(d=0; d<10; d++)
						if(a+b+c+d==num) cnt++;
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
mod = int(1e9) + 7
n, a, b = map(int, input().split())

def aaa(base, n):
#     base = 2
    ans = 1
    nn = n
    while True:
    #     print(base, nn)
        if nn == 0:
            break
        if nn % 2 == 0:
            base = base ** 2
            base = base % mod + mod
            nn /= 2
        else:
            ans *= base
            ans = ans % mod + mod
            nn -= 1
    return ans

xn = aaa(2, n)

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))


def fac(start, length, mod):
    x = 1
    for k in range(start, start + length):
        x *= k
        x %= mod
    return x

aa = fac(n - a + 1 , a, mod)
aaa = fac(1, a, mod)
xa = div(aa, aaa)
if aa == 0:
    if aaa == 0:
        xa = 1


bb = fac(n - b + 1 , b, mod)
bbb = fac(1, b, mod)
xb = div(bb, bbb)
if bb == 0:
    if bbb == 0:
        xb = 1
        

x = xn - xa - xb - 1
x = x % mod
if x < 0:
    x += mod
print(x)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdlib.h>
using namespace std;

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

	vector<int> h(n);

	int count = 0;
	int max = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (i != 0) {
			if (h[i - 1] >= h[i]) {
				count++;
				if (max < count) {
					max = count;
				}
			}
			else
			{
				count = 0;
			}
		}
	}

	cout << max << endl;

	return 0;
}


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

int main() {
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N;
    cin >> N;
    vector<unsigned long> weight(N);
    {
        vector<unsigned long> hoge(N), fuga(N, 1), piyo(N, 1);
        iota(hoge.begin(), hoge.end(), 1UL);
        partial_sum(hoge.rbegin(), hoge.rend() - 1, fuga.rbegin() + 1, [&MOD](auto a, auto b){return a * b % MOD;});
        partial_sum(hoge.begin(), hoge.end() - 1, piyo.begin() + 1, [&MOD](auto a, auto b){return a * b % MOD;});
        for(unsigned long i = 0; i < N; ++i)weight[i] = fuga[i] * piyo[i] % MOD;
    }
    vector<unsigned long> A(N);
    for(auto& i : A)cin >> i;
    partial_sum(weight.begin(), weight.end(), weight.begin());
    unsigned long ans{0};
    for(unsigned long i = 0; i < N; ++i)ans += A[i] * ((weight[i] + weight[N - i - 1] - weight[0]) % MOD) % MOD;
    cout << ans % MOD << endl;
    return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll x, y;
    cin >> x >> y;
    if ((x>=0 and y>0) or (x<0 and y<=0)) {
        if (x<y) cout << y-x << endl;
        else cout << 2 + x - y << endl;
    }
    else {
        cout << 1 + abs(abs(x) - abs(y)) << endl;
    }
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    inf = 10**17
    #mod = 10**9 + 7

    N,M,R = map(int, input().split())
    r = list(map(int, input().split()))
    for i in range(R):
        r[i] -= 1

    def dijkstra_heap(start,edge):
        #始点から各頂点への最短距離(頂点番号:0~N-1)
        d = [inf]*N
        used = [False]*N
        d[start] = 0
        used[start] = True
        edgelist = []
        #a:重み(//), b:次の頂点(%)
        for a,b in edge[start]:
            heappush(edgelist,a*(10**6)+b)

        while len(edgelist):
            #まだ最短距離が決まっていない頂点の中から最小の距離のものを探す
            minedge = heappop(edgelist)
            if used[minedge%(10**6)]:
                continue
            node = minedge%(10**6)
            d[node] = minedge//(10**6)
            used[node] = True

            for e in edge[node]:
                if not used[e[1]]:
                    heappush(edgelist,(e[0]+d[node])*(10**6)+e[1])
        return d

    edge = [[] for i in range(N)]
    #edge[i] : iから出る道の[重み,行先]の配列
    for _ in range(M):
        x,y,z = map(int,input().split())
        edge[x-1].append((z,y-1))
        edge[y-1].append((z,x-1))

    kyori = []
    for i in r:
        kyori.append(dijkstra_heap(i,edge))
    
    res = inf
    for i in permutations(range(R), R):
        l = list(i)
        path = 0
        for j in range(R-1):
            path += kyori[l[j]][r[l[j+1]]]
        res = min(res, path)

    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 8140
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}


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


int main(){
    int n;
    cin >> n;
    vector<int>cnt(n+1, 0);
    rep(i, n - 1){
        int a;
        cin >> a;
        cnt[a]++;
    }
    REP(i, 1, n)cout << cnt[i] << endl;
}

Measured memory_bytes: 3964
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
	int a,b;
	cin >> a >> b;
	a -= b;
	if (a < 0) {
		a = 0;
	}
	cout << a << endl;
	
	return 0;
}



Measured memory_bytes: 256
c = [4,1,4,1,2,1,2,1,4,1,4,1,2,1,2,1]
while True:
    try:
        p = list(map(int, input().split()))
        c_tmp = 41412121
        s_min = 100000
        for i in range(8):
            s = 0
            for j in range(8):
                p_rest = p[j] - c[i + j] if p[j] - c[i + j] > 0 else 0
                s += p_rest
            if s == s_min and c_tmp > int("".join(map(str, c[i:i + 8]))):
                c_tmp = int("".join(map(str, c[i:i + 8])))
                ans = i
            elif s < s_min:
                s_min = s
                c_tmp = int("".join(map(str, c[i:i + 8])))
                ans = i
        
        print(*c[ans:ans + 8])
    except:
        break



Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,mi=0,ma=0;
cin>>a>>b;
mi=min(a,b);
ma=max(a,b);
switch(ma)
{
    case 0:cout<<mi*0;break;
	case 1:cout<<mi*1;break;
	case 2:cout<<mi*11;break;
	case 3:cout<<mi*111;break;
	case 4:cout<<mi*1111;break;
	case 5:cout<<mi*11111;break;
	case 6:cout<<mi*111111;break;
	case 7:cout<<mi*1111111;break;
	case 8:cout<<mi*11111111;break;
	case 9:cout<<mi*111111111;break; 	
}
return 0;
}



Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, x) = (line[0], line[1]);
    let mut m : Vec<usize> = vec![];

    for _ in 0..n{
        m.push(read_as_vec()[0]);
    }

    let whole_cost = m.iter().sum::<usize>();
    let x = x - whole_cost;
    m.sort();

    println!("{}", n + x/m[0]);
}


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



int main(){
	
	long long soma=0;
	
	
	int n,m;
	cin>>n>>m;
	
	
	for (int i=1; i<n; i++) soma+=i;
	for (int i=1; i<m; i++) soma+=i;
	
	
	cout<<soma<<endl;
	
	
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
ll dp[200005][3];
int main(){
int  n;
cin>>n;
V<ll> a(n);
for(int i=0;i<200005;i++)for(int j=0;j<3;j++)dp[i][j]=-inf;
dp[0][0]=0;
int skip=1+(n%2);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++){
    for(int j=0;j<=skip;j++){
        if(j!=skip){
            chmax(dp[i+1][j+1],dp[i][j]);
        }
        chmax(dp[min(n,i+2)][j],dp[i][j]+a[i]);
    }
}
cout<<max(dp[n][skip],dp[n][skip-1])<<"\n";
}


Measured memory_bytes: 9536
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 2e5 + 10;
pii a[N];
void solve(){
	int n;
	ll sum = 0;
	scanf("%d", &n);
	for(int i = 1;i <= n; i++){
		int l, r, k;
		scanf("%d %d %d", &k, &l, &r);
		sum += r;
		a[i] = {k, l - r};
	}
	sort(a + 1, a + n + 1);
	int slot = 0;
	int it = 1;
	priority_queue<int> pq;
	for(int i = 1; i <= n; i++){
		slot ++;
		for(; it <= n && a[it].st == i; it++){
			if(a[it].nd <= 0) continue;
			if(slot > 0){
				sum += 1LL * a[it].nd;
				pq.push(-a[it].nd);
				slot--;
			}
			else{
				if(-pq.top() <= a[it].nd){
					int x = -pq.top();
					pq.pop();
					sum -= 1LL * x;
					sum += 1LL * a[it].nd;
					pq.push(-a[it].nd);
				}
			}
		}
	}
	while(!pq.empty()) pq.pop();
	for(int i = 1; i <= n; i++){
		a[i].st = n - a[i].st;
	}
	sort(a + 1, a + n + 1);
	it = 1, slot = 0;
	for(int i = 1; i <= n; i++){
		slot ++;
		for(;it <= n && a[it].st <= i; it++){
			if(a[it].nd >= 0) continue;
			if(a[it].st == 0) {
				sum += 1ll * a[it].nd;
				continue;
			}
			if(slot > 0) pq.push(a[it].nd), slot--;
			else{
				if(pq.top() > a[it].nd){
					sum += 1LL * pq.top();
					pq.pop();
					pq.push(a[it].nd);
				}
				else sum += 1LL * a[it].nd;
			}
		}
	}

	printf("%lld\n", sum);
}
int main(){
	int t;
	scanf("%d", &t);
	for(int i = 1; i <= t; i ++){
		solve();
	}


}

Measured memory_bytes: 5496
A, B = [int(i) for i in input().split(" ")]

for i in range(B * 100):
    tmp1 = int(i * 0.08)
    tmp2 = int(i * 0.1)

    if tmp1 == A and tmp2 == B:
        print(i)
        break
else:
    print(-1)

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

int main() {
    int N, min_counter = 0;
    cin >> N;
    
    //最初の1回だけ特別に回す。
    int init_num;
    cin >> init_num;
    for(int j = 1; j < 100; j++){
        int devider = std::pow(2, j);
        if(init_num % devider != 0){
            min_counter = j-1;
            break;
        }
    }

    for(int i = 0; i < N-1; i++){
        int num, local_counter = 0;;
        cin >> num;
        for(int j = 1; j < 100; j++){
            int devider = std::pow(2, j);
            if(num % devider != 0){
                local_counter = j-1;
                break;
            }
        }
        if(min_counter > local_counter){
            min_counter = local_counter;
        }
    }

    cout << min_counter << endl;
}

Measured memory_bytes: 4036
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,m;
vector<int> v;

void solve(){
    cin >> n >> m;
    if(n==1 && m==0){
        cout << 0 << endl;
        return;
    } 
    v.resize(n,-1);
    rep(i,m){
        int s,c;cin >> s >> c;
        if(v[s-1]==-1) v[s-1]=c;
        else if(v[s-1]!=c) {
            cout << -1 << endl;
            return;
        }
    }
    if(v[0]==0){
        if(n==1) {
            cout << 0 << endl;
            return;
        }
        cout << -1 << endl;
        return;
    }
    rep(i,n){
       if(v[0]==-1 && i==0) cout << 1 << "";
       else if(v[i]==-1) cout << 0 << "";
       else cout << v[i] << ""; 
    }
}

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

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

int main(){
  
  long long A, B, K, i;
  long long _A, _B, _K;

  cin >> A >> B >> K;
  
  if (A <= K){
    _A = 0;
    _K = K - A;
  } else {
    cout << A - K << " " << B << endl;
    return 0;
  }
  
  if (B <= _K){
    _B = 0;
  } else {
    _B = B - _K;
  }
  cout << _A << " " << _B << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    if ( n % 2 == 0 ) {
        cout << d[n/2] - d[n/2-1] << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.io.PrintWriter;
import java.util.Arrays;;
import java.util.StringTokenizer;

/**
 * The Java template file for AtCoder online judge.
 */
public class Main {

  private static FastScanner scanner;
  private static PrintWriter printer;

  public static void solve() {
    int n = scanner.nextInt();
    int k = scanner.nextInt();
    int[] heights = new int[n];
    for (int i = 0; i < n; i++) {
      heights[i] = scanner.nextInt();
    }
    int[] dp = new int[n];
    Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0; // first stone
    for (int i = 1; i < n; i++) {
      for (int j = 1; j <= k; j++) {
        if (i - j >= 0) {
          dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(heights[i] - heights[i - j]));
        }
      }
    }
    printer.println(dp[n - 1]);
  }

  public static void main(String[] args) {
    scanner = new FastScanner();
    printer = new PrintWriter(System.out);
    solve();
    printer.flush();
  }

  private static class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(Reader in) {
      br = new BufferedReader(in);
    }

    public FastScanner() {
      this(new InputStreamReader(System.in));
    }

    public String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    public int[] readIntArray(int size) {
      int[] ret = new int[size];
      for (int i = 0; i < size; i++) {
        ret[i] = nextInt();
      }
      return ret;
    }
  }
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll h,w;

int main(){
  cin >> h >> w;
  if(h==1 || w==1){cout << 1;return 0;}
  cout << (h*w)/2+(h*w)%2;
  return 0;
}


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

using namespace std;
#define int long long 
#define inf 999999999999
#define N 2666
int arr[N],a[N],b[N];
map<int,int> mp;
signed main(){
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			/*if(i<=x&&y<=j){
				//cout<<i<<" "<<j<<" "<<(abs(j-y)+abs(i-x)+1)<<'\n';
				mp[(abs(j-y)+abs(i-x)+1)]++;
			}else{
				//cout<<i<<" "<<j<<" "<<abs(j-i)<<'\n';
				mp[abs(j-i)]++;
			}
			*/
			mp[min(abs(j-i),abs(i-x)+abs(y-j)+1)]++;
		}
	}
	for(int i=1;i<n;i++) cout<<mp[i]<<'\n';
	return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3624
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  i64 A, B;
  std::cin >> A >> B;

  const i64 min = std::max(tools::ceil<i64>(25 * A, 2), 10 * B);
  const i64 max = std::min(tools::ceil<i64>(25 * (A + 1), 2) - 1, 10 * (B + 1) - 1);
  std::cout << (min <= max ? min : -1) << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		String[] map = {"A","B","C"};
		int[] point = new int[3];
		point[0]++;
		String check;
		while((check = sc.readLine()) != null){
			String[] lo = check.split(",");
			int temp;
			for(int i = 0; i < 3; i++){
				for(int j = 0; j < 3; j++){
					if(lo[0].equals(map[i]) & lo[1].equals(map[j])){
						temp = point[i];
						point[i] = point[j];
						point[j] = temp;
					}
				}
			}

		}
		for(int i = 0; i < 3; i++){
			if(point[i] != 0) System.out.println(map[i]);
		}
	}
}

Measured memory_bytes: 24244
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n;
  cin >> n;
  vi a(n,0);
  int zenbu=0;
  rep(i,n) {
    int t;
    cin >> t;
    a.at(i) = t;
    zenbu ^= t;
  }

  rep(i,n) {
    cout << (a.at(i) ^ zenbu) << " ";
  }

  return 0;
}


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


void solve(long long N, std::vector<long long> a){
    map<long long, long long> mp;
    for(long long i=0; i<N; i++)
    {
        if(mp.count(a.at(i)) == 0)
        {
            mp[a.at(i)] = 1;
        }
        else
        {
            mp.at(a.at(i))++;
        }
    }

    long long total = 0;
    for(auto p : mp)
    {
        total += p.second * (p.second - 1) / 2;
    }
    // cout << "total : " << total << endl;

    for(long long i=0; i<N; i++)
    {
        long long dif = -1 * mp.at(a.at(i)) + 1;
        printf("%lld\n", total + dif);
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

typedef long long ll;

using namespace std;

int main() {
  string S;
  ll K;
  cin >> S >> K;
  if (S[0] == '1') {
    if (K == 1) {
      printf("1\n");
    } else {
      int idx = 1;
      for (int i = 1; i < S.size(); ++i) {
        if (S[i] != '1') {
          idx = i;
          break;
        }
      }
      if (idx <= K - 1) {
        printf("%c\n", S[idx]);
      } else {
        printf("1\n");
      }
    }
  } else {
    printf("%c\n", S[0]);
  }
}

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


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

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

    sort(a.begin(),a.end(),greater<int>());

    int ans = a.at(1);
    for(int i = 1;i < n;i ++){
        if(abs(a.at(i) - a.at(0) / 2) < abs(ans - a.at(0) / 2)){
            ans = a.at(i);
        }    
    }

    cout << a.at(0) << " " << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  cin >> n >> a;
  cout <<n*n-a fin;
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
const int mod = 998244353;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vi a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll res = a[0];
  for (int i = 1; i < n; ++i) {
    res = res * __gcd(i, a[i]) % mod;
  }
  cout << res % mod << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  int ans = 1001001001;
  rep(i, n){
    int a;
    cin >> a;
    int add = 0;
    while(a != 0 && a % 2 == 0){
      a /= 2;
      add++;
    }
    ans = min(ans, add);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+6;
int tree[26][N];
int n;
void add(int type, int id, int val)
{
	while(id<=n)
	{
		tree[type][id]+=val;
		id+=(id&-id);
	}
}
int qu(int type,int till)
{
	int ans=0;
	while(till>=1)
	{
		ans+=tree[type][till];
		till-=(till&-till);
	}
	return ans;
}
int res(int l,int r, int type)
{
	return qu(type, r)-qu(type,l-1);
}
int32_t main()
{
	cin>>n;
	string s;
	cin>>s;
	for(int i=1;i<=n;i++)
	{
		add(s[i-1]-'a',i,1);
	}
	
	int q,ch,pos,l,r;
	char c;
	cin>>q;
	while(q--)
	{
		cin>>ch;
		if(ch==1)
		{
			cin>>pos>>c;
			add(c-'a',pos,1);
			add(s[pos-1]-'a', pos, -1);
			s[pos-1]=c;
		}
		else
		{
			cin>>l>>r;
			int ans=0;
			for(int i=0;i<26;i++)
			{
				if(res(l,r,i)>0)
				ans++;
			}
			cout<<ans<<"\n";
		}
	}
	
}

Measured memory_bytes: 54708