akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())
bom_dic = {}
for h_num in range(1, h+1):
    bom_dic_child = {}
    num_row = input()
    num_list = []
    for num in num_row:
        num_list.append(num)

    for idx, num in enumerate(num_list):
        bom_dic_child[idx+1] = num
    bom_dic[h_num] = bom_dic_child

result_dic = {}
for row_idx, row_str in bom_dic.items():
    result_dic_row = {}
    for column_idx, cell_str in row_str.items():
        if cell_str == ".":
            bom_count = 0
            for dx in range(-1,2):
                for dy in range(-1,2):
                    x = column_idx + dx
                    y = row_idx + dy
                    if w >= x > 0 and h >= y > 0:
                        terget_str = bom_dic[y][x]
                        if terget_str == "#":
                            bom_count += 1 
            result_dic_row[column_idx] = bom_count
        else:
            result_dic_row[column_idx] = cell_str
    result_dic[row_idx] = result_dic_row

for print_row in result_dic.values():
    for cell_str in print_row.values():
        print(cell_str, end="")
    print()


Measured memory_bytes: 3828
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);

	int q,w,e;
	q=a+b;
	w=b+c;
	e=c+a;

	if(q<=w && q<=e){
		printf("%d",q);
		return 0;
	}
	if(w<q && w<=e){
		printf("%d",w);
		return 0;
	}
		printf("%d",e);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
struct ANS
{
    ll frow;
    ll fcol;
    ll torow;
    ll tocol;
}ans[505*505];
int main()
{
    ios;
    memset(ans , 0 , so ans);
    ll row , col ;
    cin >> row >> col;
    ll arr[row+1][col+1];
    forn(i , 1 , row){
       forn(j , 1, col){
          ll coins ;
          cin >> coins;
          arr[i][j] = coins ;
          if(coins%2 == 0){
            arr[i][j] = 0 ;
          }
       }
    }
    ll cnt = 0;
    ll moves = 0 ;
   forn(i , 1 , row){
     forn(j , 1 , col-1){
        if(arr[i][j] % 2== 0 ) {
            con;
        }
        else{
            ll currrow = i ;
            ll currcol = j ;
            ll moverow = i ;
            ll movecol = j +1;
            //cout << "i is " << i << " j is " << j << " moverow is " << moverow << " movecol is " << movecol << el ;
            ans[cnt].frow = currrow;
            ans[cnt].fcol = currcol;
            ans[cnt].torow= moverow;
            ans[cnt].tocol= movecol;
            ++cnt;
            ++moves;
            arr[i][j+1]+=arr[i][j];
            arr[i][j] = 0 ;
            arr[i][j+1] = arr[i][j+1] % 2 ;
        }
     }
   }
   forn(i , 1 , row-1){
      if(arr[i][col] % 2 == 0) {
        con;
      }
      else if(arr[i][col] % 2 == 1){
        ll currrow = i ;
        ll currcol = col;
        ll moverow = i+1;
        ll movecol = col;
        ans[cnt].frow = currrow;
        ans[cnt].fcol = currcol;
        ans[cnt].torow= moverow;
        ans[cnt].tocol= movecol;
        ++cnt;
        ++moves;
        arr[i+1][col]+=arr[i][col];
        arr[i][col] = 0 ;
        arr[i+1][col] = arr[i+1][col] % 2 ;
      }
   }
   cout << moves << el ;
    for(ll i = 0 ; i <=cnt-1;++i){
        cout << ans[i].frow << " " << ans[i].fcol << " " << ans[i].torow << " " << ans[i].tocol << el ;
    }
    cout << el ;
    ro ;

}




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

// greatest common divisor
template<class T> T gcd(T a, T b){
  while(a > 0){
    T t = a;
    a = b%a;
    b = t;
  }
  return b;
}

int main(){
  long long a, b, cnt=1;
  cin >> a >> b;
  long long c = gcd(a, b);
  for(long long i=2; i*i<=c; i++){
    if(c%i == 0){
      cnt++;
      // 素因数で割り続ける
      while(c%i == 0) c /= i;
    }
  }
  if(c > 1) cnt++;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n; cin >> n;
	
	//-匹数, 番号
	vector<PII> a(n);
	rep(i, n) {
		int x, y; cin >> x >> y;
		a[i] = mp(-y, x);
	}
	sort(all(a));

	Cout2(a[0].second, -a[0].first);
}


Measured memory_bytes: 3076
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: u64,
    }
    let mut tmp = 1;
    loop {
        if tmp * tmp > n {
            println!("{}", (tmp - 1) * (tmp - 1));
            return;
        }
        tmp += 1
    }
}


Measured memory_bytes: 4352
DICT = {
  'C' => 0, 'C#' => 1, 'D' => 2, 'D#' => 3, 'E' => 4, 'F' => 5,
  'F#' => 6, 'G' => 7, 'G#' => 8, 'A' => 9, 'A#' => 10, 'B' => 11,
}

def check(stairs, music, i, k)
  i = music.size
  while i > 0
    tone = music[i - 1]
    stair = stairs[k]
    case tone
    when (stair + 1) % 12
      if k >= 1
        k -= 2
      else
        return false
      end
    when stair
      k -= 1
    when (stair - 1) % 12
      if k < stairs.size - 1
        k += 1
      else
        return false
      end
    else
      return false
    end
    i -= 1
  end
  return k == -1
end

def work(stairs, music)
  (stairs.size >= 2 && check(stairs, music, music.size, stairs.size - 2)) ||
      check(stairs, music, music.size, stairs.size - 1)
end

s = STDIN.gets.to_i
s.times do
  STDIN.gets
  stairs = STDIN.gets.split.map{|x| DICT[x]}
  music = STDIN.gets.split.map{|x| DICT[x]}
  puts work(stairs, music) ? 'Yes' : 'No'
end

Measured memory_bytes: 18200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<pair<ll, ll>, ll> memo;
ll gcd(ll a, ll b)
{
//	if (memo.find(make_pair(a, b)) != memo.end()) return memo[make_pair(a, b)];
	if (!a) return b;
	return memo[make_pair(a, b)] = gcd(b%a, a);
}
struct Frac
{
	ll a, b;
};
Frac newfrac(ll a, ll b)
	{
		Frac ans;
		ans.a = a;
		ans.b = b;
		if (ans.b < 0)
		{
			ans.a = -ans.a;
			ans.b = -ans.b;
		}
		return ans;
	}
	Frac add(Frac a, Frac b)
	{
		Frac ans;
		ans.a = a.a*b.b+b.a*a.b;
		ans.b = a.b*b.b;
		ans = newfrac(ans.a, ans.b);
		return ans;
	}
	Frac sub(Frac a, Frac b)
	{
		Frac ans;
 
		ans.a = a.a*b.b-b.a*a.b;
		ans.b = a.b*b.b;
		ans = newfrac(ans.a, ans.b);
		return ans;
	}
ll n;
int main()
{
	scanf("%lld", &n);
	Frac a = newfrac(2, 2);
	for (ll a = 1; a <= 3500; a++)
	{
		for (ll b = 1; b <= 3500; b++)
		{
			Frac n4;
			n4 = newfrac((ll)4, n);
			n4 = sub(n4, newfrac(1, a));
			n4 = sub(n4, newfrac(1, b));
			if (n4.a == 0) continue;
			if (n4.b == 0) continue;
			if ((n4.b / n4.a)*n4.a != n4.b) continue;
			n4.b/=n4.a;
			n4.a = 1;
			if (n4.b == 0.0 || n4.a != 1 || n4.b > 5000 || n4.b < 0) continue;
			
			printf("%lld %lld %lld\n", a, b, n4.b);
			return 0;
 
		}
	}
}

Measured memory_bytes: 256
#!/usr/bin/python3

import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7

#N = int(input())
#A = [int(x) for x in input().split()]
#V = [[0] * 100 for _ in range(100)]

K = int(input())

def f(A):
    R = []
    for a in A:
        d = a%10
        if d == 0:
            R.append(a*10)
            R.append(a*10+1)
        elif d == 9:
            R.append(a*10 + 8)
            R.append(a*10 + 9)
        else:
            R.append(a*10 + d - 1)
            R.append(a*10 + d)
            R.append(a*10 + d + 1)
    return R

A = list(range(1,10))
tab = list(A)

while len(tab) < K:
    ret = f(A)
    A = ret
    tab += ret
    # print(tab)

tab = sorted(tab)
# print(tab)

print(tab[K-1])


Measured memory_bytes: 14204
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> cnt(n+1,0);
  vector<int> seq(n, 0);
  rep(i, n) {
    cin >> seq.at(i);
    cnt.at(seq.at(i))++;
  }
  ll tot = 0;
  reps(i,1, n+1) {
    ll v = cnt.at(i);
    tot += v * (v-1) / 2;
  }
  rep(i, n) {
    ll v = cnt.at(seq.at(i));
    if (v == 0) {
      cout << tot << endl;
    } else {
      ll sub = v * (v - 1) / 2;
      ll add = (v - 1) * (v - 2) / 2;
      cout << tot - sub + add << endl;
    }
  }
  return 0;
} 

Measured memory_bytes: 4840
import java.util.Scanner;
import java.io.IOException;
public class Main {
        private final static int WHITE=0;
        private final static int GRAY=1;
        private final static int BLACK=2;
        private static int[][] M;
        private static int n;
        public static void main(String[] args) throws IOException {
                final Scanner sc = new Scanner(System.in);
                int i,j;
                n=sc.nextInt();
                M = new int[n][n];

//??????????????????
                for(i=0;i<n;i++)
                        for(j=0;j<n;j++) M[i][j]=Integer.MAX_VALUE;
                int u,k,v,c;

                for(i=0;i<n;i++){
                        u=sc.nextInt();
                        k=sc.nextInt();
                        for(j=0;j<k;j++){
                                v=sc.nextInt();
                                c=sc.nextInt();
                                M[u][v]=c;
                        }
                }

                dicstra();

        }

        public static void dicstra(){
                int[] color = new int[n];
                int[] depth = new int[n];
                int i,j;
                for(i=0;i<n;i++){
                        depth[i]=Integer.MAX_VALUE;
                        color[i]=WHITE;
                }

                depth[0]=0;
                color[0]=GRAY;
                int mincost;
                int u;
                while(true){
                        mincost=Integer.MAX_VALUE;
                        u=-1;
                        for(i=0;i<n;i++){
                                if(color[i]!=BLACK && depth[i]<mincost){
                                        mincost = depth[i];
                                        u=i;
                                }
                        }
                        if(mincost==Integer.MAX_VALUE) break;
                        color[u]=BLACK;

                        for(j=0;j<n;j++){
                                if(color[j]!=BLACK && M[u][j]!=Integer.MAX_VALUE){
                                        if(depth[j]>depth[u]+M[u][j]){
                                                depth[j]=depth[u]+M[u][j];
                                                color[j]=GRAY;
                                        }
                                }
                        }

                }
                for(i=0;i<n;i++){
                        System.out.println(i+" " + (depth[i]==Integer.MAX_VALUE ? -1 : depth[i]));
                }
        }
}

Measured memory_bytes: 40220
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
const int N=1e6+7;
typedef long long ll;
int n,Q,K;
char s[N];
//DMC
ll cnt_D,cnt_M,cnt_DM,ans; 
void solve(){
	cnt_D=cnt_M=cnt_DM=ans=0;
	rep(i,1,K){
		if(s[i]=='D'){
			cnt_D++;
		}else if(s[i]=='M'){
			cnt_DM+=cnt_D;
			cnt_M++;
		}else if(s[i]=='C'){
			ans+=cnt_DM;
		}
	}
	rep(i,2,n-K+1){
		int l=i,r=i+K-1;
		if(s[l-1]=='D'){
			cnt_DM-=cnt_M;
			cnt_D--;
		}else if(s[l-1]=='M'){
			cnt_M--;
		}
		
		if(s[r]=='M'){
			cnt_DM+=cnt_D;
			cnt_M++;
		}else if(s[r]=='C'){
			ans+=cnt_DM;
		}else if(s[r]=='D'){
			cnt_D++;
		}
	}
	printf("%llu\n",ans);
} 
int main(){
	scanf("%d",&n);
	scanf("%s%d",s+1,&Q);
	while(Q--){
		scanf("%d",&K);
		solve();
	}
}

Measured memory_bytes: 1280
#include<stdio.h>
int main(){
	int i,j,t;
	int d[11];
	for(i=0;i<10&&scanf("%d",&d[i]);i++);
	for(i=0;i<10;i++){
		for(j=i;j<10;j++){
			if(d[i]<d[j]){
				t=d[i];
				d[i]=d[j];
				d[j]=t;
			}
		}
	}
	printf("%d\n%d\n%d\n",d[0],d[1],d[2]);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    int n,m,b,c;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;++i)
    cin>>a[i];
    vector<pair<int,int>>v(m);
    for(int i=0;i<m;++i)
    {
        cin>>b>>c;
        v.push_back(make_pair(c,b));
    }
    sort(a,a+n);
    sort(v.rbegin(),v.rend());
    int cnt=0,s=0,p=0;
    for(auto x:v)
    {
        int c=x.first;
        int b=x.second;
        cnt=0;
        for(int j=p;j<n;++j)
        {
            if(a[j]>=c||cnt>=b)
            break;
            if(a[j]<c&&cnt<b)
            {
                a[j]=c;
            }
            ++p;
            ++cnt;
        }
    }
    int ans=0;
    for(int i=0;i<n;++i)
    {
        ans+=a[i];
    }
    cout<<ans;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

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

/////////////////////////////////////////////////////////////
class CombinationModulo {
 public:
  static const ll MOD = (ll)(1e9 + 7);

  vector<ll> fact;
  vector<ll> inv;
  vector<ll> fact_inv;

  CombinationModulo(int n) {
    this->fact = vector<ll>(n + 1, 0LL);
    this->inv = vector<ll>(n + 1, 0LL);
    this->fact_inv = vector<ll>(n + 1, 0LL);
    init(n);
  }

  void init(int n) {
    inv[1] = fact[0] = fact_inv[0] = 1;
    for (int i = 2; i <= n; i++) {
      inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
    }
    for (int i = 1; i <= n; i++) {
      fact[i] = fact[i - 1] * i % MOD;
    }
    for (int i = 1; i <= n; i++) {
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0;
    return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
  }
};
/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
class ModuloOperator {
 public:
  ll mo_modulo;

  ModuloOperator(ll modulo) { mo_modulo = modulo; }

  ll add(ll a, ll b) {
    ll ret = a + b;
    ret %= mo_modulo;
    return ret;
  }

  ll sub(ll a, ll b) {
    ll ret = a - b;
    if (ret < 0)
      ret += mo_modulo;
    else
      ret %= mo_modulo;
    return ret;
  }

  ll mul(ll a, ll b) {
    ll ret = a * b;
    ret %= mo_modulo;
    return ret;
  }

  ll div(ll a, ll b) { return mul(a, pow(b, mo_modulo - 2)); }

  ll pow(ll x, ll y) {
    ll res = 1LL;

    x %= mo_modulo;

    while (y > 0) {
      if (y & 1) {
        res = mul(res, x);
      }

      y = y >> 1;
      x = mul(x, x);
    }

    return res;
  }
};
/////////////////////////////////////////////////////////////

ll n, m, k;

ll ans;

ModuloOperator mo(MOD);

int main(void) {
  // Here your code !
  scanf("%lld %lld %lld", &n, &m, &k);

  int size = (int)(n * m + 3);
  CombinationModulo cm(size);

  ans = 0;

  ll base_comb = cm.comb((int)(n * m - 2), (int)(k - 2));

  for (ll i = 1; i <= n - 1; ++i) {
    ll slide_size = n - i;

    ll times = mo.mul(mo.mul(slide_size, mo.mul(m, m)), base_comb);
    ll commit = mo.mul(i, times);

    ans = mo.add(ans, commit);
  }

  for (ll i = 1; i <= m - 1; ++i) {
    ll slide_size = m - i;

    ll times = mo.mul(mo.mul(slide_size, mo.mul(n, n)), base_comb);
    ll commit = mo.mul(i, times);

    ans = mo.add(ans, commit);
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main(){
    int n;
    int count=1;
    cin>>n;
    long long  max=-1000000;
    long long min=1000000;
    long long  sum=0;
    long long a;
    for(int i=0; i<n; i++){
        cin>>a;
        if(max<a){
            max=a;
        }
        if(min>a) {
            min=a;
        }
        sum += a;
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 _gcd(ll x, ll y){
    while(1){
        if(x%y == 0)return y;
        else{
            ll z = x%y;
            x = y;
            y = z;
        }
    }
}

int main() {
    ll x,y;
    cin >> x >> y;
    if(x < y)swap(x,y);
    cout << _gcd(x,y) << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define FOR_EX(i, a, b) for (int i = a; i < b; i++)
#define FOR_IN(i, a, b) for (int i = a; i <= b; i++)

#define ALL(a) a.begin(), a.end()

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
    int n, k;
    cin >> n >> k;
    int h[n];
    FOR_EX(i, 0, n) {
        cin >> h[i];
    }
    sort(h, h + n);
    int r = INT_MAX;
    FOR_IN(i, 0, n - k) {
        r = min(r, h[i + k - 1] - h[i]);
    }
    cout << r << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> num(5);
    int mi=INF;
    int idx=0;
    REP(i,5){
        int a;
        cin>>a;
        if(mi>a%10&&a%10!=0){
            mi=a%10;
            idx=i;
        }
        num[i] = a;
    }
    ll ans=0;
    REP(i,5){
        if(i==idx) ans+=num[i];
        else{
            if(num[i]%10!=0) ans+=num[i]+10-num[i]%10;
            else ans+=num[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<ll mod> struct Mod_Int{
    ll x;
    Mod_Int() {}
    Mod_Int(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}

    Mod_Int &operator += (const Mod_Int &p) {
        x = (x + p.x) % mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p) {
        x = (x + mod - p.x) % mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p) {
        x = (x * p.x) % mod;
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p) {
        *this *= p.inverse();
        return *this;
    }

    Mod_Int operator -() const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

    bool operator == (const Mod_Int &p) const {return x == p.x;}

    bool operator != (const Mod_Int &p) const {return x != p.x;}

    Mod_Int pow(ll n) const{
        Mod_Int now = *this, ret = 1;
        while(n > 0){
            if(n & 1) ret *= now;
            now *= now, n >>= 1;
        }
        return ret;
    }

    Mod_Int inverse() const{
        return pow(mod-2);
    }
};

using mint = Mod_Int<MOD>;
const int MAX_N = 1e6;
mint fac[MAX_N+1];

void init(){
    fac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = fac[i-1]*mint(i);
    }
}

mint comb(mint n, mint k){
    return fac[n.x]/(fac[n.x-k.x]*fac[k.x]);
}

mint perm(mint n, mint k){
    return fac[n.x]/fac[n.x-k.x];
}

int main(){
    int N;
    cin >> N;
    int C[N];
    rep(i, N) cin >> C[i];
    int MAX = 3e5;
    vector<int> ids[MAX];
    rep(i, N) ids[C[i]].pb(i);
    vector<int> pre(N, -1);
    rep(i, MAX){
        rep2(j, 1, sz(ids[i])-1) pre[ids[i][j]] = ids[i][j-1];
    }
    mint dp[N+1];
    dp[0] = 1;
    rep(i, N){
        dp[i+1] = dp[i];
        if(pre[i] != -1 && pre[i] != i-1) dp[i+1] += dp[pre[i]+1];
    }
    cout << dp[N].x << endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}


int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int k,a,b; cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
	    if(i%k==0){ cout<<"OK"; return 0; }
	}
	cout<<"NG";
	
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n;
double a[100001],q[100001];
int main(){
  cin>>n;
  r(i,n)cin>>a[i]>>q[i];
  double l=0,r=1e9+1;
  r(o,100){
    double mid=(l+r)/2,lm=0,rm=1e9+1;
    r(i,n){
      if(q[i]<mid)rm=-1;
      lm=max(lm,a[i]-sqrt(q[i]*q[i]-mid*mid));
      rm=min(rm,a[i]+sqrt(q[i]*q[i]-mid*mid));
    }
    if(lm<rm)l=mid;
    else r=mid;
  }
  printf("%.9f\n",l);
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define LL long long
#define SZ(X) X.size()
#define pii pair<int,int>
#define ALL(X) X.begin(),X.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 2e5 + 11;
int n,m,f[N];
vector<int>v[N],e[N];
int main() {
	ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int s,t;
        cin>>s>>t;
        v[s].pb(t);
        e[t].pb(s);
    }
    int L=1e8,pos=-1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)f[j]=1e9;
        queue<int>q;
        for(auto k:v[i])f[k]=1,q.push(k);
        while(!q.empty()){
            int now=q.front();
            q.pop();
            for(auto k:v[now]){
                if(f[k]>f[now]+1){
                    f[k]=f[now]+1;
                    q.push(k);
                }
            }
        }
        if(f[i]<L){
            L=f[i];
            pos=i;
        }
    }
    if(pos==-1)cout<<-1<<endl;
    else{
        for(int j=1;j<=n;j++)f[j]=1e9;
        queue<int>q;
        for(auto k:v[pos])f[k]=1,q.push(k);
        while(!q.empty()){
            int now=q.front();
            q.pop();
            for(auto k:v[now]){
                if(f[k]>f[now]+1){
                    f[k]=f[now]+1;
                    q.push(k);
                }
            }
        }
        cout<<f[pos]<<endl;
        int T=pos;
        while(T){
            cout<<T<<endl;
            T=0;
            for(auto k:e[pos]){
                if(f[pos]==f[k]+1){
                    pos=k;
                    T=pos;
                    break;
                }
            }
        }
    }
	return 0;
}


Measured memory_bytes: 9856
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <bitset>
using namespace std;
#define int long long
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
constexpr int INF = (int)1e9;
int N, M;
int A[1000];
int K[1000];
int memo[1 << 12];
int solve(const int S) {
  if (memo[S] != -1) return memo[S];
  if (S == (1 << N) - 1) return 0;
  int res = INF;
  REP(i, M) {
    int T = S | K[i];
    if (S == T) continue;
    int r = solve(T);
    if (r == INF) continue;
    res = min(res, r + A[i]);
  }
  return memo[S] = res;
}
signed main() {
  memset(memo, -1, sizeof(memo));
  cin >> N >> M;
  REP(i, M) {
    cin >> A[i];
    int b; cin >> b;
    int k = 0;
    REP(j, b) {
      int c; cin >> c;
      c--;
      k = k | (1 << c);
    }
    K[i] = k;
  }
  int ans = solve(0);
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    String s = sc.next();


    if (s.equals("a") || s.equals("e") || s.equals("i") || s.equals("o") || s.equals("u") ) {
      System.out.println("vowel");
    } else {
      System.out.println("consonant");
    }

  }
}

Measured memory_bytes: 20564
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, ans = 0, p, i;
    string s;
    cin >> n >> p >> s;
    if(p == 2 || p == 5)
    {
        for(i = 0; i < n; i++)
            if((s[i] - '0') % p == 0)
                ans += i + 1;
    }
    else
    {
        map <ll, ll> m;
        ll rem = 0, b = 1;
        m[0] = 1;
        for(i = n - 1; i >= 0; i--, b = (b * 10) % p)
        {
            rem = (rem + (b * (s[i] - '0') % p)) % p;
            m[rem]++;
        }
        for(auto x: m)
        {
            ans += (x.S - 1) * x.S / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
       
    using namespace std;
    #define ll long long
    #define ld long double
    #define pll pair<long long,long long>
    #define vll vector<long long>
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define deb(x) cout << #x << "=" << x << endl
    #define F(i,a,b) for(ll i=a;i<=b;i++)
    #define RF(i,a,b) for(ll i=a;i>=b;i--)
    #define in(a,n) F(i,0,n-1)cin>>a[i]
    #define vi vector<int>
    #define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
    #define mod 1000000007
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define int long long
    const int N=(int)3e3+5,INF=(int)1e18+7;
    
    double dp[N][N];
    double p[N];
   
    void solve()
    {
        int n;
        cin>>n;
        for(int i=0;i<n;i++)cin>>p[i];
        
        
        //dp[idx][head] tells probability 
        
        dp[0][0]=(1-p[0]);
        dp[0][1]=(p[0]);
        
        for(int i=1;i<n;i++)
        {
            for(int j=0;j<=3000;j++)
            {
                //tail
                dp[i][j]+=(1-p[i])*dp[i-1][j];
                //head
                if(j-1>=0)
                dp[i][j]+=p[i]*dp[i-1][j-1];
                
            }
        }
        double ans=0;
        for(int i=n/2+1;i<=3000;i++)
        {
            ans+=(dp[n-1][i]);
        }
        
        cout<<fixed<<setprecision(10)<<ans;
    }
    
    int32_t main()
    {
    	ios::sync_with_stdio(false);
        cin.tie(NULL);
        
    	int t=1;
    	//cin>>t;
    	while(t--)solve();
    	    
       
    }


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

int main() 
{
	int a, b;
	string s;
	cin >> a >> b;
	cin >> s;
	
	string checker = "0123456789";
	bool isYes = true;
	for (int i = 0; i < a + b + 1; ++i) {
		if (i == a){
			if (s[i] != '-') {
				isYes = false;
				break;
			}
			continue;
		}

		bool isNum = false;
		for (auto& j : checker) {
			if (j == s[i]) {
				isNum = true;
				break;
			}
		}

		if (!isNum) {
			isYes = false;
			break;
		}
	}

	if (isYes) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

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

	ll l;
	int n;
	cin >> l >> n;
	vector<ll> xs(n);
	trav(x, xs) cin >> x;
	vector<ll> pre(n+1);
	rep(i,0,n) pre[i+1] = pre[i] + xs[i];
	vector<ll> erp(n+1);
	rrep(i,0,n) erp[i] = erp[i+1] + l-xs[i];

	ll ans = 0;

	rep(dif,-1,2){
		rep(m,0,n+1){
			int le = m, ri = n-m;
			ri = min(ri, le+dif);
			le = min(le, ri-dif);
			if(le+ri<=0) continue;

			ll cur = 0;
			cur += pre[m] - pre[m-le];
			cur += erp[m] - erp[m+ri];
			cur *= 2;
			if(dif==0) cur -= min(xs[m-1], l-xs[m]);
			else if(dif==1) cur -= l-xs[m];
			else cur -= xs[m-1];
			ans = max(ans, cur);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 5504
plate = [int(input()) for i in range(5)]
amari=[]
for i in range(5):
    if plate[i]%10 == 0:
        amari.append(0)
    else:
        amari.append(10 - plate[i]%10)
ans = 0

def kiriage(n):
    if n%10 == 0:
        return n
    else:
        return n + (10 - n%10)

for i in range(5):
    ans += kiriage(plate[i])

ans -= max(amari)
print(ans)


Measured memory_bytes: 3060
while True:
    n,k=map(int,input().split())
    if (n,k)==(0,0):
        break
    lst=[int(input()) for i in range(n)]
    a=[]
    c=0
    for i in range(k):
        c+=lst[i]
    a.append(c)
    for j in range(n-k):
        c+=lst[k+j]
        c-=lst[j]
        a.append(c)
    print(max(a))


Measured memory_bytes: 11520
$num = gets.chomp.to_i

letters = gets.chomp.split('')

$a_to_z = [*"A".."Z"]
$answer = []
letters.each do |letter|
  if $a_to_z.index(letter) + $num < $a_to_z.count
    $answer << $a_to_z[$a_to_z.index(letter) + $num]
  else
    $answer << $a_to_z[($a_to_z.index(letter) + $num) - $a_to_z.count]
  end 
end

puts $answer.join("")


Measured memory_bytes: 2300
N, K = map(int, input().split())
V = list(map(int, input().split()))

max_value = -10**9
for kL in range(0, K+1):
    for kR in range(0, K+1):
        if kL + kR > min(N, K):
            continue
        vL = V[:kL]
        vR = []
        if kR:
            vR = V[-kR:]
        hand = list(sorted(vL + vR, reverse=True))
        rest = K - (kL + kR)
        for kD in range(rest):
            if len(hand) == 0:
                break
            if hand[-1] < 0:
                hand.pop()
            else:
                break
        value = sum(hand[:K])
        if value > max_value:
            max_value = value
print(max_value)


Measured memory_bytes: 9216
//GCD and LCM
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll gcd(ll x, ll y){
  if(y==0)return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y){
  ll g=gcd(x, y);
  return (x/g)*y;
}

int main(){
  ll a, b;
  while(scanf("%lld %lld", &a, &b)!=EOF){
    if(a<b) swap(a, b);
    printf("%lld %lld\n", gcd(a, b), lcm(a, b));
  }
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define mod 1000000007LL
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res + m) * ( a + m) % m;
        a = a * a % m;
        b >>= 1;
    }
    return (res + m) % m;
}

long long mul(long long a, long long b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return ((a + mod) * (b + mod))%mod;
}
long long add(long long a, long long b){
    a += mod;
    b += mod;
    return (a + b)%mod;
}
ll inv(ll x){
    return binpow(x, mod - 2, mod);
}
#define int ll
ll cnt(string &a, string & b)
{
    ll ans = 0;
    for (ll i = 0; i < a.length();i++)
        ans += (a[i] != b[i]);
    return ans;
}
signed main()
{
    string s, t;
    cin >> s >> t;
    string u;
    for (ll i = 0; i < t.length();i++)
    {
        string x(1, s[i]);
        u += x;
    }
    ll ans = cnt(u, t);
    for (ll i = t.length(); i < s.length();i++)
    {
        string x(1, s[i]);
        u += x;
        u = u.substr(1);
        //cout << u << endl;
        ans = min(ans, cnt(u, t));
    }
    cout << ans;
}

Measured memory_bytes: 3632
S = input()
Q = int(input())
T = ""

for q in range(Q):
  que = input().split()
  if que[0]=="1":
        S,T = T,S
  else:
    if que[1]=="1":
      T+=que[2]
    else:
      S+=que[2]

print(T[::-1]+S)

Measured memory_bytes: 9900
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c>=22){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

//Union-Find Tree
class UnionFind{
    private:
        vector<vector<pair<int,int>>> par;

    public:
        UnionFind(int h, int w) : par(h, vector<pair<int,int>>(w)){
            REP(i, h){
                REP(j, w){
                    par[i][j] = {i, j};
                }
            }
        }
        
        pair<int,int> root(int x, int y){
            if(par[x][y].first == x && par[x][y].second == y){
                return {x, y};
            }else{
                return par[x][y] = root(par[x][y].first, par[x][y].second);
            }
        }

        void unite(int x1, int y1, int x2, int y2){
            pair<int,int> rx = root(x1, y1), ry = root(x2, y2);
            if(rx != ry){
                par[rx.first][rx.second] = ry;
            }
        }
};

int main(){
    ios();
    int h, w;
    cin >> h >> w;
    vector<vector<char>> grid(h, vector<char>(w));
    UnionFind tree(h, w);
    REP(i, h){
        REP(j, w){
            cin >> grid[i][j];
        }
    }
    vector<pair<int,int>> dxy = {{-1,0}, {0,-1}, {1,0}, {0,1}};
    REP(i, h){
        REP(j, w){
            for(auto k : dxy){
                int x = i + k.first, y = j + k.second;
                if(x < 0 || x >= h || y < 0 || y >= w){
                    continue;
                }
                if(grid[i][j] != grid[x][y]){
                    tree.unite(i, j, x, y);
                }
            }
        }
    }
    vector<vector<pair<ll,ll>>> count(h, vector<pair<ll,ll>>(w));
    REP(i, h){
        REP(j, w){
            auto p = tree.root(i, j);
            if(grid[i][j] == '#'){
                count[p.first][p.second].first++;
            }else{
                count[p.first][p.second].second++;
            }
        }
    }
    ll ans = 0;
    REP(i, h){
        REP(j, w){
            ans += count[i][j].first * count[i][j].second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    for i in range(len(s)):
        if s[i]=="A":break
    for j in range(len(s)-1,-1,-1):
        if s[j]=="Z":break
    print(j-i+1)

main()

Measured memory_bytes: 3512
using System;

namespace question2
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run()
        {
            var s = Console.ReadLine();

            if (s.Length < 3)
            {
                Console.WriteLine(Math.Abs(int.Parse(s)-753));
            }
            else
            {
                var ans = int.Parse(s.Substring(0,3));
                var minDiff = Math.Abs(ans-753);

                for (int i = 1; i < s.Length - 2; i++)
                {
                    var c = int.Parse(s.Substring(i, 3));
                    var diff = Math.Abs(c-753);
                    if( minDiff > diff){
                        ans = c;
                        minDiff = diff;
                    }
                }

                Console.WriteLine(minDiff);
            }
        }
    }
}


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

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

/*
    verified https://atcoder.jp/contests/abc109/tasks/abc109_c
*/
int main() {
    int n, x; cin >> n >> x;
    vector<int> xs(n + 1);
    for (int i = 0; i < n; ++i) cin >> xs[i];
    xs[n] = x;
    int _min = *min_element(xs.begin(), xs.end());
    for (int i = 0; i < n + 1; ++i) xs[i] -= _min;
    int res = xs[0];
    for (int i = 1; i < n + 1; ++i) res = gcd(res, xs[i]);
    cout << res << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
int n,h;
int arr[200005];
int dp[200005];
 
int main() {
    cin >> n;
    for (int i=1;i<=n;i++) {
        cin >> arr[i];
    }
 
    dp[2]=dp[1]+abs(arr[2]-arr[1]);
    for (int i=3;i<=n;i++) {
        dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
    }
    cout << dp[n];
 
}

Measured memory_bytes: 4392
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
  a=list(map(int,input().split()))
  l=0
  for i in range(m):
    l += a[i]*b[i]
  if l+c > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3060
def check(n, y):
    for i in range(y // 10000 + 1):
        for j in range(n - i + 1):
            k  = n - i - j
            if 10000 * i + 5000 * j + 1000 * k == y:
                return [i, j, k]

    return [-1, -1, -1]

n, y = list(map(int, input().split()))
ans = " ".join(map(str, check(n, y)))
print(ans)

Measured memory_bytes: 3064
//BISMILLAHIR RAHMANIR RAHEEM
                                                //ALLAH IS WATCHING ME

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


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

#define ull    unsigned long long
#define ll    long long
#define ios    ios::sync_with_stdio(0);cin.tie(0);
#define ses   "\n"

string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

/////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////

//main function is here.........

int main()
{
    //ios
ll n,m;
cin>>n>>m;
ll mx= max(m,n);
while(mx--){
    cout<<min(m,n);
}
}




//Alhamdulillah


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

int selectionSort(int A[],int n){

	int sw=0,t,minX;
	for(int i=0;i<n-1;i++){
	    minX=i;               
		for(int j=i+1;j<n;j++){
			if(A[j]<A[minX])
				minX=j;
		}
		if(minX!=i){
		t=A[i];
		A[i]=A[minX];
		A[minX]=t;
		sw++;
		}
	
	}
	return sw;

}

void printArray(int A[],int n){
	for(int i=0;i<n-1;i++)
		cout<<A[i]<<" ";
	cout<<A[n-1]<<endl;
}

int main(){
	int n,A[100],time;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];
	time=selectionSort(A,n);
	printArray(A,n);
	cout<<time<<endl;
	return 0;
}


Measured memory_bytes: 3112
n=int(input())
H=[int(i) for i in input().split()]

ans=0
stc=0

for i in range(n-1):
    if H[i]>=H[i+1]:
        stc+=1
    else:
        ans=max(ans,stc)
        stc=0

ans=max(ans,stc)
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int H,W;
string S[8];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	LL N,A,B;
	cin >> N >> A >> B;
	LL m = A+B + A*(N-2);
	LL M = A+B + B*(N-2);
	cout << max(M-m+1,(LL)0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int a, n, x; cin >> n >> x;
	int ans = 1, m = 0;
	for (int i = 0; i < n; i++) {
		cin >> a; m += a; ans += (m <= x);
	}cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
long long modpow(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return ans;
}
long long modinv(long long a){
  return modpow(a, MOD - 2);
}
vector<long long> ntt(vector<long long> A, bool inv){
	int N = A.size();
	long long r = 3;
	if (inv){
		r = modinv(r);
	}
	vector<long long> B(N);
	for (int i = N / 2; i > 0; i /= 2){
		long long z = modpow(r, (MOD - 1) / (N / i));
		long long z2 = 1;
		for (int j = 0; j < N; j += i * 2){
			for (int k = 0; k < i; k++){
				A[i + j + k] *= z2;
				A[i + j + k] %= MOD;
				B[j / 2 + k] = (A[j + k] + A[i + j + k]) % MOD;
				B[N / 2 + j / 2 + k] = (A[j + k] - A[i + j + k] + MOD) % MOD;
			}
			z2 = z2 * z % MOD;
		}
		swap(A, B);
	}
	if (inv){
		int Ninv = modinv(N);
		for (int i = 0; i < N; i++){
			A[i] = A[i] * Ninv % MOD;
		}
	}
	return A;
}
vector<long long> convolution(vector<long long> A, vector<long long> B, int d = -1){
	int deg = A.size() + B.size() - 1;
	int N = 1;
	while (N < deg){
		N *= 2;
	}
	A.resize(N);
	B.resize(N);
	A = ntt(A, false);
	B = ntt(B, false);
	vector<long long> ans(N);
	for (int i = 0; i < N; i++){
		ans[i] = A[i] * B[i] % MOD;
	}
	ans = ntt(ans, true);
	if (d != -1){
		deg = d;
	}
	ans.resize(deg);
	return ans;
}
int main(){
  int N, M;
  cin >> N >> M;
  vector<long long> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<long long> b(M);
  for (int i = 0; i < M; i++){
    cin >> b[i];
  }
  vector<long long> c = convolution(a, b);
  for (int i = 0; i < N + M - 1; i++){
    cout << c[i];
    if (i < N + M - 2){
      cout << ' ';
    }
  }
  cout << endl;
}

Measured memory_bytes: 52560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<pair<ll, ll>> a(n);
	rep(i, n) cin >> a[i].first >> a[i].second;
	sort(all(a));
	rep(i, n) {
		if(a[i].second >= k) {
			cout << a[i].first << endl;
			return 0;
		} else {
			k -= a[i].second;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1792