akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){

	int n;
	cin>>n;

	vector<int> arr(n);
	for(int i = 0;i < n; i++) cin>> arr[i];

	vector<int> pre(n);
	int ans = abs(arr[0]);

	for(int i = 1; i < n; i++){
		ans += abs(arr[i] - arr[i-1]);
	}
	ans+=abs(arr[n-1]);

	cout<< ans - abs(arr[0]) - abs(arr[1]-arr[0])+abs(arr[1])<<endl;
	for(int i = 1; i < n-1; i++){
		cout<<ans - abs(arr[i] - arr[i-1]) - abs(arr[i+1] - arr[i]) + abs(arr[i+1]-arr[i-1])<<endl;
	}
	//cout<<"a:"<<abs(arr[n-1]-arr[n-2])<<endl;
	cout<<ans - abs(arr[n-1]-arr[n-2]) - abs(arr[n-1]) + abs(arr[n-2])<<endl;

}

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

int rsp(char k, int R, int S, int P){
  if(k == 'r'){return P;}
  else if(k == 's'){return R;}
  else{return S;}
}

int main(){
    long long int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T; cin >> T;
    int p = N/K;
    vector<vector<char>> vec(K, vector<char>(0));
    for(int i=0; i<p; i++){
      for(int j=0; j<K; j++){
        vec[j].push_back(T[i*K + j]);
      }
    }
    for(int i=0; i<N-p*K; i++){
      vec[i].push_back(T[K*p+i]);
    }
    long long int sum = 0;
    for(int i=0; i<K; i++){
        sum += rsp(vec[i][0], R, S, P);
        bool t = false;
        for(int j=1; j<vec[i].size(); j++){
          if(vec[i][j] == vec[i][j-1]){
            if(vec[i][j] != vec[i][j-2]){
              sum += 0;
              t = true;
            }
            else if(vec[i][j] == vec[i][j-2]&&t == true){
              sum += rsp(vec[i][j], R, S, P);
              t = false;
            }
            else if(vec[i][j] == vec[i][j-2]&&t == false){
              sum += 0;
              t = true;
            }
          }
          else{
            sum += rsp(vec[i][j], R, S, P);
            t = false;
          }
        }
      }
    cout << sum;
}

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = ll(1e9 + 7);



int main() {
	int N;
	cin >> N;
	Vi d(N);
	for (int i = 0; i < N; ++i) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	int i_mid1 = N / 2 - 1;
	int i_mid2 = N / 2;
	cout << d[i_mid2] - d[i_mid1] << endl;
}


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

int main() {
  int N,A,amari;
  cin >> N >>A ;
  amari=N%500 ;
    if (amari > A){
      cout << "No" << endl ;
    }
  else {
    cout << "Yes" << endl ;
  }
  
}


Measured memory_bytes: 256
def d1(x):
    y = x % 10
    if y == 0:
        return [0, 1]
    elif y == 9:
        return [8, 9]
    else:
        return [y-1, y, y+1]


K = int(input())

runrun = []
N = 0
digit = 0
while N < K:
    d_i = []
    if digit == 0:
        for i in range(1, 10):
            d_i.append(i)
        N += len(d_i)
        runrun.append(d_i)
        digit += 1
    else:
        tmp = runrun[digit-1]
        for x in tmp:
            for y in d1(x):
                d_i.append(10*x+y)
        N += len(d_i)
        runrun.append(d_i)
        digit += 1

print(runrun[-1][K-N-1])


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n, m;
    cin>>n>>m;
    int l=1;
    int r=n;


    set<int> seen;

    if (n%2) {
	while (m--) {
	    int dist=r-l;
	    int dist2=n-dist;
	    
	    assert(l>=1 && l<=n);
	    assert(r>=1 && r<=n);
	    cout<<l<<" "<<r<<endl;
	    assert(!seen.count(dist) && !seen.count(dist2));
	    l++;
	    r--;
	}
    } else {

	while (m--) {
	    int dist=r-l;
	    int dist2=n-dist;
	    if (seen.count(dist) || seen.count(dist2) || dist==dist2) {
		r--;
	    }
	    assert(l>=1 && l<=n);
	    assert(r>=1 && r<=n);

	    dist=r-l;
	    dist2=n-dist;

	    cout<<l<<" "<<r<<endl;
	    assert(!seen.count(dist) && !seen.count(dist2) && dist!=dist2);
	    seen.insert(dist);
	    seen.insert(dist2);
	    l++;
	    r--;
	}
    }
    
    
    return 0;
}


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

int main()
{
    bool *area;
    int H;
    int W;
    string tempString;
    cin >> H;
    cin >> W;
    area = new bool[H * W];

    for (int h = 0; h < H; h++)
    {
        cin >> tempString;
        for (int w = 0; w < W; w++)
        {
            area[h + w * H] = (tempString[w] == '#') ? true : false;
        }
    }

    for (int h = 0; h < H; h++)
    {
        for (int w = 0; w < W; w++)
        {
            if (area[h + w * H])
            {
                cout << "#";
            }
            else
            {
                int count = 0;
                for (int x = h - 1; x <= h + 1; x++)
                {
                    for (int y = w - 1; y <= w + 1; y++)
                    {
                        if (x < 0 || x >= H || y < 0 || y >= W)
                            continue;
                        else if(area[x + y * H])
                            count++;
                    }
                }
                cout << count;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    long long int a,b,c=0,o,e,d=1,i,t,j,n,y,k,m,l,x,r=0;
    scanf("%lld %lld",&x ,&y);
    if(x*2<=y&&x*4>=y&&y%2==0){printf("Yes\n");}
    else{printf("No\n");}
}


Measured memory_bytes: 1620
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <utility>
using namespace std;

template< typename T >
struct Edge {
  int from, to;
  T cost;
  Edge() {}
  Edge(int f, int t) : from(f), to(t), cost(1) {}
  Edge(int f, int t, T c) : from(f), to(t), cost(c) {}
  friend bool operator < (const Edge& lhs, const Edge& rhs) { return lhs.cost < rhs.cost; };
  friend bool operator > (const Edge& lhs, const Edge& rhs) { return rhs < lhs; };
  friend bool operator <= (const Edge& lhs, const Edge& rhs) { return !(lhs > rhs); };
  friend bool operator >= (const Edge& lhs, const Edge& rhs) { return !(lhs < rhs); };
};

template< typename T >
using Edges = std::vector< Edge< T > >;
template< typename T >
using Graph = std::vector< Edges< T > >;


int C = 0;
map<pair<int, int>, int> edges;
vector<int> ans(100000);

void dfs(Graph<int>& g, int s, int c, int par) {
    int nc = 0;
    for (auto e: g[s]) {
        if (e.to == par) continue;
        if (nc == c) ++nc;
        ans[edges[{e.from, e.to}]] = nc;
        C = max(C, nc);
        dfs(g, e.to, nc, s);
        ++nc;
    }
}

int main() {
    int n; cin >> n;
    Graph<int> g(n);
    for (int i = 0; i < n-1; ++i) { 
        int a, b; cin >> a >> b;
        --a; --b;
        g[a].emplace_back(a, b);
        g[b].emplace_back(b, a);
        edges[{a,b}] = i;
        edges[{b,a}] = i;
    }
    dfs(g, 0, -1, -1);
    cout << C+1 << endl;
    for (int i = 0; i < n-1; ++i) {
        cout << ans[i]+1 << endl;
    }
}


Measured memory_bytes: 19968
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

int main() {
  int n;
  cin >> n;
  vector<ll> num(n+1,0),cnt(n+1,0);
  for(int i=1;i<=n;i++){
    cin >> num[i]; cnt[num[i]]++;
  }
  ll mother=0;
  for(int i=1;i<=n;i++){
    mother += cnt[i]*(cnt[i]-1)/2;
  }
  for(int i=1;i<=n;i++){
    cout << mother - cnt[num[i]] + 1 << endl;
  }
}


Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int gcd(int a, int b)
{
	return b == 0 ? a : gcd(b, a%b);
}
int g_all(int a, int b, int  c)
{
	int d = gcd(a, b);
	return gcd(c, d);
}
int main()
{
	int num;
	cin >> num;
	unsigned long long add = 0;
	for (int i = 1; i <= num; i++) {
		for (int j = 1; j <= num; j++) {
			for (int k = 1; k <= num; k++) {
				add += g_all(i, j, k);
			}

		}

	}
	cout << add << endl;


}

Measured memory_bytes: 3632
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i64>().ok().unwrap());
    let (n, d) = (it.next().unwrap(), it.next().unwrap());
    let mut ans = 0;
    for _ in 0..n {
        let line = gets();
        let mut it = line
            .trim()
            .split_whitespace()
            .map(|x| x.parse::<i64>().ok().unwrap());
        let (x, y) = (it.next().unwrap(), it.next().unwrap());
        if x * x + y * y <= d * d {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2160
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF=1e9+7;
int main()
{
	int dp[1<<12];
	int n, m; cin>>n>>m;
	fill(dp, dp+(1<<n), INF);
	dp[0]=0;
	for(int i=0; i<m; i++){
		int a, b;
		cin>>a>>b;
		int x=0;
		for(int j=0; j<b; j++){
			int c; cin>>c;
			x^=(1<<(c-1));
		}
		for(int j=(1<<n)-1; j>=0; j--){
			dp[j|x]=min(dp[j|x], dp[j]+a);
		}
	}
	if(dp[(1<<n)-1]>=INF) cout<<-1<<endl;
	else cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const ll INF = 1e9;
 
int main(void) {
    int a;
    string s;
    cin >> a >> s;

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
t=0
for i in range(n-1):
 d=a[i]
 for j in range(i+1,n):
  e=a[j]
  if d==e:t=1;break
  for p in('152043','215304','302541','410352','514320'):
   f=[d[int(k)]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:t=1
print(('Yes','No')[t])


Measured memory_bytes: 5616
#include <cstdio>
#include <iostream>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;

typedef pair<double, double> p_d;

void printP(p_d p)
{
  printf("%.6f %.6f\n",p.first, p.second);
}

void koch(int n, p_d p1, p_d p2)
{
  if(n == 0) return;
  p_d s, u, t;
  s.first = (2 * p1.first + p2.first) / 3;
  s.second = (2 * p1.second + p2.second) / 3;
  t.first = (p1.first + 2 * p2.first) / 3;
  t.second = (p1.second + 2 * p2.second) / 3;
  u.first = s.first + (t.first - s.first) * cos(60 * M_PI / 180) - (t.second - s.second) * sin(60 * M_PI / 180);
  u.second = s.second + (t.first - s.first) * sin(60 * M_PI / 180) + (t.second - s.second) * cos(60 * M_PI / 180);
  koch(n-1, p1, s);
  printP(s);
  koch(n-1, s, u);
  printP(u);
  koch(n-1, u, t);
  printP(t);
  koch(n-1, t, p2);
}

int main()
{
  p_d a(0.0,0.0);
  p_d b(100.0,0.0);
  int n;
  cin >> n;
  printP(a);
  koch(n, a, b);
  printP(b);
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;ll n = s.size();
  vll num(3, 0);
  re(i, n) num[s[i]-'a']++;
  ll t = max({num[0], num[1], num[2]}) - min({num[0], num[1], num[2]});
  std::cout << (t<=1?"YES":"NO") << '\n';
  return 0;
}


Measured memory_bytes: 512
S,T=open(0).read().split()
n=len(T)
def diff(a,b):
    d=0
    for i in range(n):
        if a[i]!=b[i]:
            d+=1
    return d
dmin=1000
for i in range(len(S)-n+1):
    dmin=min(dmin,diff(S[i:],T))
print(dmin)

Measured memory_bytes: 72488
package main

import (
	"fmt"
)

func main() {
	var n, k, h, cnt int
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		fmt.Scan(&h)
		if h >= k {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 6300
#include <cstdio>
#include <algorithm>

int main(int argc, char const *argv[])
{
  int N, sum = 0;
  scanf("%d", &N);

  int arr[N];
  for (int i = 0; i < N; ++i) scanf("%d", &(arr[i]));

  std::sort(arr, arr + N);
  for (int i = 0; i < N-1; ++i) {
    sum += arr[i];
  }

  if (arr[N-1] < sum) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]


Measured memory_bytes: 215404
#include <stdio.h>

int c[64][64];

void dfs(int y, int x)
{
    int i, j;

    if (!c[y][x]) return;
    c[y][x] = 0;
    for (i = -1; i < 2; i++){
        for (j = -1; j < 2; j++){
            dfs(y + i, x + j);
        }
    }
}

int main(void)
{
    int w, h;
    int i, j;

    while (scanf("%d %d", &w, &h), w){
        int cnt = 0;

        for (i = 1; i <= h; i++){
            for (j = 1; j <= w; j++){
                scanf("%d", c[i] + j);
            }
        }

        for (i = 1; i <= h; i++){
            for (j = 1; j <= w; j++){
                if (c[i][j]){
                    cnt++;
                    dfs(i, j);
                }
            }
        }

        printf("%d\n", cnt);
    }

    return 0;
}

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

int main()
{
    int A[9];
    for (int i = 0; i < 9; i++) cin >> A[i];
    int N;
    cin >> N;
    int b[N];
    for (int i = 0; i < N; i++) cin >> b[i];

    bool bingo[9] = {false};
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < N; j++) {
            if (A[i] == b[j]) {
                bingo[i] = true;
                break;
            }
        }
    }
    string ans = "No";
    if ((bingo[0] && bingo[1] && bingo[2])
     || (bingo[3] && bingo[4] && bingo[5])
     || (bingo[6] && bingo[7] && bingo[8])) {
        ans = "Yes";
    }
    else if ((bingo[0] && bingo[3] && bingo[6])
     || (bingo[1] && bingo[4] && bingo[7])
     || (bingo[2] && bingo[5] && bingo[8])) {
         ans = "Yes";
    }
    else if ((bingo[0] && bingo[4] && bingo[8])
     || (bingo[2] && bingo[4] && bingo[6])) {
         ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
using namespace std;
long MOD=998244353;
long n,k,i,ans[2002],p2[2001]={1},C[4001][4001];
long f(long t)
{
	long p=0,ans=0;
	for(int i=1;i<=k&&t-i<=k&&i<t-i;i++)p++;
	for(long q=0;q<=p;q++)
	{
		long now=p2[q]*C[p][q]%MOD;
		long a=k-2*p+q-!(t%2),b=n-q;
		if(a+b-1>=0&&b>=0)
		{
			now=now*C[a+b-1][b]%MOD;
		}
		else now=0;
		ans=(ans+now)%MOD;
	}
	return ans;
}
main()
{
	cin>>k>>n;
	for(p2[0]=i=1;i<=2000;i++)p2[i]=p2[i-1]*2%MOD;
	for(i=0;i<=4000;i++)C[i][0]=1;
	for(i=1;i<=4000;i++)for(long j=1;j<=i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
	for(i=1;i++<=k;)
	{
		ans[i]=(ans[i]+f(i))%MOD;
		i%2||(n--,ans[i]=(ans[i]+f(i))%MOD,n++);
		cout<<ans[i]<<endl;
	}
	for(--i;--i>1;)cout<<ans[i]<<endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> b(n-1);
	rep(i,n-1) cin >> b[i];
	int ans = 0;
	rep(i,n){
		if(i==0) ans += b[0];
      	if(i==n-1) ans += b[i-1];
		else ans += min(b[i],b[i-1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var map = {};
  var aused = new Set();
  var bused = new Set();
  var alist = new Array(N);//red
  var blist = new Array(N);//blue
  for(var i = 0; i < N; i++){
    var tmp = nextIntArray();
    alist[i] = {
      no : i,
      child : [],
      x : tmp[0],
      y : tmp[1]
    };
  }
  for(var i = 0; i < N; i++){
    var tmp = nextIntArray();
    blist[i] = {
      no : i,
      child : [],
      x : tmp[0],
      y : tmp[1]
    };
  }
  for(var i = 0; i < N; i++){
    for(var j = 0; j < N; j++){
      if(alist[j].x < blist[i].x && alist[j].y < blist[i].y){
        blist[i].child.push(j);
      }
    }
    blist[i].child.sort(function(a,b){
    	return alist[b].y - alist[a].y;
    });
  }
  blist.sort(function(a, b){
  	return a.x - b.x;
  });
  //myerr(blist);
  //return;
  
  for(var i = 0; i < N; i++){
    var child = blist[i].child;
    for(var j = 0; j < child.length; j++){
      if(!aused.has(child[j])){
        aused.add(child[j]);
        break;
      }
    }
  }
  
  myout(aused.size);
}


Measured memory_bytes: 32912
N, L = map(int, input().split())
a = [L+i for i in range(N)]
b = [abs(i) for i in a]

ans = 0
min_abs = max(b)
min_i = 0

for i in range(N):
    ans += a[i]
    if min_abs > b[i]:
        min_abs = b[i]
        min_i = i

ans -= a[min_i]
print(ans)


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(int i=0;i<(int)n;++i)
#define _rep1(i,k,n) for(int i=k;i<(int)n;++i)
#define _rep2(i,k,n,d) for(int i=k;d>0?i<(int)n:i>(int)n;i+=d)
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n; cin >> n;
    vector<tuple<ll, ll, ll>> XYP(n);
    rep(i, n){
        ll x, y, p; cin >> x >> y >> p;
        XYP[i] = make_tuple(x, y, p);
    }

    auto horizon = make_vector(n, 1 << n, INF);
    auto vertical = make_vector(n, 1 << n, INF);
    rep(i, n){
        auto [x0, y0, p0] = XYP[i];
        rep(U, 1 << n){
            chmin(horizon[i][U], abs(x0) * p0);
            chmin(vertical[i][U], abs(y0) * p0);
            rep(j, n){
                if(!(U >> j & 1)) continue;
                auto [x1, y1, p1] = XYP[j];
                chmin(horizon[i][U], abs(x0 - x1) * p0);
                chmin(vertical[i][U], abs(y0 - y1) * p0);
            }
        }
    }

    vector<ll> ans(n + 1, INF);
    rep(U, 1 << n){
        ll k = __builtin_popcount(U);
        ll V = U;
        while(V){
            ll W = U ^ V;
            ll cost = 0;
            rep(i, n){
                cost += min(horizon[i][V], vertical[i][W]);
            }
            chmin(ans[k], cost);
            V = (V - 1) & U;
        }
        ll cost = 0;
        rep(i, n){
            cost += min(horizon[i][0], vertical[i][U]);
        }
        chmin(ans[k], cost);
    }
    rep(i, n + 1){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 11128
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int r = 1;
    int cnt = 0;


    for(int i = 100; i > 0; i--) {
    	if(k > cnt) {
    		if(a % i == 0 && b % i == 0) {
    			r = i;
    			cnt++;
    		}
    	}
    	else {
    		break;
    	}
    }
    System.out.println(r);
  }
}


Measured memory_bytes: 23252
import numpy as np

h, w = map(int, input().split())
s = np.array([list(input()) for _ in range(h)]) == '.'

L = np.zeros((h, w), dtype=int)
R = np.zeros((h, w), dtype=int)
U = np.zeros((h, w), dtype=int)
D = np.zeros((h, w), dtype=int)

for i in range(h):
    D[i] = (D[i-1]+1) * s[i]
    U[-i-1] = (U[-i]+1) * s[-i-1]

for i in range(w):
    R[:, i] = (R[:, i-1]+1) * s[:, i]
    L[:, -i-1] = (L[:, -i]+1) * s[:, -i-1]


print(np.max(D+U+R+L)-3)


Measured memory_bytes: 219832
// Author :mdragneell
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

 
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define pi  pair< int,int >
#define pl  pair< ll,ll >
#define f first
#define s second
 
ll const N=1e5+5;
ll const mod=1e9+7;
ll min(ll x,ll y) { if(x < y) return x; else return y; }
ll max(ll x,ll y) { if(x > y) return x; else return y; }
ll gcd(ll x,ll y) { if(x == 0) return y; else return gcd(y%x,x);}


struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
       
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
struct compare { 
    bool operator()(const pair<ll, ll>& value,  
                                const ll& key) 
    { 
        return (value.first < key); 
    } 
    bool operator()(const ll& key,  
                    const pair<ll, ll>& value) 
    { 
        return (key < value.first); 
    } 
}; 

bool compare1(const pair<ll,ll> &a, 
            const pair<ll,ll> &b) 
{ 
    if(a.first<b.first) 
        return true ;
    else if(a.first==b.first) 
        return (a.second > b.second); 
    else return false;
} 

ll powmod(ll x, ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        y>>=1;
        if(y<=0)
            break;

        x=(x*x)%mod;
    }

    return res;
}


int main()
{
 
 
       ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
        /*#ifndef ONLINE_JUDGE
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        #endif*/


        ll tt=1;
        //cin>>tt;

        while(tt--)
        {
            ll n,m;
            cin>>n>>m;


            if(n>m)
                swap(n,m);
            
            for(int i=0;i<m;i++)
                cout<<n;
            cout<<endl;







        }  
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

int main() {
  int N;
  cin >> N;
  int i = 1;
  while (true) {
    if (i * i > N)
      break;
    i++;
  }
  i--;
  cout << i*i << endl;
}

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

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

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

    int m;
    std::cin >> m;

    std::vector<std::vector<int>> med(m, std::vector<int>(3));
    int p, x;
    for(int i = 0; i < m; ++i){
        std::cin >> p >> x;
        med.at(i).at(0) = p - 1;
        med.at(i).at(1) = x;
    }

    std::vector<int> tBuf(n);
    int ans;
    for(int i = 0; i < m; ++i){
        tBuf = t;
        ans = 0;
        tBuf.at(med.at(i).at(0)) = med.at(i).at(1);
        for(const auto& e : tBuf){
             ans += e;
        }

        std::cout << ans << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

#print("=====")
ok = [True for _ in range(n)]
for i in range(m):
    #print(h[ab[i][0]-1], h[ab[i][1]-1])
    if h[ab[i][0]-1] > h[ab[i][1]-1]:
        ok[ab[i][1]-1] = False
    elif h[ab[i][0]-1] == h[ab[i][1]-1]:
        ok[ab[i][1]-1] = False
        ok[ab[i][0]-1] = False
    else:
        ok[ab[i][0]-1] = False
#print(ok)
print(sum(ok))

Measured memory_bytes: 32016
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

template <class T>
inline void relax(T &a, const T &b)
{
	if (b > a)
		a = b;
}

const int MaxN = 2000;
const int MaxM = 2000;

int n, m;
char s[MaxN + 1][MaxM + 2];

int a[MaxN][MaxM];
int up[MaxN][MaxM + 1];

int sta_n, sta[MaxM + 1];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		scanf("%s", s[i] + 1);

	for (int i = 1; i < n; ++i)
		for (int j = 1; j < m; ++j)
			a[i][j] = !((s[i][j] == '#') ^ (s[i + 1][j] == '#') ^ (s[i][j + 1] == '#') ^ (s[i + 1][j + 1] == '#'));

	for (int i = 1; i < n; ++i)
		for (int j = 1; j < m; ++j)
			up[i][j] = a[i][j] ? up[i - 1][j] + 1 : 0;
	for (int i = 1; i < n; ++i)
		up[i][m] = 0;

	int res = max(n, m);
	for (int i = 1; i < n; ++i)
	{
		sta_n = 0;
		for (int j = 1; j <= m; ++j)
		{
			while (sta_n && up[i][sta[sta_n]] >= up[i][j])
			{
				relax(res, (up[i][sta[sta_n]] + 1) * (j - sta[sta_n - 1]));
				--sta_n;
			}
			sta[++sta_n] = j;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        scanner.close();

        if (a <= b) {
            System.out.println(a);
        } else {
            System.out.println(a - 1);
        }

        // System.out.println(System.currentTimeMillis() - startTime);
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;
typedef unsigned long long ull;

int main(){
   int K;
   string S;
   cin>> K >>S;
  if(S.size() > K){
    for (int i=0; i<K; i++){
      cout << S.at(i);
    }
 	cout << "..." << endl;
  }
  else{
    cout << S << endl;
  }
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;
vector<vector<string>> graph;

//AGC 40

//A
int main(void) {
	string s;
	cin >> s;
	vector<ll> num = vector<ll>(s.size() + 1,-1);
	vector<tuple<ll, ll>> lr = vector<tuple<ll, ll>>();
	ll count = 1;
	//L = -1, R = 1;
	rep(i, 0, s.size()) {
		if (i == s.size()) {
			if (s[i - 1] == '>') lr.push_back(make_tuple(-1, count));
			else lr.push_back(make_tuple(1, count));
		}
		else if (s[i] == s[i + 1])count++;
		else {
			if (s[i] == '>') lr.push_back(make_tuple(-1, count));
			else lr.push_back(make_tuple(1, count));
			count = 1;
		}
	}
	ll ans = 0;
	if (get<0>(lr[0]) == -1) ans += get<1>(lr[0])*(get<1>(lr[0]) + 1) / 2;
	if ((lr.size() > 1 || get<0>(lr[0]) == 1) && get<0>(lr[lr.size() - 1]) == 1) ans += get<1>(lr[lr.size() - 1])*(get<1>(lr[lr.size() - 1]) + 1)/2;
	rep(i, 0, lr.size() - 1) {
		if (get<0>(lr[i]) == 1 && get<0>(lr[i + 1]) == -1) {
			ll a = get<1>(lr[i]);
			ll b = get<1>(lr[i + 1]);
			ans += a * (a + 1) / 2 + b * (b + 1) / 2 - min(a, b);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string N;
    cin >> N;
    ll num = 0;
    rep(i,N.size()){
        num += N[i]-'0';
    }
    if(num%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, string> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

bool comp(P a, P b){
	return a.first < b.first;
}

vector<P> v,u;

int search(ll x){
	int l,r,m;
	l = 0; r = (1<<16);
	while(r - l > 1){
		m = l+(r-l)/2;
		if(u[m].first > x){
			r = m;
		}else{
			l = m;
		}
	}
	return (u[l].first < x)?r:l;
}

int main(void){
	int i,j,l,r;
	ll n,t;
	string s;
	bool flag = false;
	for(i=0; i<(1<<16); ++i){
		s = "";
		t = 0ll;
		for(j=0; j<16; ++j){
			if(i&(1<<j)){
				t += ((j%2)?-1:1)*(1ll<<j);
				s = '1'+s;
			}else{
				s = '0'+s;
			}
		}
		v.push_back(P(t*(1ll<<16),s));
		u.push_back(P(t,s));
	}
	cin >> n;
	if(n == 0ll){
		cout << "0" << endl;
		return 0;
	}
	sort(u.begin(),u.end(),comp);
	for(i=0; i<(1<<16); ++i){
		j = search(n-v[i].first);
		if(j<(1<<16) && v[i].first+u[j].first==n){
			l = i;
			r = j;
			break;
		}
	}
	s = v[l].second;
	for(i=0; i<16; ++i){
		if(flag){
			cout << s[i];
		}else if(s[i]=='1'){
			flag = true;
			cout << s[i];
		}
	}
	s = u[r].second;
	for(i=0; i<16; ++i){
		if(flag){
			cout << s[i];
		}else if(s[i]=='1'){
			flag = true;
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 6376
s = input().strip()
n = len(s)

left = 0
right = 0
res = []
while left < n:
    right = left + 1
    count = 0
    found = False
    while right <= n:
        if not found:
            if s[right] == 'R':
                right += 1
            else:
                count = right - left
                found = True
        else:
            if right == n or s[right] == 'R':
                num = right - left
                a = num // 2
                b = num - a

                if count > 1:
                    res += [0] * (count - 1)
                if count % 2 == 0:
                    res += [a, b]
                else:
                    res += [b, a]
                if num - count - 1 > 0:
                    res += [0] * (num - count - 1)

                left = right
                break
            else:
                right += 1
print(' '.join(map(str, res)))

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

using namespace std;

// 163 Sunday April 1

#define SIZE 200000
char chaines[SIZE][10];
long longueur[SIZE];

bool comparaison(long i, long j)
{
    if (longueur[i] != longueur[j])
      return(longueur[i] < longueur[j]);
    else {
      int k, flag;

      flag = 1;
      for (k=0;flag && (k<longueur[i]);k++)
        if (chaines[i][k] != chaines[j][k])
          flag = 0;
      return(chaines[i][k-1] < chaines[j][k-1]);
    }
}

bool different(long i, long j)
{
    if (longueur[i] != longueur[j])
      return true;
    else {
      int k, flag;

      flag = 1;
      for (k=0;flag && (k<longueur[i]);k++)
        if (chaines[i][k] != chaines[j][k])
          flag = 0;
      return(flag == 0);
    }
}


int main() {
 long N;

 cin >> N;
 string machaine;

long i,j;
 for (i=0;i<N;i++) {
   cin >> machaine;
   longueur[i] = machaine.length();
   for (j=0;j<longueur[i];j++)
    chaines[i][j] = machaine[j];
 }

 long pos[SIZE];

 for (i=0;i<N;i++)
   pos[i] = i;

   sort(pos, pos + N,comparaison);

 long nombre;

if (N>0)
 nombre = 1;
else
  nombre = 0;

  for (i=1;i<N;i++) {
    if (different(pos[i],pos[i-1]))
      nombre++;
  }
  cout << nombre << endl;
  return 0;
}


Measured memory_bytes: 8704
while True:
    n=int(input())
    if n==0:break;
    a=list(map(int, input().split()))
    a.sort()
    ans=a[1]-a[0]
    for i in range(2, n):
        if a[i]-a[i-1]<ans:ans=a[i]-a[i-1]
    print(ans)


Measured memory_bytes: 5628
#!/usr/bin/env python3

import itertools


def inplace_convert(h, w, stage):
    for r0, c0 in itertools.product(range(h), range(w)):
        if stage[r0][c0] == ".":
            stage[r0][c0] = 0
            for dr, dc in itertools.product((-1, 0, 1), repeat=2):
                r, c = r0 + dr, c0 + dc
                if (r, c) != (r0, c0) and 0 <= r < h and 0 <= c < w:
                    cell = stage[r][c]
                    if cell == "#":
                        stage[r0][c0] += 1
            stage[r0][c0] = str(stage[r0][c0])


def main():
    h, w = (int(x) for x in input().split())
    stage = [list(input()) for _ in range(h)]
    inplace_convert(h, w, stage)
    print(*("".join(line) for line in stage), sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int K,A,B;
    cin>>K>>A>>B;
    

    while(A<=B){
        if(A%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
        A++;
    }
    cout<<"NG"<<endl;
    
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	const ll mod = 998244353;
	ll n, k;
	cin >> n >> k;

	vll t(n + 1, 0);
	vector<pair<ll, ll>> vp(k);
	rep(i, 0, k) {
		cin >> vp[i].first >> vp[i].second;
	}

	t[1] = 1;
	repeq(i, 2, n) {
		t[i] = t[i - 1];
		rep(j, 0, k) {
			ll tmp = t[max(0LL, i - vp[j].first)] - t[max(0LL, i - vp[j].second - 1)];
			if (tmp < 0) {
				tmp += mod;
			}
			t[i] += tmp;
			t[i] %= mod;
		}
	}

	ll ans = t[n] - t[n - 1];
	if (ans < 0) {
		ans += mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4816
from fractions import gcd
N = int(input())
a = list(map(int, input().split()))
def lcm(A):
  x = A[0]
  for i in range(1, len(a)):
    x = (x * A[i]) // gcd(x, A[i])
  return x

n = lcm(a) - 1
ans = 0
for v in a:
  ans += n % v
print(ans)

Measured memory_bytes: 5344
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	set<string> st;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<endl;
	return 0;
}


Measured memory_bytes: 19140
n = int(input())
a = [int(input()) - 1 for _ in range(n)]

d = set()
p = 0
ans = 1
while 1:
    if a[p] == 1:
        print(ans)
        exit()
    elif p in d:
        print(-1)
        exit()
    else:
        d.add(p)
        p = a[p]
        ans += 1

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

int main() {
  ll N;
  cin >> N;
  int i = 0;
  char ans[100];
  while (1) {
    N--;
    ll a = N%26;
    ans[i] = 'a' + a;
    i++;
    N /= 26;
    if (N == 0)
      break;
  }
  for (int j=i-1; j>=0; j--) 
    cout << ans[j];
  cout << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n;
  cin >> n;
  ll tmp = 0, sum = 0;
  REP(i,n){
    ll p;
    cin >> p;
    tmp = max(tmp,p);
    sum += p;
  }
  cout << sum - tmp/2 << endl;
  return 0;
}


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

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

int main()
{
	int N;
	map<string,ll>ss;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		ss[s]++;
	}
	ll res=0;
	for(auto it:ss)
	{
		res+=(it.second*(it.second-1))/2;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 11136
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = map(int, input().split())

union = UnionFind(n)
for _i in range(m):
    a, b = map(int, input().split())
    union.union(a-1, b-1)
print(max(union.size(i) for i in range(n)))

Measured memory_bytes: 14648
import sys
input = sys.stdin.readline

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

def main():
    mod=10**9+7
    X,N=MI()
    p=LI()
    ans=0
    d=1000
    for i in range(-100,105):
        if not(i in p):
            if abs(i-X)<d:
                ans=i
                d=abs(i-X)
    print(ans)
    

main()


Measured memory_bytes: 61776
def main():
    n, k, *h = map(int, open(0).read().split())
    dp = [0 for _ in range(n)]
    id = [0 if i - k < 0 else i - k for i in range(n)]
    for i, (hi, s) in enumerate(zip(h[1:], id[1:]), 1):
        dp[i] = min([ml + abs(hl - hi) for ml, hl in zip(dp[s:i], h[s:i])])
    print(dp[-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 16352
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>W>>A>>B;
    if(abs(B - A) <= W) cout<<0<<endl;
    else cout<<min(abs(B - A - W), abs(A - B - W))<<endl;
}

Measured memory_bytes: 384
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define end(x) prev(x.end());
# define all(x) x.begin(), x.end()
# define rall(x) x.rbegin(), x.rend()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

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

const int MOD = 1e9+7;
const int N = 2e5+5;

void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a+b-1)/b*c;
}

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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define Boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void Crack() {
	long n;
  	long d;
    cin >> n >> d;
  	long a,b,ans=0;
  	double dist;
    for(int i=0;i<n;i++) {
      cin >> a >> b;
      dist = sqrt(a*a+b*b);
      if(dist<=d) ans++;
    }
  cout << ans << endl;
}

int main()
{
	Boost;
    Crack();
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  int64_t sum = 0;
  for(int bit=0; bit<(1<<s.size()-1); bit++){
    vector<int> d(s.size()-1, 0);
    for(int i=0; i<s.size()-1; i++){
      if(bit & (1<<i)){
        d[i] = 1;
      }
    }
    int64_t num = 0;
    for(int i=0; i<d.size(); i++){
      
      if(d[i]==1){
        num += s[i] - '0';
        
        sum += num;
        num = 0;
      }
      else {
        num *= 10;
        //cout << num << endl;
        num += (s[i] - '0') * 10;
        //cout << num << endl;
      }
      
    } 
    sum += s[s.size()-1] - '0';
    sum += num;
    //cout << sum << endl;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, k;
  int remain;
  scanf("%d", &n);
  scanf("%d", &k);


  if(k == 1){
    remain = 0;
  }
  else{
    remain = n - k;
  }



  printf("%d\n", remain);

  return 0;
}


Measured memory_bytes: 128