akhauriyash/Code-Regression huggingface dataset:
import itertools

n = int(input())

products = []
for i in range(3, len(str(n)) + 1):
    tmp = list(itertools.product(['3', '5', '7'], repeat = i))
    tmp2 = list(map(''.join, tmp))
    tmp3 = list(map(int, tmp2))
    tmp4 = [j for j in tmp3 if j <= n]
    products = products + tmp4

out = 0
for p in products:
    str_p = str(p)
    if ('3' in str_p) and ('5' in str_p) and ('7' in str_p):
        out += 1
print(out)

Measured memory_bytes: 15124
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string S;
  cin >> S;
  vll a(26, 0);
  REP(i, 0, S.size()) {
    a[S[i] - 'a']++;
  }

  if (S.size() < 26) {
    cout << S;
    REP(i, 0, a.size()) {
      if (a[i] == 0) {
        char c = i + 'a';
        cout << c << endl;
        return 0;
      }
    }
  }

  if (S == "zyxwvutsrqponmlkjihgfedcba") {
    cout << "-1" << endl;
    return 0;
  }

  string s = S;
  next_permutation(S.begin(), S.end());
  REP(i, 0, S.size()) {
    cout << S[i];
    if (s[i] != S[i]) {
      cout << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; i++)
int main() {
  int n,cnt=0; cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  bool flag=true;
  rep(i,200){
    rep(i,n){
      if(a[i]%2){
        flag=false;
        break;
      }
      a[i]/=2;
    }
    if(flag) cnt++;
    else break;bool flag=true;
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << 1;
	}
	else if (a == b && b != c || b == c && a != b || a == c && a!= b) {
		cout << 2;
	}
	else {
		cout << 3;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }

typedef complex<double> base;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n,k;
int arr[200005];
bool check(int req)
{
    int moves=0;
    for(int i=0;i<n;i++)
    {
        if(arr[i]<=req)
            continue;
        int ans=0;
        ans+=arr[i]/req;
        if(arr[i]%req==0)
            ans--;
        moves+=ans;
        if(moves>k)
            return 0;
    }
    return 1;
}
int32_t main() 
{
    IOS
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int low=1;
    int high=2e9;
    while(low<high)
    {
        int mid=(low+high)/2;
        if(!check(mid))
            low=mid+1;
        else
            high=mid;
    }
    print(low);
}   


Measured memory_bytes: 5100
A,B = map(int,input().split())
print("100 100")
ans = [["#"]*100 for _ in range(50)] + [["."]*100 for _ in range(50)]
A -=1
B -=1

wR = 0 
while A>=50:
    A -= 50
    for i in range(0,100,2):
        ans[wR][i]="."
    wR += 2
     
wC = 0
while A>0:
    A -= 1
    ans[wR][wC]="."
    wC += 2
    
bR=99
while B>=50:
    B -= 50
    for i in range(0,100,2):
        ans[bR][i]="#"
    bR -= 2
    
bC = 0
while B>0:
    B -= 1
    ans[bR][bC]="#"
    bC += 2

[print("".join(i)) for i in ans]


Measured memory_bytes: 38512
#include <iostream>

using namespace std;

int gcd(int x, int y) {
	int r;
	if(x == 0 || y == 0) {
		return 0;
	}

	while(x % y != 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

long long int lcm(int x, int y) {
	if(x == 0 || y == 0) {
		return 0;
	}
	return ((x / gcd(x, y)) * y );
}

int main() {
	int x, y;

	while(cin >> x >> y) {
		if(x > y) {
			cout << gcd(x, y) << " " << lcm(x, y) << endl;
		}
		else {
			cout << gcd(y, x) << " " << lcm(y, x) << endl;
		}
	}
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int n;
        Scanner s = new Scanner(System.in);
        n = s.nextInt();
        System.out.println(0.0 + " " + 0.0);
        koch(0.0, 0.0, 100.0, 0.0, 0, n);
        System.out.println(100.0 + " " + 0.0);
    }

   
    static void koch(double ax, double ay, double bx, double by, int call, int n) {
        double x1 = ax + (bx - ax) / 3.0;
        double y1 = ay + (by - ay) / 3.0;
        double x3 = ax + (bx - ax) / 3.0 * 2;
        double y3 = ay + (by - ay) / 3.0 * 2;
        double x2 = Math.cos(Math.PI / 3) * (bx - ax) / 3 - Math.sin(Math.PI / 3) * (by - ay) / 3 + x1;
        double y2 = Math.sin(Math.PI / 3) * (bx - ax) / 3 + Math.cos(Math.PI / 3) * (by - ay) / 3 + y1;
        if (call < n) {
            koch(ax, ay, x1, y1, call + 1, n);
            System.out.println(x1 + " " + y1);
            koch(x1, y1, x2, y2, call + 1, n);
            System.out.println(x2 + " " + y2);
            koch(x2, y2, x3, y3, call + 1, n);
            System.out.println(x3 + " " + y3);
            koch(x3, y3, bx, by, call + 1, n);
        }
    }
}



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

class Dmondai
{
    static int[] parent;
    static void Main()
    {
        var nm = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = nm[0];
        var M = nm[1];
        var AB = new List<int[]>();
        var size = new long[N];
        parent = new int[N];
        for (int i=0;i<M;++i)
        {
            var ab = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            AB.Add(new int[2] { ab[0]-1,ab[1]-1 });
        }
        for (int i=0;i<N;++i)
        {
            size[i] = 1;
            parent[i] = i;
        }
        //UF
        var ans = new Stack<long>();
        ans.Push(((long)N*((long)N-1))/2);
        for (int i=M-1;0<i;--i)
        {
            var ab = AB[i];
            var parent1 = GetParent(ab[0]);
            var parent2 = GetParent(ab[1]);
            if (parent1 != parent2)
            {
                ans.Push(ans.Peek() - (size[parent1] * size[parent2]));
                parent[parent2] = parent1;
                size[parent1] += size[parent2];
            }
            else ans.Push(ans.Peek());
        }
        for (int i = 0; i < M; ++i) Console.WriteLine(ans.Pop());
    }

    static int GetParent(int num)
    {
        if (parent[num] == num) return num;
        else return parent[num]=GetParent(parent[num]);
    }
}

Measured memory_bytes: 27184
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    var a = 0
    val l = mutableListOf<List<Int>>()
    val newl = Array<Int>(y,{0})
    for (i in 0 until x) {
        l.add(readLine()!!.split(" ").map{ it.toInt()})
    }
    for(i in 0 until x - 1)for (j in i + 1 until x) {
        for (k in 0 until y) {
            newl[k] = Math.pow((l[i][k] - l[j][k]).toDouble(), 2.0).toInt()
        }
        if (Math.sqrt(newl.sum().toDouble()) % 1.0 == 0.0) a += 1
    }
    println(a)
}

Measured memory_bytes: 37920
#include <iostream>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define en '\n'

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll r = 0, g = 0, b = 0, res;
    for(auto el : s){
        if(el == 'R'){
            ++r;
        }else if(el == 'G'){
            ++g;
        }else{
            ++b;
        }
    }
    res = r*g*b;
    for(int i = 1; i < n; ++i) {
        for(int j = 0; j < i; ++j){
            if((i-j-2)%2 == 0){
                int k = (i+j)/2;
                if(s[j] != s[k] and s[j] != s[i] and s[i] != s[k]){
                    --res;
                }
            }
        }
    }
    cout << res;
}

Measured memory_bytes: 3660
/**
 *      ///----- My Info -----///
 *      Clock: nowl
 *      Code by: Ernesto Abreu
 *      Codeforces User: Ernest0_0Abreu
 *      Country: Cuba
 *      E-mail: ernestoabreup@gmail.com
 *      ©CopyRight
**/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
        ///----- My Template -----///
///=====================================================================================================================
/// Red-Black Tree
// #include <ext/pb_ds/assoc_container.hpp>  // .find_of_order(x); .order_of_key(x);
// using namespace __gnu_pbds;
// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > indexed_set;
/// Typedef
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
/// Function
#define pi (acos(-1))
#define lg2(x) 31-__builtin_clz(x)
#define lgx(x,b) log(b)/log(x)
/// Macros
#define fst first
#define scd second
#define pb push_back
#define left (node<<1)
#define right ((node<<1)+1)
#define sz(x) (int)(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
/// Debug
#define _end cout << "\n"
#define debug(x) cerr << #x << " = " << x << " "
/// Constant
const int MAXN = 1e6+7;
const int MOD = 1e9+7;
const ull BASE = 311;
const ld EPS = 1e-9;
const int INF = ((1<<30)-1);
const ll INFLL = ((1ll<<62ll)-1ll);
/// Hash Prime Numbers: 2, 277, 293, 307, 331, 337, 1009, 2027;
/// Module Prime Numbers: 3, 998244353, 1000000007, 1000000009, 1000000021, 1000000033;
///=====================================================================================================================
#define int long long
        ///----- My code -----///



int32_t main (){

    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    cout.setf(ios::fixed);cout.precision(0);
//  freopen("a.in", "r", stdin);

    string s;
    cin >> s;
    bool ans = false;
    for(int i = 0; i < sz(s); i++){
        if(s[i] =='7'){
            ans=true;
            break;
        }
    }
    
    if(ans) cout << "Yes";
    else cout << "No";

    return 0;
}
/*
Test case:

*/



Measured memory_bytes: 3652
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
 for(v = 0; v < n; v++) {
 if(M[u][v] == 0) continue;
 if(color[v] == WHITE) {
    dfs_visit(v);
 }
 
}
color[u] = BLACK;
 f[u] = ++tt;

}

void dfs() {
  int u;

 for(u = 0; u < n; u++) color[u] = WHITE;
 tt = 0;

 for(u = 0; u < n; u++) {

 if(color[u] == WHITE) dfs_visit(u);

 }
 for(u = 0; u < n; u++) {

  printf("%d %d %d\n", u+1, d[u], f[u]);
}
}

 int main() {

 int u, v, k, i, j;

 scanf("%d", &n);
 for(i = 0; i < n; i++) {
   for(j = 0; j < n; j++) M[i][j] = 0;
 }

 for(i = 0; i < n; i++) {
  scanf("%d %d", &u, &k);
 u--;
 for(j = 0; j < k; j++) {
  scanf("%d", &v);
 v--;
 M[u][v] = 1;
}
}

 dfs();

 return 0;
}



Measured memory_bytes: 2064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Capp
{
    class Program
    {
        public enum En
        {
            a
            ,b
            ,c
            ,d
            ,e
            ,f
        }

        
        static void Main(string[] args)
        {
            var c = new Solve();
            c.S();

        }
    }

    public class Solve
    {
        List<int>[] es = new List<int>[10];
        int n;
        int m;
        int res = 0;
        // 訪問管理
        bool[] visit = new bool[10];
        private void rec(int x)
        {
            bool ok = true;
            for (int i = 0; i < n; i++)
            {
                if (!visit[i])
                    ok = false;
            }
            // 全て訪問済みならok
            if (ok)
            {
                res++;
                return;
            }

            foreach (var v in es[x])
            {
                // 訪問済みならcontinue
                if (visit[v]) continue;

                // 訪問済みにする
                visit[v] = true;

                rec(v);

                // 訪問解除する
                visit[v] = false;
            }
        }
        public void S()
        {
            var nm = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            n = nm[0];
            m = nm[1];
            for (int i = 0; i < 10; i++)
            {
                es[i] = new List<int>();
            }
            for (int i = 0; i < m; i++)
            {
                var s = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var a = s[0] - 1;
                var b = s[1] - 1;
                es[a].Add(b);
                es[b].Add(a);
            }
            // 頂点1を訪問する
            visit[0] = true;
            rec(0);
            Console.WriteLine(res);
        }
    }

    public class Test<T> : ITest<T>
    {
        public string S { get; set; }
    }

    public interface ITest<out T>
    {
        string S { get; set; }
    }

    struct c
    {
        public string s { get; set; }
        private dynamic _d;
        public dynamic d { get { return _d; }}
        public void Setd(dynamic d)
        {
            _d = d;
        }
    }
    class AsTest
    {
        internal async Task<int> AsyncMethod(int x)
        {
            var t1 = Task.Run(() =>
            {
                Thread.Sleep(10000);
                return 10 * x;
            });
            var res = await t1;
            Console.WriteLine($"asyncmethod {res}");


            return res;
        }

    }
}


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

const int M[12]= {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
//	freopen("inp.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n = 0;
	cin >> n;
	int t = n / 1.08 - 20;
	
	for(int i=t;i<=t + 40;i++) {
		int k = i * 1.08;
		if (k == n) {
			cout << i;
			return 0;
		}
	}
	
	cout << ":(";
	return 0;
}


Measured memory_bytes: 256
n, k, q = map(int, input().split())
a = list(int(input()) for i in range(q)) 
points = [k for _ in range(n)]


for i in range(q):
    points[a[i]-1] += 1

for j in range(n):
    points[j] -= q

    if points[j] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 11772
#include <string>
#include <vector>
#include <iostream>
using namespace std;
struct Editor : public vector<string>{
	int CurX;int CurY;
	string Buf;
	Editor(){CurX=0;CurY=0;Buf="";}
	vector<string>::iterator Iterator(int l){
		vector<string>::iterator it=begin();
		for(int i=0;i<l;i++)it++;
		return it;
	}
	void Show(){
		for(int i=0;i<size();i++){
			cout << at(i) << endl;
		}
	}
	void Cmd_a(){
		CurX=0;
	}
	void Cmd_e(){
		CurX=at(CurY).size();
	}
	void Cmd_p(){
		if(CurY!=0)CurY--;
		Cmd_a();
	}
	void Cmd_n(){
		if(CurY!=size()-1)CurY++;
		Cmd_a();
	}
	void Cmd_f(){
		if(CurX!=at(CurY).size()){
			CurX++;
		}else if(CurX==at(CurY).size()&&CurY!=size()-1){
			Cmd_n();
		}
	}
	void Cmd_b(){
		if(CurX!=0){
			CurX--;
		}else if(CurX==0&&CurY!=0){
			CurY--;
			Cmd_e();
		}

	}
	void Cmd_d(){
		if(CurX!=at(CurY).size()){
			(*this)[CurY]=at(CurY).substr(0,CurX)+at(CurY).substr(CurX+1);
		}else if(CurX==at(CurY).size()&&CurY!=size()-1){
			(*this)[CurY]+=at(CurY+1);
			erase(Iterator(CurY+1));
		}
	}
	void Cmd_k(){
		if(CurX==at(CurY).size()&&CurY!=size()-1){
			(*this)[CurY]+=at(CurY+1);
			erase(Iterator(CurY+1));
			Buf="\n";
		}else if(CurX!=at(CurY).size()){
			Buf=at(CurY).substr(CurX);
			(*this)[CurY]=at(CurY).substr(0,CurX);
		}
	}
	void Cmd_y(){
		if(Buf=="")return;
		if(Buf=="\n"){
			insert(Iterator(CurY+1),at(CurY).substr(CurX));
			(*this)[CurY]=at(CurY).substr(0,CurX);
			CurY++;CurX=0;
		}else{
			(*this)[CurY]=at(CurY).substr(0,CurX)+Buf+at(CurY).substr(CurX);
			CurX+=Buf.size();
		}
	}
	void Cmd(string cmd){
		if(cmd=="a"){
			Cmd_a();
		}
		if(cmd=="e"){
			Cmd_e();
		}
		if(cmd=="p"){
			Cmd_p();
		}
		if(cmd=="n"){
			Cmd_n();
		}
		if(cmd=="f"){
			Cmd_f();
		}
		if(cmd=="b"){
			Cmd_b();
		}
		if(cmd=="d"){
			Cmd_d();
		}
		if(cmd=="k"){
			Cmd_k();
		}
		if(cmd=="y"){
			Cmd_y();
		}
	}
};
int main(){
	string tmp;
	Editor ed;
	while(1){
		getline(cin,tmp);
		if(tmp=="END_OF_TEXT")break;
		ed.push_back(tmp);
	}
	while(1){
		getline(cin,tmp);
		if(tmp=="-")break;
		ed.Cmd(tmp);
	}
	ed.Show();
}

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

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

	for (int i = 0; i < str.length(); i++) {
		str[i] = (str[i] + n) > 'Z' ? str[i] + n - 'Z' + 'A' - 1 : str[i] + n ;
	}

	cout << str;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K, C;
string S;
signed main() {
    cin >> N >> K >> C >> S;
    vint a, b;
    int prev = INT_MIN;
    rep(i, N) {
        if (i - prev > C && S[i] != 'x') {
            a.push_back(i);
            prev = i;
        }
        if (a.size() == K) { break; }
    }
    prev = INT_MAX;
    for (int i = N - 1; i >= 0; i--) {
        if (prev - i > C && S[i] != 'x') {
            b.push_back(i);
            prev = i;
        }
        if (b.size() == K) { break; }
    }
    reverse(all(b));
    rep(i, K) { if (a[i] == b[i]) { cout << a[i] + 1 << endl; }}

}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    ll H,W,M;
    cin >> H >> W >> M;
    // vector<vector<bool>> A(H,vector<bool>(W));
    // rep(i,H)
    //     rep(j,W)
    //         A[i][j] = false;

    vll h(H,0),w(W,0);
    vector<pair<ll,ll>> hw(M);
    rep(m,M){
        ll i,j;
        cin >> i >> j;
        i--,j--;
        hw[m] = {i,j};
        h[i]++,w[j]++;
    }
    
    vll::iterator max_iter_h = max_element(h.begin(), h.end());
    ll max_h = *max_iter_h;
    vll::iterator max_iter_w = max_element(w.begin(), w.end());
    ll max_w = *max_iter_w;
    vll max_h_idxs,max_w_idxs;

    ll h_memo=0,w_memo=0;
    rep(i,H)
        if(h[i] == max_h)
            h_memo++;
    rep(i,W)
        if(w[i] == max_w)
            w_memo++;
    
    ll memo = 0;
    rep(i,M){
        ll h_ = hw[i].first;
        ll w_ = hw[i].second;
        if(h[h_] == max_h && w[w_] == max_w)
            memo++;
    }

    
    if(h_memo * w_memo == memo)
        cout << (max_h + max_w - 1) << endl;
    else
        cout << (max_h + max_w) << endl;
    
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 12744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    int k,s; cin>>k>>s;
    int ans=0;

    rep(i,0,k+1){
        rep(j,0,k+1){
            if(s-i-j>=0 and s-i-j<=k) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	Vec p(n);
	rep(i, n) cin >> p[i];

	vector<bool> same(n, false);
	rep(i, n) if(p[i] == i+1) same[i] = true;
	ll ans = 0, cnt = 0;
	rep(i, n){
		if(same[i]) cnt++;
		else{
			ans += (cnt+1)/2;
			cnt = 0;
		}
	}
	ans += (cnt+1)/2;
	co(ans);

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,s,a[N];
LL dp[3333][3333];
const LL mod=998244353;
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>s;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  if(a[1]!=s)dp[1][a[1]]=1;LL ans=0;
  if(a[1]==s)ans=n;
  for(int i=2;i<=n;i++){
    if(a[i]<s)dp[i][a[i]]+=i;
    dp[i][a[i]]%=mod;
    if(s>a[i]){
      ans+=dp[i-1][s-a[i]]*(n-i+1)%mod;
//      cout<<i<<' '<<dp[i-1][s-a[i]]<<endl;
    }
    else if(s==a[i])ans+=1ll*(n-i+1)*i%mod;
    for(int j=a[i];j<s;j++){
      dp[i][j]+=dp[i-1][j-a[i]];
      dp[i][j]%=mod;
    }
    for(int j=1;j<s;j++){
      dp[i][j]+=dp[i-1][j];
      dp[i][j]%=mod;
    }
    //cout<<i<<' '<<dp[i][s]*(n-i+1)<<'\n';
    ans%=mod;
  }
  cout<<ans<<'\n';
  return 0;
}


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

int main(){
  int n; cin >>n;
  string s; cin >> s;
  int k; cin >> k;
  char moji = s.at(k - 1);
  for(int i = 0; i < n; i++){
    if(s.at(i) != moji)
      cout << "*";
    else
      cout << moji;
  }
    
}
  
      

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
    int a[3][3]={0},i,j,n,m,cntr=0,cntc=0,cntd=0,b;
    
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    
    cin>>n;
    
    for(m=0;m<n;m++)
    {
        cin>>b;
        
        for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
            {
                if(a[i][j]==b)
                    a[i][j] = 0;
            }
        }
    }
    
    for(i=0;i<3;i++)
    {
        if(a[i][0]==0 && a[i][1]==0 && a[i][2]==0)
            cntr++;
    }
    for(i=0;i<3;i++)
    {
        if(a[0][i]==0 && a[1][i]==0 && a[2][i]==0)
            cntc++;
    }
    
    if(a[0][0]==0 && a[1][1]==0 && a[2][2]==0)
        cntd++;
        
    if(a[0][2]==0 && a[1][1]==0 && a[2][0]==0)
        cntd++;
        
    if(cntr>0 || cntc>0 || cntd>0)
        cout<<"Yes";
    else
        cout<<"No";
        
    return 0;
    
}

Measured memory_bytes: 256
/*
ID: mckibbe1
TASK: money
LANG: C++11
*/
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
using namespace std;
int dp[100011], a[100011];
int main() {
	//freopen("file.in", "r", stdin);
	//freopen("file.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie();
	int N; cin >> N;
	for (int i = 0; i < N + 2; i++) {
		cin >> a[i];
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		dp[i + 1] = min(dp[i + 1], abs(a[i] - a[i + 1]) + dp[i]);
		dp[i + 2] = min(dp[i + 2], abs(a[i] - a[i + 2]) + dp[i]);
	}
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a =sc.nextInt();
		int b =sc.nextInt();
		int c =sc.nextInt();
		int[] arr = new int[]{a,b,c};
		Arrays.sort(arr);
        System.out.println(arr[0]+" "+arr[1]+" "+arr[2]);

	}
}


Measured memory_bytes: 26344
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
int main() {
	int h[N], n, k;
	long long int cnt=0;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	sort(h, h+n);
	//greater<int>()
	for(int i = 0; i < n-k; i++)
	{
		cnt += h[i];
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int main()
{
	int N;
	cin >> N;
	string s;
	cin >> s;
	
	vector<char> seq(N, '?');
	char which[] = { 'S', 'W' };

	rep(i, 2) {
		rep(j, 2) {
			seq = vector<char>(N, '?');
			seq[0] = which[i]; //SS,SW,WS,WWの4通り
			seq[1] = which[j];
			bool con = ((seq[0] == 'S' && ((seq[1] == 'S' && s[0] == 'o') || (seq[1] == 'W' && s[0] == 'x')))
				||
				(seq[0] == 'W' && ((seq[1] == 'S' && s[0] == 'x') || (seq[1] == 'W' && s[0] == 'o')))); //SかWの判定

			seq[N - 1] = (con) ? 'S' : 'W'; //0と1からn-1が分かる

			int seq_first = seq[0];
			int seq_last = seq[N - 1];

			REP(k, 1, N) {
				con = ((seq[k] == 'S' && ((seq[k - 1] == 'S' && s[k] == 'o') || (seq[k - 1] == 'W' && s[k] == 'x')))
					||
					(seq[k] == 'W' && ((seq[k - 1] == 'S' && s[k] == 'x') || (seq[k - 1] == 'W' && s[k] == 'o'))));
				seq[(k + 1) % N] = (con) ? 'S' : 'W'; //2~n-1,0まで求める
			}

			if (seq[0] == seq_first && seq[N - 1] == seq_last) { //最初と最後が変更前と同じか
				rep(i, N) {
					cout << seq[i];
				}
				cout << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 640
import Data.List (sort, partition)

main :: IO ()
main = do
  getLine
  as <- map read . words <$> getLine
  bs <- map read . words <$> getLine
  let
    ds = zipWith subtract bs as
    (ps', ns) = partition (>= 0) ds
    ps = reverse $ sort ps'
    d = sum ns
  print $ maybe (-1) (+ length ns) $ f 0 ps d

f :: Int -> [Integer] -> Integer -> Maybe Int
f k _ n | n >= 0 = Just k
f _ [] _ = Nothing
f k (m : ms) n = f (k + 1) ms (m + n)


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

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) cout << C << endl;
    else if (B == C) cout << A << endl;
    else cout << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define ll long long

int bit[50];
ll dp[50][15];
ll dfs(int pos,int t,int lead,int lim)
{
    if(pos==0) return lead?0:1;
    if(!lim && !lead && dp[pos][t]!=-1) return dp[pos][t];
    int num = lim?bit[pos]:9;
    ll res = 0;
    for(int i=0;i<=num;i++)
    {
        if(lead)
        {
            if(i==0) res += dfs(pos-1,0,1,lim&&i==num);
            else res += dfs(pos-1,i,0,lim&&i==num);
        }
        else
        {
            if(fabs(t-i)<=1) res += dfs(pos-1,i,0,lim&&i==num);
        }
    }
    if(!lim&&!lead)return dp[pos][t]=res;
    else return res;
}
ll calc(ll k)
{
    int len = 0;
    while(k)
    {
        bit[++len] = k%10;
        k /= 10;
    }
    return dfs(len,0,1,1);
}

int main()
{
    memset(dp,-1,sizeof(dp));
    int n;
    scanf("%d",&n);
    ll L=0,R=1LL<<60;
    ll ans;
    while(L<=R)
    {
        ll mid = (L+R)>>1;
        if(calc(mid)>=n) R=mid-1,ans=mid;
        else L=mid+1;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 128
n = int(input())
a = [int(_) for _ in input().split()]

ret1 = []
ret2 = []

idx = 0
c = 1
while idx < n-1:
    if c and a[idx] < a[idx + 1]:
        ret1.append(a[idx])
        c = not(c)
    if not(c) and a[idx] > a[idx+1]:
        ret2.append(a[idx])
        c = not(c)
    idx += 1
if not(c):
    ret2.append(a[idx])
ans = 1000
for i in range(len(ret1)):
    ans += (ret2[i]-ret1[i]) * (ans//ret1[i])

print(ans)


Measured memory_bytes: 9220
import random
import sys
input = sys.stdin.readline
#import copy
D=int(input())                                          #コンテの日数
c=list(map(int,input().split()))                        #26タイプ(AAC~AZC)のコンテストの満足度低下度
s=[list(map(int,input().split())) for _ in range(D)]    #s[d][i]...d(1<=d<=D)日目にi(1<=i<=26)番目のコンテストを行った時の満足度上昇
#types=[int(input()) for _ in range(D)]                  #コンテタイプ(1~26)
#満足度低下はΣ(1<=i<=26)ci*(d-last(d,i))                  #なおlast(d,i)=d日目以前に最後にタイプiのコンテストをやった日にち(ない場合0)
#よって満足度はs[d][i]-Σ(1<=i<=26)ci*(d-last(d,i))
#i日目のスコアはmax(10^6+s[d][i]-Σ(1<=i<=26)ci*(d-last(d,i)),0)
#last=[0]*26                                             #typeごとに、最後に使われた日にちを記録するよ
typ=0
ans=0
types=[(i%26)+1 for i in range(D)]
#print(l)
sc = [0] * D
last=[0]*26
#print(c,s)
for i in range(D):
    typ = types[i] - 1
    score = s[i][typ]
    dwn = 0
    last[typ] = (i + 1)
    for j in range(26):
        dwn = dwn + c[j] * ((i + 1) - last[j])
    ans = score - dwn
    # print(score,last)
    sc[i] = max(ans+10**6,0)
all = sum(sc)
for _ in range(25000):
    types2 = [0]*D
    mi=float("inf")
    ind=0
    for i in range(D):
        if mi>sc[i]:
            mi=sc[i]
            ind=i
    l=list(range(1,D+1))
    #print(l)
    #print(ind,types[ind]-1)
    l.pop(ind-1)
    ind2=random.choice(l)
    spans=ind//26
    for i in range(D):
        types2[i]=types[i]
    buf=types[ind]
    types[ind]=types[ind2-1]
    types[ind2-1]=buf
    sc2=[0]*D
    last=[0]*26
    for i in range(D):
        typ = types[i] - 1
        score = s[i][typ]
        dwn = 0
        last[typ] = (i + 1)
        for j in range(26):
            dwn = dwn + c[j] * ((i + 1) - last[j])
        ans = score - dwn
                # print(score,last)
        sc2[i] = max(ans+10**6,0)
    all2 = sum(sc2)
    if all2<=all:
        types=types2
    else:
        sc=sc2
        all=all2
        sc2=[]
        #print(114514)
    #print(all)
    #input()
for i in range(D):
    print(types[i])







Measured memory_bytes: 85760
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val a, b, c = sc.nextInt()
    val ans = if(a==b&&b==c) {
      1
    } else if(a==b || b == c || c == a) {
      2
    } else {
      3
    }
    println(ans)
  }
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string t; cin >> t;

    for (int i = 0; i < t.size(); ++i) {
        if (i - 1 >= 0 && t[i] == '?' && t[i - 1] == 'P') {
            t[i] = 'D';
            continue;
        }

        if (i == t.size() - 1 && t[i] == '?') {
            t[i] = 'D';
            continue;
        }

        if (t[i] == '?' && t[i + 1] == 'D') {
            t[i] = 'P';
            continue;
        }

        if (t[i] == '?' && t[i + 1] == 'P') {
            t[i] = 'D';
            continue;
        }

        if (t[i] == '?' && t[i + 1] == '?') {
            if (i - 1 >= 0 && t[i - 1] == 'P') {
                t[i] = 'D';
                t[i + 1] = 'P';
                continue;
            } else {
                t[i] = 'P';
                t[i + 1] = 'D';
                continue;
            }
        }

        if (t[i] == '?') {
            t[i] = 'D';
            continue;
        }
    }

    cout << t << endl;
}

Measured memory_bytes: 3680
S = input().split()
N = int(S[0])
K = int(S[1])
Q = int(S[2])

each_point = [0 for _ in range(N)]
for _ in range(Q):
    a = int(input())
    each_point[a-1] += 1

for point in each_point:
    if K - Q + point <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 4704
n = int(input())
d = []
for _ in range(n):
    d.append(list(map(int, input().split())))

cnt = 0
for i in d:
    if i[0] == i[1]:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        print('Yes')
        exit()

print('No')


Measured memory_bytes: 9176
import numpy as np

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

a=np.sort(np.array(a))
tmp=a[0]
k=0

for i in range(1,n):
  if tmp==a[i]:
    k=1
  else:
    tmp=a[i]
    
if k==0:
  print("YES")
else:
  print("NO")

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

#define ll long long
#define pb push_back
#define iter std::vector<int>::iterator

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

	long double r; cin >> r;

	long double pi = 2 * acos(0.0); 

	long double c = 2 * pi * r;

	cout << c;


	return 0;
}



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

const int MOD = 1000000007;

int mul(int a, int b, int m)
{
	int r = 0;
	a %= m, b %= m;
	while (b) {
		if (b&1) r = (r+a)%m;
		a = (a<<1)%m;
		b >>= 1;
	}
	return r;
}

int pwr(int b, int e, int m)
{
	if (e == 0) return 1;
	if (e == 1) return b%m;
	return mul(pwr(mul(b, b, m), e/2, m), (e&1)?b:1, m);
}

int add(int a, int b, int m)
{
	a %= m, b %= m;
	return (a+b)%m;
}

int sub(int a, int b, int m)
{
	a %= m, b %= m;
	return (a-b+m)%m;
}

int main()
{
	int n;
	scanf("%d", &n);
	printf("%d\n", sub(add(pwr(10, n, MOD), pwr(8, n, MOD), MOD), add(pwr(9, n, MOD), pwr(9, n, MOD), MOD), MOD));
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

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

int soinsu(int n) {
    int res = 0;
    int a = 2;
    while(n >= a*a) {
        if(n%a == 0) {
            res++;
            while(n%a==0) n /= a;
        }
        a++;
    }
    if(n>1) res++;
    return res;
}

signed main() {
    int A, B;
    cin >> A >> B;
    if(B > A) swap(A, B);
    
    int g = gcd(A, B);
    int res = soinsu(g) + 1;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

int main(){
  int n,i,j,e,sum;
  int M[MAX][MAX];
  int u,v;
  int minv;
  int d[MAX];
  int p[MAX];
  int vis[MAX];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j] = ( e==-1)?INFTY:e;
    }
  }

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    vis[i]=0;
    }
  
  
  d[0]=0;
  
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&!vis[i]){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    vis[u]=1;
    for(v=0;v<n;v++){
      if(!vis[v]&&M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	}
      }
    }
  }

  sum=0;

  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }

  printf("%d\n",sum);
  
  return 0;
}



Measured memory_bytes: 2060
N = int(input())
S = input()
num_r = 0
num_g = 0
num_b = 0

for i in range(N):
  if S[i] == "R":
    num_r += 1
  if S[i] == "G":
    num_g += 1
  if S[i] == "B":
    num_b += 1

rgb = num_r*num_g*num_b
x = 0

for i in range(N):
  for m in range(N):
    j = i + m
    k = j + m
    if k > N - 1:
      break
    elif S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      x += 1
rgb -= x
print(rgb)



Measured memory_bytes: 9228
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)
#define int long long

using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///====code start here====///

signed main() {
	fastio;
	int test; cin >> test;
	while(test--) {
		int n; cin >> n;
		ll k, l, r, ans = 0;
		vector<vl> left(n), right(n);
		
		rep(i, 0, n) {
			cin >> k >> l >> r;
			
			ans += min(l, r);
			if(l > r) left[k - 1].pb(l - r);
			else right[k - 1].pb(r - l);
		}
		
		priority_queue<ll> pq;
		
		Rep(i, n - 1, -1) {
			rep(j, 0, (int)left[i].size()) pq.push(left[i][j]);
			if(!pq.empty()) {
                ans += pq.top();
                pq.pop();
            }
		}
		
		while(!pq.empty()) pq.pop();
		rep(i, 0, n) {
			if(!pq.empty()) {
				ans += pq.top();
				pq.pop();
			}
			rep(j, 0, (int)right[i].size()) pq.push(right[i][j]);
		}
		
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 17420
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int R[n];
    for(int i=0;i<n;i++){
        cin >> R[i];
    }
    int maxv=-1e9;
    for(int i=0;i<n-1;i++){
        maxv=max(maxv,R[i+1]-R[i]);
        R[i+1]=min(R[i],R[i+1]);
    }
    cout << maxv << endl;
}
    


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT
 
#define sz(x) ((int)x.size())
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
 
#define FILENAME ""
 
const ll maxn = 2e5 + 50;
const int mod = 1000000007;
const int L = 10 * 1000 + 7;
const int S = 107;

void add_self (int& a, int b) {
 	a += b;
 	if (a >= mod) {
 	 	a -= mod;
 	}
}

int dp[L][S][2];
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);                                                         
	int d;
	string s;
	cin >> s >> d;
	dp[0][0][0] = 1;
	for (int i = 0; i < sz(s); i++) {
	 	for (int j = 0; j < d; j++) {
	 		for (int k = 0; k < 2; k++) {
	 			int r = 9;
	 			if (k == 0) {
	 			 	r =  s[i] - '0';
	 			}
	 		 	for (int dig = 0; dig <= r; dig++) {
	 		 		int r1 = k;
	 		 	 	if (((s[i] - '0') > dig)) {
	 		 	 		r1 = 1; 	
	 		 	 	}
	 		 	 	add_self(dp[i + 1][(j + dig) % d][r1], dp[i][j][k]);
	 		 	}
	 		}
	   	}
	}
	int answer = (dp[sz(s)][0][0] + dp[sz(s)][0][1]) % mod;
	answer = (answer + mod - 1) % mod; 
	cout << answer;
   	return 0;
}


Measured memory_bytes: 8576
from itertools import product

a,b,c,d=map(int,list(input()))
op = ['+','-']
for p in product(range(2),repeat=3):
  txt=f'{a}{op[p[0]]}{b}{op[p[1]]}{c}{op[p[2]]}{d}'
  if eval(txt)==7:
    print(txt+'=7')
    exit()

Measured memory_bytes: 9208
package main

import (
	"fmt"
	"sort"
)

// 4 3
// 3 3 -4 -2
func main() {
	var N, K int
	fmt.Scanf("%d %d\n", &N, &K)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		var a int
		fmt.Scanf("%d", &a)
		A[i] = a
	}
	sort.Ints(A)
	ld, rd := int(-1e18), int(1e18)
	for rd-ld > 1 {
		mid := (ld + rd) / 2
		//fmt.Println(ld, rd, mid)
		cnt := 0
		for i := 0; i < N; i++ {
			l, r := -1, N
			if A[i] >= 0 {
				for r-l > 1 {
					m := (l + r) / 2
					//fmt.Println(l, r, m)
					if A[i]*A[m] >= mid {
						r = m
					} else {
						l = m
					}
					//time.Sleep(time.Second * 2)
				}
				cnt += r
			} else {
				for r-l > 1 {
					m := (l + r) / 2
					//fmt.Println(l, r, m)
					if A[i]*A[m] >= mid {
						l = m
					} else {
						r = m
					}
					//time.Sleep(time.Second * 2)
				}
				cnt = cnt + N - r
			}
			if A[i]*A[i] < mid {
				cnt -= 1
			}
		}
		cnt = cnt / 2
		//fmt.Println(cnt, ld, rd, mid)

		if cnt >= K {
			rd = mid
		} else {
			ld = mid
		}
		//time.Sleep(time.Second * 2)
	}
	fmt.Println(ld)
}


Measured memory_bytes: 5632
N,M=map(int,input().split())
Q=[[int(i) for i in input().split()] for i in range(M)]
Q.sort(key=lambda x:x[1])
mod=10**9+7
dp=[[[0]*max(1,c) for c in range(max(1,b+1))] for b in range(N+1)]
dp[0][0][0]=1
k=0
for a in range(N+1):
  check=[]
  if k<=M-1:
    while a==Q[k][1]:
      l,r,x=Q[k]
      check.append((l,r,x))
      k+=1
      if k==M:
        break
  for b in range(max(1,a)):
    for c in range(max(1,b)):
      for l,r,x in check:
        if x==1:
          if not b<l:
            dp[a][b][c]=0
            continue
        elif x==2:
          if not (b>=l and c<l):
            dp[a][b][c]=0
            continue
        elif x==3:
          if not c>=l:
            dp[a][b][c]=0
            continue
      dp[a][b][c]%=mod
      if a<=N-1:
        dp[a+1][b][c]+=dp[a][b][c]
        dp[a+1][a][c]+=dp[a][b][c]
        dp[a+1][a][b]+=dp[a][b][c]
ans=0
for b in range(N):
  for c in range(max(1,b)):
    ans+=dp[N][b][c]
    ans%=mod
print(ans)


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

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

    int m; cin >> m;
    vector<string> t(m);
    for(int i = 0; i < m; ++i){
        cin >> t[i];
    }

    auto culc = [&](string st){
        int count = 0;
        for(string str: s){
            if(st == str){
                count++;
            }
        }
        for(string str: t){
            if(st == str){
                count--;
            }
        }
        return count;
    };

    int ans = 0;
    for(string str: s){
        ans = max(ans, culc(str));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    List<String> list = new ArrayList<>();

    while (sc.hasNextLine()) {
      String str = sc.nextLine();
      list.add(str);
    }
    
    Map<String, List<String>> grp = list.stream().collect(Collectors.groupingBy(s -> s));
    
    System.out.println("AC" + " x "  +  grp.getOrDefault("AC", Collections.emptyList()).size());
    System.out.println("WA" + " x "  +  grp.getOrDefault("WA", Collections.emptyList()).size());
    System.out.println("TLE" + " x "  +  grp.getOrDefault("TLE", Collections.emptyList()).size());
    System.out.println("RE" + " x "  +  grp.getOrDefault("RE", Collections.emptyList()).size());

  }
}

Measured memory_bytes: 67248
N = int(input())
a = []
for i in range(N):
    b = list(input().split())
    b[1] = int(b[1])
    b.append(i+1)
    a.append(b)
c = sorted(a, key = lambda x:(x[0], -x[1]))
for l in range(N):
    print(c[l][2])

Measured memory_bytes: 3060
package main

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

func calcTime(t int, x int) float64 {
	ans := float64(t) / float64(x)
	return ans
}

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	text := stdin.Text()
	textSlice := strings.Split(text, " ")
	t, _ := strconv.Atoi(textSlice[0])
	x, _ := strconv.Atoi(textSlice[1])
	ans := calcTime(t, x)
	fmt.Printf("%.10f", ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    
char s[256];
    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;
    
    for (auto i:s)
        s[i]++;
    if (s['A']&&s['B']) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

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

#define ENDL '\n'
#define sayy cout<<"YES"<<ENDL;
#define sayn cout<<"NO"<<ENDL;

int main(){

   string s,t;
   cin >> s >> t;

    int ans(0);
    for (int i(0); i < 3; i++) {
        if(s[i] == t[i]) ans++;
    }
    cout << ans << ENDL;

    return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct edge{
  ll to,cost;
};
vector<vector<edge>>E(222222);
ll ans[222222];
void dfs(ll now,ll par){
  for(auto a:E[now]){
    if(par == a.to)continue;
    if(a.cost%2){
      ans[a.to]=(ans[now]+1)%2;
      dfs(a.to,now);
    }else{
      ans[a.to]=ans[now];
      dfs(a.to,now);
    }
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  for(int i=0;i<n-1;i++){
    ll u,v,w;cin>>u>>v>>w;
    E[--u].pb({--v,w});
    E[v].pb({u,w});
  }
  ans[0]=0;
  dfs(0,-1);
  for(int i=0;i<n;i++)
    cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 13056
import copy
n=int(input())
t=list(map(int,input().split()))

pro=[]
m=int(input())

for i in range(m):
    pro.append(list(map(int,input().split())))

for j in range(m):
    ans=copy.deepcopy(t)
    x=pro[j][0]
    p=pro[j][1]
    ans[x-1]=p
    print(sum(ans))


Measured memory_bytes: 3444