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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 998244353;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll num_): num((num_ + MOD) % MOD) {
        assert(num >= 0);
    }
    modint(const modint &r): num(r.num) {}
    operator ll() const { return num; }

    template <typename T>
    void check_type(const T &num_) const {
        assert(num_ >= 0 && num_ < MOD);
        static_assert(is_integral<T>() || is_same<T,modint>(), "T is not integral.");
    }

    template <typename T>
    modint operator+(const T &r) const { check_type(r); return num + r; }
    template <typename T>
    modint operator-(const T &r) const { check_type(r); return num - r; }
    template <typename T>
    modint operator*(const T &r) const { check_type(r); return num * r; }
    template <typename T>
    modint operator/(const T &r) const { check_type(r); return num * pow(r, MOD-2); }

    template <typename T>
    modint operator+=(const T &r) { return *this = *this + r; }
    template <typename T>
    modint operator-=(const T &r) { return *this = *this - r; }
    template <typename T>
    modint operator*=(const T &r) { return *this = *this * r; }
    template <typename T>
    modint operator/=(const T &r) { return *this = *this / r; }

    static modint pow(const modint &x, const ll &r) {
        if(r == 0) return 1;
        return pow(x*x, r/2) * modint(r&1 ? x : modint(1));
    }

    static modint fact(int n){
        if((int)factorial.size() <= n) {
            int size = factorial.size();
            factorial.resize(n+1);
            for (int k = size; k <= n; k++) {
                factorial[k] = factorial[k-1] * k;
            }
        }
        return factorial[n];
    }

    static modint C(int n, int r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }

    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
};
vector<modint> modint::factorial = {1};
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)


int main(void){
    int n;
    cin >> n;
    modint sum = 0;
    for (int i = n/2+1; i <= n; i++) {
        sum += C(n,i) * modint::pow(2,n-i) * 2;
    }
    cout << modint::pow(3,n) - sum << endl;
    return 0;
}


Measured memory_bytes: 117376
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <cmath>
#include <stdio.h>

using namespace std;

int main()
{
    int n; cin >> n;
    int hap[3][n];
    for (int i = 0; i < n; i++)
    {
        cin >> hap[0][i] >> hap[1][i] >> hap[2][i];        
    }
    int dp[3][n]; dp[0][0] = hap[0][0], dp[1][0] = hap[1][0], dp[2][0] = hap[2][0];
    for (int i = 1; i < n; i++)
    {
        dp[0][i] = max(dp[1][i - 1] + hap[0][i], dp[2][i - 1] + hap[0][i]);
        dp[1][i] = max(dp[0][i - 1] + hap[1][i], dp[2][i - 1] + hap[1][i]);
        dp[2][i] = max(dp[0][i - 1] + hap[2][i], dp[1][i - 1] + hap[2][i]);
    }
    cout << max(dp[0][n - 1], max(dp[1][n - 1], dp[2][n - 1])) << endl;
}



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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ret = false;
            int retint = 0;
            string retstr = string.Empty;
            var num = int.Parse(Console.ReadLine());
            //var firstin = spr(Console.ReadLine()).ToList();
            List<int> ls=new List<int>(){1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
            Console.WriteLine(ls[num-1]);
            Console.ReadLine();
        }
            
        static int c2i(string c) { return int.Parse(c); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
    }
}


Measured memory_bytes: 11092
import java.util.*;

public class Main {
		public static void main(String[] args) {
		
	   Scanner sc = new Scanner(System.in);
	   
	   int X = sc.nextInt();
	   int A = sc.nextInt();
	   int B = sc.nextInt();
	   
	   int s = B - A;
	   
	   if(B <= A) {
		   System.out.println("delicious");
	   }else if(s <= X) {
		   System.out.println("safe");
	   }else {
		   System.out.println("dangerous");
	   }
		}
}


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

int main(){
  int K, X, N;
  // vector<int > ans(N);
  cin >> K >> X;
  N = 2*K - 1;

  // cout << N;

  rep(i,N) {
    if(i!=N-1){
      cout << X - K + i + 1<< " ";
    } else {
      cout << X - K + i + 1<< endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 1000005
typedef long long int ll;
int main()
{
    int i,j,k,a,b,n,m,f,p;
    string str;
    in2(a,b);
    if(a>=13)
        k=b;
    else if(a>=6)
        k=(b/2);
    else
        a=0;
    out(k);

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
int main(void){
    int A,B,C,X,i,j,k,x=0;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&X);
    for(i=0;i<=A;i++){
        for(j=0;j<=B;j++){
            for(k=0;k<=C;k++){
                if(X==500*i+100*j+50*k){
                    x++;
                }
            }
        }
    }
    printf("%d",x);
    return 0;
}

Measured memory_bytes: 128
#![allow(non_snake_case, unused_imports)]

// Input
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)*} };}
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        H: usize,
        W: usize,
        N: usize,
        AB: [(usize, usize); N],
    }
    // それぞれの黒マスを含む3x3全てについてmapを用いて集計
    let mut map = BTreeMap::new();
    for i in 0..N{
        let (a,b) = AB[i];
        for dh in 0..3{
            for dw in 0..3{
                // if 0<a-dh && a-dh<=H-2 && 0<b-dw && b-dw<=W-2{
                if a>dh && a<=H-2+dh && b>dw && b<=W-2+dw{
                    *map.entry((a-dh,b-dw)).or_insert(0) += 1;
                }
            }
        }
    }
    // 黒をいくつ含むか、0〜9まで集計
    let mut ans = [0 as u64; 10];
    let mut total = 0;
    for m in map{
        let ((_a,_b),v) = m;
        ans[v] += 1;
        total += 1;
    }
    // 0個は、全体 - 1つでも含むものの合計
    ans[0] = (H as u64 -2)*(W as u64 -2) - total;

    for i in 0..10{
        println!("{}", ans[i]);
    }
}

Measured memory_bytes: 57596
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

char tmp[7];

int main(){
  int N = 3;
  cin >> tmp;
  string ans;
  if(tmp[0] == 'S')
  {
    ans = "Cloudy";
  }
  else if(tmp[0] == 'C')
  {
    ans =  "Rainy";
  }
  else
  {
    ans = "Sunny";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define MAXN 200100
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

int32_t main(){
	fastio;
	int k,n;
    cin>>k>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    vector<int> dif;
    sort(v.begin(),v.end());
    for(int i=0;i<n-1;i++){
        dif.pb(v[i+1] - v[i]);
    }    
    dif.pb(k - v[n-1] + v[0]);

    sort(dif.begin(),dif.end(),greater<int>());
    int r=k - dif[0];
    cout<<r<<endl;
	// Math -> gcd it all
	//did you check N=1? Did you mix up N,M?
}

Measured memory_bytes: 3956
import math
n = int(input())
h = []
for i in range(n):
    l = list(map(str, input().split()))
    l.append(i+1)
    h.append(l)

h.sort(key=lambda x:(x[0], -(int(x[1]))))

for i in range(n):
    print(h[i][2])



    




        


    







        



Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) cout << c << endl;
	if (a == c) cout << b << endl;
	if (b == c) cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

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

int main(){
    ll N; cin>>N;
    ll a[N];
    rep(i,N){
        cin>>a[i];
    }
    ll s[N+1];
    ll t[N+1];
    //gcd 累積和作成
    s[0]=t[0]=0;
    rep1(i,N){
        s[i]=gcd(s[i-1],a[i-1]);
        t[i]=gcd(t[i-1],a[N-i]);
    }
    ll ans=0;
    rep(i,N){
        ans=max(ans,gcd(s[i],t[N-i-1]));
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 5944
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var ans = 1L;
            for (var i = 0; i < N; ++i)
            {
                var t = Sarray()[0];
                ans = Lcm(ans, t);
            }
            WriteLine(ans);
            //Out.Flush();
        }
        static long Gcd(long x, long y) => y == 0 ? x : Gcd(y, x % y);
        static long Lcm(long x, long y) => x * (y / Gcd(x, y));
    }
}

Measured memory_bytes: 13268
from fractions import gcd
class SegmentTree(object):
    def __init__(self, n, func, init_val):
        self.N0 = 2**((n-1).bit_length())
        self.func = func
        self.val = init_val
        self.data = [self.val]*(2*self.N0)
    def update(self, k, x):#k番目の値をxに変更する　O(logn)
        k += self.N0-1
        self.data[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.data[k] = self.func(self.data[2*k+1], self.data[2*k+2])
    def query(self, l, r):# 区間[l, r)の最小値を求める
        L = l + self.N0; R = r + self.N0
        s = self.val
        while L < R:
            if R & 1:
                R -= 1
                s = self.func(s, self.data[R-1])
 
            if L & 1:
                s = self.func(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s
N = int(input())
S = SegmentTree(N, gcd, 0)
A = list(map(int, input().split()))
for i, a in enumerate(A):
    S.update(i, a)
ans = 1
for i in range(N):
    ans = max(ans, gcd(S.query(0, i), S.query(i+1, N)))
print(ans)

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	int cur = 0;
	
	for (int t = 0; t <= 60; ++t) {
		int stop = 60 * t + c;
		
		while (cur <= stop) {
			if (cur <= stop && stop <= cur + a) {
				cout << stop << endl;
				return 0;
			}
			
			cur += a + b;
		}
	}
	
	cout << -1 << endl;
}

Measured memory_bytes: 1160
%:pragma GCC optimize("Ofast", "inline")
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
#define int long long
const int N = 3e5 + 233;
int a[N], b[N], n;
inline int F(int x) { return b[x] - a[x]; } 
inline int get(int x) { return x == 0 ? n : x == n + 1 ? 1 : x; }
inline int G(int x) { return b[get(x - 1)] + b[get(x + 1)]; } 
struct node_t {
	int id;
	friend bool operator < (node_t x, node_t y) {
		return make_pair(F(x.id) - G(x.id), x.id) > make_pair(F(y.id) - G(x.id), y.id);
	}
};
set <node_t> s;

inline void re(int u) {
	node_t t = (node_t) {u};
	if (s.count(t)) s.erase(t);
	if (F(u) >= G(u)) s.insert(t);
}

signed main(void) {
	read(n);
	rep (i, n) read(a[i]);
	rep (i, n) read(b[i]);
	rep (i, n) if (F(i) >= G(i)) s.insert((node_t) {i});
	int ans = 0;
	while (!s.empty()) {
		node_t u = *s.begin(); s.erase(s.begin());
		int la = F(u.id), per = G(u.id);
		if (la < per) return cout << -1 << "\n", 0;
		int cnt = la / per;
		b[u.id] -= cnt * per;
		ans += cnt;
		re(get(u.id - 1)); re(get(u.id + 1)); re(u.id);
	}
	rep (i, n) if (a[i] != b[i]) return cout << -1 << "\n", 0;
	cout << ans << "\n";
}


Measured memory_bytes: 8576
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {
	long long n, d;
	cin >> n >> d;
	vector<pair<long long, long long>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;

	}
	long long  ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i].first * a[i].first + a[i].second * a[i].second <= d*d) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 6424
#include <cstdio>
int m, d;
int result;
int main() {
	scanf ( "%d %d", &m, &d );
	for ( int i = 1;i <= m;i ++ ) {
		for ( int j = 1;j <= d;j ++ ) {
			int opt = j % 10, ip = j / 10;;
			if ( opt < 2 || ip < 2 || opt * ip != i ) continue;
			result ++;
		}
	}
	printf ( "%d", result );
	return 0;
}

Measured memory_bytes: 128
n = gets.to_i
data = n.times.map { gets.strip.split.map(&:to_i) }

def is_reachable?(current, next_data)
    tc, xc, yc = current
    tn, xn, yn = next_data
    dist = (xc - xn).abs + (yc - yn).abs
    
    return false if dist > tn - tc

    ((tn - tc) - dist).even?
end

current = [0, 0, 0]
data.each do |d|
    unless is_reachable?(current, d)
        puts 'No'
        exit 0
    end
    current = d
end

puts 'Yes'

Measured memory_bytes: 9596
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int x,n;
    cin >> x >> n;
    if(n == 0){
        cout << x << endl;
        return 0;
    }
    vector<int> num(n);
    for(int i = 0; i < n; i++) cin >> num[i];
    int ans = INF_INT;
    for(int i = x - 200; i <= x + 200; i++){
        int flag = false;
        for(int j = 0; j < n; j++){
            if(num[j] == i) flag = true;
        }
        if(!flag){
            if(abs(ans - x) > abs(x - i)) ans = i;
        }
        flag = false;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main () {
	char S[55];
	int N, K;
	
	scanf("%d %d", &N, &K);
	getchar();
	scanf("%s", S);
	
	S[K-1] += +32;
	
	printf("%s\n", S);
	
	
	return 0;
}

Measured memory_bytes: 1644
import math

n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]
dis = 0

ans = 0
for x1, y1 in xy:
    for x2, y2 in xy:
        ans += math.sqrt((x1-x2)**2 + (y1-y2)**2)
print(ans/n)

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	cnt := 0
	for i := 1; i <= n; i += 2 {
		if numYaku(i) == 8 {
			cnt++
		}
	}

	fmt.Println(cnt)
}

// 約数の数をカウントする
func numYaku(a int) int {
	cnt := 1
	for i := 1; i <= a/2; i++ {
		if a%i == 0 {
			cnt++
		}
	}
	return cnt
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    auto dp = make_vec<mint>(c-a+1, d-b+1, 2);
    dp[0][0][1] = mint(1);
    rep(i, c-a+1) {
        rep(j, d-b+1) {
            // to right
            if (j+1 <= d-b) {
                dp[i][j+1][0] += dp[i][j][0] * mint(a+i);
                dp[i][j+1][0] += dp[i][j][1] * mint(a+i);
            }
            // to up
            if (i+1 <= c-a) {
                dp[i+1][j][1] += dp[i][j][0];
                dp[i+1][j][1] += dp[i][j][1] * mint(b+j);
            }
        }
    }
    mint ans = dp[c-a][d-b][0] + dp[c-a][d-b][1];
    cout << ans << endl;
}


Measured memory_bytes: 495092
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
//using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
vector<llint>kai;
vector<llint>gya;
llint niko(int x,int y){
	if(y<0){return 0;}
	return kai[x+y]*gya[x]%mod*gya[y]%mod;
}
int main(void){
	llint n,m,k,i,j,z,ans=0;cin>>n>>m>>k;
	z=n+m+k+k+10;
	kai.res(z+1);
	kai[0]=1;
	for(i=1;i<=z;i++){kai[i]=kai[i-1]*i%mod;}
	gya.res(z+1);
	gya[z]=1;llint bgen=kai[z];
	for(int h=0;h<30;h++){
		if((mod-2)&(1<<h)){gya[z]*=bgen;gya[z]%=mod;}
		bgen*=bgen;bgen%=mod;
	}
	for(i=z;i>0;i--){gya[i-1]=gya[i]*i%mod;}
	for(i=0;i<=k;i++){
		int j=k-i;
		
		ans+=niko(n+i+i,m+j+j)*(niko(n+i,i)-niko(n+i+1,i-1))%mod*(niko(m+j,j)-niko(m+j+1,j-1));
		ans%=mod;
	}
	ans%=mod;ans+=mod;ans%=mod;
	cout<<ans<<endl;
}


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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define llu long long unsigned
#define pll std::pair<ll, ll> 
#define ppll std::pair<ll, pll>
#define vll std::vector<ll> 
#define vpll std::vector<pll> 
#define vppll std::vector<ppll> 
#define mll std::unordered_map<ll, ll> 
#define mpll std::unordered_map<pll, ll>
#define mppll std::unordered_map<ppll, ll>
#define sll std::set<ll>
#define ff first
#define ss second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define eb emplace_back
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define mod 1000000007
#define maxlong 1e18+5
#define len length()
#define sz size()


/*#################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
####################################################*/

ll n,a,b,c;
ll dpp[4123];

ll dp(ll k)
{
    

    if(k<0)
        return -10000000000000;
    if(dpp[k]!=-1)
        return dpp[k];
    if(k==0)
        return dpp[k]=0;
    return dpp[k]=1+max(dp(k-a),max(dp(k-b),dp(k-c)));
    // return 1+   
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef PARTH_LATHIYA_HOME

        freopen("A_in.txt","r",stdin);
    
        ll ttt,bkkk;
        cin>>ttt;
        bkkk=ttt;
        while(ttt--) {
            cout<<"Testcase - "<<bkkk-ttt<<"\n";
    #endif

//--------------------------------------------------------------------------------------

    s(t);
    ll ans=0;
    ll l,r;
    
    while(t--)
    {
    	cin>>l>>r;
    	ans+=(r-l+1);
    }
    cout<<ans;


//--------------------------------------------------------------------------------------
    
    #ifdef PARTH_LATHIYA_HOME
        cout<<"\n"; }
    #endif

    return 0;
}

Measured memory_bytes: 256
X,Y,Z = map(int,input().split())
if(X == Y):
    if(Y == Z):
        print("No")
    else:
        print("Yes")
elif(X == Z):
    if(X == Y):
        print("No")
    else:
        print("Yes")
elif(Y == Z):
    if(X == Y):
        print("No")
    else:
        print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<algorithm>
using namespace std;
int n;
int a[300005],s[300005];
bool check(int x){
	int Mn=0;
	for(int i=1;i<=n;i++)if(!(i&1))
		if(2*(s[i-1]-s[Mn])>=x&&s[i]<s[Mn])Mn=i;
	return 2*(s[n]-s[Mn])>=x;
}
int main(){
	scanf("%d",&n);
	int S=0;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),S+=a[i];
	for(int i=1;i<=n;i++)s[i]=s[i-1]+(i&1?a[i]:-a[i]);
	if(!(n&1)){
		printf("%d %d\n",(S+abs(s[n]))/2,(S-abs(s[n]))/2);
		return 0;
	}
	int l=1,r=2e9;
	int d=-s[n];
	while(l<r){
		int mid=r-((r-l)>>1);
		if(check(mid))l=mid;
		else r=mid-1;
	}
	printf("%d %d\n",(S+(d+l))/2,(S-(d+l))/2);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


signed main() {
	int n;
	cin >> n;
	rep(t, 0, n) {
		int r, c, m, y, x, y2, x2;
		cin >> r >> c;
		int dp[20][20] = { 0 };
		bool f[20][20][20][20] = {};
		/*rep(i, 0, 20) {
			rep(j, 0, 20) {
				f[i][j] = false;
			}
		}*/
		cin >> m;
		rep(i, 0, m) {
			cin >> y >> x >> y2 >> x2;
			f[y][x][y2][x2] = true;
			f[y2][x2][y][x] = true;
		}
		dp[0][0] = 1;
		rep(i, 0, r+1) {
			rep(j, 0, c+1) {
				if (!(f[i][j][i+1][j])) {
					dp[i + 1][j] += dp[i][j];
				}
				if (!(f[i][j][i][j+1])) {
					dp[i][j + 1] += dp[i][j];
				}
			}
		}
		/*rep(i,0,r+1){
			rep(j,0,c+1){
				cout<<dp[i][j]<<" ";
			}
			cout<<endl;
		}*/
		if (dp[r][c] == 0) cout << "Miserable Hokusai!" << endl;
		else cout << dp[r][c] << endl;
	}
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////

void solve(){
  inl(N , K);
  if( (2 * K + 2 * N - 1) * N > (2 * K + 5 * N - 1) * N / 2 ) die(-1);

  vl a(N) , b(N) , c(N);
  iota(all(a) , K);
  iota(all(b) , K + N);
  vl d(N);
  int bound = N / 2;
  copy( begin(b) + bound , end(b) , begin(d) );
  copy( begin(b) , begin(b) + bound , begin(d) + N - bound);
  b.swap(d);
  vi ord(N); iota(all(ord) , 0);
  sort(all(ord) , [&](int l,int r){return a[l]+b[l] < a[r]+b[r];});

  rep(i , N){
    out( a[ord[i]] , b[ord[i]] , K + 2 * N + i);
  }
}

Measured memory_bytes: 5760
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int[] line = ReadIntArray();
    int N = line[0], K = line[1];
    int[] h = new int[N];
    for (int i = 0; i < N; i++) h[i] = ReadInt();
    h = h.OrderByDescending(x => x).ToArray();
    int res = int.MaxValue;
    for (int i = 0; i < N-K+1; i++) {
      res = (h[i] - h[i+K-1] < res) ? h[i] - h[i+K-1] : res;
    }
    Console.WriteLine(res);
  }

  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
}


Measured memory_bytes: 18396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;

int main() {
    ll N, K;
    cin >> N >> K;
    ll m = (ll)sqrt(N);
    while ( (m+1)*(m+1) <= N ) m++;
    vector<ll> dp1(m+1, 1), dp2(m+1), c(m+1);
    for ( int i = 1; i <= m; i++ ) {
        if ( i < m ) c[i] = N/i - N/(i+1);
        else c[i] = N/i - m;
        dp2[i] = c[i];
    }

    vector<ll> dp1t(m+1), dp2t(m+1);
    vector<ll> dp1s(m+1), dp1st(m+1); // 1..i
    vector<ll> dp2s(m+1), dp2st(m+1); // i..m
    for ( int i = 1; i <= m; i++ ) {
        if ( i > 0 ) dp1s[i] += dp1s[i-1];
        dp1s[i] += dp1[i];
    }
    for ( int i = m; i >= 1; i-- ) {
        if ( i < m ) dp2s[i] += dp2s[i+1];
        dp2s[i] += dp2[i];
    }
    for ( int k = 1; k < K; k++ ) {
        for ( int i = 1; i <= m; i++ ) {
            dp1t[i] = 0;
            dp1t[i] += dp1s[m];
            dp1t[i] += dp2s[i];
            dp1t[i] %= MOD;
            
        }
        for ( int i = 1; i <= m; i++ ) {
            dp2t[i] = 0;
            dp2t[i] += c[i] * dp1s[i];
            dp2t[i] %= MOD;
        }
        for ( int i = 1; i <= m; i++ ) {
            dp1st[i] = 0;
            if ( i > 0 ) dp1st[i] += dp1st[i-1];
            dp1st[i] += dp1t[i];
            dp1st[i] %= MOD;
        }
        for ( int i = m; i >= 1; i-- ) {
            dp2st[i] = 0;
            if ( i < m ) dp2st[i] += dp2st[i+1];
            dp2st[i] += dp2t[i];
            dp2st[i] %= MOD;
        }
        dp1.swap(dp1t);
        dp2.swap(dp2t);
        dp1s.swap(dp1st);
        dp2s.swap(dp2st);
    }
    
    ll ans = dp1s[m] + dp2s[1];
    ans %= MOD;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 2432
// ARC092
// D - Two Sequences

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int K = 28;

int N;
vector<int> a, b;

int main() {
    cin >> N;
    a.resize(N);
    b.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }

    int ans = 0;
    for (int k = 0; k <= K; k++) {
        vector<int> q(N);
        for (int i = 0; i < N; i++) {
            q[i] = b[i] & ((1 << (k + 1)) - 1);
        }
        sort(q.begin(), q.end());

        int cnt = 0;
        for (int i = 0; i < N; i++) {
            int p = a[i] & ((1 << (k + 1)) - 1);
            // cnt += lower_bound(q.begin(), q.end(), (4 << k) - p) -
            cnt += q.end() - lower_bound(q.begin(), q.end(), (3 << k) - p);
            cnt += lower_bound(q.begin(), q.end(), (2 << k) - p) -
                   lower_bound(q.begin(), q.end(), (1 << k) - p);
        }
        if (cnt & 1) {
            ans |= (1 << k);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
n = int(input())
h = list(map(int, input().split()))
 
dp = []
for i in range(n):
	dp.append(int(0))
dp[0] = 0
dp[1] = abs(h[0]-h[1])
 
for j in range(2,n):
	dp[j] = min(dp[j-1] + abs(h[j-1] - h[j]),dp[j-2] + abs(h[j-2] - h[j]))
  
print(dp[n-1])

Measured memory_bytes: 20640
def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    drinks = []
    for _ in range(M):
        p, x = map(int, input().split())
        drinks.append([p, x])
    tot = sum(T)
    for i in range(M):
        p,x = drinks[i]
        d = T[p-1] - x
        print(tot - d)

if __name__ == '__main__':
    main()

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

int  main(){
    int n,k;
    cin >> n >>k;
    vector<int> h(n);
    rep(i,n) cin >> h[i]; 
    vector<ll> dp(n,INF);  
    dp[0] = 0; 
    for(int i =1;i<n;i++){
        for(int j = 1;j<=k;j++){
            if(i-j>=0) dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1408
// PROBLEM NAME ------>>> 
// PROBLEM LINK ------>>>  

//---------------------------------------------------------------------------------------------------------------

#include <bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define TC ll t;cin>>t; for(ll z = 1;z<=t;z++)
#define bs binary_search
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define vvll vector<vector<ll>>
#define sll stack<ll>
#define qll queue<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define vc vector <char>
#define f first
#define s second
#define MOD 10e9 + 7
#define mxn 10e18
#define ln "\n"

using namespace std;

void solve()
{
    string s,t;
    cin>>s>>t;
    if(s.length() + 1 == t.length())
    {
        for(unsigned int i  = 0;i<s.length();i++)
        {
            if(s[i] == t[i])
                continue;
            else
            {
                cout<<"No\n";
                return ;
            }
        }
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

const ll MAX = 1e5;

vector<vector<int> > drw;

int cnt(int x1, int y1, int x2, int y2) {
  return drw[x2][y2] - drw[x1][y2] - drw[x2][y1] + drw[x1][y1];
}

int main() {
  int N, K;
  cin >> N >> K;
  int K2 = 2 * K;
  vector<vector<int> > list(K2, vector<int>(K2, 0));
  for (int i = 0; i < N; i++) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    if (c == 'W') {
      x += K;
    }
    list[x % K2][y % K2]++;
  }

  drw.resize(K2 + 1, vector<int>(K2 + 1, 0));
  for (int i = 0; i < K2; i++) {
    for (int j = 0; j < K2; j++) {
      drw[i + 1][j + 1] = drw[i][j + 1] + drw[i + 1][j] - drw[i][j] + list[i][j];
    }
  }

  int ans = -1e9;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int res = cnt(0, 0, i, j)
       + cnt(i, j, i + K, j + K)
       + cnt(0, j + K, i, K2)
       + cnt(i + K, 0, K2, j)
       + cnt(i + K, j + K, K2, K2);
       ans = max(ans, res);
       ans = max(ans, N - res);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main () {
  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    cin >> b[i];
  }  
  queue<int> edge;
  int station[n + 1];
  int ans = 0;
  for (int l = 0; l < m; l++) {
    
    // 初期化
    for (int i = 0; i <= n; i++) {
      station[i] = 0;  
    }
    int ab[n + 1][n + 1];
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        ab[i][j] = 0;  
      }  
    }
    
    // a[i]とb[i]をつなぐ
    for (int i = 0; i < m; i++) {
      if (i != l) {
        ab[a[i]][b[i]] = 1;
        ab[b[i]][a[i]] = 1;    
      }  
    }

    // edgeに初期値を入れる（最低でも1 ~ 3までをいれればいいはず）
    for (int p = 1; p <= 3; p++) {
      if (n < p || !edge.empty()) {
        break;  
      }
      for (int i = 0; i <= n; i++) {
        if (ab[p][i] == 1) {
          edge.push(i);
          station[p] = 1;  
          station[i] = 1;
        }
      }
    }
    while (!edge.empty()) {
      int sub = edge.front();
      for (int i = 0; i <= n; i++) {
        if (ab[sub][i] == 1) {
          if (station[i] == 0) {
            edge.push(i);  
            station[i] = 1;
          }    
        }
      }  
      edge.pop();
    }
    bool bridge = false;
    for (int i = 1; i <= n; i++) {
      if (station[i] == 0) {
        bridge = true;  
      }
    }
    if (bridge == true) {
      ans++;  
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

struct UnionFind {
	vector<int>d;
	UnionFind(int n = 0) :d(n, -1) {}//コンストラクタ(全部根でサイズは1(根は負))
	int find(int x) {
		if (d[x] < 0)return x;//今根なら頂点番号を返す
		return  d[x] = find(d[x]);//親についてfindする(経路縮約ver）
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);//両方を根に変える
		if (x == y)return false;//一致するならfalse
		if (-d[x] < -d[y])swap(x, y);//xの方がサイズが大きくなるようにする
		d[x] += d[y];//xにyをくっつける
		d[y] = x;
		return  true;
	}
	bool same(int x, int y) { return find(x) == find(y); }//同じ集合の属しているか
	int size(int x) { return -d[find(x)]; }//サイズを返す
};
int deg[100005];
vector<int>b[100005];

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	UnionFind uf(n);
	
	rep(i, m) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		deg[A]++;
		deg[B]++;
		uf.unite(A, B);
	}
	rep(i, k) {
		int C, D;
		cin >> C >> D;
		C--; D--;
		b[C].push_back(D);
		b[D].push_back(C);
	}
	vector<vector<int>>fc(n);
	rep(i, n) {
		int ans = uf.size(i) - 1 - deg[i];
		for (int u : b[i]) {
			if (uf.same(i, u))--ans;
		}
		cout << ans << " ";
	}
}

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

using namespace std;
const int MAXN=1e5+10;
int n,l,q,a,b,dat[MAXN],nxt[MAXN][25];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&dat[i]);
	scanf("%d",&l);
	for(int i=1;i<=n;i++)
		nxt[i][0]=upper_bound(dat+1,dat+n+1,dat[i]+l)-dat-1;
	
	for(int i=n;i;i--)
		for(int j=1;j<=20;j++)
			nxt[i][j]=nxt[nxt[i][j-1]][j-1];
	
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d%d",&a,&b);
		if(a>b) swap(a,b);
		
		int res=0;
		for(int i=20;i>=0;i--)
			if(nxt[a][i]&&nxt[a][i]<b) a=nxt[a][i],res+=(1<<i);
		printf("%d\n",res+1);
	}
	return 0;
}

Measured memory_bytes: 11008
#include <stdio.h>
int main ()
{
	char s[5];
	char a[5];
	char b;
	while(scanf("%s%c%s",&s,&b,&a)!=EOF)
	{
		if(s[0] == a[2] && s[1] == a[1] && s[2] == a[0])
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<cstdlib>
using namespace std;

int main() {
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  int ans = max(a, b) + max(c, d) + max(min(a, b), min(c, d)) + max(e, f);
  cout << ans << endl;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
typedef long long ll;
ll a[maxn];
vector<ll>res;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        a[i]*=2;
    }
    ll tmp=0;
    for(int i=1;i<=n;i++){
        if(i&1) tmp+=a[i];
        else tmp-=a[i];
    }
    res.push_back(tmp/2);
    for(int i=1;i<n;i++){
        res.push_back(a[i]-res.back());
    }
    for(auto it:res){
        printf("%d ",it);
    }
    return 0;
}

Measured memory_bytes: 3060
unittest
{
	assert( [ "C0DEFESTIVAL2O16" ].parse.expand.solve == 2 );
	assert( [ "FESTIVAL2016CODE" ].parse.expand.solve == 16 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	auto ans = 0L;
	foreach( sc, tc; lockstep( s, "CODEFESTIVAL2016"d ) )
	{
		ans += ( sc != tc );
	}
	return ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] s = new int[440000];
		int[] t = new int[220000];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int left = 220000; int right = left + 1;
		for(int i = 0 ; i < n ; i++) {
			if((n + 1) % 2 == i % 2) {
				s[left--] = a[i];
			} else {
				s[right++] = a[i];
			}
		}
		for(int i = left ; i <= right ; i++) {
			t[i - left] = s[i];
		}
		for(int i = 1 ; i < n + 1 ; i++) {
			System.out.print(t[i] + " ");
		}
	}
}


Measured memory_bytes: 97464
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL a,b,c;
    cin >> a >> b >> c;

    LL m = max(a,max(b,c));
    
    cout << m*10 + a + b + c - m << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        ll a[n];
        ll val=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            val=(val^a[i]);
        }
        for(int i=0;i<n;i++){
            cout<<(val^a[i])<<" ";
        }
    }
    return 0;
}

Measured memory_bytes: 5104
while True:
    N,X = map(int,input().split())
    if N == 0 and X == 0:
        break
    ans = 0
    for a in range(1,N+1):
        for b in range(1,N+1):
            if b <= a:
                continue
            c = X-(a+b)
            if c > b and c <= N:
                ans += 1
    print("%d"%(ans))


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int size = s.nextInt();
		int[] bHeap = new int[size];
		for (int  i = 0; i < size; i++) bHeap[i] = s.nextInt();
		System.out.println("node 1: key = " + bHeap[0] + ", left key = " + bHeap[1] + ", right key = " + bHeap[2] + ", ");
		for (int i = 1; i < size; i++) {
			System.out.print("node " + (i+1) + ": key = " + bHeap[i] + ", parent key = " + bHeap[(i-1)/2] + ", ");
			int l = (2*i + 1);
			int r = (2*i + 2);
			if (l < size) System.out.print("left key = " + bHeap[l] + ", ");
			if (r < size) System.out.print("right key = " + bHeap[r] + ", ");
			System.out.println();
		}
	}	
}



Measured memory_bytes: 27264