akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    deque<char> q;
    string s;
    int Q,t,f;
    bool k = 1;
    char c;
    cin >> s >> Q;
    for(int i = 0;i < s.size(); ++i) {
        q.push_back(s[i]);
    }
    while(Q --) {
        cin >> t;
        if(t == 1) k = !k;
        else {
            cin >> f >> c;
            if(f == 1) {
                if(k == 1) q.push_front(c);
                else q.push_back(c);
            }
            else {
                if(k == 1) q.push_back(c);
                else q.push_front(c);
            }
        }
    }
    if(k) for(int i = 0;i < q.size(); ++i) cout << q[i] ;
    else for(int i = q.size() - 1;i >= 0; --i) cout << q[i];
    return 0;
}

Measured memory_bytes: 976
#include <stdio.h>
#include <string.h>
char h[]="Hoshino";
int main(){
    int n,i;
    scanf("%d ",&n);
    for(i=0;i<n;i++){
        int j,l;
        char s[1001];
        gets(s);
        l=strlen(s);
        for(j=0;j<l-6;j++){
            int k=0;
            while(s[j+k]==h[k]){
                k++;
                if(k==7){
                    s[j+6]='a';
                    k=0;
                    break;
                }
            }
        }
        printf("%s\n",s);
    }
    return 0;
}

Measured memory_bytes: 1008
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;

macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}

fn main() {
  input! {
     N:usize,
     XYP:[(i64,i64,i64);N]
  }
  let N: usize = N;
  let mut XYP: Vec<(i64, i64, i64)> = XYP;
  let inf = std::i64::MAX;
  let mut xkyori = vec![vec![inf; N]; 2usize.pow(N as u32)];
  let mut ykyori = vec![vec![inf; N]; 2usize.pow(N as u32)];

  for pat_i in 0..2usize.pow(N as u32) {
    // 組み合わせの作成
    let mut pat = vec![0; N];
    for i in 0..N {
      pat[i] = pat_i >> i & 1;
    }
    // 各patternについて、各都市からのX距離とY距離を計算する。
    for i in 0..N {
      if pat[i] == 1 {
        // 都市 i に鉄道が引かれている場合の距離は0。
        xkyori[pat_i][i] = 0;
        ykyori[pat_i][i] = 0;
      } else {
        // そうでない場合、すべての路線への距離の最小値を求める。
        let (x, y, p) = XYP[i];
        xkyori[pat_i][i] = x.abs();
        ykyori[pat_i][i] = y.abs();
        for j in 0..N {
          if pat[j] == 1 {
            xkyori[pat_i][i] = min(xkyori[pat_i][i], (x - XYP[j].0).abs());
            ykyori[pat_i][i] = min(ykyori[pat_i][i], (y - XYP[j].1).abs());
          }
        }
        xkyori[pat_i][i] *= p;
        ykyori[pat_i][i] *= p;
      }
      debug!(pat,i,xkyori[pat_i]);
    }
  }
  debug!(xkyori);
  debug!(ykyori);
  // ここまでで前処理。xkyoriとykyoriが計算できた。
  let mut ans = vec![inf; N + 1];
  // 3進数を計算。0=線路なし,1=X路線, 2=Y路線
  for pat_i in 0..3usize.pow(N as u32) {
    // pat_xとpat_yの作成
    let mut k = 0;
    let mut pat = pat_i;
    let mut pat_x = 0;
    let mut pat_y = 0;
    for i in 0..N {
      match pat % 3 {
        1 => {
          pat_x += 2usize.pow(i as u32);
          k += 1;
        }
        2 => {
          pat_y += 2usize.pow(i as u32);
          k += 1;
        }
        _ => (),
      }
      pat = pat / 3;
    }
    let mut t_ans = 0;
    for i in 0..N {
      t_ans += min(xkyori[pat_x][i], ykyori[pat_y][i]);
    }
    ans[k] = min(ans[k], t_ans);
  }
  for a in ans {
    println!("{}", a);
  }
}


Measured memory_bytes: 11816
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG




int main() {
  string S;
  cin >> S;

  for(ll i=0; i< S.size(); i++){
    cout << "x";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3608
//https://atcoder.jp/contests/abc069/tasks/arc080_a
//C - 4-adjacent
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N;
vector<ll> a;

ll get2order(int num) {
    int temp = 0;
    while(!(num%2)) {
        num/=2;
        temp++;
    }
    return temp;
}

int main() {
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; i++) scanf("%Ld", &a[i]);
    vector<int> orders(N);
    for (int i = 0; i < N; i++) orders[i] = get2order(a[i]);
    int count0 = 0, count4 = 0;
    for (int i = 0; i < N; i++) {
        if (!orders[i]) count0++;
        else if (orders[i] >= 2) count4++;
    }
    string ans;
    if (N%2 && count0-1 == count4 && N/2+1 == count0) ans = "Yes";
    else ans = (count0 <= count4) ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	h := nextInt()
	w := nextInt()
	n := nextInt()
	m := max(h, w)
	cnt := n / m
	if n%m != 0 {
		cnt++
	}
	fmt.Println(cnt)
}

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

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

int main(){
    int n; cin>>n;
    string s,t;
    cin>>s>>t;
    for(int i=n;i<=2*n;i++){
        if(s.substr(i-n)==t.substr(0,2*n-i)){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<s.size()+t.size()<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
double r;
int main(){ //srand((unsigned)time(NULL));
  cin >> r;
  cout << syo(6) << r*r*M_PI << " " << 2*r*M_PI << endl;
}



Measured memory_bytes: 3292
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << min(C, (int)(B/A)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	cout << abs(*max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end()));
	return 0;
}

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

int main() {
	vector<int> a(5);
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	vector<int> b(5);
	for (int i = 0; i < 5; i++) {
		if(a[i]%10 != 0)b[i] = 10 - a[i]%10;
		else b[i] = 0;
	}

	vector<pair<long long int, long long int>> ba(5);
	for (int i = 0; i < 5; i++) {
		ba[i] = make_pair(b[i], a[i]);
	}

	sort(ba.begin(), ba.end());

	int sum = 0;
	for (int i = 0; i < 4; i++) {
		sum += ba[i].first + ba[i].second;
	}

	sum += ba[4].second;

	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a.begin(), a.end());
    ll x = a[n / 2];
    for(int i = 0; i < n; ++i){
        a[i] -= x;
        if(a[i] < 0)    a[i] *= -1;
    }
    cout << accumulate(a.begin(), a.end(), 0ll) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  if ("SUN" == a){
    cout << 7 << endl;
  }
  if ("MON" == a){
    cout << 6 << endl;
  }
  if ("TUE" == a){
    cout << 5 << endl;
  }
  if ("WED" == a){
    cout << 4 << endl;
  }
  if ("THU" == a){
    cout << 3 << endl;
  }
  if ("FRI" == a){
    cout << 2 << endl;
  }
  if ("SAT" == a){
    cout << 1 << endl;
  }
}
 

Measured memory_bytes: 256
#include<stdio.h>
#define PMAX 1000000000
int wmax=0;
int n,k,w[100000];
 
int check(int P){
    int i;
    int count=1,now=P;
    if(P<wmax) return 0;
    for(i=0;i<n;i++){
        if(now>=w[i]){
           now-=w[i];
        }else{
            count++;
            now=P-w[i];
        }
    }
    if(count>k) return 0;
    else return 1;
}
 
int main(void){
    int i;
    int left,right,mid;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
        if(w[i]>wmax) wmax=w[i];
    }
 
    left=0,right=PMAX;
    while(right-left>1){
        mid=(left+right)/2;
        if( check(mid) ) right=mid;
        else left=mid;
    }
    printf("%d\n",right);
    return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
VL a;

ll sign(ll A) { return (A > 0) - (A < 0); }

signed main() {
    cin >> N;
    REP(i, N) a.emplace_back(IN());
    ll ans = LINF, odd = -1, even = 1;
    REP(loop, 2) {
        ll sum = 0, tmp = 0;
        REP(i, N) {
            sum += a[i];
            if(i % 2) {
                if(sign(sum) != sign(odd)) {
                    tmp += abs(sum - odd);
                    sum = odd;
                }
            } else {
                if(sign(sum) != sign(even)) {
                    tmp += abs(sum - even);
                    sum = even;
                }
            }
        }
        ans = min(ans, tmp);
        swap(odd, even);
    }
    cout << ans << "\n";
}

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

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> b(n,0);
    
    rep(i,n/2+1){
        b[0] += a[2*i];
        if(2*i+1<n) b[0] -= a[2*i+1];
    }
    
    for(int i=1;i<n;++i) {
        b[i] = 2*a[i-1] - b[i-1];
    }
    rep(i,n){
        cout << b[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=1e9+7;cin>>n;
  lvector A(n,0);rep(i,n) cin>>A[i];
  for(ll i=-100;i<=100;++i) {
    ll ans_=0;
    rep(j,n) ans_+=(A[j]-i)*(A[j]-i);
    ans=min(ans,ans_);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, T int
	fmt.Scan(&N, &T)

	var c, t int
	min := 9999
	for i := 0; i < N; i++ {
		fmt.Scan(&c, &t)
		if t <= T && c <= min{
			min = c
		}
	}

	if min == 9999 {
		fmt.Println("TLE")
	} else {
		fmt.Println(min)
	}
}

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

#define all(x) (x).begin(), (x).end()
#define int long long
unordered_map<int, int> mp;

bool check(int k, int n) {
    while (n % k == 0) {
        n /= k;
    }
    return n % k == 1;
}
void go(int divs, int n) {
    for (int i = 2; i * i <= divs; ++i) {
        if (divs % i == 0) {
            if(check(i, n)) mp[i] = 1;
            if(check(divs / i, n)) mp[divs / i] = 1;
        }
    }
}
signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    mp[n] = 1;
    if (n > 2)
        mp[n - 1] = 1;
    go(n - 1, n);
    go(n, n);
    cout << mp.size();
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
int main()
{
    // freopen("A.01.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    scanf("%c", &c);
    // for (short i = 65; i <= 90; i++)
    // {
    //     if (c == i)
    //     {
    //         printf("%c", 'A');
    //         return 0;
    //     }
    // }
    (c > 'Z') ? printf("%c", 'a') : printf("%c", 'A');
    return 0;
}

Measured memory_bytes: 3776
from numba import njit
import numpy as np

@njit
def main(N, P):
    lista = [1, -1, N, -N]
    d = np.zeros((N, N), dtype=np.int32)
    d = d.ravel()
    sit = np.ones_like(d)
    stack = np.empty_like(d)
    count = 0
    for i in range(N*N):
        d[i] = min(i % N, (N-1-i) % N, i//N, N-1-i//N)
    for player in P:
        sit[player-1] = 0
        count += d[player-1]
        stack[0] = player
        num = 0
        while num >= 0:
            p = stack[num]
            num -= 1
            a = d[p-1]+sit[p-1]
            for i in lista:
                if p+i < 1 or p + i > N*N:
                    continue
                if d[p+i-1] > a:
                    d[p+i-1] = a
                    num += 1
                    stack[num] = p+i
    print(count)

N = int(input())
P = np.array(input().split(), np.int32)

main(N, P)


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

using namespace std;
typedef long long ll;

int main(void) {
  long long x, y;
  cin >> x >> y;

  ll ans = 1e18;
  int b[2] = {1, -1}, c[4] = {0, 1, 1, 2};
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      ll nx = x * b[i], ny = y * b[j];
      if (nx <= ny) {
        ans = min(ans, ny - nx + c[2 * i + j]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
l = [(a, 1) for a in list(map(int, input().split()))]
for i in range(m):
    b, c = map(int, input().split())
    l.append((c, b))
l = sorted(l)[::-1]
ans = 0

for i, j in l:
    if j < n:
        ans += i*j
        n -= j
    else:
        ans += n*i
        break

print(ans)

Measured memory_bytes: 37424
from collections import defaultdict
class UnionFind:
    def __init__(self, num):
        self.table = [-1 for _ in range(num)]
        self.sz = defaultdict(lambda:1)

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

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

        if s1 != s2:
            size = self.sz[s1]+self.sz[s2]
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            s = self.find(x)
            self.sz[s] = size
            return True
        return False

    def size(self, x):
        s = self.find(x)
        return self.sz[s]
N,M = map(int,input().split())
AB = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
ans = N*(N-1)//2
l = []
u = UnionFind(N)
for i in range(M-1,-1,-1):
    l.append(ans)
    a,b = AB[i]
    if u.find(a)!=u.find(b):
        ans -= u.size(a)*u.size(b)
        u.union(a,b)
for i in range(M-1,-1,-1):
    print(l[i])


Measured memory_bytes: 135256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    string in; cin >> in;
    int res = in.size();

    for(char c = 'a'; c <= 'z'; c++){
        int cur = 0;
        int n = in.size();
        string S = in;
        while(true){
            if(S.size() == 0) break;
            bool ok = true;
            for(auto& e : S){
                if(e != c){
                    ok = false;
                    break;
                }
            }
            if(ok) break;

            string T = "";
            rep(i, (int)S.size() - 1){
                if(S[i] == c){
                    T.push_back(S[i]);
                }
                else T.push_back(S[i + 1]);
            }
            S = T;
            cur++;
        }
        chmin(res, cur);
    }
    cout << res << endl;

    return 0;
}


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

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

using namespace std;

int main(){
  string s;
  cin >> s;
  string s2 = string(s);
  reverse(s2.begin(), s2.end());
  
  rep(i, s2.size()){
    if(s2[i] == 'b') s2[i] = 'd';
    else if(s2[i] == 'd')  s2[i] = 'b';
    else if(s2[i] == 'p')  s2[i] = 'q';
    else if(s2[i] == 'q')  s2[i] = 'p';
  }
  
  if(s == s2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
ll mod = 1e9 + 7;

int main() {

    
    ll ln, rn;
    cin >> ln >> rn;
    
    vector<vector<vector<vector<ll>>>> dp(64, vector<vector<vector<ll>>>(2, vector<vector<ll>>(2, vector<ll>(2))));
    dp[0][0][0][0] = 1;
    for (int i = 1; i < 64; ++i)
    {
        bool lb = (ln >> (63 - i)) & 1;
        bool rb = (rn >> (63 - i)) & 1;
        for (int j = 0; j < 2; ++j)
        {
            for (int k = 0; k < 2; ++k)
            {
                for (int l = 0; l < 2; ++l)
                {
                    for (int a = 0; a < 2; ++a)
                    {
                        for (int b = 0; b < 2; ++b)
                        {
                            if ((a && !b) || (!j && !a && lb) || (!k && b && !rb) || (!l && a != b))
                            {
                                continue;
                            }
                            int nj = j;
                            int nk = k;
                            int nl = l;
                            if (a && !lb)
                            {
                                nj = 1;
                            }
                            if (!b && rb)
                            {
                                nk = 1;
                            }
                            if (a || b)
                            {
                                nl = 1;
                            }
                            dp[i][nj][nk][nl] = (dp[i][nj][nk][nl] + dp[i - 1][j][k][l]) % mod;
                        }
                    }
                }
            }
        }
    }
    
    ll ret = 0;
    
    for (int i = 0; i < 2; ++i)
    {
        for (int j = 0; j < 2; ++j)
        {
            for (int k = 0; k < 2; ++k)
            {
                ret = (ret + dp[63][i][j][k]) % mod;
            }
        }
    }
    
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int N = 50 + 5, mod = 1000000007;

int f[N][N][N * N];
inline int add (int u, int v) { return u + v >= mod ? u + v - mod : u + v; }
inline int mns (int u, int v) { return u - v < 0 ? u - v + mod : u - v; }
inline int mul (int u, int v) { return 1LL * u * v % mod; }

int main () {
	#ifdef chitongz
	freopen ("x.in", "r", stdin);
	#endif
	int n, k;
	scanf ("%d%d", &n, &k);
	if (k % 2) return puts ("0"), 0;
	f[1][1][0] = f[1][0][0] = 1;
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			for (int k = 0; k <= i * i / 2; ++k) {
				f[i + 1][j][k + j] = add (f[i + 1][j][k + j], mul (2 * j + 1, f[i][j][k]));
				f[i + 1][j + 1][k + j] = add (f[i + 1][j + 1][k + j], f[i][j][k]);
				if (j) f[i + 1][j - 1][k + j] = add (f[i + 1][j - 1][k + j], mul (j * j, f[i][j][k]));
			}
		}
	}
	printf ("%d\n", f[n][0][k / 2]);
	return 0;
}

Measured memory_bytes: 33024
#include "bits/stdc++.h"
#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(), (obj).end()

using namespace std;

int main()
{
    speed;
    int n;
    cin >> n;
    if (n >= 1000)
        cout << "ABD";
    else
        cout << "ABC";
    ed;
    return 0;
}

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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int n, k;
int a[200005];

bool check(int key) {
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        cnt += (a[i] - 1) / key;
    }

    if (cnt <= k){
        return true;
    }else{
        return false;
    }
}

int main(void){

    cin >> n >> k;

    int amax = 0;
    for(int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
        amax = max(a[i], amax);
    }

    int ng = 0, ok = amax, mid;
    while (abs(ok - ng) > 1) {
        mid = (ok + ng) / 2;

        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }

    //cout << ok << "\n";
    printf("%d\n", ok);

    return 0;
}


Measured memory_bytes: 4456
#include<stdio.h>
#include<string.h>

int main(){

  int k;
  int i = 0, j = 0;
  int x[100];

  for(i = 0;i < 5;i++){
    scanf("%d",&x[i]);
  }
  scanf("%d",&k);
  for(i = 0;i < 4;i++){
    for(j = i + 1;j < 5;j++){
      if(x[j] - x[i] > k){
        printf(":(");
        return 0;
      }
    }
  }
  printf("Yay!");
  return 0;
}

Measured memory_bytes: 128
program codefestival2016qualb
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,a,b,i
    integer(int32):: qualifier, foregin_qualifier
    character(:),allocatable:: s

    read*, n,a,b
    allocate(character(n):: s)
    read*, s
    qualifier = 0
    foregin_qualifier = 0

    do i=1,n
        if (qualifier >= a+b) then
            print'(a)', 'No'
            cycle
        end if
        
        if (s(i:i) == 'a') then
            print'(a)', 'Yes'
            qualifier=qualifier+1
        else if (s(i:i) == 'b') then
            if (foregin_qualifier >= b) then
                print'(a)', 'No'
            else
                print'(a)', 'Yes'
                qualifier=qualifier+1
                foregin_qualifier=foregin_qualifier+1
            end if
        else
            print'(a)', 'No'
        end if
    end do
end program codefestival2016qualb

Measured memory_bytes: 1000
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll k,s;cin>>k>>s;
    ll ans=0;
    repe(x,k)repe(y,k){
        ll z=s-x-y;
        if(0<=z&&z<=k)++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]r){Scanner s=new Scanner(System.in);int n=s.nextInt(),i=n,m=s.nextInt(),b=(int)10e9;int[]a=new int[n];for(;i>0;)a[--i]=s.nextInt();Arrays.sort(a);for(;i+m-1<n;i++)b=Math.min(b,a[i+m-1]-a[i]);System.out.print(b);}}

Measured memory_bytes: 53040
# include <bits/stdc++.h>
# define MOD 998244353
using namespace std;
typedef long long ll;
ll N,A,B,K;
ll qpow(ll x,int n,ll d=1){
	for(;n;n>>=1,x=x*x%MOD)if(n&1)d=d*x%MOD; return d;
}
const int maxn = 3e5+10;
ll jc[maxn];
ll C(int a,int b){
	return jc[a]*qpow(jc[b]*jc[a-b]%MOD,MOD-2)%MOD;
}
int main(){
	cin >> N >> A >> B >> K;
	if (B==0 && A!=0)swap(A,B);
	if (A==0 && B==0){
		if (K==0) cout << qpow(4,N) << endl;
		else cout << 0 << endl;
	}
	jc[0]=1; for(int i=1;i<maxn;++i) jc[i]=jc[i-1]*i%MOD;
	ll ans = 0;
	for(ll a=0;a<=N;++a){
		if (K-a*A<0 || (K-a*A)%B!=0)continue;
		ll b=(K-a*A)/B; if (b > N) continue;
	//	cerr << a << ' ' << b << endl;
		//cerr << C(N,a)*C(N,b) << endl;
		(ans += C(N,a)*C(N,b)%MOD)%=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int n;
int main(){
  cin>>n;
  if(n%2==0){
    prin(n*(n-1)/2-n/2);
    rep1(i,n-1){
      for(int j=i+1;j<=n;j++){
	if(i+j!=n+1){
	  prin2(i,j);
	}
      }
    }
  }
  else{
    n--;
    prin(n*(n-1)/2-n/2+n);   
    rep1(i,n-1){
      for(int j=i+1;j<=n;j++){
	if(i+j!=n+1){
	  prin2(i,j);
	}
      }
    }
    rep1(i,n){
      prin2(i,n+1);
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
#define pp(a,b) push(make_pair(a,b))
typedef pair<string,int> NODE;
char color(char a, char b){
	if(a>b)swap(a,b);
	if(a==b)return a;
	if(a=='b' && b=='r')return 'g';
	if(a=='b' && b=='g')return 'r';
	if(a=='g' && b=='r')return 'b';
	cout << "unko" << endl;
}
int main(){
	string n;
	char p1,p2;
	map<string,bool> done;
	while(cin >> n && n != "0"){
		bool f = false;
		queue<NODE> Q;
		done.clear();
		Q.pp(n,0);
		while(Q.size()){
			NODE q = Q.front();
			Q.pop();
			if( count(q.first.begin(),q.first.end(),'r') == q.first.size() || 
			    count(q.first.begin(),q.first.end(),'g') == q.first.size() ||
			    count(q.first.begin(),q.first.end(),'b') == q.first.size()
			){
				cout << q.second << endl;
				f = true;
				break;
			} 
			for(int i=0;i+1<q.first.size();i++){
				p1 = q.first[i];p2 = q.first[i+1];
				q.first[i] = q.first[i+1] = color(p1,p2);
				if(!done[q.first]){
					Q.pp(q.first,q.second+1);
					done[q.first] = true;
				}
				q.first[i] = p1;
				q.first[i+1] = p2;
			}
		}
		if(!f)cout << "NA" << endl;
	}
}

Measured memory_bytes: 1880
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main() {
  int N, K; cin >> N >> K;
  vector<vector<int> > G;

  int M = N*(N-1)/2 - K;
  if(N-1 <= M){
    reps(i,N-1){
      vector<int> l;
      l.push_back(1);
      l.push_back(i+1);
      G.push_back(l);
    }
    for(int i=2; i<=N; i++){
      for(int j=i+1; j<=N; j++){
        if(K>0){
          K--;
        }else{
          vector<int> l;
          l.push_back(j);
          l.push_back(i);
          G.push_back(l);
        }
      }
    }
    cout << M << endl;
    rep(i,G.size()){
      cout << G[i][0] << ' ' << G[i][1] << endl;
    }

  }else{
    cout << -1 << endl;
  }



  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MOD =(int)(1e9)+7;
int main()
{
    int N;
    cin >> N;
    long long ans=0;
    long long sum=0;
    for(int i=0;i<N;i++){
        long long a;
        cin >> a;
        if(a==0){
            ans+=sum/2;
            sum=0;
        }
        else{
            sum+=a;
        }
    }
    ans+=sum/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
d, x = map(int, input().split())
c = [0 for i in range(d)]
a = []
for i in range(n):
  a.append(int(input()))

for i in range(n):
  tmp = 0
  while tmp * a[i] < d:
    c[tmp * a[i]] += 1
    tmp += 1
    
print(sum(c) + x)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Repi(i, a, b) for(int i = int(a); i < (int)(b); i++)
#define Repl(i, list) for(int i : list)
#define Sort(v) sort(v.begin(), v.end())
#define lli long long int
template<typename _T> void Out(_T x) { cout << x << endl; }
template<typename _T> void PrintVec(vector<_T> vec) { Rep(i, vec.size()) { cout << vec.at(i) << " "; } cout << endl; }

int main()
{
    // input
    string S, T;
    cin >> S >> T;

    // output
    Out(T+S);
}

Measured memory_bytes: 256
N,X = map(int,input().split())
L = list(map(int,input().split()))
List = [0]*(N+1)
for i in range(1,N+1):
    List[i] = List[i-1] + L[i-1]
import bisect  
# A = [i for i in List if i <=X]
# print(len(A))
print(bisect.bisect_left(List,X+1))


Measured memory_bytes: 9148
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int comp(int x, int y, int i, int j){
	if(x==i) return (y<j)-(y>j); else return (x<i)-(x>i);
}

int n;
int a[300000][2];
bool bs(int x, int y){
	int l=0, r=n-1;
	while(l<=r){
		int m=(l+r)/2;
		if(comp(x, y, a[m][0], a[m][1])>=0) r=m-1; else l=m+1;
	}
	return comp(x, y, a[l][0], a[l][1])==0;
}
int bx[300000][2], by[300000][2];
int cx[300000], cy[300000];
int main(void){
	int h=nextint();
	int w=nextint();
	n=nextint();
	for(int i=0; i<n; i++){
		int x=nextint()-1;
		int y=nextint()-1;
		a[i][0]=x; bx[x][1]++; cx[x]++;
		a[i][1]=y; by[y][1]++; cy[y]++;
	}
	for(int x=0; x<h; x++) bx[x][0]=x;
	for(int y=0; y<w; y++) by[y][0]=y;
	rsorta_d32(a, n, 2, 1);
	rsorta_d32(a, n, 2, 0);
	rsorta_d32(bx, h, 2, 1);
	rsorta_d32(by, w, 2, 1);
	int ans=0;
	for(int i=h-1; i>=0; i--){
		if(bx[i][1]!=bx[h-1][1]) break;
		for(int j=w-1; j>=0; j--){
			if(by[j][1]!=by[w-1][1]) break;
			int x=bx[i][0], y=by[j][0];
			int now=cx[x]+cy[y];
			if(bs(x, y)){
				now--;
				if(now>ans) ans=now;
			}else{
				if(now>ans) ans=now;
				break;
			}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 14468
n = int(input())
temp = [int(s) for s in input().split()]
rarry = 0
min = 100000007
min_temp = 0
#print(max(temp))
for n_ in range(max(temp) + 1):
    for i in temp:
        min_temp += ((i - n_) ** 2)
    #print(min_temp)
    if(min > min_temp):
        min = min_temp
    min_temp = 0


print("{}".format(str(min)))

Measured memory_bytes: 3064
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m;
	cin>>n>>m;
	if(n>=10)cout<<m<<endl;
	else cout<<m+100*(10-n)<<endl;
}









Measured memory_bytes: 256
while True:
    try:
        p = list(map(float,input().split()))
    except EOFError:
        break
    a = p[2] - p[0]
    b = p[4] - p[0]
    c = p[6] - p[0]
    d = p[3] - p[1]
    e = p[5] - p[1]
    f = p[7] - p[1]
    s = (c*e-b*f)/(a*e-b*d)
    t = (a*f-c*d)/(a*e-b*d)

    print("YES" if s>0 and s<1 and t>0 and t<1 and s+t<1 else "NO")

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


int main(){
    int a[210];
    int N;
    cin >> N;
    for(int i = 0; i < N ; i++){
        cin >> a[i];
    }
    int ans = 0;
    while(1){
        bool odd = false;
        for(int i = 0; i < N; i++){
            if(a[i] % 2 == 1){
                odd = true;
            }
        }
        if(odd) break;
        ans++;
        for(int i = 0; i < N; i++){
            a[i] /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	string ans = "No";
	for (int C = 1; C <= 3; C++) {
		if (A * B * C % 2 == 1) ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max1 = 11;
const intt max2 = 102;
const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;
const intt lg2 = 7;
const intt lg3 = 10;
const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;
const intt lg7 = 24;
const intt lg8 = 27;
const intt lg9 = 30;
const intt lg18 = 60;
const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a, intt b) { while(b) b ^= a ^= b ^= a %= b; return a;}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}
/**************************/

intt n, m, a, b;
vector <intt> g[maxx << 1];

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    cin >> n >> m;
    for (intt i = 1; i <= m; i++)
        cin >> a >> b, g[a].pb (b), g[b].pb (a);
    for (intt i = 0; i < g[n].size(); i++) {
        intt to = g[n][i];
        for (intt j = 0; j < g[to].size(); j++)
            if (g[to][j] == 1) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 12776
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,arr[1000000],m;
  cin >> m>>n;
  if(m==n||(m+n)%2==0){
    cout<< (m+n)/2;
  }
  else {
      cout <<"IMPOSSIBLE";
  }
}
 


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
double eps=1e-9;
int main(){
	double a,b,c,d,e,f;
	while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF) printf("%.3f %.3f\n",(c*e-b*f)/(a*e-b*d)+eps,(a*f-c*d)/(a*e-b*d)+eps);
	return 0;
}

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

int main(void) {
char a, b;
cin >> a >> b;
if (a == 'H' && b == 'H') cout << 'H';
else if (a == 'H' && b == 'D') cout << 'D';
else if (a == 'D' && b == 'H') cout << 'D';
else if (a == 'D' && b == 'D') cout << 'H';
cout << endl;
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#include<bits/stdc++.h>                               
using namespace std;

#define PI acos(-1)
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector<string> vs;

const int MAXN = 2e5 + 9;
const int MOD = (int)(1e9 + 7);
const int INF = 100500;

int dd[333][333], ddd[333][333];

void input() {

}

void solve() {
	int n;
	cin >> n;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			cin >> dd[i][j];
			ans += dd[i][j];
			ddd[i][j] = dd[i][j];
		}
	}
	for(int k = 0; k < n; k++) {
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(i == j) continue;
				if(dd[i][j] > dd[i][k] + dd[k][j]) {
					cout << -1;
					exit(0);
				}
				else if(k != i && k != j && dd[i][j] == dd[i][k] + dd[k][j]) {
					ans -= ddd[i][j];	
					ddd[i][j] = 0;
				}
			}
		}
	}
	cout << ans / 2 << endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen("xxx.in", "r", stdin);
	//freopen("xxx.out", "w", stdout);
#endif	
	input();
	solve();
	return 0;
}

Measured memory_bytes: 1024
# Problem B - Chocolate

# input process
N = int(input())
D, X = map(int, input().split())
a_list = []
for i in range(N):
    a = int(input())
    a_list.append(a)

# initialization
day_count = X

# count process
for a in a_list:
    tmp = 1
    while tmp<=D:
        day_count += 1
        tmp += a

# output process
print(day_count)


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

int main() {
	int N; cin >> N;
	int A[N+1], B[N];
	for(int i = 0; i < N+1; i++) cin >> A[i];
	for(int i = 0; i < N; i++) cin >> B[i];

	long long res = 0;
	for (int i = 0; i < N; i++)
	{
		res += min(A[i] + A[i+1], B[i]);
		if(A[i] + A[i+1] <= B[i]) A[i+1] = 0;
		else A[i+1] -= max(0, B[i] - A[i]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
def main():
	s = list(map(str,input().split()))
	a = list(map(int,input().split()))
	u = str(input())
	#List=list(map(int,input().split()))
	
	a[s.index(u)] -= 1
 
	print(' '.join(map(str, a)))
 
	
 
if __name__ == '__main__':
	main()


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  for(int i=0,l=str.size();i<l;i++){
    if(str[i]>='a'&&str[i]<='z') printf("%c",str[i]-('a'-'A'));
    else if(str[i]>='A'&&str[i]<='Z') printf("%c",str[i]+('a'-'A'));
    else cout << str[i];
  }
  cout << endl;
}


Measured memory_bytes: 3148