akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

ll pow_(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = (x * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return x;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N;
  string A;
  string B = "keyence";
  ll count = 0;
  ll once = 0;
  cin >> A;
  REP(i, A.size()) {
    if (A[i] == B[count] && count < 7) {
      count++;
    } else {
      break;
    }
  }

  ll po = 7 - count;
  FOR(i, A.size() - po, A.size()) {
    if (A[i] == B[count])
      count++;
  }
  if (count == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    vector<int> list{105, 135, 165, 189, 195};
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < 5; i++)
        if (N >= list[i])
            ans++;
    cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int X = Integer.parseInt(scan.next());
		int T = Integer.parseInt(scan.next());
		int ans = 0;

		while (N > 0) {
			ans+=T;
			N-=X;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 35572
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,a;
int main(){
    cin>>n>>a;
    cout<<n*n-a<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, T, *t = map(int, read().split())
ans = 0
for cur, nex in zip(t, t[1:]):
    ans += min(T, nex - cur)
print(ans + T)


Measured memory_bytes: 23424
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String s = sc.next();
            if (s.equals("0")) {
                break;
            }
            int ret = 0;
            for (int i = 0; i < s.length(); i++) {
                ret += s.charAt(i) - 48;
            }
            System.out.println(ret);
        }
    }
}


Measured memory_bytes: 26280
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    m: i64,
    shop: [(i64, i64); n],
  }
  let mut shop = shop;
  shop.sort();
  let mut m = m;
  let mut ans = 0;
  for &(a, b) in &shop {
    ans += a * cmp::min(m, b);
    m -= cmp::min(m, b);
    if m == 0 {
      break;
    }
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 8444
while 1:
    n = int(input())
    if n == 0:
        break
    S = 1
    for i in range(n):
        S = S * (i+1)
    A = 0
    while 1:
        if S %10 !=0:
            break
        else:
            S = S //10
            A = A+1
    print(A)


Measured memory_bytes: 5628
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i = 0; i < N; i++)
            W[i] = sc.nextInt();
        
        int sum = 0;

        for(int i = 0; i < N; i++)
            sum += W[i];
        
        int ans = sum;
        
        for(int i = 0; i < N; i++){
            int sum_i = sum_t(W, i);
            if(Math.abs((sum_i)-(sum-sum_i)) < ans)
                ans = Math.abs((sum_i)-(sum-sum_i));
        }
        System.out.println(ans);
        sc.close();
    }
    
    static int sum_t(int[] a, int t){
        int sum = 0;
        for(int i = 0; i < t; i++)
            sum += a[i];
        return sum;
    }
}

Measured memory_bytes: 22612
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++) a[i]=i+1;
        for(int i=0;i<m;i++){
            String s=sc.next();
            int k=0;
            //System.out.println(s);
            String[] t=s.split(",");
            int aa=Integer.parseInt(t[0]);
            int bb=Integer.parseInt(t[1]);
            aa--;
            bb--;
            int tmp=a[aa];
            a[aa]=a[bb];
            a[bb]=tmp;
        }
        for(int i=0;i<n;i++)System.out.println(a[i]);
    }
}


Measured memory_bytes: 25820
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char a = sc.next().charAt(0);
		char b = sc.next().charAt(0);
		sc.close();
		
		if(a == b)
			System.out.println("H");
		else
			System.out.println("D");
	}
}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll INF = 1e17;

int main(){
  int n, m;
  cin >> n >> m;
  string s[n];
  rep(i,n) cin >> s[i];
  mf_graph<ll> graph(n*m+2);
  int dx[4] = {0,1,0,-1};
  int dy[4] = {1,0,-1,0};
  rep(i,n) {
    rep(j,m) {
      if((i+j) % 2 == 0) {
        graph.add_edge(n*m,i*m+j,1);
        if(s[i][j] != '#') {
          rep(k,4) {
            int ni = i + dx[k], nj = j + dy[k];
            if(ni >= 0 and ni < n and nj >= 0 and nj < m and s[ni][nj] != '#') graph.add_edge(i*m+j,ni*m+nj,1);
          }
        }
      } else {
        graph.add_edge(i*m+j,n*m+1,1);
      }
    }
  }
  ll ans = graph.flow(n*m,n*m+1);
  vector<mf_graph<ll>::edge> state = graph.edges();
  for(auto e : state) {
    if(e.flow == 1 and e.from != n*m and e.to != n*m+1) {
      int x = e.from/m, y = e.from % m, nx = e.to/m, ny = e.to % m;
      if(x < nx or y < ny) swap(x,nx), swap(y,ny);
      if(x > nx) s[x][y] = '^', s[nx][ny] = 'v';
      if(y > ny) s[x][y] = '<', s[nx][ny] = '>';
    }
  }
  cout << ans << endl;
  rep(i,n) cout << s[i] << endl;
  return 0;
}


Measured memory_bytes: 6324
#include<stdio.h>
int main(void){
    int a,b,d,r;
        scanf("%d%d",&a,&b);
        d = a / b;
        r = a % b;
        double f;
        f = 1.0 * a / b;
        printf("%d %d %.5lf\n",d,r,f);

return 0;
}

Measured memory_bytes: 640
import sys
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


a, b = sp()
out(a * b)


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

int main() {
    int N;
    cin >> N;
    int A = 0;
    int B = 0;
    vector<int> vec(N);
    for (int j = 0; j < N; j++){
        cin >> vec.at(j);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    
    for (int i = 0; i < N; i++){
        if (i % 2 == 0){
            A += vec.at(i);
        }
        else{
            B += vec.at(i);
        }
    }
    cout << A - B << endl;
}

Measured memory_bytes: 256
#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(){
    string s;
    cin >> s;
    int sum = 0;
    rep(i,s.size()){
        sum += s[i] - '0';
        sum %= 9;
    }
    if(sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

Measured memory_bytes: 3632
import numpy as np


def main():
    a, b, m = map(int, input().split())
    a_c = np.array(list(map(int, input().split())), dtype=int)
    b_c = np.array(list(map(int, input().split())), dtype=int)
    discount = [tuple(map(int, input().split())) for _ in range(m)]
    answer = min(a_c) + min(b_c)
    for d in discount:
        answer = min(answer, a_c[d[0] - 1] + b_c[d[1] - 1] - d[2])
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 31620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
using namespace std;
#define Would
#define you

int main() {
	int a, b, c, d, e, f, ans;
	cin >> a >> b >> c >> d >> e >> f;
	if (a + 5 * b + 10 * c + 50 * d + 100 * e + 500 * f >= 1000) { ans = 1; }
	else { ans = 0; }
	cout << ans << endl;
}



Measured memory_bytes: 3124
N = int(input())
As = list(map(int, input().split()))
As.sort()
ans = 0
mod = 10**9+7
flag = True
if N%2 == 1:
    x = 0
    for i in range(N):
        if i%2 == 0:
            if As[i] != x:
                flag = False
                break
        else:
            x += 2
            if As[i] != x:
                flag = False
                break
    if flag:
        ans = pow(2, (N-1)//2, mod)
else:
    x = -1
    for i in range(N):
        if i%2 == 0:
            x += 2
            if As[i] != x:
                flag = False
                break
        else:
            if As[i] != x:
                flag = False
                break
    if flag:
        ans = pow(2, N//2, mod)
print(ans)

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

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

int main()
{
    int N; cin >> N;
    vector<int> odd_cnt(100002, 0);
    vector<int> even_cnt(100002, 0);
    int max_cnt1 = 0, max_cnt2 = 0;
    int max_elm1 = 0, max_elm2 = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (i % 2 == 0) {
            even_cnt[a]++;
            if (max_cnt1 < even_cnt[a]) {
                max_cnt1 = even_cnt[a];
                max_elm1 = a;
            }
        }
        else {
            odd_cnt[a]++;
            if (max_cnt2 < odd_cnt[a]) {
                max_cnt2 = odd_cnt[a];
                max_elm2 = a;
            }
        }
    }

    sort(odd_cnt.begin(), odd_cnt.end(), greater<int>());
    sort(even_cnt.begin(), even_cnt.end(), greater<int>());
    if (max_elm1 != max_elm2) {
        cout << N - max_cnt1 - max_cnt2 << endl;
    }
    else {
        cout << min(N - even_cnt[0] - odd_cnt[1], N - even_cnt[1] - odd_cnt[0]) << endl;
    }
}

Measured memory_bytes: 1024
#coding:utf-8

N = int(input())

flows = []
for i in range(5):
    flows.append(int(input()))

min_flow = min(flows)

if N % min_flow == 0:
    ans = int(N / min_flow)
else:
    ans = int(N / min_flow) + 1
    
print(ans + 4)


Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
using namespace std; 
void solve() 
{
    string S,T; 
    cin >> S >> T; 
    int count =0; 
    for(int i = 0 ; i<S.size() ; i++) 
    {
        if(S[i]!=T[i]) 
            count ++; 
    }
    cout << count << endl; 
}
int main () 
{
    int t=1; 
    for (int i=1;i<=t; i++) 
    {
        solve() ; 
    }
    return 0;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 18
#define LL long long
#define RL Reg LL
#define CL Con LL&
#define INF 1e18
#define Gmin(x,y) (x>(y)&&(x=(y)))
using namespace std;
int n,a[N+5];
I LL dfs(CI l,CI r,CL tl,CL tr)
{
	if(r-l==1) return 0;RL t,res=INF;
	for(RI i=l+1;i^r;++i) t=dfs(l,i,tl,tl+tr)+dfs(i,r,tl+tr,tr)+a[i]*(tl+tr),Gmin(res,t);
	return res;
}
int main()
{
	RI i;for(scanf("%d",&n),i=1;i<=n;++i) scanf("%d",a+i);
	return printf("%lld",dfs(1,n,1,1)+a[1]+a[n]),0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func run() int {
	var n, k int
	fmt.Scanf("%d %d\n", &n, &k)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &p[i])
	}

	if k > len(p) {
		k = len(p)
	}

	prevSum := 0.0
	sums := make([]float64, k, k)
	total := 0.0
	for i := 0; i < len(p); i++ {
		sum := float64(1+p[i]) / 2.0
		if i >= k {
			total -= sums[i%k]
		}
		sums[i%k] = sum
		total += sum
		if prevSum < total {
			prevSum = total
		}
	}

	fmt.Println(prevSum)

	return 0
}

func main() {
	os.Exit(run())
}


Measured memory_bytes: 6272
using System;

public class A {
    public static void Main(){
        string S = Console.ReadLine();
        char[] str = S.ToCharArray();
    
        bool isHitachi = true;
        if (S.Length%2 ==1)
        {
            isHitachi = false;
        }
        else
        {
        for (int i=0;i<S.Length;i+=2)
        {
            if (!((str[i]=='h')&&(str[i+1]=='i')))
            {
                isHitachi = false;
                break;
            }
        }
        }
        if (isHitachi) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}


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

typedef struct list{
    int H;
    int W;
    struct list *next;
}List;

List *head = NULL;


void insert(int a, int b){
    List *node = (List *) malloc(sizeof(List));
    node->H = a;
    node->W = b;
    node->next = NULL;

    if (head == NULL){
        head = node;
    }

    else
    {
        List *p = head;

        while (p->next != NULL)
        {
            p = p->next;
        }
        p->next = node;
    }
}

void print(){
    List *p = head;

    while (p != NULL)
    {
        // printf("%d %d\n",p->H , p->W);

        for (int i = 0; i < p->H; i++)
        {
            for (int j = 0; j < p->W; j++){
                if (i == 0 || i == p->H - 1){
                printf("#");
                }

                else if (j == 0 || j == p->W - 1){
                    printf("#");
                }

                else{
                    printf(".");
                }
            }

            printf("\n");

        }
        printf("\n");

        p = p->next;
    }

}



int main(){
    while(1){
        int H, W;
        scanf("%d" "%d" , &H, &W);
        if (H == 0 && W == 0){
            break;
        }
        insert(H, W);
    }

    print();



    return 0;
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define fi first
#define se second
#define be begin()
#define en end()
#define reverse
const int mod=1000000007;
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
  return max(a,b)-min(a,b);
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(true){
    c-=b;
    if(c<=0){
      cout<<"Yes\n";
      break;
    }
    a-=d;
    if(a<=0){
      cout<<"No\n";
      break;
    }
  }
}


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

#define IOS cin.tie(0);ios::sync_with_stdio(0)

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail>
void OUT(Head&& head,Tail&&...tail){
    cout<<head<<(sizeof...(tail)?' ':'\n');
    OUT(move(tail)...);
}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSUBLE\n");}

void print(){}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
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 NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}
int first_digit(int x){
    x%=10;
    return x;
}

int order_time(pair<int,int> p){
    if(p.first==10) return p.second;
    int a=10-p.first;
    return a+p.second;
}

signed main(){
//  IOS;
    vp dish(5);
    rep(i,5){
        int x;cin>>x;
        dish[i].second=x;
        if(first_digit(x)==0)dish[i].first=10;
        else dish[i].first=first_digit(x);
    }
    sort(all(dish),greater<pair<int,int>>());
    int sum=dish[4].second;
    rep(i,4){
        sum+=order_time(dish[i]);
    }
    printf("%d\n",sum);

    return 0;
}

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

using namespace std;

typedef long long int ll;

void solve()
{unordered_set <int> s;
int x, n;cin >> x >> n;
for(int i = 0; i < n; i++)
{
	int y;
	cin >> y;
	s.insert(y);
}
int mas = INT_MAX, val = x;
for(int i = 0; i <= 100; i++)
{
	if(s.find(x - i) == s.end())
	{
		cout << x-i << "\n";
		return;
	}
	else if(s.find(x + i) == s.end())
	{
		cout << x+i << "\n";
		return;
	}
}
}

int main()
{
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}



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

using namespace std;
const int MOD = 1e9 + 7;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int main(int argc, char*argv[])
{
	int N, K;
	cin >> N >> K;
	vector<int> a(N+1, 0);
	vector<vector<pair<int, int>>> dp(N+1, vector<pair<int, int>>(K+1, make_pair(0, 0)));
	for (int i = 1; i <= N; ++i)
		cin >> a[i];
	
	for (int i=0; i<=K ; ++i)
	{
		dp[0][i].first = 1;
		dp[0][i].second = 1;
	}
		
	for (int i = 1 ; i <= N; ++i) //child loop
	{
		for(int j = 0; j <= K; ++j)
        {
            int left = j, right = (j - a[i] - 1);

            dp[i][j].first = dp[i - 1][left].second;

            if(right >= 0)
            {
                dp[i][j].first = sub(dp[i][j].first , dp[i - 1][right].second);
            }
			if(j)
				dp[i][j].second = add(dp[i][j].first, dp[i][j-1].second);
			else
				dp[i][j].second = dp[i][j].first;
        }
	}
	cout << dp[N][K].first%MOD;
}

Measured memory_bytes: 80256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <cstdio>
#include <cstdlib>

typedef long long int lld;
typedef unsigned long long int ulld;
const int mod = 1000000007;

using namespace std;

string uinps[104];

int main (void) {
	ios::sync_with_stdio (false);
	int n, l;
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		cin >> uinps[i];
	}

	sort (uinps, uinps + n);
	for (int i = 0; i < n; i++) {
		cout << uinps[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const ll c=1e3,cn=1e7,con=1e4;
const ll mod=1e9+7;
int nm,m,cntr=1e9,pos=0,cntr2=0,sum=0,temp;
vector<pair<int,pair<int,int> > >v;
vector<ll>ve;
bool lef[cn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    ll ac,b;
    cin>>n;
    ll arr[n+6],a[n+5],ans=0;
    for(int i=0;i<=n;i++){
        cin>>arr[i];
    }
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(arr[i]==a[i]){
            ans+=arr[i];
        }
        else if (arr[i]<a[i]){
            ans+=arr[i];
            a[i]-=arr[i];
            if(arr[i+1]<=a[i]){
               ans+=arr[i+1];
               arr[i+1]=0;
            }
            else {
                ans+=a[i];
                arr[i+1]-=a[i];
            }

        }
         else {
                ans+=a[i];

            }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

s = input()
cnt = {l:0 for l in set(s)}
if len(cnt) != 2:
    print('No')
    exit(0)

for l in s:
    cnt[l] += 1
    if cnt[l] > 2:
        print('No')
        exit(0)

print('Yes')


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

int main(){
  int N,total,K;
  cin >> N;
  K=N;
  total=0;
  for(int i=0;i<8;i++){
    total+=K%10;
    K/=10;
  }
  if(N%total==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	int H, W;
	cin >> H >> W;
	string   c[1000];
	int side[1000][2];
	for (int i = 0; i < H; i++) {
		side[i][0] = 99999;
		side[i][1] = -1;
			cin >> c[i];
			for (int j = 0; j < W; j++) {
				if (c[i][j] == 'B') {
					side[i][0] = min(side[i][0], j);
					side[i][1] = max(side[i][1], j);
				}
			}
	}
	int answer = 0;
	for (int i = 0; i < H; i++) {
		for (int k = 0; k < H; k++) {
			if (side[i][0] != 99999 && side[k][1] != -1) {
			answer = max(answer, abs(i - k) + abs(side[i][0] - side[k][1]));
		}
	}
	}
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<T> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }
};
using namespace Printer;



int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n, W;
    cin >> n >> W;
    vector<ll> v(n), w(n);
    rep(i, n){
        cin >> v[i] >> w[i];
    }
    ll ans = 0;
    vector<ll> dp(MAX);
    fill(ALL(dp), -1);
    dp[0] = 0;
    rep(i, n){
        vector<ll> dp2(MAX);
        fill(ALL(dp2), -1);
        dp2 = dp;
        for(int j=MAX-1; j>=0; j--){
            if(dp[j] != -1){
                if(j+w[i] <= W) {
                    dp2[j+w[i]] = max(dp2[j+w[i]], dp[j]+v[i]);
                    ans = max(dp2[j+w[i]], ans);
                }
            }
        }
        dp = dp2;
        // rep(i, W+1){
        //     if(i) cout << " ";
        //     cout << dp[i];
        // }
        // cout << endl;
    }
    print(ans);

    
    return 0;
}



Measured memory_bytes: 4600
#include <stdio.h>

#define N 100

int main()
{
  int i, j;
  int n, u, k, v;
  int Adj[N][N];

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ )
    for( j = 0 ; j < n ; j++ )
      Adj[i][j] = 0;

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

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      if( j > 0 ) printf(" ");
      printf("%d", Adj[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		for (int i = 0; i <  9; i++) {
			int mod =N % (i + 1);
			int div = N / (i + 1);
			
			if (mod == 0 && div < 10) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

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

int main()
{
	int a2,a3,b1,b2,b3;
	int x[4][4];
	
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin>>x[i][j];
		}
	}
	
	b1=x[1][1];
	b2=x[1][2];
	b3=x[1][3];
	
	a2=x[2][1]-b1;
	a3=x[3][1]-b1;
	
	if(a2+b2==x[2][2]&&a2+b3==x[2][3]&&\
	a3+b2==x[3][2]&&a3+b3==x[3][3])
	{
	   	cout<<"Yes"<<endl;
	   	return 0;
	}
	
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  int n;
  int const teamname = 0;
  int const point = 1;
  while(cin>>n,n){
    vector < vector<int > > team(n+1,vector<int>(2));
    rep(i,n){
		
      int m,s;
      cin>>team[i][teamname];
      rep(h,4){
				cin>>m>>s;
				team[i][point]+=m*60+s;
			}
	
    }
    
    rep(i,n-1){
			loop(j,i,n){
	  		if(team[i][point]>team[j][point]){
	    		team[n][teamname]=team[i][teamname];
	    		team[i][teamname]=team[j][teamname];
	    		team[j][teamname]=team[n][teamname];
	    		team[n][teamname]=0;
				
	  		  team[n][point]=team[i][point];
	 		   team[i][point]=team[j][point];
	   		 team[j][point]=team[n][point];
	   		 team[n][point]=0;
				
			  }
			}
    }
    
/*    rep(i,n){
    	cout<<team[i][teamname]<<" "<<team[i][point]<<endl;
    }
    */
		rep(i,2){
	
	 	 cout<<team[i][teamname]<<endl;		

		}
		cout<<team[n-2][teamname]<<endl;
  }

}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    print(N*(N+1)/2);

}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	int n, k;
	cin >> n >> k;
	long long ans = 0;
	for (int i = k; i <= n + 1; i++)
	{
		long long small = (long long)i * (i - 1) / 2;
		long long big = (long long)n * (n + 1) / 2 - ((long long)n - i + 1) * (n - i) / 2;
		ans += (big - small + 1);
		ans %= 1000000007;
	}
	cout << ans;
}


Measured memory_bytes: 34220
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>


using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
ll inf = 1000000000 + 7;

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



vector<pint> sushi;
vector<pint> mlist;
priority_queue<pint, vector<pint>, less<pint>> q;
priority_queue<pint, vector<pint>, greater<pint>> q2;
ll shurui[100005];
ll ma[100005];

int main() {
	ll N, K;
	ll t, d;
	cin >> N >> K;
	
	rep(i, N) {

		cin >> t >> d;

		q.push({ d,t });
	}
	
	ll ret = 0;
	ll sum = 0;
	rep(i, K) {
		ret += q.top().first;
		shurui[q.top().second] += 1;
		
		if (shurui[q.top().second] == 1)
			sum += 1;


		if (shurui[q.top().second] > 1) {
			q2.push(q.top());
		}
		q.pop();		
	}

	ll tokuten = ret + sum * sum;
	ma[sum] = tokuten;

	for (int i = 0; i < N - K; i++) {


		if (sum >= K) {
			break;
		}
		if (shurui[q.top().second] == 0) {
			ma[sum + 1] = ma[sum] - q2.top().first - sum * sum + q.top().first + (sum + 1) * (sum + 1);
			shurui[q.top().second] += 1;
			if (tokuten < ma[sum + 1])
				tokuten = ma[sum + 1];

			q2.pop();
			sum += 1;
		}
		q.pop();
	}

	cout << tokuten << endl;




	return 0;
}

Measured memory_bytes: 4208
import java.util.Scanner;

public class Main {

	// ２点間の距離
	public static double getDistance (double x1, double y1, double x2, double y2) {
		return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
	}

	public static double[] func1 (double x1, double y1, double x2, double y2, double x3, double y3) {
		double a1 = 2 * (x2 - x1);
		double b1 = 2 * (y2 - y1);
		double c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
		double a2 = 2 * (x3 - x1);
		double b2 = 2 * (y3 - y1);
		double c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		double x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
		double y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
		return new double[]{x, y};
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for (int i = 0; i < n; i++) {
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			double[] ans = func1(x1,y1,x2,y2,x3,y3);
			double ans3 = getDistance(ans[0],ans[1],x1,y1);
			System.out.printf("%.3f %.3f %.3f\n", ans[0], ans[1], ans3);
		}
	}

}

Measured memory_bytes: 20800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            String[] values = line.split("[ ,\\.]");
            boolean appended = false;
            for (String word : values) {
                if (word.length() >= 3 && word.length() <= 6) {
                    if (!appended) {
                        appended = true;
                    } else {
                        out.print(" ");
                    }
                    out.print(word);
                }
            }
            out.println();
        }
    }
}

Measured memory_bytes: 10000
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func gcd(a, b int64) int64 {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func lcm(a, b int64) int64 {
	return a / gcd(a, b) * b
}

func main() {
	defer write.Flush()

	var a, b, c, d int64
	fmt.Fscan(read, &a, &b, &c, &d)
	n1 := b/c - (a-1)/c
	n2 := b/d - (a-1)/d
	n3 := b/lcm(c, d) - (a-1)/lcm(c, d)
	fmt.Fprintln(write, b-a+1-n1-n2+n3)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    string s;
    cin >> s;

    vector<string> subs;
    string aux;

    for ( auto l : s ) {
        aux += l;
        if ( (subs.size() == 0 or aux != subs.back() ) ) {
            subs.pb(aux);
            aux = "";
        }
    }
    // cout << aux << endl;
    cout << subs.size() << endl;

    return 0;
}

Measured memory_bytes: 10996
s = input()
b = 0
w = 0
for i in range(len(s)):
  if s[i] == '0':
    if i % 2 == 0:
      # 偶数番目が0
      w += 1
    else:
      # 奇数番目が0
      b += 1
  else:
    if i % 2 == 0:
      # 偶数番目が1
      b += 1
    else:
      # 奇数番目が1
      w += 1
print(min(b, w))

Measured memory_bytes: 65828
import numpy as np
import itertools
x,y,z,k = [int(_) for _ in input().split(" ")]
A = np.array([int(_) for _ in input().split(" ")])
B = np.array([int(_) for _ in input().split(" ")])                                                  
C = np.sort([int(_) for _ in input().split(" ")])

AB = A.reshape(1,x) + B.reshape(y,1)
sorted_ab  = np.sort(AB.flatten())[::-1][:k]
abc = np.expand_dims(sorted_ab,0) + C.reshape(z,1)
sorted_abc = np.sort(abc.flatten())[::-1]
for i in range(k):
    print(sorted_abc[i])

Measured memory_bytes: 98548
ranges = [range(10), range(10, 100), range(100, 1000)]

N, M = map(int, input().split())
s = [0 for i in range(M)]
c = [0 for i in range(M)]
for i in range(M):
    s[i], c[i] = map(int, input().split())

ans = 0
found = False
for candidate in ranges[N - 1]:
    valid = True
    for i in range(M):
        if not (str(candidate)[s[i] - 1] == str(c[i])):
            valid = False
            break
    if valid:
        print(candidate)
        found = True
        break
if not found:
    print(-1)

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = nextLine()
	}
	b := make([]string, m)
	for i := 0; i < m; i++ {
		b[i] = nextLine()
	}

	for i := 0; i <= n-m; i++ {
	L:
		for j := 0; j <= n-m; j++ {
			for k := 0; k < m; k++ {
				if a[i+k][j:j+m] != b[k] {
					continue L
				}
			}
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
//Only the Creator has given me strength!🖤
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<bitset>
typedef long long ll;
#define pi 3.1415926535897931159979635
#define pb push_back
#define vctr vector<int>
#define vvtr vector<vctr>

using namespace std;
void fastio() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
    fastio();
    int x,y;
    cin>>x;
    y=x%1000;
    if(y==0) cout<<y<<"\n";
    else cout<<1000-y<<"\n";
    return 0;
}

Measured memory_bytes: 3648
# coding: utf-8
# Your code here!
import sys
#sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
#s = input()
#a = [int(i) for i in readline().split()]
#m = [[int(i) for i in readline().split()] for _ in range(n)]


for x in range(1,n+1):
    if n <= x*1.08 < n+1:
        print(x)
        break
else:
    print(":(")


Measured memory_bytes: 2940
n, m = map(int, input().split())

N_ab = []
M_cd = []

for i in range(n):
  a, b = map(int, input().split())
  N_ab.append([a, b])
  
for i in range(m):
  c, d = map(int, input().split())
  M_cd.append([c, d])
  
for i in range(n):
  Mi = abs(N_ab[i][0]-M_cd[0][0]) + abs(N_ab[i][1]-M_cd[0][1])
  #print(Mi)
  num = 0
  for j in range(1, m):
    tmp = abs(N_ab[i][0]-M_cd[j][0]) + abs(N_ab[i][1]-M_cd[j][1])
    #print(tmp)
    if tmp<Mi:
      Mi=tmp
      num=j
  print(num+1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    string S;
    rep(i,N) S+='0';
    if(N!=1) S[0]='1';
    map<int,int> m;
    bool can=true;
    rep(i,M){
        int a,b; cin >> a >> b;
        if(m[a]){
            if(m[a]!=b+1) can=false;
        } else {
            m[a]=b+1;
        }
        if(a==1 && b==0 && N!=1) can=false;
        S[a-1]=(char)('0'+b);
    }
    if(can) cout << S << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    int X,Y;cin >> X >> Y;
    vector<int> x,y;
    int n=s.size();
    int cnt=0;
    bool f=true;
    rep(i,n){
        if(s[i]=='F'){
            cnt++;
        }
        else{
            if(cnt){
                if(f){
                    x.push_back(cnt);
                }
                else{
                    y.push_back(cnt);
                }
                cnt=0;
            }
            f=!f;
        }
    }
    if(cnt){
        if(f){
            x.push_back(cnt);
        }
        else{
            y.push_back(cnt);
        }
    }
    vector<bool> vx(16001),vy(16001);
    vx[8000]=true,vy[8000]=true;
    for(int j=0;j<x.size();j++){
        vector<bool> tmp(16001);
        if(j==0&&s[0]=='F'){
            rep(i,16001){
                if(vx[i]){
                    tmp[i+x[j]]=true;
                }
            }
        }
        else{
            rep(i,16001){
                if(vx[i]){
                    tmp[i+x[j]]=true;
                    tmp[i-x[j]]=true;
                }
            }
        }
        rep(i,16001){
            vx[i]=tmp[i];
        }
    }
    for(int t:y){
        vector<bool> tmp(16001);
        rep(i,16001){
            if(vy[i]){
                tmp[i+t]=true;
                tmp[i-t]=true;
            }
        }
        rep(i,16001){
            vy[i]=tmp[i];
        }
    }
    if(vx[X+8000]&&vy[Y+8000]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	unordered_map<string, long long> mp;
	for(int i=1; i<=N; i++){
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		if(mp.count(s)==0){
			mp[s] = 1;
		}
		else{
			mp[s]++;
		}
	}

	long long ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		long long v = itr->second;
		v = v * (v - 1);
		v /= 2;
		ans += v;
	}

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

Measured memory_bytes: 10660