akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

    class Main{
        static final int n = 8;
        static boolean[] row = new boolean[n];
        static boolean[] col = new boolean[n];
        static boolean[] dpos = new boolean[2*n -1];
        static boolean[] dneg = new boolean[2*n -1];
        static boolean[][] X = new boolean[n][n];
        static void print_Board(){
          int i,j;
            for(i=0;i<n;i++){
                for(j=0;j<n;j++){
                    if(X[i][j]){
                        if(j==n-1)
                            System.out.println("Q");
                        else
                            System.out.print("Q");
                    }
                    else{
                        if(j==n-1)
                            System.out.println(".");
                        else System.out.print(".");
                    }
                }
            }
        }
        static void putQueen(int i){
          int j;
            if(i==n){
                print_Board();
                return;
            }
            else{
                for(j=0;j<n;j++){
                    if(X[i][j])
                        putQueen(i+1);
                    else if(col[j] || dpos[i+j] || dneg[i-j+n-1]){
                        continue;
                    }
                    else{
                        row[i] = true;
                        col[j] = true;
                        dpos[i+j] = true;
                        dneg[i-j+n-1] = true;
                        X[i][j] = true;
                        putQueen(i+1);
                        row[i] = false;
                        col[j] = false;
                        dpos[i+j] = false;
                        dneg[i-j+n-1] = false;
                        X[i][j] = false;
                    }
                }
                return;
            }
        }
        public static void main(String[] args){
            Scanner scan = new Scanner(System.in);
            int k = scan.nextInt();
            int i,j;
            for(i=0;i<n;i++){
                row[i] = false;
                col[i] = false;
            }
            for(i=0;i<2*n-1;i++){
                dpos[i] = false;
                dneg[i] = false;
            }
            for(i=0;i<n;i++)
                for(j=0;j<n;j++)
                    X[i][j] = false;
            for(i=0;i<k;i++){
                int x = scan.nextInt();
                int y = scan.nextInt();
                X[x][y] = true;
                row[x] = true;
                col[y] = true;
                dpos[x+y] = true;
                dneg[x-y+n-1] = true;
            }
            putQueen(0);
        }
    }



Measured memory_bytes: 26424
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n;
  cin >> n;
  vector<char> data(n);
  rep(i,n) cin >> data[i];
  in6 ans = 0;
  char c = 1;
  rep(i,n) {
    if(c == data[i]) continue;
    else {
      ans++;
      c = data[i];
    }
  }
  cout << ans;
  hinata;
}

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

int N;
int a[100010];
int data[100010];

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

    cin >> N;

    int m = 0;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        a[i]++;
        data[a[i]]++;
        data[a[i] - 1]++;
        data[a[i] + 1]++;
        m = max(m, a[i] + 1);
    }

    int cnt = 0;
    for(int i = 0; i <= m; ++i){
        cnt = max(cnt, data[i]);
    }
    cout << cnt << endl;

	return 0;
}

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

#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ll long long
//π M_PI
//deg = rad*180/M_PI

int main() {
    string s;
    cin >> s;
    if ( s.length() == 1 ) {
        cout << 1 << endl;
        return 0;
    }
    std::vector<ll> v;
    ll num = 0;
    if ( s[0] == '<' ) {
        v.push_back(0);
    } else {
        num++;
    }
    bool keep = false; //<>keep
    ll keep_num;

    for (ll i = 1; i < s.length(); ++i) {
        if ( s[i] == '<' ) {
            if ( s[i-1] == '<' ) {
                v.push_back(v[v.size()-1]+1);
            } else {
                if (keep) {
                    if ( keep_num >= num ) {
                        v.push_back(keep_num+1);
                        num--;
                    }
                }
                v.push_back( ((num+1)*num)/2 );
                v.push_back(0);
                num = 0;
                keep = false;
            }
        } else { //>
            if ( s[i-1] == '<' ) {
                keep = true;
                keep_num = v[v.size()-1];
                num++;
                if ( i == s.length()-1 ) {
                    if ( s[s.length()-2] == '<') {
                        v.push_back(v[v.size()-1]+1);
                    } else {
                        v.push_back(1);
                    }
                    v.push_back(0);
                }
            } else {
                num++;
                if ( i == s.length()-1 ) {
                    if (keep) {
                        keep = false;
                        if ( keep_num >= num ) {
                            v.push_back(keep_num+1);
                        }
                    }
                    v.push_back( ((num+1)*num)/2 );
                    v.push_back(0);
                }
            }
        }

        if ( i == s.length()-1 ) {
            if ( s[i] == '<' ) {
                v.push_back(v[v.size()-1]+1);
            }
        }
    }
    cout << accumulate(v.begin(), v.end(), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 6392
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
		boolean check = false;
		for (int i = 0; i < s.length(); i++) {
			char ch = s.charAt(i);
			if (ch == '7') {
				check = true;
				break;
			}
		}

		if (check) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35684
<?php
  $N=intval(fgets(STDIN));
  $L[0]=2;
  $L[1]=1;
  $cnt=2;

  if($N==1)
  {
    echo"$L[1]";
  }
  else
  {
    while($cnt<($N+1))
    {
      $L[$cnt]=$L[($cnt-1)]+$L[($cnt-2)];
      $cnt++;
    }
    echo"$L[$N]";
  }
?>

Measured memory_bytes: 4856
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>,rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
const int N = 2e5 + 5;
int n , a[N];
ll ans;
ordered_set st1 , st2;
int main() {
    abdelrahman010
    cin >> n;
    for(int i = 0;i < n;i++) {
        int x;
        cin >> x;
        st1.insert(x);
    }
    for(int i = 0;i < n;i++)
        cin >> a[i];
    for(int i = 0;i < n;i++) {
        int x;
        cin >> x;
        st2.insert(-x);
    }
    for(int i = 0;i < n;i++)
        ans += 1ll * st1.order_of_key(a[i]) * st2.order_of_key(-a[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 9984
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,X,L;
    cin >> N >> X;
    ll H=0,ans=1,i;
    for(i=0;i<N;i++){
        cin >> L;
        H+=L;
        if(H<=X)ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder1
{
    class Program2
    {
        static void Main()
        {
            // A の中の転倒数*K + 別のAに存在する転倒数を Σ(K-1) * それぞれの値

            var input = Console.ReadLine().Split(' ').Select(long.Parse);
            var N = input.First();
            var K = input.Skip(1).First();
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var m = (long)Math.Pow(10, 9) + 7;

            decimal ans = 0;
            for (int i = 1; i < N; i++)
            {
                var tmp = 0L;
                for (int j = 0; j < i; j++)
                {
                    if (A[j] > A[i]) tmp++;
                }

                ans += (tmp % m) * K % m;
                ans %= m;
            }

            decimal sigma = K * (K - 1) / 2;

            for (int i = 0; i < N; i++)
            {
                var tmp = 0L;
                for (int j = 0; j < N; j++)
                {
                    if (A[j] > A[i]) tmp++;
                }

                ans += sigma * tmp % m;
                ans %= m;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

vector<string> v;
signed main(void)
{
	cin.sync_with_stdio(false);
	while(true) {
		string s;
		cin >> s;
		if(s == "#") break;
		const int n = s.size();
		v.clear();
		set<string> st;
		string t;
		REP(i, 1<<n) {
			t = s;
			REP(j, n) {
				if((1<<j)&i && s[j] != 'z') {
					t[j] = t[j] + 1;
				}
				//cout << t << " i:" << j << " s[j]:" << s[j] << endl;
			}
			//cout << "t:" << t << endl;
			string tmp = t;
			bool f[26] = {};
			REP(j, n) {
				if(t[j] != 'a' && !f[t[j]-'a']) {
					f[t[j]-'a'] = true;
					t[j] = t[j] - 1;
				}
			}
			if(t == s) {
				st.insert(tmp);
			}
		}

		for(string i: st) v.PB(i);
		cout << v.size() << "\n";
		if(v.size() <= 10) {
			REP(i, v.size()) {
				cout << v[i] << "\n";
			}
		} else {
			REP(i, 5) cout << v[i] << "\n";
			FOR(i, v.size()-5, v.size()) cout << v[i] << "\n";
		}
}
	return 0;
}

Measured memory_bytes: 5268
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B, K;
	vector<int> x;
	
	cin>>A>>B>>K;
	
	for(int i = A; i < K+A && i <= B; i++){
		x.push_back(i);
	}
	
	
	for(int i = max(B-K+1, A); i <= B; i++){
		x.push_back(i);
	}
	
	sort(x.begin(), x.end());
	x.erase(unique(x.begin(), x.end()),x.end());
	
	for(int i = 0; i < x.size(); i++){
		cout<<x[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import sys
from fractions import Fraction
for x1, y1, x2, y2, x3, y3, x4, y4 in (map(Fraction, l.split()) for l in sys.stdin.readlines()):
    if (x2-x1)*(x4-x3) + (y4-y3)*(y2-y1) == 0:
        print("YES")
    else:
        print("NO")


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

int main() {
    string a, b;
    cin >> a >> b;

    string repa = a;
    rep(i, stoi(b)-1)
    {
        repa += a;
    }

    string repb = b;
    rep(i, stoi(a)-1)
    {
        repb += b;
    }

    vector<string> vs = {repa, repb};
    sort(vs.begin(), vs.end());
    cout << vs[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint N, A;

int main(void)
{
	cin >> N >> A;
	
	if(N == 1){
		cout << 1 << endl;
		return 0;
	}
	
	llint ans = 1e18;
	for(int k = 1; k < 50; k++){
		llint ub = N+1, lb = 0, mid;
		while(ub - lb > 1){
			mid = (ub + lb) / 2;
			llint mul = 1;
			for(int i = 0; i < k; i++){
				if(mul >= (N+mid-1) / mid){
					mul = N;
					break;
				}
				mul *= mid;
			}
			if(mul >= N) ub = mid;
			else lb = mid;
		}
		llint s = ub;
		
		ub = k, lb = 0, mid;
		while(ub - lb > 1){
			mid = (ub + lb) / 2;
			llint mul = 1;
			for(int i = 0; i < k-mid; i++){
				if(mul >= (N+s-1) / s){
					mul = N;
					break;
				}
				mul *= s;
			}
			for(int i = k-mid; i < k; i++){
				if(mul >= (N+s-2) / (s-1)){
					mul = N;
					break;
				}
				mul *= s-1;
			}
			if(mul >= N) lb = mid;
			else ub = mid;
		}
		llint x = lb;
		
		//cout << k << " " << s << " " << x << endl;
		ans = min(ans, s*k-x + A*(k-1));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    double R;
    cin>>R;
    double PI = 3.1415926535;
    cout<<setprecision(10)<<2*PI*R<<endl;
}



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

int main(){
ll h,n,sum=0;
cin>>sum>>h;
if (sum==h)
{
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}



}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

enum MAX = 1_000_100;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto G = new long[][](n, 0);
    auto P = new Pair[](n - 1);
    foreach (i; iota(n - 1))
    {
        long a, b;
        scan(a, b);
        a--, b--;
        G[a] ~= b, G[b] ~= a;
        P[i] = Pair(a, b);
    }
    long root;
    iota(1, n).each!(x => root = G[x].length > G[root].length ? x : root);
    G[root].length.writeln();
    auto edge = new long[long][](n);
    auto Q = DList!long(root);
    while (!Q.empty)
    {
        auto current = Q.front();
        Q.removeFront();
        long used, cnt = 1;
        if (!edge[current].keys.array.empty)
            used = edge[current][edge[current].keys[0]];
        foreach (g; G[current])
        {
            if (g in edge[current])
                continue;

            if (cnt == used)
                cnt++;
            
            edge[current][g] = edge[g][current] = cnt++;
            Q.insertBack(g);
        }
    }
    // edge.writeln();
    foreach(p; P)
        writeln(edge[p.a][p.b]);
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 36860
N,M = map(int,input().split())
H = list(map(int,input().split()))
obs = {}
for i in range(1,N+1):
  obs[i] = []
for i in range(M):
  A,B = map(int,input().split())
  obs[A].append(B)
  obs[B].append(A)

cnt = N

for i in range(1,N+1):
  h = H[i-1]
  l = len(obs[i])
  for j in range(l):
    if H[obs[i][j]-1] >= h:
      cnt -= 1
      break
      
print(cnt)

Measured memory_bytes: 37832
N = int(raw_input())
nums = map(int, raw_input().split(" "))

count = 0
for i in range(0, len(nums)):
    mini = i
    for j in range(i, len(nums)):
        if nums[mini] > nums[j]:
            mini = j
    if i != mini:
        count += 1
    temp = nums[i]
    nums[i] = nums[mini]
    nums[mini] = temp


nums = map(str, nums)
print(" ".join(nums))
print(count)

Measured memory_bytes: 6384
#coding:utf-8
def main():
    s = raw_input()
    t = raw_input()
    
    if min(s) <  max(t):
        print "Yes"
    elif s.count(s[0]) == len(s) and t.count(t[0]) == len(t) and len(s) < len(t):
        print "Yes"
    else:
        print "No"

if __name__=="__main__":
    main()


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

int main() {
  long long  x;
  cin >> x;
  long long y;
  y = x/11;
  x = x%11;
  if(x == 0){
    cout << 2*y << endl;
  }
  else if(0<x && x<7){
    cout << 2*y +1 << endl;
  }
  else {
    cout << 2*y +2 << endl;
  }
  
  return 0;
}


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

using namespace std;

int main() {

	int n, m;

	cin >> n >> m;

	vector<int> v(n,0);

	for (int i = 0; i < m; i++) {

		int a, b;
		cin >> a >> b;

		v[a - 1]++;
		v[b - 1]++;

	}

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

		cout << v[i] << endl;

	}

	return 0;

}

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

 int main(){ 

 int n, d, s, ans;
 cin >> n >> d;

 s =  d * 2 + 1;
 ans = n / s;

 if (n % s != 0) ans++;
 cout << ans << endl;

 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main()
{
  int a[10], i, j, mpos;

  for(i = 0;i < 10;i++)
    scanf("%d", &a[i]);

  for(i = 0;i < 3;i++){
    mpos = 0;
    for(j = 0;j < 10;j++){
      if(a[mpos] < a[j])
	mpos = j;
    }
    printf("%d\n", a[mpos]);
    a[mpos] = 0;
  }
  return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '?'){
      s[i] = 'D';
    }
  }
  cout << s << endl;
  // int ans = 0;
  // if(s[0] == 'D') ans ++;
  // for(int i = 1; i < s.size(); i++){
  //   if(s[i] == 'D') ans ++;
  //   if(s[i-1] == 'P' && s[i] == 'D') ans ++;
  // }

  return 0;
}

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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n;
    cin >> n;
    vi tmp(n),a(n),b(n);
    ffor(i,n) cin >> a[i];
    ffor(i,n) cin >> b[i];
    ffor(i,n) tmp[i] = i + 1;
    int ac = 0,bc = 0;
    int cur = 0;
    do{
        if(tmp == a)ac = cur;
        if(tmp == b)bc = cur;
        ++cur;
    }while(next_permutation(all(tmp)));
    // cout << ac << ' ' << bc << ' ';
    cout << abs(ac - bc);
}

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

using namespace std;

int main(){
    int N, M;
    int T[100], X[100], P[100];
    //入力
    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> T[i];
    }
    cin >> M;
    for(int i = 0; i < M; ++i){
        cin >> P[i] >> X[i];
    }
    //出力
    for(int i = 0; i < M; ++i){
        int ans = 0;
        for(int j = 0; j < N; ++j){
            if(j == P[i] - 1){
                ans += X[i];
            }else{
                ans += T[j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        int t;
        cin >> t;
        a[i] = b[i] = t;
    }
    sort(b.begin(), b.end());
    int l = -1, r = n - 1;
    while(r - l > 1) {
        int c = (l + r) / 2;
        int m = b[c];
        ll cnt = 0;
        BIT<ll> d(3 * n + 5);
        int s = 0;
        rep(i, n + 1) {
            int t = i - 2 * s + 2 * n;
            cnt += d.sum(t - 1);
            d.add(t);
            if (i < n) s += a[i] > m;
        }
        ll len = (ll)n * (n + 1) / 2;
        if (len - cnt < (len + 1) / 2) {
            r = c;
        } else {
            l = c;
        }
    }
    cout << b[r] << endl;
}

Measured memory_bytes: 6420
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int MAX = 999999999;

int search(ll n, ll num, int cnt){
    if(num > n) return cnt;

    string tmp = to_string(num);
    int n_3 = count(all(tmp), '3');
    int n_5 = count(all(tmp), '5');
    int n_7 = count(all(tmp), '7');
    if(n_3 + n_5 + n_7 == tmp.size() && n_3 > 0 && n_5 > 0 && n_7 > 0){
        cnt ++;
    }

    cnt = search(n, num*10+3, cnt);
    cnt = search(n, num*10+5, cnt);
    cnt = search(n, num*10+7, cnt);

    return cnt;
}

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

    cout << search(n, 0, 0) << endl;;
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
// const int MOD = 1e9 + 7;
const ull MOD = 2019;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  ull L, R;
  cin >> L >> R;
  dump(L, R);
  ull diff = R - L;
  if (MOD < diff)
    diff = MOD;
  ull ans = LINF;
  for (ull i = L; i <= min(L + diff, R); i++) {
    for (ull j = max(i + 1, R - diff); j <= R; j++) {
      ans = min(ans, (i * j) % MOD);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
dict={}
while n > 0:
    s = input()
    if s in dict.keys():
        dict[s] = dict[s] + 1
    else:
        dict[s]=1
    n = n - 1
maxnum = 0
for v in dict.values():
    if v > maxnum:
        maxnum = v
a=[]
for k,v in dict.items():
    if v == maxnum:
        a.append(k)
a.sort()
for s in a:
    print(s)


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

int main() {
    string t;
    cin >> t;
    for(int i=0; i<t.length(); i++) {
        if(t[i]=='?') {
            t[i] = 'D';
        }
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3756
//In the name of God
//SMani24
#include<bits/stdc++.h>
using namespace std;

int n;
string s, t;

int main() {
	cin >> n >> s >> t;
	for (int i = 0; i < n; i++)
		cout << s[i] << t[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
import numpy as np
a = list(range(1,n+1))
b = list(range(1,n+1))
c = [0] * n
for i in range(n):
  while a[i] % 2 == 0:
    a[i] /= 2
    c[i] += 1
print(b[np.argmax(c)])




Measured memory_bytes: 14536
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)

ll mini(ll *A,int N,int s1,int s2,int s3){
    if(s2==s1 || s2==s3 || s1==0) return A[N];
    ll m=A[N],M=0;
    M=max(M,A[s1]); m=min(m,A[s1]);
    M=max(M,A[s2]-A[s1]); m=min(m,A[s2]-A[s1]);
    M=max(M,A[s3]-A[s2]); m=min(m,A[s3]-A[s2]);
    M=max(M,A[N]-A[s3]); m=min(m,A[N]-A[s3]);
    return M-m;
}

int main(){
    int N;
    ll A[200001],a;
    cin>>N;
    A[0]=0;
    Rep(i,N) {
        cin>>a;
        A[i]=A[i-1]+a;
    }
    ll ans=A[N];
    int s1=1,s2=2,s3=3;
    while(s2<N-1){
        s3=max(s3,s2+1);

        while(true){
            if(s2-s1==1 || A[s1]>A[s2]/2) break;
            s1++;
        }
        while(true){
            if(N-s3==1 || A[s3]-A[s2]>(A[N]-A[s2])/2) break;
            s3++;
        }
        ans=min(ans,mini(A,N,s1,s2,s3));
        ans=min(ans,mini(A,N,s1-1,s2,s3));
        ans=min(ans,mini(A,N,s1,s2,s3-1));
        ans=min(ans,mini(A,N,s1-1,s2,s3-1));
        s2++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int jou[][]=new int[n][3];

		for(int i=0;i<n;i++) {
			jou[i][0]=sc.nextInt();
			jou[i][1]=sc.nextInt();
			jou[i][2]=sc.nextInt();
		}

		for(int i=0;i<=100;i++) {
			for(int j=0;j<=100;j++) {
				sindan(i,j,n, jou);
			}
		}

	}

	public static void sindan(int x, int y, int n, int[][] jou) {

		int height=0;
		boolean ha = true;
		for(int i=0;i<n;i++) {
			if(jou[i][2]!=0) {
				if(height==0) {
					height= jou[i][2] + zettaichi(jou[i][0]-x) + zettaichi(jou[i][1]-y);
					continue;
				}

				if(height!=jou[i][2] + zettaichi(jou[i][0]-x) + zettaichi(jou[i][1]-y)) {
					ha=false;
				}
			}
		}

		for(int i=0;i<n;i++) {
			if(jou[i][2]==0) {
				if(height>jou[i][2] + zettaichi(jou[i][0]-x) + zettaichi(jou[i][1]-y)) {
					ha=false;
				}
			}
		}

		if(ha)
			System.out.print(x + " " + y + " " + height);

	}



	public static int zettaichi(int x) {
		if(x>=0)
			return x;
		else
			return -x;
	}

}


Measured memory_bytes: 23892
n = int(input())
li = []
for i in range(n):
  li.append([str(i+1),input().split()])
li = sorted(li,key = lambda x:int(x[1][1]),reverse=True)
li = sorted(li,key = lambda x:x[1][0])
for j in li:
  print(int(j[0]))

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 5;
typedef long long ll;
ll a[maxn], b[maxn], c[maxn];
ll cnt[maxn];
bool Cmp(ll a, ll b){return a>b;}
int main(){
//    freopen("e:\\in.txt","r",stdin);
    memset(cnt, 0, sizeof(cnt));
    int n;
    cin>>n;
    for(int i = 0; i < n; i++)scanf("%lld",&a[i]);
    for(int i = 0; i < n; i++)scanf("%lld",&b[i]);
    for(int i = 0; i < n; i++)scanf("%lld",&c[i]);
    sort(a, a + n, Cmp);
    sort(b, b + n, Cmp);
    sort(c, c + n, Cmp);
    int i = 0, j = 0;
    while(i < n){
        while(j < n && c[j] > b[i])cnt[i]++, j++;
        i++;
        cnt[i] = cnt[i - 1];
    }
    for(int i = 1; i < n; i++)cnt[i] += cnt[i - 1];
    for(int i = n - 1; i > 0; i--)if(b[i] == b[i - 1])cnt[i - 1] = cnt [i];
    i = 0; j = 0;
    ll ans = 0;
    while(i < n){
        while(j < n && b[j] > a[i])j++;
        if(j == n || (j > 0 && b[j] <= a[i]))j--;
        ans += a[i] >= b[0]?0:cnt[j];
        i++;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;
using Graph = vector<vector<int>>;

int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;
    Graph g(n);
    for (int i = 0; i < n - 1; i++)
    {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);

    vector<vector<int>> dists(n);

    for (int snode = 0; snode < n; snode++)
    {
        vector<int> dist(n, -1);
        queue<int> que;
        dist[snode] = 0;
        que.push(snode);

        while (!que.empty())
        {
            int v = que.front();
            que.pop();

            for (auto &&nv : g[v])
            {
                if (dist[nv] != -1)
                    continue;
                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }

        dists[snode] = dist;
    }

    vector<int> dis(n);

    for (auto &&dist : dists)
    {
        for (auto &&d : dist)
        {
            dis[d]++;
        }
    }

    for (int i = 1; i < n; i++)
    {
        cout << (dis[i] >> 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n, m; cin >> n >> m;
    vector<tuple<ll, ll, ll>> a(n);
    FOR(i, 0, n) {
        ll x, y, z; cin >> x >> y >> z;
        a[i] = make_tuple(x, y, z);
    }

    ll ans = -LLINF;
    vector<VI> match = {
        {1,1,1},{1,1,-1},{1,-1,1},{1,-1,-1},
        {-1,1,1},{-1,1,-1},{-1,-1,1},{-1,-1,-1}
    };
    FOR(i, 0, 8) {
        VL points(n, 0);
        FOR(j, 0, n) {
            points[j] += get<0>(a[j]) * match[i][0];
            points[j] += get<1>(a[j]) * match[i][1];
            points[j] += get<2>(a[j]) * match[i][2];
        }
        rSORT(points, greater<ll>());
        ll sum = 0;
        FOR(j, 0, m)sum += points[j];
        chmax(ans, sum);
    }
    cout << ans << "\n";
}


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

int main() {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  sort(H.rbegin(), H.rend());
  long cnt = 0;
  for (int i = K; i < N; i++) {
    cnt += H.at(i);
  }
  cout << cnt << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6;
vector<int>a(N);
vector<int>b(N);
vector<pair<int,int>>vx;


int32_t main()
{
    int n; cin>>n; int t=n; while(n--)
    {
        int x,l; cin>>x>>l;
        vx.push_back({x-l,x+l});
    }
    sort(vx.begin(),vx.end(),[](auto a,auto b) { return b.second>a.second; });
    
    int ans=-INT_MAX; int cnt=0;
    
    for(int i=0;i<vx.size();i++)
    {
        if(vx[i].first>=ans) { cnt++; ans=vx[i].second;  }
    }
    cout<<cnt;
}

                        
           
                            

Measured memory_bytes: 18036
#include<iostream>
using namespace std;
int main()
{
	string s;
  	cin >> s;
    int ac=0,bc=0;
  	for(int i=0;i<3;i++)
    {
      if(s[i]=='A')
        ac++;
      else
        bc++;
    }
  	if(ac==0 || bc==0)
      cout<<"No";
  	else
      cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define   ll  long long int
#define   sz  1000100

using namespace std;


int main()
{


    ll a,b,n,d,k,s;

    cin>>n>>a>>b;

    d=n/(a+b);
    s=d*a;
    d=n%(a+b);

    s+=min(a,d);
    cout<<s<<endl;


    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b)
{
	ll res = 1;
	a %= mod;
	assert(b >= 0);
	for (; b; b >>= 1)
	{
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
	}
	return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt
{
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M &set_v(uint _v)
	{
		v = (_v < MD) ? _v : _v - MD;
		return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M &r) const { return M().set_v(v + r.v); }
	M operator-(const M &r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M &r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M &r) const { return *this * r.inv(); }
	M &operator+=(const M &r) { return *this = *this + r; }
	M &operator-=(const M &r) { return *this = *this - r; }
	M &operator*=(const M &r) { return *this = *this * r; }
	M &operator/=(const M &r) { return *this = *this / r; }
	bool operator==(const M &r) const { return v == r.v; }
	M pow(ll n) const
	{
		M x = *this, r = 1;
		while (n)
		{
			if (n & 1)
				r *= x;
			x *= x;
			n >>= 1;
		}
		return r;
	}
	M inv() const { return pow(MD - 2); }
	friend ostream &operator<<(ostream &os, const M &r) { return os << r.v; }
};
using Mint = ModInt;
//head
// cin >> t;
// for (int cas = 1; cas <= t; ++cas)
// {
// 	cout << "Case #" << cas << ": ";
// }
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin>>n;
	ll ans = (1+n)*n/2;
	ans -= 3*(1+n/3)*(n/3)/2; 
	ans -= 5*(1+n/5)*(n/5)/2; 
	ans += 15*(1+n/15)*(n/15)/2; 
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int A;
    ll B, N;
    cin >> A;
    cin >> B >> N;
    if( N >= B) cout << A*(B-1)/B << endl;
    else cout << A*N/B << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1LL<<60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main(){
  string s;
  cin >> s;
  int a = -1, b = -1;
  REP(i, s.size()-2){
    if(s[i] == s[i+2]){
      a = i+1;
      b = i+3;
    }
  }
  REP(i, s.size()-1){
    if(s[i] == s[i+1]){
      a = i+1;
      b = i+2;
    }
  }
  cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    int ans = 0;

    for(int i = 0;i<s.length();i++){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3880
// AOJ 1213: Heavenly Jewels
// 2017.12.17 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define EPS 1e-8

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } LINE;

PP p[3];
PP pol0[5] = {{0,0},{10000,0},{10000,10000},{0,10000},{0,0}};

int dcmp(double x)
{
	if (fabs(x) < EPS) return 0;
	return x < 0 ? -1 : 1;
}

double cross(double ax, double ay, double bx, double by) { return ax*by - ay*bx; }

void lineIntersection(PP *p, LINE *a, PP *vs, PP *ve)
{
    double a1, a2;

	a1 = cross(ve->x  - vs->x, ve->y  - vs->y,
			   a->s.x - vs->x, a->s.y - vs->y);
	a2 = cross(ve->x  - vs->x, ve->y  - vs->y,
			   a->e.x - vs->x, a->e.y - vs->y);
	p->x = (a->s.x*a2 - a->e.x*a1) / (a2-a1);
	p->y = (a->s.y*a2 - a->e.y*a1) / (a2-a1);
}

int convex_cut(LINE *u, int n, PP *p, PP *po)
{
	int i, d1, d2, top = 0;

    for (i = 0; i < n; i++) {
        d1 = dcmp(cross(u->e.x - u->s.x, u->e.y - u->s.y,
						p[i].x - u->s.x, p[i].y - u->s.y));
        d2 = dcmp(cross(u->e.x - u->s.x, u->e.y - u->s.y,
				      p[i+1].x - u->s.x, p[i+1].y - u->s.y));
        if (d1 >= 0) po[top++] = p[i];
        if (d1*d2 < 0) lineIntersection(po + top++, u, p+i, p+i+1);
    }
	po[top].x = po[0].x, po[top].y = po[0].y;
    return top;
}

// ?????´????????????
void bisector(LINE *u, PP a, PP b)
{
	double ax = (a.x + b.x)/2;
	double ay = (a.y + b.y)/2;
	u->s.x = ax, u->s.y = ay;
	if (fabs(a.y - b.y) <= EPS) u->e.x = ax, u->e.y = ay + (b.x-a.x)*4096;
	else u->e.x = ax-(b.y-a.y)*4096, u->e.y = (ax - u->e.x)*(b.x - a.x)/(b.y - a.y) + ay;
}

double polygonArea(int n, PP *p)
{
    double area = 0;
    for (int i = 1; i < n-1; i++) {
        area += cross(p[i].x-p[0].x, p[i].y-p[0].y, p[i+1].x-p[0].x, p[i+1].y-p[0].y);
    }
    return fabs(area) / 2;
}

int main()
{
	int cno = 0, k;
	PP pol[10], pol2[10];
	LINE u;

	while(scanf("%lf%lf%lf%lf%lf%lf", &p[0].x, &p[0].y, &p[1].x, &p[1].y, &p[2].x, &p[2].y) && p[0].x > 0) {
		memcpy(pol, pol0, sizeof(pol0));

		bisector(&u, p[0], p[1]);
		k = convex_cut(&u, 4, pol, pol2);

		bisector(&u, p[0], p[2]);
		k = convex_cut(&u, k, pol2, pol);

		printf("%d %.5lf\n", ++cno, polygonArea(k, pol) / ((double)10000*10000));
	}
	return 0;
}

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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int[] x = new int[m];
		
		for(int i = 0; i < m; i++) {
			x[i] = Integer.parseInt(sc.next());
		}
		
		Arrays.sort(x);
		
		Integer[] d = new Integer[m-1];
		
		for(int i = 0; i < m-1; i++) {
			d[i] = x[i+1] - x[i];
		}
		
		Arrays.sort(d);
		
		int res = 0;
		
		for(int i = 0; i < m-n; i++) {
			res+=d[i];
		}
		
		System.out.println(res);
	}
}


Measured memory_bytes: 47140
N, K = map(int,input().split())

ARR = []

for i in range(K):
    num = int(input())
    ele = list(map(int,input().split()))
    ARR.append({"num": num, "ele": ele})

def calculate(n, k, arr):
    result = {}
    for i in range(1, n + 1):
        result.__setitem__(i, False)

    for ar in arr:
        for sr in ar["ele"]:
            result.__setitem__(sr,True)
    tt = 0

    for index,res in result.items():
        if res == False:
            tt = tt + 1

    print(tt)


calculate(N, K, ARR)


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

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

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

int main(void){

    int n;
    cin >> n;

    map<string, int> mp;

    roop(i, n){
        string s; cin >> s;
        mp[s]++;
    }

    cout << mp.size() << endl;

    return 0;
}


Measured memory_bytes: 19076
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    cin >> N;
    int d[100000];
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    sort(d, d + N);
    res = d[N / 2] - d[N / 2-1];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int h,w;cin>>h>>w;
    char t[h][w];
    int r[h][w];
    rep(i,h)rep(j,w) r[i][j]=100000;
    rep(i,h)rep(j,w) cin>>t[i][j];
    r[0][0]=(t[0][0]=='#')? 1:0;
    queue<pair<int,int>> que;
    que.push({0,0});
    int roty[2]={0,1},rotx[2]={1,0};
    while(que.size()){
        auto p=que.front();que.pop();
        int y=p.first,x=p.second;
        int buf=r[y][x];
        rep(i,2){
            int ny=y+roty[i],nx=x+rotx[i];
            int nb=buf;
            if(0<=ny&&ny<h&&0<=nx&&nx<w){
                if(t[ny][nx]=='#')if(t[y][x]!='#')nb++;
                if(chmin(r[ny][nx],nb))que.push({ny,nx});
            }
        }
    }
    cout<<r[h-1][w-1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> L(2*N);
	for (auto& x : L) cin >> x;
	sort(L.begin(), L.end());
	int r = 0;
	for (int i = 0; i < 2*N; i += 2) r += L[i];
	cout << r << endl;
}


Measured memory_bytes: 764
import math
# print(math.cos(math.pi))

Ar, Br, H, M = map(int, input().split())
Ht = math.pi * (H / 6) + math.pi * (M / 360)
Mt = math.pi * (M / 30)
Ax =  Ar * math.cos(Ht)
Ay = Ar * math.sin(Ht)

Bx =  Br * math.cos(Mt)
By = Br * math.sin(Mt)
# print(Ax, Ay)
# print(Bx, By)
# print(H / 6, M / 30)


print(math.sqrt((Ax-Bx) ** 2 + (Ay-By)**2))

Measured memory_bytes: 9516
N, K = map(int, input().split())
MOD = 998244353
LR = []
for _ in range(K):
    L, R = map(int, input().split())
    LR.append((L, R))
# print(f'{LR=}')

DP = [0] * (N + 1)
DP[1] = 1
S = [0] * (N + 1)

for i in range(1, len(DP)):
    for L, R in LR:
        v = S[max(i - L, 0)] - S[max(i - R - 1, 0)]
        DP[i] += v
    DP[i] %= MOD
    S[i] = (S[i - 1] + DP[i]) % MOD

# print(f'{DP=}')
# print(f'{S=}')
print(DP[-1])


Measured memory_bytes: 24592
n,a,b = map(int, input().split())
s = input()
passed = 0
passed_b = 0
for i in s:
    if i == 'a':
        if passed < a+b:
            print('Yes')
            passed += 1
        else:
            print('No')
    elif i == 'b':
        if (passed < a+b) and (passed_b < b):
            print('Yes')
            passed += 1
            passed_b += 1
        else:
            print('No')
    else:
        print('No')

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.rbegin(), v.rend());
  double cur = v[n-1];
  v.pop_back();
  while (!v.empty()) {
    cur += v.back();
    v.pop_back();
    cur /= 2.0;
  }
  printf("%.7f\n", cur);
  return 0;
}

Measured memory_bytes: 3792
#include<iostream>

using namespace std;

char *solve(int d[10])
{
	int l,r;
	l=r=0;
	for(int i=0;i<10;i++)
	{
		if(l>d[i]&&r>d[i])
		{
			return "NO";
		}
		else if(l<d[i]&&r>d[i])
		{
			l=d[i];
		}
		else if(r<d[i]&&l>d[i])
		{
			r=d[i];
		}
		else if(r<l)
		{
			l=d[i];
		}
		else
		{
			r=d[i];
		}
	}
	return "YES";
}

int main(void)
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int d[10];
		for(int j=0;j<10;j++)
		{
			cin>>d[j];
		}
		cout<<solve(d)<<endl;
	}
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }


ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

void solve() {
    string s;
    cin >> s;
    int N = s.size();
    vector<ll> accA(N + 1), accC(N + 1), accH(N + 1);

    // 累積和の計算
    for (int i = 0; i < N; i++) {
        accA[i + 1] = accA[i] + (s[i] == 'A');
        accH[i + 1] = accH[i] + (s[i] == '?');
        accC[i + 1] = accC[i] + (s[i] == 'C');
    }
    ll ans = 0;
    const int mod = 1000000007;

    // Bとしてj番目を採用する場合の"ABC"の選び方を j = 1, 2, ..., N - 1 について和を取ったものが解
    // （ここで、j = k と j = k' (k != k') について、採用するBの位置だけが違い、出来上がる全体の文字列は同じパターンが重複してカウントされる（ABBCなど）がそれは気にしなくて良い。
    // 実際求めたいのは「ABC数」であって、「ABCが含まれるように?にA,B,Cのいずれかを入れてできる文字列の種類」ではない。むしろ重複してカウントされるべき。）
    // 採用するBの位置を決めた時、作れるABCの数は
    // 「採用するBより左側のA, ?の全ての文字についての『その文字を採用するAと決めて、残りの左側の?にA,B,Cを入れたときにできる文字列の種類』の総和」
    //  *
    // 「採用するBより右側のC, ?の全ての文字についての『その文字を採用するCと決めて、残りの右側の?にA,B,Cを入れたときにできる文字列の種類』の総和」である。
    // である。前者は、「採用するBより左側の文字Aの数」をcntA「採用するBより左側の文字?の数」を cntHl と置くと
    // cntA * 3^cntHl + cntHl * 3^{cntHl - 1}
    // と計算できる。（'A'をAとして採用する場合と'?'を'A'として採用する場合で場合分け）
    // (ここで、採用するAの位置だけが違い、出来上がる文字列が同じ場合を重複してカウントしていることがやはり気になる(A?BCなど)が、重複して数える方が求めたい方である。)
    // 後者も同様に計算できる。
    // これらを累積和で計算することで、O(N)の計算量で問題を解くことができる。
    for(int j = 1; j < N - 1; j++) {
        if (s[j] != 'B' && s[j] != '?') continue;
        ll cntA = accA[j]; // 採用するBより左にある文字Aの数
        ll cntC = accC[N] - accC[j + 1]; // 採用するBより右にある文字Cの数
        ll cntHl = accH[j]; // 採用するBより左にある文字?の数
        ll cntHr = accH[N] - accH[j + 1]; // 採用するBより右にある文字?の数
        ll l = ((cntA * mod_pow(3, cntHl, mod)) % mod + (cntHl * mod_pow(3, cntHl - 1, mod)) % mod) % mod;
        ll r = ((cntC * mod_pow(3, cntHr, mod)) % mod + (cntHr * mod_pow(3, cntHr - 1, mod)) % mod) % mod;
        ans += l * r % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 2896
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i % 2 == 0 && a[i] % 2 != 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	list := make([]int, 100)
	count := 0
	for i := 1; i <= 100; i++ {
		if a%i == 0 && b%i == 0 {
			list[count] = i
			count++
		}
	}
	fmt.Println(list[count-k])
}


Measured memory_bytes: 512