akhauriyash/Code-Regression huggingface dataset:
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/03 21:31:01 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	int	n, m;
	cin >> n >> m;
	bitset<100005>	bs;

	VI	V(n);
	rep(i, n)
		cin >> V.at(i);
	rep(i, m)
	{
		int	a, b;
		cin >> a >> b;
		a--;
		b--;

		if (V.at(a) < V.at(b))
			bs.set(a);
		else if (V.at(a) > V.at(b))
			bs.set(b);
		else
		{
			bs.set(a);
			bs.set(b);
		}
	}
	cout << n - bs.count() << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


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

int n;
long long int a[300000];

int main(){
  cin >> n;
  rep(i, n){
    cin >> a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  
  const long long int INI = 0LL;
  long long int edge[2] = {INI, INI};
  rep(i, n - 1){
    if(edge[0] == INI && a[i] == a[i + 1]){
      edge[0] = a[i];
      i++;
    }else if(edge[1] == INI && a[i] == a[i + 1]){
      edge[1] = a[i];
      break;
    }
  }
  long long int res = edge[0] * edge[1];
  cout << res << endl;
}


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

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

int a, b;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b;
	if(a <= 8 && b <= 8)
		cout << "Yay!";
	else
		cout << ":(";
	return 0;
}

Measured memory_bytes: 256
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 12

// Includes.
#include <bits/stdc++.h>

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	cout << fixed;
	cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	int n;
	cin >> n;
	
	vector<tuple<double, double>> points;
	for (int i = 0; i < n; i++)
	{
		double x, y;
		cin >> x >> y;
		points.emplace_back(x, y);
	}
	
	map<tuple<int, int>, double> distance;
	for (int i = 0; i < n; i++)
	{
		for (int j = (i + 1); j < n; j++)
		{
			distance[make_tuple(i, j)] = pow(pow((get<0>(points[i]) - get<0>(points[j])), 2.0) + pow((get<1>(points[i]) - get<1>(points[j])), 2.0), 0.5);
		}
	}
	
	vector<int> order;
	for (int i = 0; i < n; i++)
	{
		order.push_back(i);
	}
	
	double total = 0.0;
	int counter = 0;
	do
	{
		counter++;
		
		for (int i = 1; i < n; i++)
		{
			if (order[i - 1] < order[i])
			{
				total += distance[make_tuple(order[i - 1], order[i])];
			}
			else
			{
				total += distance[make_tuple(order[i], order[i - 1])];
			}
		}
	}
	while (next_permutation(order.begin(), order.end()));
	
	cout << (total / (double)counter) << endl;
	
#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;


int main() {

    int n;
    cin >> n;
    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];
    sort(numbers.begin(), numbers.end());

    deque<ll> q;
    for (ll l : numbers) q.push_back(l);

    list<ll> l;
    l.push_back(q.front());
    q.pop_front();

    while (!q.empty()) {

        ll f = q.front();
        ll b = q.back();

        ll ff = abs(f - l.front());
        ll fb = abs(f - l.back());
        ll bf = abs(b - l.front());
        ll bb = abs(b - l.back());

        if (ff >= fb && ff >= bf && ff >= bb) {
            l.push_front(f);
            q.pop_front();
            continue;
        }
        if (fb >= ff && fb >= bf && fb >= bb) {
            l.push_back(f);
            q.pop_front();
            continue;
        }
        if (bf >= ff && bf >= fb && bf >= bb) {
            l.push_front(b);
            q.pop_back();
            continue;
        }
        if (bb >= ff && bb >= fb && bb >= bf) {
            l.push_back(b);
            q.pop_back();
            continue;
        }
        __throw_runtime_error("konai");
    }

    ll prev = l.front(), ans = 0;
    for (ll i : l) {
        ans += abs(i - prev);
        prev = i;
    }


    cout << ans << endl;
}

Measured memory_bytes: 4224
// constructing bitsets
#include <iostream>       // std::cout
#include <string>         // std::string
#include <bitset>         // std::bitset
#include <vector>
#include <algorithm> 
using namespace std;

int n, K;
vector <int> a;
int p[5001][5001];
int q[5001][5001];
int M = 5000;


bool f(int i){
	bool ok = true;
	for (int v = 0; v <= M; v++){
		for (int w = 0; w <= M; w++){
			int s = v + w;
			if (K - a[i] <= s and s < K){
				if (p[i][v] and q[n - 1 - i][w]){
					ok = false;
				}
			}
		}
	}
	

	return ok;
}


int solve(){
	if (f(n - 1)){
		return n;
	}
	if (not f(0)){
		return 0;
	}
	int l = 0, r = n - 1;
	while (r - l > 1){
		int i = (l + r) / 2;
		bool ok = f(i);
		if (ok){
			l = i;
		}
		else{
			r = i;
		}
	}
	return l + 1;
}


int main ()
{
	cin >> n >> K;

	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort (a.begin(), a.end());
	

	for (int v = 0; v <= M; v++)
		if (v == 0)
			p[0][v] = 1;
		else
			p[0][v] = 0;


	for (int k = 0; k < n; k++) {
		for (int v = 0; v <= M; v++){
			p[k + 1][v] = p[k][v];
			if (v >= a[k]){
				p[k + 1][v] |= p[k][v - a[k]];
			}
		}
	}


	for (int k = 0; k < n; k++) {

	}

	for (int v = 0; v <= M; v++)
		if (v == 0)
			q[0][v] = 1;
		else
			q[0][v] = 0;

	for (int k = 0; k < n; k++) {
		for (int v = 0; v <= M; v++){
			q[k + 1][v] = q[k][v];
			if (v >= a[n - 1 - k]){
				q[k + 1][v] |= q[k][v - a[n - 1 - k]];
			}
		}

	}


	// for (int i = 0; i < n; i++) {
	// 	cout << f(i) << endl;
	// }

	cout << solve() << endl;
	return 0;
}

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

int main(){
  char s[4];
  bool ans = false;
  cin >> s[0] >> s[1] >> s[2] >> s[3];
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2])ans = true;
  if(s[0] == s[2] && s[1] == s[3] && s[2] != s[1])ans = true;
  if(s[0] == s[3] && s[1] == s[2] && s[3] != s[1])ans = true;
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static long[] list=new long[87];

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  // String nyuA=sc.nextLine();
//  String nyuB=sc.nextLine(); 
 

   String[] s=sc.nextLine().split(" ");
 //    String[] t=sc.nextLine().split("");

//int N=Integer.parseInt(nyuA);
int A=Integer.parseInt(s[0]);
int B=Integer.parseInt(s[1]);
int K=Integer.parseInt(s[2]);

TreeSet<Long> list=new TreeSet<>();
for(long i=A;i<=B;i++){
if(i<A+K)list.add(i);
if(i>B-K)list.add(i);

}
ArrayList<Long> set=new ArrayList<>(list);
for(Long temp:set)
System.out.println(temp);



}

}



Measured memory_bytes: 21972
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;

int main(){
        string s; cin >> s;
        int n = s.size(),cnt = 0;
        if(s[0] != 'A') {
            cout << "WA" << endl;
            return 0;
        }
        int I;
        for(int i = 2;i < n- 1;i++){
            if(s[i] == 'C') {
                cnt++;
                I = i;
            }
        }
        if(cnt != 1){
            cout << "WA" << endl;
            return 0;
        }

        for(int i = 1;i < n;i++){
            if(i == I) continue;
            if(isupper(s[i])){
                cout << "WA" << endl;
                return 0;
            }
        }

        cout << "AC" << endl;
}

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

#define int long long
#define pb emplace_back
#define f(i,n) for(int i=0 ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);


int32_t main(){
	fast;
	string s;
	cin >> s;
	sort(s.begin() , s.end());
	if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])    cout << "Yes";
	else    cout << "No";
}






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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    ll in, b = 0, ans = 0;
    rep(i, n){
        cin >> in;
        if(in == i+1 && b == 0){
            ans++;
            b = 2;
        }
        if(b) b--;
    }

    cout << ans << endl;

    return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


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

Measured memory_bytes: 1024
from sys import stdin
input = stdin.readline

N, M = map(int, input().split())
H = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(M)]

ok = [1 for _ in range(N)]

for a, b in ab:
    if H[a - 1] < H[b - 1]:
        ok[a - 1] = 0
    if H[b - 1] < H[a - 1]:
        ok[b - 1] = 0
    if H[a - 1] == H[b - 1]:
        ok[a - 1] = 0
        ok[b - 1] = 0

ans = 0

for o in ok:
    if o == 1:
        ans += 1

print(ans)


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




int main() {
    int n; cin >> n;
    vector<int> tmp;
    rep(i, n) tmp.push_back(i+1);
    vector<int> p(n);
    vector<int> q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];

    int a,b;
    int now = 1;
    do {
        bool a_flag = true, b_flag = true;
        rep(i, n) {
            if(tmp[i] != p[i]) a_flag = false;
            if(tmp[i] != q[i]) b_flag = false;
        }
        if(a_flag) a = now;
        if(b_flag) b = now;
        now++;
    } while (next_permutation(tmp.begin(), tmp.end()));


    cout << abs(a-b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
#define Step(i, a, b, x) for (i = a; i <= b; i += x)
using namespace std;
inline int read() {
    int res = 0; bool bo = 0; char c;
    while (((c = getchar()) < '0' || c > '9') && c != '-');
    if (c == '-') bo = 1; else res = c - 48;
    while ((c = getchar()) >= '0' && c <= '9')
        res = (res << 3) + (res << 1) + (c - 48);
    return bo ? ~res + 1 : res;
}
const int PYZ = 998244353;
map<string, int> f, g;
int F(string); int G(string);
int G(string s) {
    if (g[s]) return g[s]; int i, n = s.size(); if (n == 1) return g[s] = s[0] - '0' + 1;
    int j, k, res = 0; For (i, 1, n - 1) if (n % i == 0) {
        string t = ""; For (j, 1, i) {
            int r = 1; Step (k, j - 1, n - 1, i) r &= s[k] - '0';
            t += (char) (r + '0');
        }
        res = (res + F(t)) % PYZ;
    }
    return g[s] = res;
}
int F(string s) {
    if (f[s]) return f[s]; int i, n = s.size(); if (!n) return f[s] = 1;
    int res = 0; For (i, 1, n)
        res = (res + 1ll * G(s.substr(0, i)) * F(s.substr(i, n)) % PYZ) % PYZ;
    return f[s] = res;
}
int main() {
    string s; cin >> s; cout << F(s) << endl;
    return 0;
}

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

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}

int main(){
    int a[32]={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};
    int K;cin>>K;
    cout<<a[K-1]<<endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);

ll fun(ll &x){
    ll low=1;
    ll high=100;
    ll ans=-1;
    while(low<=high){
        ll mid=(low+high)/2LL;if(mid*(mid+1)/2LL<=x){ans=mid;low=mid+1;}else{high=mid-1;}
    }
    return ans;
}



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

   sort(a.begin(),a.end());
   sort(b.begin(),b.end());

   if(n%2==1){
    cout<<b[n/2]-a[n/2]+1<<endl;
   }else{
    cout<<(b[n/2]+b[n/2-1])-(a[n/2]+a[n/2-1])+1<<endl;
   }

   return 0;

   
   
    
}


 
    



    



    
    
    




    


    

    






    
    

    
 
    
 

 
 
    
 
 


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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll a[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll n, x;
        cin >> n >> x;
        cout << 3 * (n - __gcd(n, x));
}



Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll tc = 1; //cin >> tc;
	while (tc--)
	{
		ll i, j, n, m;
		cin >> n >> m;
		cout << (n*(n-1))/2 + (m*(m - 1))/2 << '\n';
	}

	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int ans = Math.abs(Math.abs(x) - Math.abs(y));
        if((x<0 && y>0) || (x>=0 && y<=0) ) ans++;
        else if(x>y) ans += 2;
        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 21844
def bubble_sort(N, A):
    num = 0
    for k in range(0, N-1):
        for i in range(N-1, k, -1):
            if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                num += 1
    return [num, *A]

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    ans = bubble_sort(N, A)
    print(*ans[1:])
    print(ans[0])


Measured memory_bytes: 5608
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	int x, y;
	cin>>x>>y;
	if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
		x = 1;
	}
	else if(x == 4 || x == 6 || x == 9 || x == 11) {
		x = 2;
	}
	else {
		x = 3;
	}
	if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
		y = 1;
	}
	else if(y == 4 || y == 6 || y == 9 || y == 11) {
		y = 2;
	}
	else {
		y = 3;
	}
	if(x==y) {
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    vector<int> a(n - 1, 0);
    int prev = -1;
    REP(i, 0, n) {
        int b;
        cin >> b;
        if (b - prev == 1) {
            a[prev - 1] = 1;
        }
        prev = b;
    }
    REP(i, 0, n) {
        int b;
        cin >> b;
        ans += b;
    }
    REP(i, 0, n - 1) {
        int b;
        cin >> b;
        ans += a[i] * b;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int n;
vector<string>  v = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n"};
void rec(int c,string s){
    if(s.length()==n){
        cout << s << '\n';
        return;
    }
    else{
        for(int i=0;i<c;i++){
            rec(c,s+v[i]);
        }
        rec(c+1,s+v[c]);
    }
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin >> n;
    rec(0,"");
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main()
{
int n,r,rev=0,temp;
  cin>>n;
 temp=n;
 while(n>0)
{
 r=n%10;
 rev=(rev*10)+r;
 n=n/10;
}
if(temp==rev)
cout<<"Yes \n";
else
cout<<"No \n";
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(std::string s){
    rep(i, s.length() - 1){
        if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return;
        }else if(i < s.length() - 2 && s[i] == s[i + 2]){
            cout << i + 1 << " " << i + 3 << endl;
            return;
        }
    }
    cout << "-1 -1" << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!

l = input().split(" ")
N = int(l[0])
M = int(l[1])
 
wa_dict = {}
answered = set()
 
ac_count = 0
wa_count = 0
 
for n in range(M):
    result = [i for i in input().split(" ")]
    p = result[0]
    if p in answered:
        continue
    s = result[1]
    if s == "WA":
        if p not in wa_dict:
            wa_dict[p] = 1
        else:
            wa_dict[p] += 1
    else:
        ac_count += 1
        if p in wa_dict:
        	wa_count += wa_dict[p]
        answered.add(p)
        if len(answered) == N:
            break
 
print(ac_count, wa_count)

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


        // Scannerクラスのインスタンスの生成
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = (a + b) / 2;

        if ((a - k) == -(b - k) || -(a - k) == (b - k)) {
        	System.out.println(k);

        } else {
        	System.out.println("IMPOSSIBLE");
        }



	}



}

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

int main(){
	int N,A,M;
	cin >> N;
	for(int i = 0;N>i;i++){
		cin >> A;
		int C=0;
		for(int j = 0;j==0;){
			j = A%2;
			A = A/2;
			if(j==0){
				C++;
			}
		}
		if(i==0){
			M =C;
		}
		if(M>C){
			M=C;
		}
		C=0;
	}
	
	cout << M <<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

//トレーニング数 1≦ N ≦10^5 が与えられる
// i 回目のトレーニングでパワーが i 倍される
//パワーの初期値は 1

//最終的なパワーを10^9+7で割ったあまりを求める

#define MOD (int)(1e+9)+7
#define debug(x) cout << #x << " = " << x << endl;

long long fact(long long N){

    if(N == 0) return 1;
    long long res = N * fact(N-1);
    res %= MOD;
    return res;
}

int main(void){

    int  N;
    cin >> N;

    cout << fact(N) << endl;

    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

ll n,a,b;
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[1],R[1];
void make(){
	F[0] = 1;
	for(int i=1;i<1;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<1;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
int main(){
	cin>>n>>a>>b;
	ll ans = modpow(2LL,n)-1;
	ll cur = 1;
	repn(i,200000){
		cur = cur * (n-i+1) % mod * modpow(i,mod-2) % mod;
		if(i == a || i == b) ans -= cur;
		if(i == b) break;
	}
	cout<<(ans%mod+mod)%mod<<endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

typedef pair< int, int > P;

int H,W,SUPPLY,SUM;
int demand[32][32];
P dp[32][32][32][32];

int calc_demand_sum(int row1,int col1,int row2,int col2){
	int A = 0,B = 0,C = 0;

	if(row1 == 0 || col1 == 0){
		C = 0;
	}else{
		C = demand[row1-1][col1-1];
	}

	if(row1 == 0){
		B = 0;
	}else{
		B = demand[row1-1][col2];
	}

	if(col1 == 0){
		A = 0;
	}else{
		A = demand[row2][col1-1];
	}

	return demand[row2][col2]-A-B+C;
}

P recursive(int row1,int col1,int row2,int col2){

	 if(dp[row1][col1][row2][col2].first != -1)return dp[row1][col1][row2][col2];

	    P ret = P(-BIG_NUM, BIG_NUM);

	    int tmp_value = SUM - calc_demand_sum(row1,col1,row2,col2);
	    if(tmp_value <= SUPPLY) {
	        ret.first = 1;
	        ret.second = -tmp_value;

	        for(int bottom_row = row1; bottom_row < row2; bottom_row++){

				P ret_a = recursive(row1,col1,bottom_row,col2);
				if(ret_a.first == -BIG_NUM)continue;
				P ret_b = recursive(bottom_row+1,col1,row2,col2);
				if(ret_b.first == -BIG_NUM)continue;

				P ret_c;
				ret_c.first = ret_a.first+ret_b.first;
				ret_c.second = min(ret_a.second,ret_b.second);

				ret = max(ret,ret_c);
			}

			for(int mid_col = col1; mid_col < col2; mid_col++){

				P ret_a = recursive(row1,col1,row2,mid_col);
				if(ret_a.first == -BIG_NUM)continue;
				P ret_b = recursive(row1,mid_col+1,row2,col2);
				if(ret_b.first == -BIG_NUM)continue;

				P ret_c;
				ret_c.first = ret_a.first+ret_b.first;
				ret_c.second = min(ret_a.second,ret_b.second);

				ret = max(ret,ret_c);
			}
	    }
	    return dp[row1][col1][row2][col2] = ret;
}

void func(){

	SUM = 0;
	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			scanf("%d",&demand[row][col]);
			SUM += demand[row][col];
		}
	}

	for(int row = 0; row < H; row++){
		for(int col = 1; col < W; col++){
			demand[row][col] += demand[row][col-1];
		}
	}

	for(int col = 0; col < W; col++){
		for(int row = 1; row < H; row++){
			demand[row][col] += demand[row-1][col];
		}
	}

	for(int a = 0; a < H; a++){
		for(int b = 0; b < W; b++){
			for(int c = 0; c < H; c++){
				for(int d = 0; d < W; d++){

					dp[a][b][c][d].first = -1;
					dp[a][b][c][d].second = -1;
				}
			}
		}
	}

	P ans = recursive(0,0,H-1,W-1);

	printf("%d %d\n",ans.first,SUPPLY+ans.second);
}

int main(){

	while(true){
		scanf("%d %d %d",&H,&W,&SUPPLY);
		if(H == 0 && W == 0 && SUPPLY == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 11348
#include <stdio.h>

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

    while(1){
        scanf( "%d %d ", &h, &w );
        if( h==0&&w==0 ) break;
        for( i=0;i<h;i++ ){
            for( j = 0;j<w;j++){
                if ( (i % 2 == 0 && j % 2 == 0 ) || (j%2 == 1 && i%2 == 1 ) ){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf( "\n" );
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1812
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int h, w, cnt = 0, ans = 3000, vsd[50][50] = { 0 };
char grid[50][50];

void solve(int x, int y) {
	if (x < 0 || y < 0 || x >= w || y >= h)return;
	else if (vsd[x][y] || grid[x][y] == '.') {
		vsd[x][y] = 1;
		return;
	}
	else {
		vsd[x][y] = 1;
		cnt++;

		solve(x - 1, y);
		solve(x + 1, y);
		solve(x, y - 1);
		solve(x, y + 1);
	}
}

int main() {

	cin >> h >> w;
	FOR(i, h) {
		string s;
		cin >> s;
		FOR(j, w)grid[j][i] = s[j];
	}

	FOR(i, h) {
		FOR(j, w) {
			if (!(vsd[j][i])&&grid[j][i]=='#') {
				solve(j, i);
				ans = min(ans, cnt);
				cnt = 0;
			}
		}
	}

	if (ans < 2)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 384
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int r; cin >> r;
  int A[] = {1200, 2800, 1000000};
  string S[] = {"ABC", "ARC", "AGC"};
  loop(i,0,3) {
    if (r < A[i]) {
      cout << S[i] << endl;
      return;
    }
  }
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){

int N;
cin >> N;

int ans = N / 3;
print(ans);

}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    h = list(map(int, readline().split()))
    dp = [10 ** 10] * n
    dp[0] = 0
    for i in range(1, n):
        if i == 1:
            dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i])
        else:
            dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]), dp[i])
    print(dp[-1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 51696
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>


// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

int main(){
	int t, d;
	cin >> t >> d;
	int ta, tb, da, db;
	cin >> ta >> tb >> da >> db;

	double ans = 1e9;
	rep(i, 1001) rep(j, 1001){
		if (da*i + db*j < 1) continue;
		if (da*i + db*j > d) continue;
		double va = da*i, vb = db*j;
		double tt = (ta*va + tb*vb) / (va + vb);
		ans = min(ans, abs(tt-t));
	}
	cout.setf(ios::fixed);
	cout.precision(10);
	cout << ans << endl;



	return 0;
}

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

int shortest(int D, int G, vector<int> p, vector<int> &c) {
  if (G <= 0)
    return 0;
  int stay1, stay2, shortest_number = -1;
  for (int i = 0; i < D; i++) {
    if (p.at(i) == 0)
      continue;
    if (G >= (i + 1) * 100 * p.at(i) + c.at(i)) {
      stay1 = p.at(i);
      p.at(i) = 0;
      stay2 = shortest(D, G - (i + 1) * 100 * stay1 - c.at(i), p, c) + stay1;
      p.at(i) = stay1;
    }
    else if(G >= (i + 1) * 100 * p.at(i)) {
      stay2 = p.at(i);
    }
    else {
      int g = G;
      for (int j = 0; j < p.at(i); j++) {
        g -= (i + 1) * 100;
        if (g <= 0) {
          stay2 = j + 1;
          break;
        }
      }
    }
    if (shortest_number > stay2 || shortest_number == -1) {
      shortest_number = stay2;
    }
  }
  return shortest_number;
}

int main() {
  int D;
  int G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  for (int i = 0; i < D; i++)
    cin >> p.at(i) >> c.at(i);
  cout << shortest(D, G, p, c) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int x = sc.nextInt();
			int i = 0;
			if (n == 0 && a == 0 && b == 0 && c == 0 && x == 0)
				break;
			int num[] = new int[n];
			int count = 0;
			for (i = 0; i < n; i++) {
				num[i] = sc.nextInt();
			}
			for (i = 0; i <= 10000; i++) {
				if (num[count] == x) {
					count += 1;
				}
				if (count == n)
					break;
				x = (a * x + b) % c;
			}
			if (i != 10001)
				System.out.println(i);
			else
				System.out.println(-1);
		}
	}
}

Measured memory_bytes: 12000
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, D, A, X[212345], H[212345], C[212345], c[212345], csum[212345];
pair<ll, ll> XC[212345];

int main() {

	cin >> N >> D >> A;
	rep(i, N) cin >> X[i] >> H[i];
	rep(i, N) C[i] = H[i] / A + !!(H[i] % A);

	rep(i, N) XC[i] = { X[i], C[i] };
	sort(XC, XC + N);


	rep(i, N) {
		if (i == 0) {
			csum[i] = XC[i].second;
			c[i] = XC[i].second;
		}
		else {
			ll ac = 0;
			ll d = distance(XC, lower_bound(XC, XC + N, make_pair(XC[i].first - D * 2, 0ll)));
			if (d)
				ac = csum[i - 1] - csum[d - 1];
			else ac = csum[i - 1];

			c[i] = max(0ll, XC[i].second - ac);
			csum[i] = csum[i - 1] + c[i];
		}
	}

	cout << accumulate(c, c + N, 0ll) << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)


struct UnionFind{
  vi par;
  vi rank;

  UnionFind(int n=1){
    init(n);
  }

  // n要素で初期化
  void init(int n=1){
    par.resize(n);
    rank.resize(n);
    REP(i, n){
      par[i]=i;
      rank[i]=0;
    }
  }

  // xの根を求める
  int find(int x){
    if(par[x]==x){
      return x;
    }
    else{
      return par[x]=find(par[x]);
    }
  }

  // xとyが属する集合を併合
  bool unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x==y){
      return false;
    }
    if(rank[x]<rank[y]){
      par[x]=y;
    }
    else{
      par[y]=x;
      if(rank[x]==rank[y]){
        ++rank[x];
      }
    }
    return true;
  }

  // xとyが同じ集合に属するか判定
  bool issame(int x, int y){
    return find(x)==find(y);
  }
};

ll cnt[125252];
ll ans[125252];
ll num[125252];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, m, k, a[125252], b[125252], c[125252], d[125252];
  cin>>n>>m>>k;
  UnionFind uf(n);
  REP(i, m){
    cin>>a[i]>>b[i];
    --a[i];--b[i];
    uf.unite(a[i], b[i]);
    ++num[a[i]];
    ++num[b[i]];
  }
  REP(i, n){
    ++cnt[uf.find(i)];
  }
  REP(i, n){
    ans[i]=cnt[uf.find(i)]-1-num[i];
  }
  REP(i, k){
    cin>>c[i]>>d[i];
    --c[i];--d[i];
    if(uf.issame(c[i], d[i])){
      --ans[c[i]];
      --ans[d[i]];
    }
  }
  REP(i, n){
    cout<<ans[i]<<" \n"[i==n-1];
  }
  return 0;
}


Measured memory_bytes: 5504
# Aizu Problem ITP_1_6_D: Matrix Vector Multiplication
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


n, m = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for __ in range(n)]
V = [int(input()) for _ in range(m)]

for row in range(n):
    print(sum([A[row][k] * V[k] for k in range(m)]))

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vector<pii> > vvpii;

#define pb push_back
#define endl '\n'
#define INF (int)1e9
#define EPS 1e-9
#define gcd __gcd
#define rs resize
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define by(T, x) [](const T& a, const T& b) { return a.x < b.x; } //for struct sorting

void printV(vector<int> v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " " ;
	}
	cout << endl;
}

void print2V(vvi v){
	FOR(i, 0, v.size()){
		FOR(j, 0, v[i].size()){
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
}


int h, w, a[82][82], b[82][82], dp[82][82][15000];

int solve(int i, int j, int dif){
	int cur = a[i][j] - b[i][j];
	int ans = INF;
	
	if(i > h || i < 1 || j > w || j < 1){//can be optimized using difference
		return INF;
	}
	if(i == h && j == w){
		ans = min(ans, abs(dif+cur) );
		ans = min(ans, abs(dif-cur) );
		return ans;
	}
	if(dp[i][j][dif] != -1){
		return dp[i][j][dif];
	}
	ans = min( ans, solve(i+1, j, abs(dif+cur) ) );
	ans = min( ans, solve(i+1, j, abs(dif-cur) ) );
	ans = min( ans, solve(i, j+1, abs(dif+cur) ) );
	ans = min( ans, solve(i, j+1, abs(dif-cur) ) );
	dp[i][j][dif] = ans;
	return ans;
}

int main(){
	memset(dp, -1, sizeof dp);
	cin >> h >> w;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> b[i][j];
		}
	}
	cout << solve(1, 1, 0);
}

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

int main() {
  string s; cin >> s;
  if( s[0] == s[1] && s[1] == s[2] && s[2] == s[3] ) cout << "Yes" << endl;
  else if ( s[0] == s[1] && s[1] == s[2] ) cout << "Yes" << endl;
  else if ( s[1] == s[2] && s[2] == s[3] ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll a;
string s;
cin>>a>>s;
if(a>=3200){
    cout<<s<<endl;
}else{
    cout<<"red"<<endl;
}
}









Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
 
int main()  {

  int N,A,B;
  // 空白文字で区切られた数字を 3 つ取得
  std::cin >> N >> A >> B;
  if(A+B>=N){
	printf("%d %d\n",min(A,B),A+B-N);
  }
  
  else{
	printf("%d %d\n",min(A,B),0);
  }
}

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

int main() {
    int N;
    cin >> N;
    int d[4];
    FOR(i, 4){
        d[i] = N % 10;
        N /= 10;
    }
    int hoge = d[0], num = 1;
    for(int i = 1; i < 4; i++) {
        if(hoge == d[i]) num++;
        else {
            num = 1;
            hoge = d[i];
        }
        if(num == 3) break;
    }

    if(num == 3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256