akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(i,n-1)if(in[i]+in[i+1]>=m){
		cout<<"Possible"<<endl;
		rep(j,i)cout<<j+1<<endl;
		for(int j=n-1;j>i;j--)cout<<j<<endl;
		goto end;
	}
	cout<<"Impossible"<<endl;
	end:;
}







Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
 #include<math.h>
#define PI 3.1415926535
 
int dim;

int main(){
  int i;
  double x1=0, y1=0, x2=100, y2=0;
      
  scanf("%d", &dim);
  printf("%1.8f %1.8f\n",x1,y1);
      
  if(0 <= dim || dim <= 6){
    Koch(x1,y1,x2,y2,dim);
  }  
  printf("%1.8f %1.8f\n",x2,y2);
      
  return 0;
}

void Koch(double x1, double y1, double x2, double y2, int dim){
  double x3=0, y3=0, x4=0, y4=0, x5=0, y5=0;
  double s, c;
      
  if(dim != 0){
    s = sin(PI/3);
    c = cos(PI/3);
    
    x3 = (2 * x1 + x2) / 3;
    y3 = (2 * y1 + y2) / 3;
    x5 = (x1 + 2 * x2) / 3;
    y5 = (y1 + 2 * y2) / 3;
    x4 = x3 + (x5 - x3) * c + (y5 - y3) * s;
    y4 = y3 - (x5-x3) * s + (y5 - y3) * c;
     
    Koch(x1, y1, x3, y3, dim-1);
    printf("%1.8f %1.8f\n",x3,fabs(y3));
    Koch(x3, y3, x4, y4, dim-1);
    printf("%1.8f %1.8f\n",x4,fabs(y4));
    Koch(x4, y4, x5, y5, dim-1);
    printf("%1.8f %1.8f\n",x5,fabs(y5));
    Koch(x5, y5, x2, y2, dim-1);
  }
     
  return;
}

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

using namespace std;

const int MOD = 2019;

int main() {
    long long L, R;
    cin >> L >> R;
    int div_L = L / MOD;
    int div_R = R / MOD;
    if (div_R - div_L > 0) cout << 0 << endl;
    else {
        int min_v = 2020;
        int rem_L = L % MOD;
        int rem_R = R % MOD;
        for (int i = rem_L; i < rem_R; ++i) {
            for (int j = rem_L + 1; j <= rem_R; ++j) {
                long long int tmp = (i * j) % MOD;
                if (tmp < min_v) min_v = tmp;
            }
        }
        cout << min_v << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	M := nextInt()
	pq := make(pqueue, N)

	for i := 0; i < N; i++ {
		a := nextInt64()
		item := cost{value: a, priority: a}
		pq[i] = &item
	}
	heap.Init(&pq)

	for i := 0; i < M; i++ {
		item := heap.Pop(&pq).(*cost)
		item.value /= 2
		item.priority /= 2
		heap.Push(&pq, item)
	}
	all := int64(0)
	for i := 0; i < N; i++ {
		item := heap.Pop(&pq)
		all += (item.(*cost)).value
	}

	fmt.Println(all)
}

type cost struct {
	value    int64
	priority int64
	index    int
}

type pqueue []*cost

// キューの長さ
func (pq pqueue) Len() int { return len(pq) }

// キューの大小比較
// 基本は大きい方を優先する
func (pq pqueue) Less(i, j int) bool { return pq[i].priority > pq[j].priority }

// キューの内容交換
func (pq pqueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

// キューへの追加
func (pq *pqueue) Push(x interface{}) {
	n := len(*pq)
	i := x.(*cost)
	i.index = n
	*pq = append(*pq, x.(*cost))
}

// キューからの取り出し
func (pq *pqueue) Pop() interface{} {
	old := *pq
	n := len(old)
	if n == 0 {
		fmt.Println("queue is empty")
		return nil
	}
	i := old[n-1]
	i.index = -1
	*pq = old[0 : n-1]
	return i
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

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

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 6656
N=int(input())
ans=0;last=-1;same=[]
for A in list(map(int,input().split())):
    if A==last+1:
        same.append(last)
    last=A
for B in list(map(int,input().split())):
    ans+=B
i=1
for C in list(map(int,input().split())):
    if i in same:
        ans+=C
    i+=1
print(ans)

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  int N,b,res,power;
  vector<int> X;

  cin >> N;
  REPI(N)
  {
    cin >> b;
    X.push_back (b);
  }

  res = INT_MAX;
  REPI(101)
  {
    power = 0;
    REPJ(N)
    {
      power += pow(X[j]-i,2);
    }
    if (res > power)
      res = power;
  }

  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

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

    vector<int> A(n); 
    rep(i,n) cin >> A[i];

    vector<int> ans(n);
    rep(i,n) ans[A[i]-1] = i+1;
    rep(i,n) {
        cout << ans[i] << endl;
    }
    return 0;}

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

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

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

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#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 concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if (x < a.x) {
          x += mod;
        }
        x -= a.x;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint a(*this);
        mint res = 1;
        while (n > 0) {
            if (n & 1) res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        return pow(mod - 2);
    }
};

long gcd( long m, long n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

long lcm( long m, long n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n);
}


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

  long n;
  cin >> n;

  vector<long> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  int broken = 0;
  rep(i, n) {
    if (i + 1 - broken != a[i]) {
      broken++;
    }
  }
  
  cout << (broken == n ? -1 : broken) << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
char s[20];
int main(){
	scanf("%s", s);
	int l = strlen(s);
	LL ans = 0;
	for(int i=0;i<l;i++) ans += s[i]-'0';
	ans = max(ans, (s[0]-'0'-1)+9LL*(l-1));
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int digit(ll n) {
	int d = 0;
	while (1) {
		d++;
		n /= 10;
		if (n == 0) {
			break;
		}
	}
	return d;
}

int main() {
	ll N; cin >> N;
	ll minv = 1 << 23;
	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ll a = N / i;
			ll F = (digit(a) > digit(i)) ? digit(a) : digit(i);
			minv = (minv > F) ? F : minv;
		}
	}

	cout << minv << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int gcd(int a, int b) {
    if(b==0) return a;
    return gcd(b, a%b);
}
int main() {
    int N; cin >> N;
    ll sum = 0;
    for(int i=1;i<=N;i++) {
        for(int j=1;j<=N;j++) {
            for(int k=1;k<=N;k++) {
                sum += gcd(i, gcd(j, k));
            }
        }
    }
    cout << sum;
}


Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define Max 110000
#define S 0
#define T 1
int A, B, Q;
ll s[Max], t[Max], x[Max];

ll* get_nearest(ll now, ll* first, int len) {
    auto near = lower_bound(first, first+len, now);
    if (near == first) return near;
    if (abs(*near - now) < abs(*(near-1) - now)) return near;
    else return near-1;
}

ll* get_nearest_east(ll now, int* st) {
    auto nears = lower_bound(s, s+A, now);
    auto neart = lower_bound(t, t+B, now);
    if (abs(*nears - now) > abs(*neart - now)) {
        *st = T;
        return neart;
    } else {
        *st = S;
        return nears;
    }
}

ll* get_nearest_west(ll now, int* st) {
    auto nears = lower_bound(s, s+A, now);
    auto neart = lower_bound(t, t+B, now);
    if (nears != s) nears = nears - 1;
    if (neart != t) neart = neart - 1;
    if (abs(*nears - now) > abs(*neart - now)) {
        *st = T;
        return neart;
    } else {
        *st = S;
        return nears;
    }
}

ll solve(int q) {
    ll anse, answ;
    ll now = x[q];
    ll snear = *get_nearest(now, s, A);
    ll tnear = *get_nearest(now, t, B);

    int st = 0;
    ll *neare1, *neare2;
    // まず東行く
    neare1 = get_nearest_east(now, &st);
    if (st == S) {
        neare2 = get_nearest(*neare1, t, B);
    } else {
        neare2 = get_nearest(*neare1, s, A);
    }
    anse = abs(*neare1 - now) + abs(*neare1 - *neare2);

    // まず西行く
    ll *nearw1, *nearw2;
    nearw1 = get_nearest_west(now, &st);
    if (st == S) {
        nearw2 = get_nearest(*nearw1, t, B);
    } else {
        nearw2 = get_nearest(*nearw1, s, A);
    }
    answ = abs(*nearw1 - now) + abs(*nearw1 - *nearw2);

    return min(anse, answ);
}

int main(int argc, const char * argv[]) {
    A = inputValue();
    B = inputValue();
    Q = inputValue();
    inputArray(s, A);
    inputArray(t, B);
    inputArray(x, Q);

    rep(i, Q) {
        output(solve(i));
    }

    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
#define Repe(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;--i)
#define For(i,a,b) for(i=(a),i<=(b);++i)
#define Forward(i,a,b) for(i=(a),i>=(b);--i)
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
template<typename T>inline void read(T &x)
{
	T f=1;x=0;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+(c^48);
	x*=f;
}
using namespace std;
const int MAXN=111;
static int a,b,m[MAXN][MAXN];
inline void init()
{
	read(a);read(b);
	Rep(i,1,50)Rep(j,1,100)m[i][j]=1;
	--a;--b;
	static int pos;pos=1;
	while(a)
	{
		if(a<50){Rep(i,1,a)m[pos][i*2]=0;a=0;}
		else {Rep(i,1,50)m[pos][i*2]=0;a-=50;}
		pos+=2;
	}
	pos=100;
	while(b)
	{
		if(b<50){Rep(i,1,b)m[pos][i*2]=1;b=0;}
		else {Rep(i,1,50)m[pos][i*2]=1;b-=50;}
		pos-=2;
	}
	printf("100 100\n");
	Rep(i,1,100){Rep(j,1,100)putchar(m[i][j]?'#':'.');putchar('\n');}
}
inline void solve()
{
}
int main()
{
	init();
	solve();
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n,h,w;
	cin>>h>>w>>n;
	if(h>w)
	{
		if(n%h==0)
		{
			cout<<n/h;
		}
		else
		{
			cout<<1+n/h;
		}
	}
	else
	{
		if(n%w==0)
		{
			cout<<n/w;
		}
		else
		{
			cout<<n/w+1;
		}
	}
}


Measured memory_bytes: 256
a=input()

if a=='hi':
  print('Yes')
  exit()
elif a=='hihi':
  print('Yes')
  exit()
elif a=='hihihi':
  print('Yes')
  exit()
elif a=='hihihihi':
  print('Yes')
  exit()
elif a=='hihihihihi':
  print('Yes')
  exit()
  
print('No')

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
ans=10**1000
for i in range(100):
    cnt=0
    for j in range(n):
        cnt+=(arr[j]-(i+1))**2
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 66668
/**
  * author : thegeniushead
**/
#include <bits/stdc++.h>
 
/*.....DEFINITIONS...... */
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T() int tt; cin>>tt; while(tt--)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define lchild (2*node+1)
#define rchild (2*node+2)
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define eps (1e-6)
#define sll(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define what_is(x) cerr << #x << " is " << x << "\n";
#define infll 9e18
#define inf 1e9
#define int long long int

using namespace std;
 
/*.....TYPEDEFS ....*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long double ld;
 
/*....USEFUL FUNCTIONS....*/
ll pwr(ll base, ll exp, ll mod=MOD){ll res=1; while(exp>0){if(exp%2){res=(res*base)%mod;}base=(base*base)%mod;exp/=2;}return res;}
ll gcd(ll a, ll b){ if(b==0)return a; else gcd(b, a%b);}
bool isPrime(ll n){if(n<=1)return false;if(n<=3)return true;if (n%2==0||n%3==0)return false;for(int i=5; i*i<=n; i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
 
/*....I/O Functions...*/
inline string rs(){char x[1234567];scanf("%s", x);string s = x; return s;}
inline int ri(){int x; scanf("%d", &x);return x;}
inline long long rl(){long long x; scanf("%lld", &x); return x;}
 
/*---------Solution below this line --------*/
 
const int N = 1234567;

string s1, s2;

int32_t main()
{
	//FIO
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	s1 = rs();
	s2 = rs();
	
	while(s1.size() < s2.size()) s1 = '0' + s1;
	while(s1.size() > s2.size()) s2 = s2 + '0';
	
	rep(i,0,s1.size()){
		if(s1[i] < s2[i]){
			puts("LESS");
			return 0;
		}
		else if(s1[i] > s2[i]){
			return 0 * puts("GREATER");
		}
	}
	
	puts("EQUAL");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

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

int main() {
    int n,k;


    cin>>n>>k;
    cout<<n-k+1<<endl;




    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100001;
int n,m;
int par[MAXN];
int depth[MAXN];//parent , rank
int p[MAXN];
//n initialize
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    depth[i]=0;
    cin>>p[i];
  }
  return;
}
// tree's root
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x==y) return;
  if(depth[x]<depth[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(depth[x]==depth[y]) depth[x]++;
  }
  return;
}

bool same(int x,int y){
  return find(x)==find(y);
}

int main(){
  cin>>n>>m;
  init(n);
  for(int i=0;i<m;i++){
    int x,y; cin>>x>>y;
    unite(x,y);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(same(i+1,p[i])){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
import java.util.*;

import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = parseInt(sc.next());
		int[] p = new int[n];
		for(i=0;i<n;i++) {
			p[i] = parseInt(sc.next());
		}
		sc.close();
		int cnt=0;
		for(i=1;i<n-1;i++) {
			if((p[i-1] < p[i] && p[i] <= p[i+1])
			|| (p[i-1] >= p[i] && p[i] > p[i+1])) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 22228
from collections import defaultdict

def collatz(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1

ｓ = int(input())
ans = 2
d = defaultdict(lambda: 0)
d[s] += 1

while True:
    s = collatz(s)

    if d[s] != 0:
        print(ans)
        break

    d[s] += 1
    ans += 1


Measured memory_bytes: 3572
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 998244353


def resolve():
    A, B, C, D = map(int, input().split())

    dp = [[0] * (D + 1) for _ in range(C + 1)]
    dp[A][B] = 1
    for i in range(A, C + 1):
        for j in range(B, D + 1):
            if i == A and j == B:
                continue
            dp[i][j] = dp[i][j - 1] * i + dp[i - 1][j] * j - dp[i - 1][j - 1] * (i - 1) * (j - 1)
            dp[i][j] %= mod

    print(dp[-1][-1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 144412
#include <stdio.h>
int main (void)

{
	char num[1010]; 
	int dig, sum;
	while(1){
	sum=0;	
	scanf("%s", num);
	if(num[0] == '0') break;
	for(dig=0; num[dig] != '\0'; dig++)
		sum += num[dig]-'0';
	
	printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 536
#include <cstdio>
int main() {
  int ans=0;
  char w[4];
  scanf("%s", &w);
  if(w[0]=='R') ans=1;
  if(w[1]=='R') ans++;
  if(w[1]=='R' && w[2]=='R') ans++;
  else if(w[1]!='R' && w[2]=='R') ans=1;
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
string s;
int ans=1<<30; 
int main()
{
    cin>>s;
    for(int i=1;i<s.length();i++) //一位一位枚举
        if(s[i]!=s[i-1]) //若第i-1位和第i位不一样
            ans=min(ans,max(i,int(s.length())-i)); 
            //因为每次要改动更多的，所以取max,因为所有操作都要>=k所以ans取最小。
    cout<<min(ans,int(s.length()))<<endl; //ans不大于s的长度
    return 0;
}

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

public class Main {

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

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		Pair p[] = new Pair[n];
		Pair check[] = new Pair[m];

		for (int i = 0; i < n; i++) {
			str = br.readLine().split(" ");

			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[1]);

			p[i] = new Pair(a, b);
		}

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");

			int c = Integer.parseInt(str[0]);
			int d = Integer.parseInt(str[1]);

			check[i] = new Pair(c, d);
		}

		for (int i = 0; i < n; i++) {
			int min = Integer.MAX_VALUE;
			int minI = -1;
			for (int j = 0; j < m; j++) {
				if (p[i].getDist(check[j].x, check[j].y) < min) {
					min = p[i].getDist(check[j].x, check[j].y);
					minI = j;
				}
			}
			System.out.println(minI + 1);
		}
	}
}

class Pair {
	int x;
	int y;

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public int getDist(int x, int y) {
		return Math.abs(x - this.x) + Math.abs(y - this.y);
	}
}


Measured memory_bytes: 32736
#include <bits/stdc++.h>
#define Maxn 400007
using namespace std;
int n,m;
int cnt=0,last[Maxn],pre[Maxn],other[Maxn],val[Maxn];
long long mn,mx;
long long t[Maxn];
bool vis[Maxn];
bool ans=true;
void insert(int u,int v,int t)
{
	other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;
	val[cnt]=t;
}
void dfs(int u,int fa)
{
	for (int q=last[u];q;q=pre[q])
	{
		int v=other[q];
		if (v!=fa)
		{
			if (!vis[v])
			{
				vis[v]=true;
				t[v]=t[u]+val[q];
				mx=max(mx,t[v]);
				mn=min(mn,t[v]);
				dfs(v,u);
			} else if (t[v]!=t[u]+val[q]) ans=false;
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		insert(a,b,c);
		insert(b,a,-c);
	}
	memset(vis,false,sizeof(vis));
	for (int i=1;i<=n;i++)
		if (!vis[i])
		{
			mn=0,mx=0;
			t[i]=0;
			dfs(i,-1);
			if (mx-mn>1000000000LL) ans=false;
		}
	if (ans) printf("Yes\n"); else printf("No\n");
	return 0;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec a(n), b(n);
    init(a);
    init(b);
    vec diff(n);

    rep (i, n)
        diff[i] = a[i] - b[i];

    int cnt = 0, pos = 0;
    rep (i, n) {
        if (diff[i] < 0)
            cnt += -diff[i] / 2;
        else
            pos += diff[i];
    }

    yn(pos <= cnt);

    return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
from collections import *

H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
xd = defaultdict(int)
yd = defaultdict(int)

for i in range(H):
    for j in range(W):
        xd[A[i][j]] = i
        yd[A[i][j]] = j

acc = [[0] for _ in range(D)]

for i in range(D+1, H*W+1):
    cost = abs(xd[i]-xd[i-D])+abs(yd[i]-yd[i-D])
    acc[i%D].append(acc[i%D][-1]+cost)
    
Q = int(input())

for _ in range(Q):
    L, R = map(int, input().split())
    
    if L%D==0:
        print(acc[0][R//D-1]-acc[0][L//D-1])
    else:
        print(acc[L%D][R//D]-acc[L%D][L//D])

Measured memory_bytes: 81108
#include <iostream>
int main(void){
  int a,b,c;
  std::cin >> a>>b>>c;
  if(a==b && a != c){
    std::cout << "Yes" << std::endl;
  }
  else if(a!=b && a == c){
    std::cout << "Yes" << std::endl;
  }
  else if(a!=b && b == c){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

void solve()
{
	int w;
	while(cin >> w, w != -1)
	{
		int sum = 1150;
		if(w >= 20)
		{
			sum += 1250;
			if(w >= 30)
			{
				sum += 1400 + 160 * (w - 30);
			}
			else
			{
				sum += 140 * (w - 20);
			}
		}
		else if(w >= 10)
		{
			sum += 125 * (w - 10);
		}
		cout << 4280 - sum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>

int main () {
  int N;
  std::cin >> N;
  std::vector<int> a(N);
  for (int i = 0; i < N; i++) {
    std::cin >> a[i];  
  }  

  // sortする.
  std::sort(a.begin(),a.end());
  int answer = a[0];
  int answer_sub = a[0];
  int sub = -1;
  for (int i = 1; i < (N-1); i++) {
    sub = ((a[N-1] - a[i]) > a[i]) ? a[i]:(a[N-1] - a[i]);
    if (sub > answer) {
      answer = sub;
      answer_sub = a[i];  
    }
  }
  std::cout << a[N-1] << " " << answer_sub << std::endl;

}

Measured memory_bytes: 640
import java.util.Scanner;
class Main{
	public static void main(String[]args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		boolean bool=false;
		for(int i=0;i<=a;i++) {
			for(int j=0;j<=b;j++) {
				int bla=(a-i)*j+(b-j)*i;
				if(bla==c) {
					bool=true;
				}
			}
		}
		if(bool==true) {
			pl("Yes");
		}
		else {
			pl("No");
		}
	}
	public static void pl(String str) {
		System.out.println(str);
	}
}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 1e9+7
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int mod = 1e9 + 7;
const int N = 2e5+5, M = N;
//=========================================

int parent[N], sz[N];

void make_set(int x){
    parent[x] = x;
    sz[x] = 1;
}

int find_set(int x){
    if(x == parent[x])
        return x;
    return parent[x] = find_set(parent[x]);
}

void merge(int a, int b){
    a = find_set(a);
    b = find_set(b);
    if(a != b){
        if(sz[a] < sz[b])
            swap(a, b);
        parent[b] = a;
        sz[a] += sz[b];
    }
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    int n, m;
    cin >> n >> m;

    for(int i = 1; i <= n; ++i)
        make_set(i);

    vpii a(m);
    vector<int> ans(m + 1);

    for(int i = 0; i < m; ++i){
        cin >> a[i].first >> a[i].second;
    }

    ans[m] = (n * (n - 1)) / 2; // when all bridges are removed

    // start from the last bridge removed to the first bridge removed
    // and one by one add the bridge and reduce the count of inconvenience
    for(int i = m - 1; i >= 0; --i){
        int x = a[i].first;
        int y = a[i].second;

        // already in the same set then continue
        if(find_set(x) == find_set(y)){
            ans[i] = ans[i + 1];
            continue;
        }

        int sz_x = sz[find_set(x)];
        int sz_y = sz[find_set(y)];

        // merge the two disjoint sets
        merge(x, y);

        // by merging the two components, we reduce the pair
        // of cities we can reach from the total inconveniences.
        ans[i] = max(ans[i + 1] - (sz_x * sz_y), 0LL);
    }

    for(int i = 1; i <= m; ++i)
        cout << ans[i] << "\n";
    //cout << endl;

    return 0;
}


Measured memory_bytes: 7132
#include <iostream>
#include <string>
#include <algorithm>

#define dbg if(0)
using namespace std;
#define ll long long

int main(){
    int h,w;
    cin >> h>>w;
    string rows[h];
    bool column[w];
    bool row[h];
    for(int i=0;i<h;i++){
        row[i]=false;
    }
    for(int i=0;i<w;i++){
        column[i]=false;
    }
    for(int i=0;i<h;i++){
        cin >>rows[i];
        for(int j=0;j<w;j++){
            if (rows[i][j]=='#'){
                column[j]=true;
                row[i]=true;
            }
        }
    }
    for(int i=0;i<h;i++){
        cin >>rows[i];
        bool f=false;
        for(int j=0;j<w;j++){
            if(column[j]&&row[i]){
                cout <<rows[i][j];
                f=true;
            }
        }
        if(f)cout <<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define reps2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n;

int main() {
    cin >> n;
    set<string> s;
    rep(i, n) {
        string str;
        cin >> str;
        s.insert(str);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 19104
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func main() {
	a, _ := strconv.Atoi(input())
	b, _ := strconv.Atoi(input())
	if b < 0 {
		if (b-a)%2 == 0 {
			fmt.Println("Negative")
		} else {
			fmt.Println("Positive")
		}
	} else if a > 0 {
		fmt.Println("Positive")
	} else {
		fmt.Println("Zero")
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
using namespace std;

int main(){
    int a;
    int b;
    int c;
    cin >> a >> b;
    c = a-b+1;
    cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(void) {
	int N;
	std::cin >> N;
	int *A = new int[N];
	int res = 0;
	for (int i = 0; i < N; i++) {
		std::cin >> A[i];
	}
	while (1) {
		bool fail = 0;
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 != 0) {
				fail = 1;
				break;
			}
			A[i] = A[i] >> 1;
		}
		if (fail) {
			break;
		}
		res++;
	}
	delete[] A;
	std::cout << res;
	return 0;
}

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

int main(){
    int a, b ,c;
    cin >> a >> b >> c;

    int flag = 0;
    if(a == b){
        flag++;
    }
    if(b == c){
        flag++;
    }
    if(a == c){
        flag++;
    }

    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <algorithm>

using namespace std;

int n, m;
vector<pair<int, int>> job;
bool check[100001];

int main(){
    cin >> n >> m;
    job.resize(n);
    for(auto&& i : job){
        cin >> i.second >> i.first;
    }
    set<int> s;
    for(int i = 0; i <= m; i++){
        s.insert(i);
    }
    sort(rbegin(job), rend(job));
    long long ans = 0;
    for(auto&& i : job){
        if(s.lower_bound(i.second) != s.end()){
            s.erase(s.lower_bound(i.second));
            ans += i.first;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n,t,a;
    cin >> n >> t >> a;
    int mi = INF,ans;
    for(int i = 0; i < n; i++){
        int h; cin >> h;
        if(abs(a*1000-t*1000+h*6) < mi){
            mi = abs(a*1000-t*1000+h*6);
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
bool initialized = false;

/**
 * @fn
 * This function must be called at first.
 */
void combination_init() {
    initialized = true;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

/**
 * @fn
 * Calculates the combination  ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ n ≤ 10^7
 * @return nCK % MOD
 */
long long combination(int n, int k) {
    assert(initialized);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/**
 * @fn
 * Calculates the factorial of the number.
 *
 * @return N! % MOD
 */
long long factorial(int n) {
    assert(initialized);
    if (n < 0) return 0;
    return fac[n] % MOD;
}

/**
 * @fn
 * Calculates the combination ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ 10^7 and 1 ≤ n ≤ 10^9
 * @return nCK % MOD
 */
long long combination2(int n, int k) {
    assert(initialized);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll res = 1;
    k = min(k, n - k);
    for (long long x = 1; x <= k; x++) {
        res *= (n - x + 1);
        res %= MOD;
        res *= inv[x];
        res %= MOD;
    }
    return res;
}


void Main() {
    ll N, K;
    cin >> N >> K;
    combination_init();
    ll ans = 0;
    rep(i, min(N, K + 1)) {
        ans += (combination(N, i) * combination(N - 1, N - i - 1));
        ans %= MOD;
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 12160
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#include <map>

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define mp(A, B) make_pair(A, B)
#define pb push_back
#define fu(A, B, C) for(ll (A) = (B); (A) < (C); (A)++)
#define fu0(A, B) fu((A), 0, (B))
#define fd(A, B, C) for(ll (A) = (B); (A) >= (C); (A)--)
#define mem(A, B) memset((A), (B), sizeof((A)))
#define v(A, B, C) vector<ll> (A)((B), (C));
#define v0(A, B) v((A), (B), 0);


using namespace std;

typedef pair<int, int> pi;

void perform() {
  int n; cin >> n;
  cout << (2 * M_PI * n) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1; //cin >> t;
  fu0(i, t) {perform();}
}


Measured memory_bytes: 3236
import java.util.*;

public class Main {
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] Hz = new int[N];
        for (int i = 0; i < N; i++){
            Hz[i] = sc.nextInt();
        }
        int[] Az = new int[M];
        int[] Bz = new int[M];
        for (int i = 0; i < M; i++){
            Az[i] = sc.nextInt() - 1;
            Bz[i] = sc.nextInt() - 1;
        }

        int[] good_flgz = new int[N];
        Arrays.fill(good_flgz, 1);
        for (int i = 0; i < M; i++){
//            System.out.println("aaa> "+Hz[Az[i]]+" "+Hz[Bz[i]]);
            if (Hz[Az[i]] > Hz[Bz[i]]){
//                System.out.println(Bz[i]);
                good_flgz[Bz[i]] = 0;
            } else if (Hz[Az[i]] < Hz[Bz[i]]){
//                System.out.println(Az[i]);
                good_flgz[Az[i]] = 0;
            } else {
//                System.out.println("bb> "+Az[i]+" "+Bz[i]);
                good_flgz[Az[i]] = 0;
                good_flgz[Bz[i]] = 0;
            }
        }
        int sum = 0;
        for (int i = 0; i < N; i++){
//            System.out.println("good_flgz "+good_flgz[i]);
            sum += good_flgz[i];
        }
        System.out.println(sum);
    }


}

Measured memory_bytes: 60392
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#include <limits.h>
#include <ios>
#include <iomanip>
#include <map> // pair
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  int numWhiteRemain = 0;
  for(int i = 0; i < N; i++){
    if(S[i] == '.'){
      numWhiteRemain++;
    }
  }
  int ans = numWhiteRemain;
  if(numWhiteRemain==0 || numWhiteRemain == N){
    ans = 0;
  }
  int numChangedBlack = 0;
  for(int i = 0; i < N; i++){
    if(numWhiteRemain > 0){
      int change = 0;
      if(S[i] == '.'){
        numWhiteRemain--;
      }else{
        numChangedBlack++;
      }
      change = numWhiteRemain + numChangedBlack;
      if(change < ans){
        ans = change;
      }
    }else{
      int change = numChangedBlack;
      if(change < ans){
        ans = change;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 720
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;





signed main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include <vector>

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

using namespace std;

vector<int>G1[200000], G2[200000];

//頂点rからの深さ優先探索木
void dfs(int r, int c, int A[], vector<int> G[]) {
	stack<int> S;
	S.push(r);
	A[r] = c;
	while (!S.empty()) {
		int u = S.top();
		S.pop();
		REP(i, G[u].size()) {
			int v = G[u][i];
			if (A[v] == 0) {
				A[v] = c;
				S.push(v);
			}
		}
	}
}

//グラフGにおける深さ優先探索森
void DFSF(int A[], vector<int> G[], int n) {
	int color = 1;
	REP(i, n) {
		A[i] = 0;
	}
	REP(i, n) {
		if (A[i] == 0) {
			dfs(i, color, A, G);
			color++;
		}
	}
}


int main() {
	int N, K, L, p, q, A[200000] = { 0 }, B[200000] = { 0 };

	cin >> N >> K >> L;
	REP(i, K) {
		cin >> p >> q;
		G1[p - 1].push_back(q - 1);
		G1[q - 1].push_back(p - 1);
	}
	REP(i, L) {
		cin >> p >> q;
		G2[p - 1].push_back(q - 1);
		G2[q - 1].push_back(p - 1);
	}

	DFSF(A, G1, N);
	DFSF(B, G2, N);
	map<pair<int, int>, vector<int>>mp2;
	REP(i, N) {
		mp2[pair<int, int>(A[i], B[i])].push_back(i);
	}

	REP(i, N) {
		int num = mp2[pair<int, int>(A[i], B[i])].size();
		cout << num << endl;
	}


	return 0;
}

Measured memory_bytes: 35884
N = int(input())

list = []
for n in range(0, N):
    tmp = []
    for _ in range(0, 2):
        tmp.append(int(input()))
    list.append(tmp)

for a, b in list:
    c = a + b
    if c >= 10 ** 80:
        print('overflow')
    else:
        print(str(c))


Measured memory_bytes: 5596
#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int arr[m];
    for(int i=0;i<m;i++)
        cin>>arr[i];
    int tt=0;
    for(int i=0;i<m;i++)
        tt+=arr[i];
    if(n-tt<0)
        cout<<-1;
    else
        cout<<n-tt<<endl;
    return 0;
}


Measured memory_bytes: 3668
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
 
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= x; i--) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX, MOD = 1000000007, MODA = 1e9 - 1;
const ll MIN = LLONG_MIN;
const long double PI = 3.1415926535;

int main()
{
  fast();
  
  
  ll a,b ;
  cin >> a >> b;
  string n, m;
  f(i,0,b)
  {
    n += '0' + a;
  }
  f(i,0,a)
  {
    m += '0' + b;
  }
  if(n < m)
  {
    cout << n;
  }
  else 
  {
    cout << m;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mypow(ll a, ll b) {
    ll ret = 1;
    while (b--) {
        ret *= a;
    }
    return ret;
}

int main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        if (i % 2 == 0) {
            cout << s[i];
        }
    }
    cout << "\n";
    return 0;
}

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

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;

	int num = 1;
	for (int i = 0; i < N; i++) {
		int a = num * 2;
		int b = num + K;

		if (a < b) {
			num = num * 2;
		}
		else {
			num = num + K;
		}
	}
	cout << num << endl;
}


Measured memory_bytes: 3620
from itertools import product

n = int(input())
s = [c == "o" for c in input()]


def is_consistent(is_sheep_0, is_sheep_1):
    list_is_sheep = [None] * (n + 2)
    list_is_sheep[0] = is_sheep_0
    list_is_sheep[1] = is_sheep_1
    for i in range(2, n + 2):
        is_sheep = list_is_sheep[i - 2]
        if not s[(i - 1) % n]:
            is_sheep = not is_sheep
        if not list_is_sheep[i - 1]:
            is_sheep = not is_sheep
        list_is_sheep[i] = is_sheep
    c = list_is_sheep[0] == list_is_sheep[-2] and list_is_sheep[1] == list_is_sheep[-1]
    return c, list_is_sheep


def answer():
    for is_sheep_0, is_sheep_1 in product([True, False], repeat=2):
        c, list_is_sheep = is_consistent(is_sheep_0, is_sheep_1)
        if c:
            return list_is_sheep
    return -1


answer = answer()

if answer == -1:
    print(answer)
else:
    print("".join(["S" if is_sheep else "W" for is_sheep in answer[:-2]]))


Measured memory_bytes: 12064