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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	int n;
	cin >> n;
	ll res = 0;
	vector<int> L(n);
	FOR(i, 0, n - 1) {
		cin >> L[i];
	}
	sort(ALL(L));
	FOR(i, 0, SZ(L) - 3) {
		FOR(j, i + 1, SZ(L) - 2) {
			int sa = lower_bound(ALL(L),L[i]+L[j]) - (L.begin() + j);
			if (sa>1) {
				res += sa-1;
			}
		}
	}
	pv(res)
	return(0);
}

Measured memory_bytes: 256
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [0]*n

for i in li:
    if i[0] == 1:
        lin[i[1]-1] += 1
    if i[1] == n:
        lin[i[0]-1] += 1

for i in lin:
    if i == 2:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Measured memory_bytes: 53276
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<=b && b<c) {
		printf("%d %d %d\n", a,b,c);
	}
	else if(a<=c && c<b) {
		printf("%d %d %d\n", a,c,b);
	}
	else if(b<a && a<c) {
		printf("%d %d %d\n", b,a,c);
	}
	else if(b<=c && c<a) {
		printf("%d %d %d\n", b,c,a);
	}
	else if(c<a && a<b) {
		printf("%d %d %d\n", c,a,b);
	}
	else if(c<b && b<a) {
		printf("%d %d %d\n", c,b,a);
	}
	
	return 0;
}


Measured memory_bytes: 2000
N = int(input())
s =[input() for i in range(N)]
M = int(input())
t =[input() for i in range(M)]

ans=[]

strset =set(s)
strlist = list(strset)

for i in strlist:
    ans.append(s.count(i)-t.count(i)) 

print(max(max(ans),0))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,M; cin >> N >> M;
    if(N == M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[100005];
int dp[100005];
int solve(int ind,int n)
{
    if(ind==(n-1))
    return 0;
    if(ind>=n)
    return INT_MAX;
    if(dp[ind]!=-1)
    return dp[ind];
    int right = INT_MAX;
    int left = abs(arr[ind]-arr[ind+1]) + solve(ind+1,n);
    if(ind+2<n)
     right = abs(arr[ind]-arr[ind+2]) + solve(ind+2,n);
    return dp[ind] = min(left,right);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,n);
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    std::vector<std::string> s(3);
    std::cin>>s[0]>>s[1]>>s[2];

    std::string ans = "";
    for(int i = 0;i < 3;i++){
        ans += std::string(1, s[i][i]);
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()
  val a = sc.nextLong()
  val b = sc.nextLong()

  val ba = b - a
  if ((ba) % 2L == 0L) {
    println(ba / 2L)
    return
  }

  if (a - 1 < n - b) {
    val x = a - 1 + 1
    val y = (b - x - 1) / 2L
    println(x + y)
    return
  } else {
    val x = n - b + 1
    val y = (n - (a + x)) / 2L
    println(x + y)
    return
  }
}

Measured memory_bytes: 31260
N = int(input())
A = list(map(int,input().split()))
C = {0:0,2:0,4:0}
for i in range(N):
    a = A[i]
    if a%2==1:
        C[0] += 1
    elif a%4==0:
        C[4] += 1
C[2] = N-C[0]-C[4]
if C[4]==C[0]-1:
    if C[2]<=C[4]-1:
        print("Yes")
    else:
        print("No")
elif C[4]>=C[0]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62576
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible" : "Impossible");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; i++)
#define why(n, x)                                                              \
  int n;                                                                       \
  while (cin >> n, n != x)
#define iFOR(i, x, n) for (int i = x; i < n; i++)
#define fin << '\n'
#define __ << " " <<
#define ___ << " "
#define bash push_back
#define ALL(x) x.begin(), x.end()
#define SWAP(a, b) ((a != b) && (a += b, b = a - b, a -= b))
//#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vit;
typedef map<string, int> mstit;
typedef vector<pii> vpi;
typedef greater<pii> gpi;
typedef priority_queue<pii, vpi, gpi> dijk;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
static const signed int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

bool inside(int x, int y, int w, int h) {
  return (x >= 0 && y >= 0 && x < w && y < h);
}
template <class T> T abs(T &x) { return x < 0 ? -x : x; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int qp(int a, ll b, int mo) {
  int ans = 1;
  do {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

inline void solve() {

  int n, k, c = 0;
  string s;
  cin >> n >> k;
  cin >> s;

  for (int i = 0; i < n - 1; i++) {
    if (s[i] == s[i + 1])
      c++;
  }
  cout << min(c + 2 * k, n - 1) << endl;
}
struct xyz {
  xyz() {
    cin.tie(0), ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
  };
} xyzzy;
signed main() {
  solve();
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <random>
#define int long long
#define double long double
#define endl "\n" 
const int INF = (int) 1e18 + 7;
const int maxn = (int) 1e6 + 6;
//const md = (int) 1e9 + 7;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

signed main() {
    char ch;
    cin >> ch;
    if(ch >= 'a' && ch <= 'z') cout << 'a' << endl;
    else cout << 'A';

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int mi = 1000000000;
  int ma = 0;
  for (int i = 0; i < N; i++) {
    mi = min(mi, A.at(i));
    ma = max(ma, A.at(i));
  }
  
  cout << ma - mi << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}


int main(){
  ll a,b ; cin >> a >> b; ll c; bool flag = false;
  if(b < 10) c = b + 10*a;
  else if(b == 100) c = b + 1000*a;
  else c = b + 100*a;
  
  
  for(ll i=1; i < 400; i++){
    if(c == i*i){
      flag = true;
      break;
    }
    if(i*i > 100100) break;
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    const long double PI=3.14159265358979323846;
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double rad = 2*PI*(30*h-5.5*m)/360;
    if(rad > PI)rad = 2*PI-2*PI*(30*h-5.5*m)/360;
    long double ans = sqrt(pow(a, 2)+pow(b, 2)-2*a*b*cos(rad));
    cout << fixed << setprecision(10)<< ans << endl;
}

Measured memory_bytes: 4156
using System;
using static System.Console;

namespace dp
{
    class Program
    {
        static decimal[] ReadNumList()
        {
            var line = ReadLine().Split(' ');
            if (line.Length == 1 && string.IsNullOrEmpty(line[0]))
            {
                return new decimal[0];
            }
            var numList = new decimal[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = decimal.Parse(line[i]);
            }
            return numList;
        }
        static void Main()
        {
            var n = int.Parse(ReadLine());
            var pList = ReadNumList();
            var dp = new decimal[n + 1];
            dp[0] = 1;
            decimal[] next;
            for (var i = 0; i < n; ++i)
            {
                next = new decimal[n + 1];
                for (var m = 0; m <= i; ++m)
                {
                    next[m] += dp[m] * (1 - pList[i]);
                    next[m + 1] += dp[m] * pList[i];
                }
                dp = next;
            }
            var total = decimal.Zero;
            for (var i = n / 2 + 1; i <= n; ++i)
            {
                total += dp[i];
            }
            WriteLine(total);
        }
    }
}


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

int main(){
int A,B,C;
string ans="NO";
cin>>A>>B>>C;
for(int i = 1;i<=B;i++){
  if((i*A)%B==C){
    ans="YES";
    break;
  }
}

  cout<<ans<<endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    s = S()
    s1 = s[:n]
    s2 = s[n:][::-1]
    d1 = collections.defaultdict(int)
    d2 = collections.defaultdict(int)
    ii = [2**_ for _ in range(n)]
    for i in range(2**n):
        t = t2 = t3 = t4 = ','
        for j in range(n):
            if ii[j] & i:
                t += s1[j]
                t3 += s2[j]
            else:
                t2 += s1[j]
                t4 += s2[j]
        d1[t+t2] += 1
        d2[t3+t4] += 1
    r = 0
    for k in d1.keys():
        r += d1[k] * d2[k]

    return r


print(main())


Measured memory_bytes: 92396
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr; typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; } char nextChar(){ char r; ist>>r; return r;} }; Scanner sc(cin);
void ALERT(bool judgememt, const char* phrase) { if (judgememt) { puts(phrase); throw "ALERT"; } }
bool alert(bool judgememt, const char* phrase) { if (judgememt) puts("phrase"); return judgememt; }

const int N = 200005;
int a[N], b[N];
int n;

void init() {
    scanf(I,&n);
    rep (i,n) scanf(II,&a[i],&b[i]); 
    sort(a, a+n); sort(b, b+n);
}

double getMedian(int* a) {
    if (n&1) return a[n/2];
    else return (a[n/2] + a[n/2-1]) / 2.0;
}

void solve() {
    if (n&1) printf(IN,(int)( getMedian(b) - getMedian(a) + 1)    );
    else     printf(IN,(int)((getMedian(b) - getMedian(a))* 2 + 1));
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
#ifndef CUSTOM_MAIN
#ifdef MULTIPLE_TEST_CASES_WITH_T

int T; scanf("%d",&T); while(T--) {init(); solve();}

#else
#ifdef MULTIPLE_TEST_CASES_WITHOUT_T

while(1) {try{init(); } catch(bool t){return 0;} solve(); }

#else

init(); solve();

#endif
#endif
#endif
    return 0;
}



Measured memory_bytes: 5312
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,x,a[200040],b[200040];
string s,t;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	cout<<n+n*n+n*n*n;
}

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

int main()
{
	priority_queue<int> que;
	vector<int> vec;
	while( 1 ) {
		string com;
		cin >> com;
		if( com == "end" ) {
			break;
		}
		if( com == "insert" ) {
			int k;
			cin >> k;
			que.push( k );
		}
		else {
			vec.push_back( que.top() );
			que.pop();
		}
	}

	for( int i = 0; i < vec.size(); i++ ) {
		cout << vec[i] << endl;
	}
}



Measured memory_bytes: 10604
import math
n=int(input())
arr=list(map(int,input().split()))
a=True

if n%2!=0:
    if len([0 for c in arr if c==0])!=1 or len(set(arr))!=int(n/2)+1:
    	a=False
else:
    if 0 in arr or len(set(arr))!=int(n/2):
        a=False

if a:
    print(2**math.floor(n/2)%((10**9)+7))
else:
    print(0)

Measured memory_bytes: 13940
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

#define int long long
#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 rrep1(i, n) for (int i=n;i>=1;--i)
#define all(a) begin(a),end(a)

using vi = vector<int>;
using pii = pair<int, int>;

const int inf = 1e9 + 5;

int N;
int T[100010], A[100010];
bool decided[100010];

signed main()
{
	cin >> N;
	rep1(i, N) cin >> T[i];
	rep1(i, N) cin >> A[i];

	rep1(i, N) {
		if (T[i] > T[i - 1]) {
			decided[i] = true;

			if (T[i] > A[i]) {
				cout << 0 << endl;
				return 0;
			}
		} 
	}

	rrep1(i, N) {
		if (A[i] > A[i + 1]) {
			decided[i] = true;

			if (A[i] > T[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
	}

	int ans = 1;

	rep1(i, N) {
		if (decided[i]) continue;

		ans *= min(A[i], T[i]);
		ans %= 1000000007;
	}

	cout << ans << endl;
}



Measured memory_bytes: 5260
import java.io.IOException;
import java.util.Scanner;

public class Main {
	/**
	 * Iterate through each line of input.
	 */
	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
      	String t = scan.next();
      	int cnt = 0;
      	for(int i=0; i<s.length(); i++){
          if (s.charAt(i)!=t.charAt(i)){
            cnt++;
          }
        }
      	
      	
		System.out.println(cnt);
    }
}

Measured memory_bytes: 41132
object Main {
  def main(args: Array[String]): Unit = {
    val factors    = scala.io.StdIn.readLine.split(" ")
    val last_point = factors(1).toInt - factors(2).toInt

    var scores = Array.fill(factors(0).toInt)(last_point)

    var count = 1
    while(count <= factors(2).toInt) {
      var num = scala.io.StdIn.readInt
      scores(num - 1) += 1
      count += 1
    }

    scores.foreach{ i =>
      if(i > 0) println("Yes")
      else      println("No")
    }
  }
}

Measured memory_bytes: 40460
#include<stdio.h>

typedef struct{
  char suit;
  int value;
} Card;

void bubble(Card *A,int N){
  int i,j;
  Card temp;
  for(i=0 ; i<N ; i++){
    for(j=N-1 ; j>=i+1 ; j--){
      if(A[j].value < A[j-1].value){
        temp = A[j];
        A[j] = A[j-1];
        A[j-1] = temp;
      }
    }
  }
}

void selection(Card *A,int N){
  int i,j,minj;
  Card temp;
  for(i=0 ; i<N ; i++){
    minj = i;
    for(j=i ; j<N ; j++){
      if(A[j].value < A[minj].value) minj = j;
    }
    temp = A[i];
    A[i] = A[minj];
    A[minj] = temp;
  }
}

void print(Card *A,int N){
  int i;
  for(i=0 ; i<N ; i++){
    if(i == N-1) printf("%c%d\n",A[i].suit,A[i].value);
    else printf("%c%d ",A[i].suit,A[i].value);
  }
}

char isStable(Card C1[],Card C2[],int N){
  int i;
  for(i=0 ; i<N ; i++) if(C1[i].suit != C2[i].suit) return 'F';
  return 'T';
}

int main(){
  Card C1[100],C2[100];
  char c;
  int N;
  int i;
  char ch;

  scanf("%d",&N);
  for(i=0 ; i<N ; i++) scanf(" %c%d",&C1[i].suit,&C1[i].value);
  for(i=0 ; i<N ; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");

  print(C2,N);
  if(isStable(C1,C2,N) == 'T') printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

Measured memory_bytes: 612
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
vector<vector<int>> g;
int n,m,s,t;
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif
	int u,v;
	cin>>n>>m;
	g=vector<vector<int>>(3*n+1);
	for(int i=0;i<m;i++)
	{
		cin>>u>>v;
		g[u].push_back(v+n);
		g[u+n].push_back(v+2*n);
		g[u+2*n].push_back(v);
	}
	cin>>s>>t;

	queue<int> q;
	int cur=0;q.push(s);
	vector<int> dist(3*n+1,1e9);
	vector<bool> vis(3*n+1);
	dist[s]=0;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(auto u:g[x])
		{
			if(vis[u])continue;
			dist[u]=min(dist[u],dist[x]+1);
			q.push(u);vis[u]=1;
		}

	}

	if(dist[t]==1e9)cout<<-1;
	else cout<<dist[t]/3;


	

}

Measured memory_bytes: 21876
h,w = list(map(int,input().split()))
table = list()
x = [0,1,0,-1]
y =[1,0,-1,0]

for i in range(h):
    table.append(list(input()))
    
for i in range(h):
    j_check = False
    for j in range(w):
        if table[i][j] == "#":
            counter = 0
            for a,b in zip(x,y):
                if i + b >= h or i + b < 0 or j + a >= w or j + a < 0:
                    continue
                elif table[i+b][j+a] == "#":
                    counter += 1
            if counter == 0:
                print("No")
                j_check = True
                break
    if j_check:
        break
else:
    print("Yes")

Measured memory_bytes: 3064
#include <stdio.h>
 
struct heap{
  int id, k;
};
 
struct heap A[500000];
 
int size;
void maxHeapify(int);
 
void print(){
  int i;
   
  for(i = 1; i <= size; i++){
    printf(" %d", A[i].k);
  }
  printf("\n");
 
}
 
 
void buildMaxHeap(){
  int i;
   
  for(i = size/2; i>0; i--){
     maxHeapify(i);
  }
   
}
 
void maxHeapify(int i){
  int a, l, r, largest = i;
  struct heap B;
 
  l = r = -1;
 
  if( 2*i > 0 && 2*i <= size){
    l = 2*i;
  }
   
  if( 2*i +1 <= size){
    r = 2*i +1;
  }
 
   if(l <= size && A[l].k > A[i].k && l != -1){
    largest = l;
  }

  if(r <= size && A[r].k > A[largest].k && r != -1){
    largest = r;
    } 
 
  if(largest != i){
    B.k = A[i].k;
    A[i].k = A[largest].k;
    A[largest].k = B.k;

    maxHeapify(largest);
  
  }
}

 
main(){
  int i;
 
  scanf("%d", &size);
 
  for(i=1; i<=size; i++){
    scanf("%d", &A[i].k);
    A[i].id = i;
  }
 
  buildMaxHeap();
 
  print();
 
  return 0;
 
}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

ll dp[101][100001];
ll ma=1e9+7;
ll mod(ll a){
if(a>=0)
    return a;
else return -a;
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,k;
cin>>n>>k;
ll a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
}
dp[0][0]=1;
for(int i=1;i<=k;i++){
    dp[0][i]+=dp[0][i-1];
}
for(int i=1;i<=n;i++){
    for(int j=0;j<=k;j++){
            ll r=j,l=max(1LL*0,j-a[i-1]);
            dp[i][j]+=dp[i-1][r];
            if(l!=0){
                dp[i][j]=(dp[i][j]-dp[i-1][l-1]+ma)%ma;
            }


    }
    for(int j=1;j<=k;j++)
        dp[i][j]=(dp[i][j]+dp[i][j-1])%ma;
}

if(k>0)
    cout<<(dp[n][k]-dp[n][k-1]+ma)%ma<<endl;
    else cout<<dp[n][k]<<endl;



}


Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
constexpr int mod = 2019;

int main(){
    int l,r,len,min;
    cin>>l>>r;
    len=r-l+1;
    if( len>mod ){
        cout<<0<<"\n";
        return 0;
    }
    vector<int> a(len,l%mod);
    min=1e9;
    for(int i=1;i<len;i++){
        a[i]=(a[i-1]+1)%mod;
    }
    for(int i=0;i<len;i++){
        for(int j=i+1;j<len;j++){
            min=( (a[i]*a[j])%mod ) < min ?
                ( (a[i]*a[j])%mod ) : min;
        }
    }
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'

// const main = (input) => {
//     let arr = input.split('\n')[0].split('')
//     let ans = 0

//     while (true) {
//         for(let i = 0; i < arr.length - 1; i++) {
//             if (arr[i] !== arr[i + 1]) {
//                 arr.splice(i, 2)
//                 ans += 2
//             } 
//         }

//         let set = new Set(arr)
//         if (set.size < 2) {
//             console.log(ans)
//             return
//         }
//     }
// }

const main = (input) => {
    let arr = input.split('\n')[0].split('')
    let count0 = 0
    let count1 = 0
    arr.forEach(v => {
        if(v === '0') count0++
        if(v === '1') count1++
    })
    
    console.log(Math.min(count0, count1) * 2)
}


main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 10444
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    set<int> s;
    for (int i = 0; i < M; i++){
        cin >> a.at(i) >> b.at(i);
    }
    
    bool can = false;
    for (int i = 0; i < M; i++){
        if (a.at(i) == 1) s.insert(b.at(i));
    }
    for (int i = 0; i < M; i++){
        if (b.at(i) == N && s.count(a.at(i))) {
            can = true;
            break;
        }
    }
    
    if(can) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 6528
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    long[] A = new long[N];

    for (int i = 0; i < N; i++) {
      A[i] = sc.nextLong();
    }

    sc.close();

    Arrays.sort(A);

    int count = 1;
    long tate = 0;
    long yoko = 0;

    for (int i = N-1; 0 < i; i--) {
      if (A[i] == A[i-1]) {
        count++;
      } else {
        count = 1;
      }
      if (count == 2) {
        if (tate == 0) {
          tate = A[i];
          count = 0;
        } else if (yoko == 0) {
          yoko = A[i];
          break;
        }
      }

    }

    System.out.println(tate * yoko);

  }

}

Measured memory_bytes: 49256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iterator>
#include <set>
#include <functional>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)

int main() {
	ifstream fin("Text.txt");
	int i, j, q;
	DT h,w,a, b, c, d, n, m, k, s = 0, t = 0, c4=0,c2=0;
	//scanf("%I64d", &n);
	//scanf_s("%d", &n);
	cin >> h>>w;
	cin >> n;
	vector<vector<DT> > vec(h, vector<DT>(w));
	forn(i, n) {
		cin >> a;
		forn(j, a) {
			if ((t/w) % 2 == 0) {
				vec[(t / w)][t%w] = i + 1;
			}
			else {
				vec[t/w][w - 1 - t%w] = i + 1;
			}
			t++;
		}
	}

	forn(i, h) {
		forn(j, w) {
			cout << vec[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
use std::io::{self, BufRead};                                                                                                                  
                                                                                                                                               
fn main()->io::Result<()>{                                                                                                                     
    let mut stdin = io::BufReader::new(io::stdin());                                                                                           
    let mut buf = String::new();                                                                                                               
    stdin.read_line(&mut buf)?;                                                                                                                
    buf.retain(|c| !c.is_whitespace());                                                                                                        
    let should_be_on = buf.parse::<i32>().unwrap() >= 30;                                                                                      
    if should_be_on{                                                                                                                           
        println!("Yes");                                                                                                                       
    }else{                                                                                                                                     
        println!("No");                                                                                                                        
    }                                                                                                                                          
                                                                                                                                               
    Ok(())                                                                                                                                     
}                                                                                                                                              


Measured memory_bytes: 2112
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)

	H, W, h, w := read(), read(), read(), read()

	var Hint, Wint, hint, wint int
	Hint, _ = strconv.Atoi(H) //文字列から１０進整数への変換
	Wint, _ = strconv.Atoi(W)
	hint, _ = strconv.Atoi(h)
	wint, _ = strconv.Atoi(w)
	ans := Hint*Wint - (hint*Wint + Hint*wint - (hint * wint))
	fmt.Println(ans)
}


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

using namespace std;
using ll = long long;

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

    char a;

    cin >> a;

    if(a - 'a' < 0) printf("A\n");
    else printf("a\n");

    return 0;
}

Measured memory_bytes: 3652
// ref. https://img.atcoder.jp/agc017/editorial.pdf

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

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

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;

  rep(m, n) { // loop in [0, m-1]
    // we pick m as -D <= yi <= -C and pick (n-1-m) as C <= yi <= D
    ll lo = c*(n-1-m) - d*m;
    ll hi = -c*m + d*(n-1-m);
    if (lo <= (b-a) && (b-a) <= hi) {
      cout << "YES" << endl;
      return 0;
    }
  }
  // Here, we can not find valid m
  cout << "NO" << endl;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
dp = [0]*n
for i in range(1,n):
    dp_0 = dp[i-1] + abs(h[i]-h[i-1])
    if i -2 < 0:
        dp_1 = 10**10
    else:
        dp_1 = dp[i-2] + abs(h[i]-h[i-2])
    dp[i] = min(dp_0,dp_1)
print(dp[-1])

Measured memory_bytes: 13976
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

int dp[65010] = {};


/*----------------------------------------------------------------*/
signed main(){

    int n,m;
	cin >> n >> m;
	int c[21];
	rep(i,m)cin >> c[i];
	rep(j,65000)dp[j] = INF;
	dp[0] = 0;
	rep(i,n+1){
		rep(j,m){
			dp[i+c[j]] = min(dp[i+c[j]],dp[i]+1);
		}
	}
	cout << dp[n] << endl;
	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc088.contest.atcoder.jp/tasks/abc088_d


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  int n, m; cin >> n >> m;
  vector<vector<int>> t(n);
  rep(i, m){
    int a, b; cin >> a >> b;
    a--; b--;
    t[a].push_back(b);
  }
  int s, e; cin >> s >> e;
  s--; e--;

  vector<vector<int>> d(n);
  queue<P> q;
  q.push(make_pair(s, 0));
  d[s].push_back(0);
  while(q.size() > 0){
    int now = q.front().first, dis = q.front().second + 1; q.pop();
    rep(i, t[now].size()){
      int next = t[now][i];
      bool ok = true;
      rep(j, d[next].size()){
        if(d[next][j] % 3 == dis % 3) ok = false;
      }
      if(ok){
        d[next].push_back(dis);
        q.push(make_pair(next, dis));
      }
    }
  }

  /*rep(i, n){
    cout << i << " : ";
    rep(j, d[i].size()){
      cout << d[i][j] << " ";
    }
    cout << endl;
  }*/

  rep(i, d[e].size()){
    if(d[e][i] % 3 == 0){
      cout << d[e][i] / 3 << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 14344
from fractions import gcd
from functools import reduce
import sys

def lcm(nums):
    return reduce(lambda x, y: x * y // gcd(x, y), nums)

n, m = map(int, input().split())
a = [int(item) // 2 for item in input().split()]
b = [0] * n

for i in range(n):
    tmp = a[i]
    while True:
        if tmp % 2 == 0:
            b[i] += 1
            tmp /= 2
        else:
            break

if len(set(b)) != 1:
    print(0)
    sys.exit()

a_lcm = lcm(a)
count = m // a_lcm
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int x = sc.nextInt();
		if(x == 0) {
			System.out.println(1);
		}else {
			System.out.println(0);
		}
	}

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


Measured memory_bytes: 32652
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  cout << (n-1)/max(h,w)+1;
  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt(),c=nxt();
    cout<<c<<" "<<a<<" "<<b<<endl;
   
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define M 1000000007
#define N 100001
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MAXN   1000001 

int spf[MAXN]; 
void sieve() { 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
        spf[i] = i; 
  
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

int getFactorization(int x) { 
    if(x <= 2) return x;

    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    
    int prev = 0, fact = 1, cnt = 0;
    for(int e: ret) {
        if(e == prev) cnt++;
        else {
            fact *= (cnt + 1);
            cnt = 1;
            prev = e;
        }
    }
    fact *= (cnt + 1);

    return fact;        // number of factors
}

int t, n, ans;
void printArray(int*, int);

int findComb(int x) {
    if(x <= 2) return x;

    int pairs = 0, eqPair = 0;
    for(int i=1; i<=sqrt(x); i++) if(x % i == 0) {
        if(i == x / i) eqPair++;
        else pairs++;
    }

    //printf("[Num:%d, ans:%d]\n", x, pairs * 2 + eqPair);
    return pairs * 2 + eqPair;
}

int main() {
    scanf("%d", &n);

    sieve();

    ans = 0;
    for(int i=1; i<n; i++) 
        ans += getFactorization(n - i);

    cout<<ans<<endl;
	return 0;
}



void printArray(int *nums, int n) {
    for(int i=0; i<n; i++) printf("%d ", nums[i]);
    printf("\n");
}

Measured memory_bytes: 7688
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<<b*2-1<<endl;
    }
    
    else if(a>b){
        cout<<a*2-1<<endl;
    }
    
    else if(a==b){
        cout<<a+b<<endl;
    }
}

Measured memory_bytes: 256
#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;
    cin >> n;
    vi A;
    map<int, ll> m;
    map<int, ll> b;
    ll sum = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        A.push_back(a);
        m[a]++;
    }
    for (auto &i : m)
    {
        b[i.first] = i.second * (i.second - 1) / 2;
        sum += b[i.first];
    }
    rep(i, n)
    {
        int a = A[i];
        cout << sum - b[a] + (m[a] - 1) * (m[a] - 2) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 18164
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class UnionFind:
    def __init__(self, size):
        """
        size:頂点の数
        """
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]
        self.big = [1 for _ in range(size)]

    def find(self, x):
        """
        xのrootを返す
        """
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        """
        x,yを同じグループとしてまとめる
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.big[y] += self.big[x]
        else:
            self.parent[y] = x
            self.big[x] += self.big[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        """
        xとyが同じグループならTrue
        """
        return self.find(x) == self.find(y)

    def component(self):
        """
        各連結成分のrootの集合を返す
        len()をとれば連結成分の数が求められる
        return-> set()
        """
        comp = set()
        for i in self.parent:
            p = self.find(i)
            comp.add(p)
        return comp

    def __str__(self):
        """
        for debug
        クラスのlistの情報を出力
        """
        ret = "parents\n"
        ret += " ".join(map(str, self.parent))
        ret += '\n'
        ret += " ".join(map(str, self.rank))
        return ret


N, M = map(int, input().split())
edges = []
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    edges.append([a, b])
edges = reversed(edges)

Un = UnionFind(N)

s = sum(list(range(1, N)))
ans = []
for a, b in edges:
    if not Un.same(a, b):
        d = Un.big[Un.find(a)]*Un.big[Un.find(b)]
        ans.append(s)
        Un.union(a, b)
        s -= d
    else:
        ans.append(s)
print("\n".join(map(str, reversed(ans))))


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

int main() {
	int h, w;
	cin >> h >> w;
	//各数字を1にかえる時の最短魔力を求めておく
	//warfloだったわ
	vector<vector<ll>>dp(10, vector<ll>(10, 100000000000));
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++)cin >> dp.at(i).at(j);
	}
	for (int i = 0; i < 10; i++)dp.at(i).at(i) = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++)dp.at(j).at(k) = min(dp.at(j).at(k), dp.at(j).at(i) + dp.at(i).at(k));
		}
	}
	//行列について足していきans出力
	ll ans = 0;
	for (int i = 0; i < h * w; i++) {
		ll x;
		cin >> x;
		if(x!=-1)ans += dp.at(x).at(1);
	}
	cout << ans << endl;
}

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

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


signed main()
{
  int n,c,k; cin>>n>>c>>k;
  vector<int> t(n);
  rep(i,n) cin>>t[i];
  sort(t.begin(),t.end());
  
  int pos=0;
  int ans=0;
  bool flg=false;
  while(pos<n){
    for(int i=pos;i<n;i++){
      if(t[pos]+k<t[i] || i-pos+1>c){
        // cout<<i<<endl;
        ans++;
        pos=i;
      }
      if(i==n-1){
        ans++;
        flg=true;
        break;
      }
    }
    if(flg) break;
  }
  cout<<ans<<endl;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n;
    m = (n + 1) / 2;
    double ans;
    ans = (double) m / n;
    cout << fixed << setprecision(6);
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256