akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
vvi G;
void dfs(int v, int pre, int d, vector<int>& bi){
    bi[v] = d % 2;
    for(auto nv: G[v]){
        if(pre == nv)continue;
        dfs(nv, v, d + 1, bi);
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin>>N;
    G.resize(N);
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> biparty(N,-1);
    dfs(0,-1,0, biparty);
    print(biparty);
    //二部グラフ
    vector<int> even, odd;
    rep(i,N){
        if(biparty[i] == 0){
            even.push_back(i);
        }
        else{
            odd.push_back(i);
        }
    }
    vector<int> nums[3];
    rep1(i,N+1){
        nums[i % 3].push_back(i);
    }
    //色塗りをする
    vector<int> ans(N, -1);

    //evenのほうが小さい保証
    if(even.size() > odd.size()){
        swap(even, odd);
    }
    //両方入る場合
    if(even.size() >= max(nums[1].size(),  nums[2].size())){
        rep(i,nums[1].size()){
            ans[even[i]] = nums[1][i];
        }
        rep(i, nums[2].size()){
            ans[odd[i]] = nums[2][i];
        }
        int idx = 0;
        for(int i = 0; i < N; i++){
            if(ans[i] == -1){
                ans[i] = nums[0][idx];
                idx++;
            }
        }
    }
    else{
        //このとき、even.size() <= num[0].size()
        //evenを0埋めする
        rep(i, even.size()){
            ans[even[i]] = nums[0][i];
        }
        //残りの0をoddへ
        int idx = 0;
        for(int i = even.size(); i < nums[0].size();i++){
            ans[odd[idx]] = nums[0][i];
            idx++;
        }
        rep(i, nums[1].size()){
            ans[odd[idx]] = nums[1][i];
            idx++;
        }
        rep(i,nums[2].size()){
            ans[odd[idx]] = nums[2][i];
            idx++;
        }
    }
    rep(i,N){
        cout<<ans[i];
        if(i == N-1)cout<<endl;
        else cout<<" ";
    }
}

Measured memory_bytes: 21876
n = int(input())
if(n <= 599):
    print(8)
elif(n >= 600)and(n <= 799):
    print(7)
elif(n >= 800)and(n <= 999):
    print(6)
elif(n >= 1000)and(n <= 1199):
    print(5)
elif(n >= 1200)and(n <= 1399):
    print(4)
elif(n >= 1400)and(n <= 1599):
    print(3)
elif(n >= 1600)and(n <= 1799):
    print(2)
elif(n >= 1800)and(n <= 1999):
    print(1)

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
const long long inf=0x3f3f3f3f;
const double eps=1e-6;
const long long mod=1000000007;
typedef long long ll;
struct matrix{
	int n=50,a[55][55]={};ll k;
	void input(){
		cin>>n>>k;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				cin>>a[i][j];
	}
	matrix operator*(matrix b){
		matrix ret;
		for(int i=0;i<n;i++){
			for(int k=0;k<n;k++){
				for(int j=0;j<n;j++){
					ret.a[i][j]+=(1ll*a[i][k]*b.a[k][j]%mod);
					ret.a[i][j]%=mod;
				}
			}
		}
		return ret;
	}
	matrix fastpow(matrix x,ll y){
		if(y==1)return x;
		matrix ret=fastpow(x,y/2);
		ret=ret*ret;
		if(y&1)ret=ret*x;
		return ret;
	}
	int answer(){
		if(k==0)return n;
		matrix mat=fastpow(*this,k);
		ll ans=0;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				ans=(ll)(ans+mat.a[i][j])%mod;
		return ans%mod;
	}
}graph;
signed main(){
	ios::sync_with_stdio(false);
	graph.input();
	cout<<graph.answer()<<endl;
	return 0;
}
/*
10 1000000000000000000
0 0 1 1 0 0 0 1 1 0
0 0 0 0 0 1 1 1 0 0
0 1 0 0 0 1 0 1 0 1
1 1 1 0 1 1 0 1 1 0
0 1 1 1 0 1 0 1 1 1
0 0 0 1 0 0 1 0 1 0
0 0 0 1 1 0 0 1 0 1
1 0 0 0 1 0 1 0 0 0
0 0 0 0 0 1 0 0 0 0
1 0 1 1 1 0 1 1 1 0
*/


Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<math.h>
#include <stdlib.h>
#define M 100000
using namespace std;
 
 
int n, m,l, p = 0 , result = 0;
int x[100010];
 
int main(){
    scanf("%d %d",&n,&m);
    x[0] = 0;
    for (int i = 1; i < n; i++){
        scanf("%d", &x[i]);
        x[i] += x[i - 1];
    }
    while (m--){
        scanf("%d", &l);
        result += abs(x[p + l] - x[p]);
        result %= M;
        p += l;
    }
    printf("%d\n", result);
}

Measured memory_bytes: 1576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    Long[][] r = new Long[n][2];
    for (int i = 0; i < n; i++) {
      long x = sc.nextLong();
      long l = sc.nextLong();
      r[i] = new Long[]{x - l, x + l};
    }
    Arrays.sort(r, (Long[] r1, Long[] r2) -> {
      if (r1[1].compareTo(r2[1]) == 0) {
        return r1[0].compareTo(r2[0]);
      }
      return r1[1].compareTo(r2[1]);
    });
    int count = 1;
    int lastIndex = 0;
    for (int i = 1; i < n; i++) {
      if (r[lastIndex][1] <= r[i][0]) {
        count++;
        lastIndex = i;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 53412
H, W = map(int, input().split())
board = [input() for i in range(H)]
used  = [[False]*W for i in range(H)]

used[0][0] = True
q = [(0, 0)]

while len(q) > 0:
    y, x = q[0]
    q = q[1:]
    if x+1 < W and board[y][x+1]=='#' and not used[y][x+1]:
        used[y][x+1] = True;
        q.append((y, x+1))
    elif y+1 < H and board[y+1][x]=='#' and not used[y+1][x]:
        used[y+1][x] = True;
        q.append((y+1, x))

ans = True
for i in range(H):
    for j in range(W):
        if board[i][j] == '#':
            ans = ans and used[i][j]

print("Possible") if ans else print("Impossible")


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

using namespace std;

#define gc c=getchar()
#define r(x) read(x)
#define ll long long

template<typename T>
inline void read(T&x){
    x=0;T k=1;char gc;
    while(!isdigit(c)){if(c=='-')k=-1;gc;}
    while(isdigit(c)){x=x*10+c-'0';gc;}x*=k;
}

const int N=2005;

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}

vector<int>G1[N];
vector<int>G2[N];

int a[N];
int deg[N];
bool vis[N];

void dfs(int x){
	vis[x]=1;
	for(int i=0;i<G1[x].size();++i){
		int v=G1[x][i];
		if(!vis[v]){
			G2[x].push_back(v);
			deg[v]++;
			dfs(v);
		}
	}
}

int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;r(n);
	for(int i=1;i<=n;++i)r(a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			if(gcd(a[i],a[j])!=1){
				G1[i].push_back(j);
				G1[j].push_back(i);
			}
		}
	}
	for(int i=1;i<=n;++i){
		if(!vis[i]){
			dfs(i);
		}
	}
	priority_queue<pair<int,int> >Q;
	for(int i=1;i<=n;++i){
		if(!deg[i]){
			Q.push(make_pair(a[i],i));
		}
	}
	while(!Q.empty()){
		int x=Q.top().second;Q.pop();
		printf("%d ",a[x]);
		for(int i=0;i<G2[x].size();++i){
			int v=G2[x][i];
			if(!--deg[v]){
				Q.push(make_pair(a[v],v));
			}
		}
	}
	return 0;
}


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


void solve(long long N, std::vector<long long> a){
    bool result = false;
    for (const auto num :a){
        if (num%2 ==1) result = true;
    }
    if (result){
        printf("first\n");
    }else{
        printf("second\n");
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long n,pro,sum[200001],x;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>sum[i];
	}
	int s=0;
	for(int i=n-1;i>=1;i--){
		s=(s+sum[i+1])%1000000007;
		pro=(sum[i]*s+pro)%1000000007;
	}
	cout<<pro;
	return 0;
} 

Measured memory_bytes: 5148
#include <iostream>

using namespace std;

int main()
{
    int N;
    string s;
    scanf("%d", &N);
    cin>>s;
    long long red, green, blue, result;
    red = green = blue = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'R')
            red++;
        if(s[i] == 'G')
            green++;
        if(s[i] == 'B')
            blue++;
    }
    result = red * green * blue;
    for(int i = 0; 2 * i < N; i++)
    {
        for(int j = 0; 2 * i + j < N; j++)
        {
            if(s[j] != s[j+i] && s[j] != s[2 * i + j] && s[j + i] != s[2 * i + j])
            {
                result--;
            }

        }
    }
    printf("%lld", result);
    return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5+5;
int n;
char str[N];
bool wlf[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

bool jdg(const int v1,const int v2){
	wlf[1]=v1,wlf[2]=v2;
	for(int i=3; i<=n; ++i){
		wlf[i]=wlf[i-2]^(wlf[i-1]^(str[i-1]=='x'));
	}
	if((wlf[n]^wlf[2])!=(wlf[1]^(str[1]=='x'))) return 0;
	if((wlf[1]^wlf[n-1])!=(wlf[n]^(str[n]=='x'))) return 0;
	return 1;
}

void oput(){
	for(int i=1; i<=n; ++i){
		putchar(wlf[i]?'W':'S');
	}
	puts("");
}

int main(){
	n=nxi();
	scanf("%s",str+1);
	if(jdg(0,0)) oput();
	else if(jdg(0,1)) oput();
	else if(jdg(1,0)) oput();
	else if(jdg(1,1)) oput();
	else puts("-1");
	return 0;
}


Measured memory_bytes: 512
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
struct edge {
    int to;
    ll cost;
};

int n, k;
vec<edge> g[MAX_N];
ll cost[MAX_N];

void dfs(int u, int p = -1, ll c = 0) {
    cost[u] = c;

    for (edge e : g[u]) {
        if (e.to == p) continue;
        dfs(e.to, u, c + e.cost);
    }
}

int main() {
    fastio();

    cin >> n;
    forn(i, n - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        g[a - 1].push_back((edge) { b - 1, c });
        g[b - 1].emplace_back((edge) { a - 1, c });
    }

    int q;
    cin >> q >> k;

    dfs(k - 1);

    while (q--) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << cost[x] + cost[y] << "\n";
    }

    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n;
    int b = -2;
    int c = 0;
    int ans = 0;
    cin >> n;
    rep(i, n)
    {
        int a;
        cin >> a;
        if (b == -2)
        {
            c = a;
            b = 0;
        }
        else if (b == 0)
        {
            if (a < c)
            {
                b = -1;
                c = a;
            }
            else if (c < a)
            {
                b = 1;
                c = a;
            }
        }
        else if (b == -1)
        {
            if (a <= c)
            {
                c = a;
            }
            else
            {
                b = 0;
                c = a;
                ans++;
            }
        }
        else if (b == 1)
        {
            if (a < c)
            {
                b = 0;
                c = a;
                ans++;
            }
            else
            {
                c = a;
            }
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

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


int main() {

    int K, X;
    cin >> K >> X;

    for (int i = -(K - 1); i <= (K - 1); i++) {
        cout << X + i << " ";
    }

}
























Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
vector<ll> adj[100011];
vector<bool> visited(100000);
ll arr[100011];
ll n , m ;
ll solve(){
	ll ans =0 ;
	for(ll i=1;i<=n ; i++){
		bool flag=1;
		for(auto v : adj[i]){
			if(arr[i]<=arr[v])flag=0;
		}
		if(flag){
			// cerr<<i<<endl;
			ans++;
		}
	}
	return ans ;
}

int main(){
	//mahakal(),fast;
	
	cin>> n >> m ;
	for(ll i=1;i<=n ;i++)cin>>arr[i];

	for(ll i=0 , a , b ; i< m ;i++){
		cin>> a >> b ;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	ll ans = solve();
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 10224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll s,H,M,S;
    cin>>s;
    H=s/3600;
    M=(s%3600)/60;
    S=(s%3600%60);
    cout<<H<<":"<<M<<":"<<S<<endl;
    return 0;
}





Measured memory_bytes: 3084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String kosu=br.readLine();
		int nako=Integer.parseInt(kosu);
		int[] suji=new int[nako];
		String[] egara=new String[nako];

		for(int j=0; j<nako; j++){
			String strArr[] = br.readLine().split(" ");
			egara[j]=(strArr[0]);
			suji[j]=Integer.parseInt(strArr[1]);
			
		}

		int[] trump=new int[52];
		int tmp=0;

		for(int i=0; i<52; i++){
			trump[i]=0;
		}

		for(int i=0; i<nako; i++){

			if(egara[i].equals("S")){
				tmp=-1;
				tmp+=suji[i];
			}
			else if(egara[i].equals("H")){
				tmp=12;
				tmp+=suji[i];
			}
			else if(egara[i].equals("C")){
				tmp=25;
				tmp+=suji[i];
			}
			else if(egara[i].equals("D")){
				tmp=38;
				tmp+=suji[i];
			}

			trump[tmp]=1;
		}


		int[] none_card=new int[52-nako];
		int none_count=0;

		for(int i=0; i<52; i++){
			if(trump[i]==0){
				none_card[none_count]=i+1;
				none_count++;
			}
			else{}
		}

		for(int i=0; i<52-nako; i++){
			if((none_card[i]-1)/13==0){
				if(none_card[i]%13==0){
					System.out.println("S 13");
				}
				else{
					System.out.println("S "+none_card[i]%13);
				}
			}

			else if((none_card[i]-1)/13==1){
				if(none_card[i]%13==0){
				System.out.println("H 13");
				}
				else{
					System.out.println("H "+none_card[i]%13);
				}
			}

			else if((none_card[i]-1)/13==2){
				if(none_card[i]%13==0){
					System.out.println("C 13");
					}
					else{
						System.out.println("C "+none_card[i]%13);
					}
			}

			else if((none_card[i]-1)/13==3){
				if(none_card[i]%13==0){
					System.out.println("D 13");
					}
					else{
						System.out.println("D "+none_card[i]%13);
					}
			}
		}
	}
}

Measured memory_bytes: 24268
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int

ll cnt[200005],c[200005];

int main()
{
 	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	//ll tt;	cin>>tt;	while(tt--)
  	{
  		ll n,i,x,sum;
  		cin>>n;

  		ll arr[n+1];

  		for(i=0;i<n;i++)	{cin>>arr[i],c[arr[i]]++;}

  			sum=0;
		for(i=0;i<=n;i++)
		{
			cnt[i]=c[i]*(c[i]-1);
			cnt[i]/=2;

			sum+=cnt[i];
		}
		//cout<<sum;

		for(i=0;i<n;i++)
		{
			cout<<sum-c[arr[i]]+1<<endl;
		}



  	}
 	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
    return 0;
  		
}

Measured memory_bytes: 6272
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <cctype>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> d(k);
    vector<int> snuke(n);

    rep(i,n){
        snuke[i]=0;
    }

    rep(i,k){
        cin >> d[i];
        vector<int> a(d[i]);
        rep(j,d[i]){
            cin >> a[j];
            snuke[a[j]-1]++;
            }
    }
    int ans=0;
    rep(i,n){
        if(snuke[i]==0)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n==1)
            System.out.println("Hello World");
        else{
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a+b);
        }
     }
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> p(n),a(n),b(n);
	for(int i=0;i<n;i++)
		cin >> p[i];
	
	for(int i=0;i<n;i++)
	{
		a[i]=i+1;
		b[i]=n-i;
	}

	for(int i=1;i<=n;i++)
	{
		for(int j=p[i-1];j<=n;j++)
			a[j-1]+=i;
		for(int j=1;j<=p[i-1];j++)
			b[j-1]+=i;
	}
	for(int i=0;i<n;i++)
		cout << a[i] << " ";
	cout << endl;
	for(int i=0;i<n;i++)
		cout << b[i] << " ";
	cout << endl;
}
	


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


int main()
{
	int i, j, k,l,m,n,o,p,q;
	cin >> i>>j>> k;
	if (j < k) { l = k, k = j, j = l; }
	if (i < j&&i < k) { l = i, i = j, j = k, k = l; }
	else { if (i < j) { l = i, i = j, j = l; } }
	m = i - k;
	n = m % 2;
	o = m / 2;
	m = i - j;
	p = m % 2;
	q = m / 2;
	if (n == 0 && p == 0) { cout << o + q; }
	else {
		if (n == 1 && p == 1) { cout << o + q + 1; }
		else {
			cout << o + q + 2;
		}
	}



	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(N);
  REP(i, N) cin >> A[i];

  ll now = 0;
  ll ans = 0;
  REP(i, N) {
    if (A[i] >= now) {
      now = A[i];
    } else {
      ans += now - A[i];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4780
N,H=map(int,input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)

max_A=max(A)

D=[]
for i in range(N):
  if B[i]>max_A:
    D.append(B[i])
D.sort(reverse=True)

ans=0
for i in range(len(D)):
  H-=D[i]
  ans+=1
  if H<=0:
    break

if H>0:
  if H%max_A==0:
    ans+=int(H/max_A)
  else:
    ans+=(int(H/max_A)+1)

print(ans)

Measured memory_bytes: 12072
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

int N, M;
int A[301][301];
int current[301];
int selected[301];
int cnt[301];

inline int solve() {
    int ans = N;
    for(int k = 0; k < M - 1; k++) {
        for(int i = 0; i < M; i++) cnt[i] = 0;
        for(int i = 0; i < N; i++) {
            while(selected[A[i][current[i]]]) current[i]++;
            cnt[A[i][current[i]]]++;
        }
        auto max_id = max_element(cnt, cnt + M);
        ans = min(ans, *max_id);
        selected[max_id - cnt] = 1;
    }
    return ans;
}

int x;
const int cm = 1 << 20;
char cn[cm], *ci = cn, ct;

inline int readint() {
	x = 0;
	while ((ct = *ci++) >= '0') x = (x >> 1) + (x >> 3) + ct - '0';
    return x;
}

int main() {
    // fread_unlocked(cn, 1, cm, stdin);
    // N = readint();
    // M = readint();
    scanf("%d %d", &N, &M);
    REP(i, N) REP(j, M) {
        scanf("%d", &A[i][j]);
        // A[i][j] = readint();
        A[i][j]--;
    }
    cout << solve() << "\n";
	return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final FastReader s=new FastReader();
        int n = s.nextInt();
        
        int[] l = new int[n];
        while (n-- > 0)
        {
            l[n] = s.nextInt();
        }
        int count = 0;
        Arrays.sort(l);
        n=l.length;
        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                if(l[i]==l[j])  continue;
                for(int k=j+1;k<n;k++){
                    if(l[j]==l[k])  continue;
                    if(l[i]+l[j]>l[k])
                        count++;
                }
            }
        }
        System.out.println(count);
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try { st = new StringTokenizer(br.readLine()); }
                catch (final IOException  e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }
        String nextLine() {
            String str = "";
            try { str = br.readLine(); }
            catch (final IOException e) { e.printStackTrace(); }
            return str;
        }
    }
}

Measured memory_bytes: 25864
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] c = new int[101];
        int m = 0;
        while(sc.hasNext()){
        	c[sc.nextInt()]++;
        }
        int max=0;
        for(int e: c){
        	if(e>max){
        		max = e;
        	}
        }
        for(int i=1;i<=100;i++){
        	if(c[i]==max){
        		System.out.println(i);
        	}
        }
    }
}

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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

const int N = 200100;

int n,a[N],mx;
ll ans;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    for(int i=1;i<=n;i++)
    {
        mx = max( mx , a[i] );
        ans += mx-a[i];
    }

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


Measured memory_bytes: 4536
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll n,m,k,d,q;

int b[maxn],a[maxn];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&b[i]);
    }
    for(int i=n-1;i>=0;i--)
    {
        a[i]+=a[i+1]+b[i];
    }
    int sum=0;
    for(int i=0;i<n-1;i++)
    {
        sum+=b[i]*a[i+1];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define INF 1000000007
int main(){
    int n,m;
    cin>>n>>m;
    int a[30];
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    sort(a,a+m);
    int dp[114514];
    dp[0]=0;
    for(int i=1;i<=n;i++){
        int mi=INF;
        for(int j=0;j<m;j++){
            if(i-a[j]>=0)mi=min(mi,dp[i-a[j]]+1);
        }
        dp[i]=mi;
    }
    cout<<dp[n]<<endl;
    return 0;
}



Measured memory_bytes: 3364
# include<cstdio>
# include<iostream>
# include<algorithm>
# include<cmath>
# include<cstring>
# include<string>
using namespace std;
typedef long long ll;
bool vis[1000];
int main()
{
    int n,s;
    cin>>n>>s;
    int x,y,z;bool ok=false;
    for(x=0;x<=n;x++)
    for(y=0;y<=n;y++){
        if(x+y>n) continue;
        z=n-x-y;
        if(10000*x+5000*y+1000*z==s){
                ok=true;
            goto kk;
        }

    }
    kk:
    if(ok) cout<<x<<" "<<y<<" "<<z<<endl;
    else cout<<"-1 -1 -1"<<endl;
    return 0;
}


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

int main()
{
  int N, M, C;
  std::cin >> N >> M >> C;
  
  auto A = (int*)alloca(M * sizeof(int));
  auto B = (int*)alloca(M * sizeof(int));
  for (int i = 0; i < M; ++i)
  {
    std::cin >> B[i];
  }
  
  int x = 0;
  for (int n = 0; n < N; ++n)
  {
    for (int i = 0; i < M; ++i)
    {
      std::cin >> A[i];
    }
    if (std::inner_product(A, A + M, B, C) > 0)
    {
      ++x;
    }
  }
  
  std::cout << x << std::endl;
}

Measured memory_bytes: 256
n=int(input())
List=[1,2,4,8,16,32,64]
if (n==1):
  print(List[0])
elif (2<=n<4):
  print(List[1])
elif (4<=n<8):
  print(List[2])
elif (8<=n<16):
  print(List[3])
elif (16<=n<32):
  print(List[4])
elif (32<=n<64):
  print(List[5])
else:
  print(List[6])

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

int main()
{
	int k,a,b,s=0;
	cin>>k>>a>>b;
	for (int i=a; i<=b; i++)
	{
		if (i%k==0)
		{
			s++;
		}
	}
	if (s!=0)
	  cout<<"OK";
	else
	  cout<<"NG";
	return 0;
}

Measured memory_bytes: 3588
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

A, B = list(map(int, sys.stdin.readline().split()))
a = math.ceil((B - 1) / (A - 1))
print(a)


Measured memory_bytes: 22872
/* author: Tarek */ 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int n,m;
cin>>n>>m;
if(m<=n){
  for(int i=0;i<n;i++){
     cout<<m<<"";
  }
  cout<<endl;
}
else{
 for(int i=0;i<m;i++){
   cout<<n<<"";
 }
 cout<<endl;
}
 return 0;
}



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

int main() {
    string s; cin >> s;
    
    int len = int(s.size());
    s.erase(len-2, len);
    for (int i = len; i >= 2; i -= 2) {
        if (s.substr(0, i/2) == s.substr(i/2, i)) {
            cout << i << endl;
            return 0;
        }
        s.erase(i-2, i);
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

int main(void)
{
    int n;
    cin >> n;
    int x = (n / 100) % 10;
    if (100 * x + 10 * x + x < n)
    {
        cout << 100 * (x + 1) + 10 * (x + 1) + (x + 1);
    }
    else
    {
        cout << 100 * x + 10 * x + x;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  //vector<vector<int>> A(100001, vector<int>(0));
  vector<ll> A(100001, 0);
  ll sum = 0;
  rep(i,N){
    int a;
    cin >> a;
    A[a]++;
    sum += a;
  }
  int Q;
  cin >> Q;
  rep(i,Q) {
    ll b,c;
    cin >> b >> c;
    sum -= b * A[b];
    sum += c * A[b];
    A[c] += A[b];
    A[b] = 0;
    //rep(i, 4) cout << A[i+1] <<" ";
    //cout<<endl;
    cout << sum << endl;
  }


}


Measured memory_bytes: 4028
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n, a;
	cin >> n >> a;
	int min=a, max=a;
	for(int i=1; i<n; i++){
		cin >> a;
		if(a > max)
			max = a;
		else if(a < min)
			min = a;
	}
	cout << max-min << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b);

int main(void)
{
	int a, b;
	while (scanf("%d %d", &a, &b) != EOF){
		if (a < b){
			a ^= b;
			b ^= a;
			a ^= b;
		}

		printf("%d %d\n", gcd(a, b), (a / gcd(a, b)) * b);
	}

	return (0);
}

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

	return (gcd(b, a % b));
}

Measured memory_bytes: 596
import sys
sys.setrecursionlimit(10**7)


def dfs(v, p, p_col, tree, res):
    col = 1
    for u, id in tree[v - 1]:
        if u == p:
            continue
        if col == p_col:
            col += 1
        res[id] = col
        dfs(u, v, col, tree, res)
        col += 1


def main():
    n = int(input())
    tree = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        tree[a-1].append([b, i])
        tree[b-1].append([a, i])

    ans = [0 for _ in range(n-1)]
    dfs(1, -1, -1, tree, ans)
    print(max(ans))
    print("\n".join(map(str, ans)))


if __name__ == '__main__':
    main()


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

int main(void){
  char str[102];
  int i,count;
  int len;
  int flag;

  count = 0;
  while(fgets(str,102,stdin)!=NULL){
    len = strlen(str)-1;

    flag = 1;
    for(i=0;i<len/2;i++){
      if(str[i] != str[len-i-1]){
	flag = 0;
	break;
      }
    }
    if(flag)count++;
  }

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

  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[100100];
map<pair<ll,ll>,ll> ma;

vector<vector<ll> > vv;

void dfs(ll a, ll p, ll h){
  if(vv[a].sz==1&&p!=-1){
    return;
  }
  ll c = 0;
  rep(i,0,vv[a].sz){
    if(vv[a][i]==p)continue;
    ll p1 = a;
    ll q1 = vv[a][i];
    if(p1>q1)swap(p1,q1);
    if(c==h)c++;
    ll index = ma[mp(p1,q1)];
    d[index] = c;
    dfs(vv[a][i],a,c);
    c++;
  }
  return;
}


int main(){
  clr(d,-1);
  ll n;
  cin>>n;
  vector<vector<ll> > vv_(n,vector<ll>());
  vv = vv_;

  rep(i,0,n-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b)swap(a,b);
    vv[a].pb(b);
    vv[b].pb(a);
    ma[mp(a,b)] = i;
  }
  dfs(0,-1,-1);
  ll mx = 0;
  rep(i,0,n-1){
    mx = max(mx,d[i]+1);
  }
  cout << mx << endl;
  rep(i,0,n-1){
    cout << d[i]+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const int INF=10010010;
const double PI=3.141592653589;

int kai(int n){
  int ans=1;
  rep(i,n)
  ans*=i+1;
  return ans;
}

int main(){
  int n; cin>>n;
  vector<P> z(n);
  rep(i,n) cin>>z[i].first>>z[i].second;
  sort(z.begin(),z.end());

  double sum=0;
  do{
    // cout<<"sento"<<endl<<z[0].first<<" "<<z[0].second<<endl;
    rep(i,n-1){
      double x2=(z[i].first-z[i+1].first)*(z[i].first-z[i+1].first);
      double y2=(z[i].second-z[i+1].second)*(z[i].second-z[i+1].second);
      sum+=sqrt(x2+y2);
      // cout<<z[i].first<<"⇒"<<z[i+1].first<<" "<<z[i].second<<"⇒"<<z[i+1].second<<endl;
    }
  }while(next_permutation(z.begin(),z.end()));
  sum/=kai(n);
  cout<<fixed<<setprecision(6)<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
     int i,j,k,n,m;
     scanf("%d%d",&n,&m);
     printf("%d\n",2*m-n);
     return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

ll attack(ll a) {
  if (a == 1) return 1;
  a /= 2;
  return 1 + 2 * attack(a);
}

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

  ll h;
  cin >> h;
  cout << attack(h) << endl;
}

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

using namespace std;

void solve(int N, int M, vector<int> v){
    sort(v.begin(), v.end());
    for(int i = 0 ; i < M-1 ; i++){
        v[i] = v[i+1]-v[i];
    }
    v.pop_back();
    sort(v.begin(), v.end());
    int sum=0;
    for(int i = 0 ; i < (int)v.size()-N+1 ; i++){ // M-N = M-1-N+1
        sum += v[i];
    }
    cout << sum << endl;
    return;
}

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> X(M);
    for(int i = 0 ; i <  M ; i++){
        cin >> X[i];
    }
    solve(N,M, move(X));
    return 0;
}


Measured memory_bytes: 640
h, w = [int(s) for s in input().split(' ')]
 
s = []
for i in range(h):
    s.append([s == '.' for s in input()])
 
inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

queue = [(0, 0)]
p = []
for i in range(h):
    p.append([inf] * w)
p[0][0] = 1
 
while len(queue) > 0:
    x, y = queue.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h:
            if s[yy][xx] and p[yy][xx] > p[y][x] + 1:
                p[yy][xx] = p[y][x] + 1
                queue.insert(0, (xx, yy))
           
if p[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - p[h-1][w-1])

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<N;i++) cin>>h[i];
  sort(h.begin(),h.end());
  int ans=h[N-1]-h[0];
  for(int i=0;i<N-K+1;i++){
    int reg=h[i+K-1]-h[i];
    ans=min(ans,reg);
  }
  cout<<ans<<endl;
}


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


int main(){
	
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	
	if( b-a == c-b ){
		printf("YES\n");
	}else{
		printf("NO\n");
	}	
	
	return 0;
	
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int w, d;
		cin >> w >> d;
		if (!w)break;
		vi h1(w), h2(d);
		REP(i, w)cin >> h1[i];
		REP(i, d)cin >> h2[i];
		sort(ALL(h1), greater<int>());
		sort(ALL(h2), greater<int>());
		int i = 0, j = 0;
		int ans = 0;
		while (i < w || j < d) {
			if (i == w) {
				ans += h2[j];
				++j;
			}
			else if (j == d) {
				ans += h1[i];
				++i;
			}
			else {
				if (h1[i] == h2[j]) {
					ans += h1[i];
					++i;
					++j;
				}
				else if (h1[i] < h2[j]) {
					ans += h2[j];
					++j;
				}
				else {
					ans += h1[i];
					++i;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=305*2,mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int n,k;
pair <int,int> p[N];
int fac2[N];
int s[N];
int f[N][N];
int g(int i,int j){
	int c=i<=j?s[j]-s[i-1]:s[n]-s[i-1]+s[j];
	return c%2==0?fac2[c/2]:0;
}
int check(int L,int R){
	For(i,1,k)
		if ((L<=p[i].fi&&p[i].fi<=R)^(L<=p[i].se&&p[i].se<=R))
			return 0;
	return 1;
}
int main(){
	n=read()*2,k=read();
	For(i,1,n)
		s[i]=1;
	For(i,1,k){
		p[i].fi=read(),p[i].se=read();
		s[p[i].fi]=s[p[i].se]=0;
	}
	For(i,1,n)
		s[i]+=s[i-1];
	fac2[0]=1;
	For(i,1,n)
		fac2[i]=(LL)fac2[i-1]*(i*2-1)%mod;
	For(i,1,n+1)
		f[i][i-1]=1;
	For(len,2,n)
		For(i,1,n-len+1){
			int j=i+len-1;
			if (!check(i,j))
				continue;
			f[i][j]=g(i,j);
			For(k,i+1,j-1)
				Del(f[i][j],(LL)f[i][k]*g(k+1,j)%mod);
		}
	int ans=0;
	For(i,1,n)
		For(j,i+1,n)
			Add(ans,(LL)f[i][j]*g(j+1,i-1)%mod);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N; cin>>N;
	vector<int> a(114514,0);
	rep(i,N){
		int t; cin>>t;
		++a[t];
	}
	int ans = 0;
	ans += a[0]+a[1];
	for(int i = 1; i<=114514-2; ++i){
		ans = max(ans, a[i]+a[i+1]+a[i+2]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
//const ll INF = 10000000000;//INFinity
const int INF = 1000000000;
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    int n,m,r;
    cin>>n>>m>>r;
    vector<int> visit(r);
    struct road{
        int a,b,c;
    };
    vector<road> roads(m);
    REP(i,r)cin>>visit[i];
    REP(i,m)cin>>roads[i].a>>roads[i].b>>roads[i].c;

    vector<vector<int>> sides(n+1);
    for(auto&s:sides){s.resize(n+1);for(auto&m:s)m=INF;}
    REP(i,n+1)sides[i][i]=0;
    for(auto ro:roads){
        sides[ro.a][ro.b]=ro.c;sides[ro.b][ro.a]=ro.c;
    }
    REP(k,n+1)REP(i,n+1)REP(j,n+1)sides[i][j]=min(sides[i][j],sides[i][k]+sides[k][j]);
    /*
    map<int,vector<pair<int,int>>> map_;
    for(auto x:visit)for(auto y:visit)map_[x].push_back(mp(y,sides[x][y]));
    for(auto rrr:visit)for(auto rr:map_[rrr])cout<<rrr<<" "<<rr.first<<" "<<rr.second<<endl;
    */
    map<pair<int,int>,int> map_;
    for(auto x:visit)for(auto y:visit)map_[mp(x,y)]=sides[x][y];

    vector<int> suii(r,0); 
    int min_=INF;
    while(count(suii.begin(),suii.end(),r-1)!=r){
        REP(i,r){
            if(suii[i]==r-1){suii[i]=0;continue;}
            if(suii[i]!=r-1){
                suii[i]++;
                int sum=0;
                bool flag=true;
                REP(i,r-1)if(count(suii.begin(),suii.end(),i)!=1){flag=false;break;}
                if(flag){
                    REP(i,r-1)sum+=map_[mp(visit[suii[i]],visit[suii[i+1]])];
                    min_=min(min_,sum);
                }
                break;
            }
        }
    }
    cout<<min_<<endl;
    return 0;
}


Measured memory_bytes: 640