akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 500005
using namespace std;
int n,x[maxn],sum;
char s[maxn];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	reverse(s+1,s+n+1);
	for(int i=1;i<=n;i++) x[i]=(s[i]-'0')*9;
	for(int i=1;i<=n;i++) x[i+1]+=x[i]/10,x[i]%=10;
	if(x[n+1]) n++;
	for(int i=1;i<=n;i++) sum+=x[i];
	for(int k=1;k<=n*2;k++)
	{
		int v=9,j=1;
		while(v)
		{
			sum-=x[j],x[j]+=v;
			v=x[j]/10,x[j]%=10;
			sum+=x[j];
			if(j>n) n++;
			j++;
		}
		if(sum<=9*k) { printf("%d\n",k); return 0; }
	}
}

Measured memory_bytes: 2560
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) ->
      if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  inorder (fun e -> print_string " "; print_int e) t;
  print_newline ();
  preorder (fun e -> print_string " "; print_int e) t;
  print_newline ()

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r in
  doit t

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let m = read_int () in
  let t = ref (create ()) in
  for _ = 0 to m - 1 do
    match read_line () |> split_on_char ' ' with
    | ["insert"; n] -> t := insert (int_of_string n) !t
    | ["find"; n] -> print_endline (if find (int_of_string n) !t then "yes" else "no")
    | _ -> print !t
  done

Measured memory_bytes: 25172
#include <iostream>
using namespace std;
int d[10];
int l;
int r;

bool choose(int i, bool b);

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

  for (int i=0; i<n; i++) {
    for (int j=0; j<10; j++) {
      cin >> d[j];
    }
    l = r = 0;
    if (choose(0, true)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

}

bool choose(int i, bool b) {
  int old;
  int *p;
  if (b) p = &l;
  else p = &r;
  if (d[i] > *p) {
    if (i == 9) return true;
    old = *p;
    *p = d[i];
    if (choose(i+1, true)) return true;
    if (choose(i+1, false)) return true;
    *p = old;
    return false;
  } else {
    return false;
  }
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();
        int H = int.Parse(s.Split(' ')[0]);
        int W = int.Parse(s.Split(' ')[1]);

        int[,] A = new int[H, W];
        List<int> list = new List<int>();
        for (int i = 0; i < H; i++) {
            string t = Console.ReadLine();
            for (int j = 0; j < W; j++) {
                if (t.Substring(j, 1) == "#") {
                    A[i, j] = 1;
                    list.Add(i * 1000 + j);
                }
            }
        }

        //解答となる数値
        int max = 0;

        while (list.Count > 0) {
            List<int> list2 = new List<int>(list);
            list.Clear();

            for (int i = 0; i < list2.Count; i++) {
                int x = list2[i] / 1000;
                int y = list2[i] % 1000;
                int cnt = A[x, y];

                if (x > 0) {
                    if (A[x - 1, y] == 0) {
                        A[x - 1, y] = cnt + 1;
                        max = Math.Max(max, cnt);
                        list.Add((x - 1) * 1000 + y);
                    }
                }
                if (x < H - 1) {
                    if (A[x + 1, y] == 0) {
                        A[x + 1, y] = cnt + 1;
                        max = Math.Max(max, cnt);
                        list.Add((x + 1) * 1000 + y);
                    }
                }
                if (y > 0) {
                    if (A[x, y - 1] == 0) {
                        A[x, y - 1] = cnt + 1;
                        max = Math.Max(max, cnt);
                        list.Add(x * 1000 + y - 1);
                    }
                }
                if (y < W - 1) {
                    if (A[x, y + 1] == 0) {
                        A[x, y + 1] = cnt + 1;
                        max = Math.Max(max, cnt);
                        list.Add(x * 1000 + y + 1);
                    }
                }
            }
        }

        //出力
        Console.WriteLine(max);
    }
}

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

int main(){
    int i=1,x,a[10000];
    0 <= x <= 10000;
    while (1){
        cin >> x;
        a[i] = x;
        if(x == 0) break;
        cout << "Case " << i <<": "<< a[i] << endl;
        i++;
        if(i > 10000) break;
    }
    return 0;
}


Measured memory_bytes: 3096
q = int(input())
A = []
 
for i in range(q):
    Q, *x = (int(x) for x in input().split())
    x = x[0] if x else None
    if Q == 0:
        A.append(x)
    elif Q == 1:
        print(A[x])
    else:
        del A[-1]


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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int first = a.at(0);
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    int tmp = max(0, a.at(i) + a.at(i - 1) - x);
    ans += tmp;
    a.at(i) = max(0, a.at(i) - tmp);
  }
  cout << ans;
  return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int[] array = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			int n = array[0];
			int a = array[1];
			int b = array[2];

			System.out.println(Math.min(n*a, b));
		}
	}
}

Measured memory_bytes: 27092
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();


        if (a >= c) {
            System.out.println(c + b);
        } else {
            int diff = c - a;
            if (b + 2 <= diff) {
                System.out.println(a + b + b + 1);
            } else {
                System.out.println(c + b);
            }
        }


    }


}


Measured memory_bytes: 22612
use std::io;
use std::str::FromStr;

fn main() {
    let (a, b) = {
        let stdin = io::stdin();
        let mut buf = String::new();
        stdin.read_line(&mut buf).ok();
        let mut it = buf.split_whitespace().map(|n| i32::from_str(n).unwrap());
        let a = it.next().unwrap();
        let b = it.next().unwrap();
        (a, b)
    };
    
    let md = (a * b) % 2;
    if md == 1 {
        println!("Odd");
    } else{
        println!("Even");
    }
}

Measured memory_bytes: 4352
// Mon Aug 24 16:24:09 IST 2020        
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7; 
// const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
void print(vector <int>v){
    for(int t : v){
        cout << t << ' ';
    }
    cout << '\n';
}
int tests(){  
    string s;
    cin >> s;
    if(s[1] == 'B')
        s[1] = 'R';
    else
        s[1] = 'B';
    cout << s << '\n';
    return 0;
}    
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 

Measured memory_bytes: 3644
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]

count = 0

for row in A:
    cal = 0
    for col in enumerate(row):
        cal += col[1] * B[col[0]]
    cal += C
    if cal > 0:
        count += 1

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> vec(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    vec[i] = {a, b};
  }
  
  sort(vec.begin(), vec.end());
  
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    int c = min(vec[i].second, M);
    sum += (ll) c * vec[i].first;
    M -= c;
    if (M == 0) {
      break;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

ll pow(ll num,ll count){

	if(count == 0)return 1;
	if(count == 1)return num;

	ll ret;

	if(count%2 == 0){

		ret = pow(num,count/2);
		ret = ret*ret%MOD;

	}else{

		ret = pow(num,(count-1)/2);
		ret = ret*ret%MOD;
		ret *= num;
		ret %= MOD;
	}

	return ret%MOD;
}


int main(){

	ll M,N;
	scanf("%lld %lld",&M,&N);

	printf("%lld\n",pow(M,N)%MOD);

	return 0;
}

Measured memory_bytes: 3228
// MODULAREXPONENTIATION
// NCR
// LOOP IN DIRECTED GRAPH
// DSU
// LIS
// DISTINCT_CHARACTER_BETWEEN_L_TO_R



#include<bits/stdc++.h>
using namespace std;


typedef long long int ll;

vector<ll> adj[1000001]; 

ll i;
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define rep(i,st,end) for( i=st;i<end;i++)
#define repv(i,st,end) for( i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
	ll n;
	cin>>n;
	string na;
	cin>>na;
	if(n==0)
		cout<<na;
	else
	{
		string s;
		for(i=0;i<na.length();i++)
		{
			int t=(na[i]-'A'+n)%26;
			char c=t+65;
			s=s+c;
			
			
// 			cout<<t<<" "<<c;
// 			endl;
		
			
		//	s=s+c;

		}
		cout<<s;
	}
	return 0;
}

Measured memory_bytes: 23680
import math
n,k = map(int, input().split())
alst = list(map(int, input().split()))
flst = list(map(int, input().split()))

sorted_flst = sorted(flst, key = lambda x: -x)
sorted_alst = sorted(alst)

pair_lst = []
for a, b in zip(sorted_flst, sorted_alst):
    pair_lst.append((a*b, a))
sorted_pair_lst = sorted(pair_lst, key = lambda x:-x[0])

def judge(sorted_pair_lst, x):
    cnt = 0
    for pair in sorted_pair_lst:
        if pair[0] <= x:
            return True
        else:
            cnt += math.ceil((pair[0] - x) / pair[1])
            if cnt > k:
                return False
    return True

low = 0
high = 10**15
while high - low > 1:
    middle = (low+high) // 2
    if judge(sorted_pair_lst, middle):
        high = middle
    else:
        low = middle
print(low) if judge(sorted_pair_lst, low) else print(high)

Measured memory_bytes: 122572
import java.util.Scanner;
     
    public class Main {
        public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] a = new int[n+1];
            a[0] = 0;
            for (int i = 1; i < n+1; i++) {
                a[i] = sc.nextInt();
            }
            int q = sc.nextInt();
            int[] b = new int[q+1];
            int[] c = new int[q+1];
            b[0] = 0;
            c[0] = 0;
            for (int i= 1; i < q+1; i++) {
                b[i] = sc.nextInt();
                c[i] = sc.nextInt();
            }
            long[] s = new long[q+1];
            s[0] = 0;
            for (int i = 0; i < a.length; i++) {
                s[0] = s[0] + a[i];
            }
            int[] num = new int[100000+1];
          for (int i = 0; i < num.length; i++) {
            num[i] = 0;
           }
            for (int i = 1; i < a.length; i++) {
                num[a[i]] = num[a[i]] + 1;
            }
            for (int i = 1; i < q+1; i++) {
                s[i] = (c[i]-b[i])*num[b[i]] + s[i-1];
                System.out.println(s[i]);
                num[c[i]] = num[c[i]] + num[b[i]];
                num[b[i]] = 0;
            }
        }
    }

Measured memory_bytes: 62588
#include<iostream>
#include<stack>
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        stack<pair<int,int>> s;
        int c;
        cin >> c;
        int nowc = c, nowcnt = 1;
        for(int i = 2; i <= n; i++){
            cin >> c;
            if(nowc != c){
                if(i%2 == 1){
                    s.push({nowc, nowcnt});
                    nowc = c;
                    nowcnt = 1;
                }else{
                    nowc = c;
                    nowcnt++;
                    if(!s.empty()){
                        pair<int,int> p = s.top(); s.pop();
                        nowcnt += p.second;
                    }
                }
            }else{
                nowcnt++;
            }
        }
        s.push({nowc, nowcnt});

        int white = 0;
        while(!s.empty()){
            pair<int,int> p = s.top();  s.pop();
            if(p.first == 0)    white += p.second;
        }
        cout << white << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
import std.stdio, std.algorithm, std.math;

void main() {
  for(int n, m; scanf("%d %d\n", &n, &m), n != 0;) {
    double[][] table = new double[][](n, n);
    double[][] dp = new double[][](m + 1, n + 1);
    int[] next = new int[](n);
    double ans = 0.0;
    
    for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
        scanf(j == n - 1 ?  "%lf\n" : "%lf ", &table[i][j]);

    foreach(ref d; dp) d[] = 0.0;
    dp[1][] = 1.0;

    for(int t = 1; t < m; t++) {
      for(int prev = 0; prev < n; prev++) {
        for(int curr = 0; curr < n; curr++) {
          dp[t + 1][curr] = max(dp[t + 1][curr], dp[t][prev] * table[prev][curr]);
        }
      }
    }
    writefln("%.2f", dp[m].reduce!(max));
  }
}

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

int main(int argc, const char * argv[]) {
    
    long long int n,num;
    
    cin >> n;
    
    for(int i=0;;i++){
        num=i*i;
        if(num>n){
            num=(i-1)*(i-1);
            break;
        }
    }
    
    cout << num << endl;
    
    return 0;
}


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 all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    rep(i, A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) cin >> r[i];
    sort(all(p), greater<int>());
    sort(all(q), greater<int>());
    sort(all(r), greater<int>());
    vector<int> Ans;
    rep(i, X) Ans.push_back(p[i]);
    rep(i, Y) Ans.push_back(q[i]);
    rep(i, C) Ans.push_back(r[i]);
    int ans = 0;
    sort(all(Ans), greater<int>());
    rep(i, X + Y) ans += Ans[i];
    cout << ans << endl;
}


Measured memory_bytes: 8688
from math import ceil

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

rows, cols = ceil(n / k), k
ans = 0
for j in range(cols):
    dp = [[0, 0, 0] for _ in range(rows + 1)]
    for i in range(rows):
        ri, si, pi = dp[i]
        if i * k + j < n:
            c = t[i * k + j]
        else:
            c = ''
        dp[i + 1][0] = max(si, pi) + r * (c == 's')
        dp[i + 1][1] = max(pi, ri) + s * (c == 'p')
        dp[i + 1][2] = max(ri, si) + p * (c == 'r')
    ans += max(dp[rows])

print(ans)

Measured memory_bytes: 22712
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 2e5 + 5;
const double eps = 1e-9;
ll fac[MAXN], ifac[MAXN];

ll pw(ll a, ll b) {
	ll r = 1;
	while (b)
		if (b & 1)
			r = (r*a) % MOD, b--;
		else
			a = (a*a) % MOD, b /= 2ll;
	return r;
}

inline ll inv(ll x) {
	return pw(x, MOD-2);
}

inline ll bin(ll n, ll k) {
	return (fac[n] * ifac[k] % MOD) * ifac[n-k] % MOD;
}

int main() {
	fac[0] = ifac[0] = 1;
	for (ll i = 1; i < MAXN; i++)
		fac[i] = fac[i-1] * i % MOD, ifac[i] = inv(fac[i]);
	ll n, m, k; scanf("%lld %lld %lld", &n, &m, &k);
	ll ans = 0, dx = 0, dy = 0;
	for (ll i = 1; i < n; i++)
		dx = (dx + ((i * (n-i) % MOD) * (bin(n*m-2, k-2) * (m*m%MOD) % MOD) % MOD)) % MOD;
	for (ll i = 1; i < m; i++)
		dy = (dy + ((i * (m-i) % MOD) * (bin(n*m-2, k-2) * (n*n%MOD) % MOD) % MOD)) % MOD;
	ans = (dx+dy) % MOD;
	prl(ans);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>

using namespace std;

int main(){


	string s,t;

	cin>>s>>t;


	for(int i=0;i<s.size();i++){
		cout<<s[i];
		if(i<t.size()){
			cout<<t[i];
		}
	}
	
	return 0;
}

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

int main() {

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


    bool ans = false;
    int k = 0;

    while (k <= a || k <= b) {
        if (abs(a - k) == abs(b - k)) {
            break;
        }
        k++;
    }

    if (k <= a || k <= b) {
        cout << k << endl;;
    }
    else {
        cout << "IMPOSSIBLE" << endl;;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N,K;
   cin >> N >> K;
   int R,S,P;
   cin >> R >> S >> P;
   string T;
   cin >> T;
   long long ans = 0;
   for(int i=T.size()-1; i>=0; i--){
      if(i >= K && T[i-K] == T[i]){
         T[i-K]='X';
      }
      if(T[i]=='r'){ans+=P;}
      if(T[i]=='p'){ans+=S;}
      if(T[i]=='s'){ans+=R;}
   }
   //cout << T << endl;
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 512
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}

template <typename T>
T power(T a, T n, T mod) {
  T res = 1;
  T tmp = n;
  T curr = a;
  while(tmp){
    if(tmp % 2 == 1){
      res = (T)((ll)res * curr % mod);
    }
    curr = (T)((ll)curr * curr % mod);
    tmp >>= 1;
  }
  return res;
}

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  vector<int> cnt(26, 0);
  rep(i, sz(s)){
    cnt[s[i] - 'a']++;
  }
  ll res = 1;
  for(int i = 0; i < 26; i++){
    res = res * (cnt[i] + 1) % mod;
  }
  cout << res - 1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn];
int main()
{
    int n;
    while (scanf("%d",&n)!=EOF) {
        for(int i=1;i<=n;i++)scanf("%d",&a[i]);
        sort(a+1,a+n+1);
        int l=a[n]/2;
            int dist=1<<30,id=-1;
            for(int i=1;i<=n-1;i++)
                if(abs(a[i]-l)<=dist)dist=abs(a[i]-l),id=i;
            printf("%d %d\n",a[n],a[id]);
     }
}

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

int main(){
    std::vector<int> a(6);
    for (int i = 0; i < 6; i++){
      std::cin>>a[i];
    }

    std::sort(a.begin(),a.end());
    int sum = 0;
    for (int i = 0; i < 6; i++){
      if(a[i+1] - a[i] == 0){
        sum++;
      }else{
        sum = 0;
      }
      if(sum == 2){
        break;
      }
    }
    if(sum == 2){
      std::cout<<"NO"<<std::endl;
    }else{
      std::cout<<"YES"<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll factorial(ll a, ll b) {
    ll ret = 1;
    while(1) {
        if (b == 0) break;
        ret = ret * a % mod;
        --a;
        --b;
    }
    return ret;
}

ll expo(ll a, ll b) {
    ll ret = 1;
    while(1) {
        if (b == 0) break;
        if (b&1LL) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1LL;
    }
    return ret;
}

ll inv(ll a) {
    return expo(a, mod-2);
}

ll comb(ll a, ll b) {
    //cout << factorial(a, b) << " " << factorial(b, b) << " " << inv(factorial(b,b)) << endl;
    return factorial(a, b) * inv(factorial(b,b)) % mod;
}

int main() {
    ll n, k;
    cin >> n >> k;
    for (ll i = 1; i <= k; ++i) {
        cout << comb(n-k+1, i) * comb(k-1, i-1) % mod << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    long int n, a[200001], d = 0, max = 0;
    scanf("%ld",&n);
    for(int i=0;i<n;i++) scanf("%ld",&a[i]);
    max = a[0];
    for(int i=0;i<n-1;i++) { 
        if(max <= a[i+1]) max = a[i+1];       
        else if(max > a[i+1]) {
            d += (max - a[i+1]);
        }
    }
    printf("%ld\n", d);
    return 0;
}

Measured memory_bytes: 3256
//貪欲撃墜ケース：
// {{{))iwi(]}}}
// )){{{iwi}}}](
#include<stdio.h>
#include<string.h>
#define bit(N) ((1)<<(N))
char str[17];

int taisyo( char p, char q ){
	if( p == 'i' && q == 'i' )
		return 1;
	if( p == 'w' && q == 'w' )
		return 1;
	if( p == '(' && q == ')' )
		return 1;
	if( p == ')' && q == '(' )
		return 1;
	if( p == '{' && q == '}' )
		return 1;
	if( p == '}' && q == '{' )
		return 1;
	if( p == '[' && q == ']' )
		return 1;
	if( p == ']' && q == '[' )
		return 1;
	return 0;
}

int main(){
	int i,j;
	int len;
	int ans = 0;
	
	scanf("%s",str);
	len = strlen(str);
	
	for( i = 0; i < bit(len); i++ ){
		char substr[17];
		int cnt = 0;
		for( j = 0; j < len; j++ ){
			if( (i/bit(j))%2 ){
				substr[cnt++] = str[j];
			}
		}
		substr[cnt] = '\0';
		
		if( strstr( substr, "iwi" ) == NULL )
			continue;
		
		//整合性のチェック
		for( j = 0; j < cnt; j++ ){
			if( !taisyo( substr[j], substr[cnt-j-1] ) )
				break;
		}
		if( j < cnt )
			continue;
			
		if( ans < cnt )
			ans = cnt;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int k = scn.nextInt();
		int count = 0;
		double ans = 0;
		for (int i = 1; i <= n; i++) {
			int j = 0;
			count = i;
			for(;count<k;j++) {
				count *=2;
			}
			ans += 1.0 / (n * Math.pow(2,j));
		}
		System.out.println(ans);
		scn.close();
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  string t = s.substr(0,2);
  string u = s.substr(2,2);
  int a = atoi(t.c_str());
  int b = atoi(u.c_str());
  int x = 0;
  if(1 <= a && a <= 12) {
    x += 1;
  }
  if(1 <= b && b <= 12) {
    x += 2;
  }
  switch(x) {
    case 0:
      cout << "NA" << endl;
      break;
    case 1:
      cout << "MMYY" << endl;
      break;
    case 2:
      cout << "YYMM" << endl;
      break;
    case 3:
      cout << "AMBIGUOUS" << endl;
      break;
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
/*-----------------------------------------------------------------------------------------------*/
const int N = 2e5+10;
int n,t;
string s,ss;
int a[N];

int main()
{
    _SAD()
    cin>>n;
    rep(i,n) cin>>a[i];
    int cnt=0;
    t=a[0];
    rep(i,n)
    {
        if(a[i]<=t)
        {
            cnt++;
        }
        t=min(t,a[i]);
    }
    cout<<cnt<<nl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}



int n;

void doit(){
	int ma=0,mi=1e9,cnt=0;
	read(n);
	for(int i=1,x;i<=n;i++){
		read(x);
		if(x>ma) ma=x,cnt=0;
		if(x==ma) cnt++;
		mi=min(mi,x);
	}
	if(ma-mi>1){
		puts("No");
		return ;
	}
	if(cnt==n){
		if(ma==n-1) puts("Yes");
		else{
			if(n/ma>=2) puts("Yes");
			else puts("No");
		}
		return ;
	}
	int alone=n-cnt;
	if(ma-alone>=1&&cnt/(ma-alone)>=2) puts("Yes");
	else puts("No");
}

signed main(){
	doit();
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;

		while (true) {
			int n = sc.nextInt();
			if(n==0) {
				break;
			}
			ans =0;
			List<String> step = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				step.add(sc.next());
			}

			for (int i = 0; i < n-1; i++) {
				if ((ans == 0 || ans % 2 == 0) && (step.get(i).equals("ru")
						&& step.get(i + 1).equals("lu")) || (step.get(i).equals("lu")
								&& step.get(i + 1).equals("ru"))) {
					ans++;
					i++;
				} else if (ans % 2 == 1 && (step.get(i).equals("rd")
						&& step.get(i + 1).equals("ld")) || (step.get(i).equals("ld")
								&& step.get(i + 1).equals("rd"))) {
					ans++;
					i++;
				}
			}
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 37720
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    vector<vector<int>> b(H, vector<int>(W));
    REP(i,H) REP(j,W) cin >> a[i][j];
    REP(i,H) REP(j,W) cin >> b[i][j];
    vector<vector<bitset<2*80*88>>> dp(H, vector<bitset<2*80*88>>(W));
    dp[0][0][abs(a[0][0]-b[0][0])+80*80] = 1;
    REP(i,H) REP(j,W){
        if(i > 0){
            dp[i][j] |= (dp[i-1][j] << abs(a[i][j] - b[i][j]));
            dp[i][j] |= (dp[i-1][j] >> abs(a[i][j] - b[i][j]));
        }
        if(j > 0){
            dp[i][j] |= (dp[i][j-1] << abs(a[i][j] - b[i][j]));
            dp[i][j] |= (dp[i][j-1] >> abs(a[i][j] - b[i][j]));
        }
    }
    int ans = INF;
    REP(i,2*80*88){
        if(dp[H-1][W-1][i]){
            chmin(ans, abs(6400-i));
        }
    }
    cout << ans << endl;
}

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

int main() {
  int A,B;
  cin>>A>>B;
  if(A==B){
    cout<<"Draw"<<endl;
  }
  else if(A==1){
    cout<<"Alice"<<endl;
  }
  else if(B==1){
    cout<<"Bob"<<endl;
  }
  else if(A>B){
    cout<<"Alice"<<endl;
  }
  else{
    cout<<"Bob"<<endl;
  }
  
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			r = scanner.nextInt();
			if (r == 0)
				break;
			map = new int[2][250001];
			for (int[] ma : map)
				Arrays.fill(ma, 1 << 30);
			map[0][0] = map[1][0] = 0;
			for (int i = 0; i < 2; i++) {
				w = scanner.nextInt();
				h = scanner.nextInt();
				sx = scanner.nextInt() - 1;
				sy = scanner.nextInt() - 1;
				int[][] m = new int[h][w];
				for (int j = 0; j < h; j++)
					for (int k = 0; k < w; k++)
						m[j][k] = scanner.nextInt();
				slove(m, i);
			}
			int res = 1 << 30;
			for (int i = 0; i <= r; i++) {
				res = Math.min(res, map[0][i] + map[1][r - i]);
			}
			System.out.println(res);

		}
	}

	private void slove(int[][] m, int i) {
		boolean[][] b = new boolean[h][w];
		int id = 1;
		int l = -1;
		b[sy][sx] = true;
		PriorityQueue<Point> pq = new PriorityQueue<Point>();
		pq.offer(new Point(m[sy][sx], sy, sx));
		while (!pq.isEmpty()) {
			Point point = pq.poll();
			l = Math.max(l, point.k);
			map[i][id++] = l;
			for (int[] mo : move) {
				int ny = point.y + mo[0];
				int nx = point.x + mo[1];
				if (!isOK(ny, nx))
					continue;
				if (b[ny][nx])
					continue;
				b[ny][nx] = true;
				pq.offer(new Point(m[ny][nx], ny, nx));
			}
		}
	}

	private boolean isOK(int ny, int nx) {
		if (0 <= ny && ny < h && 0 <= nx && nx < w)
			return true;
		return false;
	}

	int r, w, h, sx, sy;
	int[][] map;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	class Point implements Comparable<Point> {
		int k, y, x;

		@Override
		public String toString() {
			return "Point [k=" + k + ", y=" + y + ", x=" + x + "]";
		}

		public Point(int k, int y, int x) {
			super();
			this.k = k;
			this.y = y;
			this.x = x;
		}

		@Override
		public int compareTo(Point o) {
			return this.k - o.k;
		}

	}
}

Measured memory_bytes: 173156
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

#n = ip()                                     #入力整数1つ
a,b,t= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#k = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
s = t//a*b
print(s)

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

const int INF = 0x3f3f3f3f;
const int MAXN = 1e3+10;
int nums[MAXN];

int main()
{
	int n; cin>>n;
	for(int i = 0; i < n; ++i) {
		cin>>nums[i];
	}
	for(int i = 0; i < n; ++i) {
		if(nums[i]&1) {
			continue;
		} else {
			if(nums[i]%3==0||nums[i]%5==0) {
				continue;
			} else {
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0; 
}

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

int main()
{
		int H[10000], W[10000], n, i, j, k;
		while (1) {
				cin >> H[n] >> W[n];
				if (H[n]==0 && W[n]==0) break;
				n++;
		}

		for (i=0; i<n; i++) {
				for (j=0; j<H[i]; j++) {
						for (k=0; k<W[i]; k++) {
								if ((j%2==0 && k%2==0) || (j%2==1 && k%2==1)) cout << "#";
								else if ((j%2==0 && k%2==1) || (j%2==1 && k%2==0)) cout << ".";
						}
						cout << "\n";
				}
				cout << "\n";
		}
}

Measured memory_bytes: 3048
n, y = map(int, input().split())
y //= 1000
flag = False
for i in range(n+1):
  for j in range(n+1-i):
    k = n - i - j
    z = y - i - j * 5
    if z >= 0 and z % 10 == 0 and z // 10 == k:
      print(k, j, i)
      flag = True
      break
  if flag:
    break
  
else:
  print("-1 -1 -1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (1e5) + 5;
vector<int> adj[N];
int n, m;

int memo[N];

int DP(int u) {
	if (adj[u].size() == 0) return 0;
	int &ret = memo[u];
	if (ret != -1) return ret;
	ret = 0;
	int sz = adj[u].size();
	for (int i = 0; i < sz; ++i) {
		int v = adj[u][i];
		ret = max(ret, 1 + DP(v));
	}
	return ret;
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int u, v; scanf("%d %d", &u, &v);
		--u; --v;
		adj[v].push_back(u);
	}
	memset(memo, -1, sizeof memo);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ans = max(ans, DP(i));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, h, w;
  cin >> n >> h >> w;
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    //cout << h - a << " " << w - b << endl;
    if (a >= h && b >= w) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall

INF = 10 ** 18
N, M = map(int, input().split())
d = [[INF for _ in range(N)] for _ in range(N)]
abc = []

for i in range(M):
    a, b, c = map(int, input().split())
    abc.append([a - 1, b - 1, c])
    d[a - 1][b - 1] = c
    d[b - 1][a - 1] = c

wf = floyd_warshall(d)
cnt = 0
for i in range(M):
    if abc[i][2] > wf[abc[i][0]][abc[i][1]]:
        cnt += 1


print(cnt)

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

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(ll x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(ll x){writ(x);putchar('\n');}

int main()
{
	int a=read(),b=read();
	if (b!=100)write((ll)b*(ll)pow(100,a));
	else write((ll)(b+1)*(ll)pow(100,a));
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int X = input.nextInt();
        input.nextLine();
        if (X >= 30) {
            System.out.println("Yes");
        } else {System.out.println("No");
        }
    }
}

Measured memory_bytes: 35696
import java.io.*;
import java.util.*;

public class Main {
  private static long solve(long h) {
    if (h == 1) {
      return 1;
    }
    return 1 + 2 * solve(h / 2);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    long h = reader.nextLong();
    out.println(solve(h));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 23252
import sys
input = sys.stdin.readline
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
m = 1 
mindis = abs(A-(T-H[0]*0.006))
for i in range(1,N):
  cd = abs(A-(T-H[i]*0.006))
  if mindis > cd:
    m = i+1
    mindis = cd
print(m)
        

Measured memory_bytes: 9128
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
struct LCS{
  double l,a,b;
  LCS(double l,double a,double b):l(l),a(a),b(b){};
};
int n,m;
double ans = 0;
vector<LCS> vec;
vector<int> used;
double cal(LCS a,LCS b){
  return pow(a.l - b.l,2) + pow(a.a - b.a,2) + pow(a.b - b.b,2);
}
double solve(){
  double res = 0;
  for(int i = 0;i < n;i++){
	if(used[i]){
	  for(int j = i+1;j < n;j++){
		if(used[j]){
		  res+= cal(vec[i],vec[j]);
		}
	  }
	}
  }
  return res;
}
void dfs(int cnt,int num){
/*  cout << "cnt = " << cnt << "   num = " << num << endl;
  cout << "used flag " ;
  for(int i = 0;i < n;i++){
	if(used[i])cout << i << " " ;
	
  }
  cout << endl;
*/


  
  if(cnt == m){
	ans = max(ans,solve());
	return;
  }
  if(num >= n)return;
  if(!used[num]){
	used[num] = 1;
	dfs(cnt+1,num+1);
	used[num] = 0;
  }
  dfs(cnt,num+1);
  
}

int main(){
  
  cin >> n >> m;
  used = vector<int>(n,0);
  for(int i = 0;i < n;i++){
	double l,a,b;
	cin >> l >> a >> b;
	vec.emplace_back(l,a,b);	
  }
  dfs(0,0);
  cout << fixed << setprecision(5) << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1304
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 1e5 + 10;
int a[N];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++) scanf("%d",&a[i]);
    int flag = 0;
    for(int i = 0 ; i < n ; i++){
        if(a[i] % 2 == 1) flag++;
    }
    if(flag % 2 == 0) printf("YES\n");
    else printf("NO\n");
    return 0;
}



Measured memory_bytes: 512
#include<cstdio>
using namespace std;
int h,w;
long long f[1001][1001];
bool a[1001][1001];
char t;
int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf(" %c",&t);
			if(t=='.'){
				a[i][j]=true;
			}
		}
	}
	f[1][1]=1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i-1][j]==true){
				f[i][j]+=f[i-1][j];
				f[i][j]%=1000000007;
			}
			if(a[i][j-1]==true){
				f[i][j]+=f[i][j-1];
				f[i][j]%=1000000007;
			}
		}
	}
	printf("%lld",f[h][w]);
}

Measured memory_bytes: 8960
import sys
import math
sys.setrecursionlimit(1000000000)
 
def solve(robots):
    total = len(robots)
    prev = None
    for current in robots:
        if prev and prev[0] + prev[1] > current[0] - current[1]:
            total -= 1
        else:
            prev = current
            
    return total
 
N, = map(int, input().split())
ROBOTS = [list(map(int, input().split())) for _ in range(N)]
ROBOTS = sorted(ROBOTS, key=lambda x: x[0] + x[1])
print(solve(ROBOTS))

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



// int main(){

//     int n,r;
//     cin >> n>>r;
//     int ans  = r+100*max(0,10-n);
//     cout<<ans<< endl;
//     return 0;
// }




int main(){

    int n,k;
    cin >>n>>k;
    int ans = 0;
    while (n>0)
    {
        n/=k;
        ans++;

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

}


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

int main(){
  int H, W; cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  int white = 1;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      cin >> S[i][j];
    }
  }
  long long ans = 0;
  vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      if (S[i][j]!='#') continue;
      long long count = 0;
      long long tmpans = 0;
      queue<pair<int, int>>  que;
      S[i][j] = '$';
      que.push(make_pair(i,j));
      while (!que.empty()){
        count++;
        auto check = que.front();
        que.pop();
        for (int k=0; k<4; k++){
          if (check.first+dx[k]<0||check.first+dx[k]>=H||check.second+dy[k]<0||check.second+dy[k]>=W) continue;
          if (S[check.first+dx[k]][check.second+dy[k]]!='.') continue;
          S[check.first+dx[k]][check.second+dy[k]] = '$';
          tmpans++;
          for (int l=0; l<4; l++){
            if (check.first+dx[k]+dx[l]<0||check.first+dx[k]+dx[l]>=H||check.second+dy[k]+dy[l]<0||check.second+dy[k]+dy[l]>=W) continue;
            if (S[check.first+dx[k]+dx[l]][check.second+dy[k]+dy[l]]!='#') continue;
            S[check.first+dx[k]+dx[l]][check.second+dy[k]+dy[l]] = '$';
            que.push(make_pair(check.first+dx[k]+dx[l],check.second+dy[k]+dy[l]));
          }
        }
      }
      ans += tmpans*count;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;

int a = 0;
int b = 0;
int k = 0;

int main() {

	cin >> a;
	cin >> b;
	cin >> k;

	for (int i = a; i <= b; ++i) {
		if (i < a + k || i > b - k) {
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
from collections import Counter


def solve():
    YES, NO = "Yes", "No"
    if H % 2 and W % 2:
        if rems[1] == 0 and rems[3] == 1:
            rems[1] += 1
            rems[2] += 1
            rems[3] = 0
        if rems[1] != 1 or rems[3] or rems[2] > H // 2 + W // 2:
            return NO
        else:
            return YES
    elif H % 2 or W % 2:
        even_edge = H if W % 2 else W
        if rems[1] + rems[3] or rems[2] > even_edge // 2:
            return NO
        else:
            return YES
    else:
        if rems[1] + rems[2] + rems[3]:
            return NO
        else:
            return YES


H, W = map(int, input().split())
c = Counter()
for _ in range(H):
    c += Counter(input())
rems = Counter(v % 4 for v in c.values())
print(solve())


Measured memory_bytes: 9472