akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N, A, B;
    int[] t;
    void Solve() {
        //input
        N = io.Int;
        A = io.Int;
        B = io.Int;
        t = new int[N];
        for (int i = 0; i < N; ++i)
            t[i] = io.Int;
        //cal
        var ans = 0;
        for (int i = 0; i < N; ++i)
            if (t[i] < A || B <= t[i])
                ans++;
        //ret
        Console.WriteLine(ans);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }   
}

class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define foreach(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define all(c) begin(c),end(c)
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

bool valid(vs ns)
{
	return any_of(all(ns),[](string n){return n=="0" || n[0]!='0';});
}
int sum(vs ns)
{
	return accumulate(all(ns),0,[](int x,string s){return x+atoi(s.c_str());});
}

int main()
{
	for(int t,n;cin>>t>>n,t|n;){
		string ds;
		{ ostringstream oss; oss<<n; ds=oss.str(); }
		
		vs res; int cnt=0;
		rep(i,1<<ds.size()-1){
			vs tmp(1); tmp[0]+=ds[0];
			rep(j,ds.size()-1){
				if(i&1<<j)
					tmp.push_back("");
				tmp.back()+=ds[j+1];
			}
			if(valid(tmp) && sum(tmp)<=t){
				if(res.empty() || sum(tmp)>sum(res))
					res=tmp,cnt=1;
				else if(sum(tmp)==sum(res))
					cnt++;
			}
		}
		if(cnt==0)
			cout<<"error"<<endl;
		else if(cnt>1)
			cout<<"rejected"<<endl;
		else{
			cout<<sum(res);
			rep(i,res.size()) cout<<' '<<res[i];
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    string s;
    cin >> s;
    string ls = s.substr(0, n);
    string rs = s.substr(n, n);
    reverse(all(rs));
    map<pair<string, string>, ll> lcnt;
    rep(i, 1 << n) {
        string ls1 = "", ls2 = "";
        rep(ii, n) {
            if ((i & (1 << ii)) != 0) {
                ls1 += ls[ii];
            }
            else {
                ls2 += ls[ii];
            }
        }
        lcnt[make_pair(ls1, ls2)]++;
    }
    ll ans = 0;
    rep(i, 1 << n) {
        string rs1 = "", rs2 = "";
        rep(ii, n) {
            if ((i & (1 << ii)) != 0) {
                rs1 += rs[ii];
            }
            else {
                rs2 += rs[ii];
            }
        }
        ans += lcnt[make_pair(rs1, rs2)];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 91904
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>


int descending_compare(const void *a, const void *b) {
	if (*(int*)a > *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

int ascending_compare(const void *a, const void *b) {
	if (*(int*)a < *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y) {
	if (y == 0) {
		return x;
	}
	else if (x > y) {
		return gcd(y, x % y);
	}
	else {
		return gcd(x, y % x);
	}
}



long long factorial(int x) {
	long long rtn = 1;
	int i;
	for (i = x; i > 1; i--) {
		rtn = (rtn*i);
	}
	return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

int e[105][105];
int d[105][105];
int eb[105][105];


int main(void) {
	int INF = 1000000;
	for (int i = 0; i < 105; i++) {
		for (int j = 0; j < 105; j++)
		{
			e[i][j] = INF;
			d[i][j] = INF;
			eb[i][j] = 1;
		}
	}
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		e[a][b] = c;
		e[b][a] = c;
		d[a][b] = c;
		d[b][a] = c;
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (d[i][j] > d[i][k] + d[k][j]) {
					d[i][j] = d[i][k] + d[k][j];
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (d[i][j] < e[i][j] && e[i][j] != INF) {
				ans++;
			}
		}
	}
	
	printf("%d\n", ans/2);
	return 0;
}


Measured memory_bytes: 632
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  rep(i,N){
    cin >> A.at(i);
  }
  rep(i,N){
    cin >> B.at(i);
  }
  vector<int> sumA(N+1,0);
  vector<int> sumB(N+1,0);
  rep(i,N){
    sumA.at(i+1) = sumA.at(i) + A.at(i);
  }
  rep(i,N){
    sumB.at(i+1) = sumB.at(i) + B.at(i);
  }

  int sum = 0;
  for(int i = 1;i <= N;i++){
    if(sum <= sumA.at(i) + sumB.at(N) - sumB.at(i-1)){
      sum = sumA.at(i) + sumB.at(N) - sumB.at(i-1);
    }
  }
  cout << sum <<endl;

}


Measured memory_bytes: 256
#import <stdio.h>
typedef long long INT;
int main(){
    int n;
    scanf("%d",&n);
    INT t = 1;
    INT r = 1;
    for(int i=0;i<n;i++){
        int a;
        scanf("%d",&a);
        t *= 3;
        r *= (a%2==0) ? 2 : 1;
    }
    printf("%lld",t-r);
}


Measured memory_bytes: 7504
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	long long n,m,a,b;
	long long sum;
	while(scanf("%lld %lld",&n,&m)==2)
	{
		sum=0;
		b=m/2;
		if(b>=n)
		{
			sum=sum+n;
			m=m-2*n;
			a=m/4;
			sum=sum+a;
			printf("%lld\n",sum);
			continue;
		}
		if(b<n)
		{
			sum=sum+b;
			printf("%lld\n",sum);
		}
	}
	return 0;
}

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

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

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

    vector<long long> left(n, 0), right(n, 0);

    left[0] = a[0];
    for (int i = 1; i < n; i++)
    {
        left[i] = left[i - 1] + a[i];
    }
    
    right[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--)
    {
        right[i] = right[i + 1] + a[i];
    }

    long long ans = 3e9;
    for (int i = 0; i < n - 1; i++)
    {
        ans = min(ans, abs(left[i] - right[i + 1]));
    }
    
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N,num[100],tmp
    ;
  int i,j;
  int min,cnt=0;

  cin >> N;

  for(i = 0 ; i < N ; i++){
    cin >> num[i];
  }

  for(i = 0 ; i < N ; i++){
    min = i;
    for(j = i ; j < N ; j++){
      if(num[j] < num[min]){
	min = j;       
      }
    }
     
    tmp = num[i];
    num[i] = num[min];
    num[min] = tmp; 

    if(i != min){
      cnt++;
    }
  }

  for(i = 0 ; i < N-1 ; i++){
    cout << num[i] << " ";
  }

  cout << num[N-1] << endl;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

class UnionFind {
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<ll> Parent;
 
    //作るときはParentの値を全て-1にする
    //こうすると全てバラバラになる
    UnionFind(ll N) {
        Parent = vector<ll>(N, -1);
    }
 
    //Aがどのグループに属しているか調べる
    ll root(ll A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
 
    //自分のいるグループの頂点数を調べる
    ll size(ll A) {
        return -Parent[root(A)];//親をとってきたい]
    }
 
    //AとBをくっ付ける
    bool connect(ll A, ll B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
 
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらひっくり返しちゃう。
        if (size(A) < size(B)) swap(A, B);
 
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
 
        return true;
    }
};

ll solve()
{
    ll ans = 0;
    ll N,M;
    cin >> N >> M;
    UnionFind uni(N);
    for1(i,M) {
        ll X,Y,Z;
        cin >> X >> Y >> Z;
        --X;
        --Y;
        uni.connect(X,Y);
    }

    set<ll> parents;
    for1(i,N) {
        ll pa = uni.root(i);
        parents.insert(pa);
    }

    return parents.size();
}

int main()
{
    do {
        //solve();
        cout << solve() << endl;
    } while (DEBUG);
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int n, k, ans = 0;
	cin >> n >> k;
	vector<int>l(n);
	for (int i = 0; i < n; i++) cin >> l[i];
	sort(l.begin(),l.end());
	for (int i = 0; i < k; i++) {
		ans += l[n - 1 - i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
bool prime(int n);
int main()
{
	const int MAX=10000;
	int i,n,count,A[MAX];
	count=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>A[i];
	for(i=0;i<n;i++)
		if(prime(A[i]))
			count++;
	cout<<count<<endl;
	return 0;
}
bool prime(int n)
{
	int i;
	for(i=2;i<=int(sqrt(double(n)));i++)
		if(n%i==0)
			return false;
	return true;
}


Measured memory_bytes: 3088
n = int(input())
a = list(map(int, input().split()))

a_abs = [abs(a[i]) for i in range(n)]
a_abs_sum = sum(a_abs)

# aに0が含まれれば、全部正となるようフリップできる
if 0 in a:
    print(a_abs_sum)
else:
    # 0を含まず、かつ負の数が偶数ならば、同様にすべて正にフリップできる
    even = len([1 for i in range(n) if a[i] < 0])
    if even % 2 == 0:
        print(a_abs_sum)
    else: # 上記以外の場合は、絶対値のもっとも小さいものに負を寄せる
        print(a_abs_sum - 2*min(a_abs))

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e933
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int temp[3]={1,5,10};

using namespace std;

int main() {
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}



Measured memory_bytes: 3124
N = int(input())
cook_list = list(map(int,input().split()))
satisfy_list = list(map(int,input().split()))
plus_satisfy_list = list(map(int,input().split()))

sum_point = 0
prev_num = 0

for now_num in cook_list:
  sum_point += satisfy_list[now_num - 1]
  if (now_num - prev_num) == 1 and (now_num > 1):
    sum_point += plus_satisfy_list[prev_num - 1]
  prev_num = now_num
  
print(sum_point)

Measured memory_bytes: 3064
//C Go to School
#include "bits/stdc++.h"
using namespace std;

int main()
{
  int n,a;
  cin>>n;
  vector<int> vec(n);
  for(int i=1;i<n+1;i++)
  {
    cin>>a;
    vec.at(a-1)=i;
  }
  for(int i=0;i<n;i++)
  {
    cout<<vec.at(i)<<' ';
  }
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 1000000007

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

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
int n;

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

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

    ll res = b[0];
    for (int i = 1; i < n; ++i) {
        res = res * (b[i] / gcd(res, b[i]));
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI3(N,Z,W);
    GVI(a,N);
    int ans1=abs(W-LAST(a));
    int ans2;
    if(N<2){
        ans2=ans1;
    }else{
        ans2=abs(a[N-1]-a[N-2]);
    }
    print(max(ans1,ans2));
    return 0;
}


Measured memory_bytes: 256
S = str(input())

if S == 'SUN':
    print(7)
if S == 'MON':
    print(6)
if S == 'TUE':
    print(5)
if S == 'WED':
    print(4)
if S == 'THU':
    print(3)
if S == 'FRI':
    print(2)
if S == 'SAT':
    print(1)

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



Measured memory_bytes: 2048
#include<stdio.h>
int main(void)
{
    int a[100],b[100];
    int i = 0,count = 0,cou = 0;
    while(scanf("%d",&a[i]) != EOF){
        if(a[i] == 0){
            i--;
            b[cou] = a[i];
            cou++;
        }
        else i++;
    }
    for(i = 0; i < cou; i++){
        printf("%d\n",b[i]);
    }

    return 0;
}

Measured memory_bytes: 600
#include<iostream>

using namespace std;

int main(void)
{
  int n; cin>>n;
  int num[]={1,2,4,8,16,32,64};
  int ans;
  
  for(int i=0;i<7;i++){
    if(num[i]<=n){ans=num[i];} 
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var p = new B();
            p.run();
        }
    }

    public class B
    {
        int N, M;
        int[] T, P, X;
        public B()
        {
            N = int.Parse(Console.ReadLine());
            T = new int[N+1];
            string[] s = Console.ReadLine().Split(' ');            
            for (int i=1; i<=N; i++) 
            {
                T[i] = int.Parse(s[i-1]);
            }
            M = int.Parse(Console.ReadLine());
            P = new int[M+1];
            X = new int[M+1];
            for (int i=1; i<=M; i++)
            {
                s = Console.ReadLine().Split(' ');
                P[i] = int.Parse(s[0]);
                X[i] = int.Parse(s[1]);
            }
        }

        public void run()
        {
            int sumT = 0;
            for (int i=1; i<=N; i++) 
            {
                sumT += T[i];
            }

            for (int i=1; i<=M; i++) 
            {
                int ans = sumT - T[P[i]] + X[i];
                System.Console.WriteLine(ans);
            }
        }
    }
}


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

int main() {
    int ans = 1;
    rep(i, 5) {
        int temp;
        cin >> temp;
        if(!temp) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main(){
    string s; cin >> s;
    bool check = false;
    for(int i = 0; i < s.size() - 1; i++) {
        if(s[i] != s[i + 1]) {
            check = true;
            break;
        }
    }
    if(check) {
        cout << "Yes";
    }
    else{
        cout << "No" ;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int>G[200000];
int imos[200000];
void dfs(int s,int p){
    imos[s]+=(p==-1?0:imos[p]);
    for(int i=0;i<G[s].size();i++)
        if(G[s][i]!=p)
            dfs(G[s][i],s);
}
signed main(){
    int n,q,a,b,p,x;
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        G[--a].push_back(--b);
        G[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        cin>>p>>x;
        imos[--p]+=x;
    }
    dfs(0,-1);
    for(int i=0;i<n;i++)
        cout<<imos[i]<<(i+1==n?'\n':' ');
}


Measured memory_bytes: 24320
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double ans = 0.0;

    ans = A*A + B*B - 2*A*B*cos(((60*H+M)/720*2*M_PI)-M/60*2*M_PI);
    ans = sqrt(ans);

    cout << setprecision(14) << ans;
    

}

Measured memory_bytes: 4180
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
class UnionFind{
  private:
    vector<int>par;
  public:
    UnionFind(int n):par(n,-1){}
    int root(int x){
      if(par[x] < 0)return x;
      return par[x] = root(par[x]);
    }
    bool unite(int x,int y){
      x = root(x); y = root(y);
      if (x == y) return false;
      if (par[x] > par[y]) swap(x, y);
      par[x] += par[y];
      par[y] = x;
      return true;
    }
    bool same(int x,int y){
      return root(x) == root(y);
    }
    int size(int x) {
      return -par[root(x)];
    }
};
int solve(){
  int n,k,l;
  cin >> n >> k >> l;
  UnionFind uf(n),uf2(n);
  rep(i,k){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a,b);
  }
  rep(i,l){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    uf2.unite(a,b);
  }
  map<pair<int,int>,int>m;
  rep(i,n){
    pair<int,int>P;
    P.first = uf.root(i);
    P.second = uf2.root(i);
    m[P]++;
  }
  rep(i,n){
    pair<int,int>P;
    P.first = uf.root(i);
    P.second = uf2.root(i);
    cout << m[P] << " ";
  }
  cout << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int main()
{
    f_io;
    int n,num=0;
    cin>>n;
    long long a[n],b[n],c[n],dp[n+1][3];
    foi(0,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp,0,sizeof(dp));
    foi(0,n)
    {
        dp[i+1][0]=max(dp[i+1][0],max(dp[i][1],dp[i][2])+a[i]);
        dp[i+1][1]=max(dp[i+1][1],max(dp[i][2],dp[i][0])+b[i]);
        dp[i+1][2]=max(dp[i+1][2],max(dp[i][1],dp[i][0])+c[i]);
        
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  ll K;
  cin >> N >> K;
  ll A;
  vector<ll> B;
  vector<ll> C;
  ll z = 0;
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A == 0)
      z++;
    else if (A < 0)
      B.push_back(A);
    else
      C.push_back(A);
  }
  ll nb = B.size();
  ll nc = C.size();
  ll f0 = nb * nc;
  ll f1 = f0 + z * (nb + nc) + (z * (z - 1)) / 2;
  sort(B.begin(), B.end());
  if (K <= f0) {
    sort(C.begin(), C.end(), greater<ll>());
    ll l = -1e18 - 1ll;
    ll r = 0;
    while (r - l > 1) {
      ll m = (l + r) / 2;
      ll sum = 0;
      int j = nb;
      for (int i = 0; i < nc && sum < K; i++) {
        j = upper_bound(B.begin(), B.begin() + j, m / C[i] - (m % C[i] ? 1 : 0))
            - B.begin();
//        while (j < nc && B[i] * C[j] <= m)
//          j++;
        if (j == 0)
          break;
//        cout << i << " " << j << " " << m << endl;
        sum += j;
      }
      //cout << sum << " " << m << "\n";
      if (sum < K)
        l = m;
      else
        r = m;
    }
    cout << r << "\n";
  } else if (K <= f1) {
    cout << "0\n";
  } else {
    sort(C.begin(), C.end());
    ll l = 0;
    ll r = 1e18 + 1ll;
    while (r - l > 1) {
      ll m = (l + r) / 2;
      ll sum = f1;
      int j = nb - 1;
      for (int i = 0; i < nb - 1 && sum < K; i++) {
        while (j >= 0 && B[i] * B[j] <= m)
          j--;
        sum += min((int) nb - j - 1, (int) nb - i - 1);
      }

      j = 0;
      for (int i = nc - 1; i >= 1 && sum < K; i--) {
        while (j < nc && C[i] * C[j] <= m)
          j++;
        sum += min(i, j);
      }
      // cout << sum << " " << m << "\n";
      if (sum < K)
        l = m;
      else
        r = m;
    }
    cout << r << "\n";
  }
  return 0;
}


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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

const long MOD = 1e9+7;

int n;
int dp[2000003];
vector<int> vec[200003];

long pwr(long a, long b)
{
	if(b == 0) return 1;
	else if(b == 2) return (a*a)%MOD;
	else if(b&1) return (a*pwr(a,b-1))%MOD;
	else return pwr(pwr(a,b/2), 2);
}

long res = 0;
void dfs(int u)
{
	long com = pwr(2,n-1);
	dp[u] = 1;
	for(int v : vec[u])
	{
		if(dp[v]) continue;
		dfs(v);
		dp[u] += dp[v];
		com -= pwr(2, dp[v])-1;
		com %= MOD;
	}
	com -= pwr(2, (n-dp[u]))-1;
	com -= 1;
	com %= MOD;

	res = (res+com)%MOD;
	// printf("%d %lld\n", u, com);
}

int main()
{
	// freopen("input.in", "r", stdin);

	scanf("%d", &n);
	for(int i = 1; i < n; i++)
	{
		int u, v; scanf("%d %d", &u, &v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	dfs(1);
	res = (res+MOD)%MOD;
	printf("%lld\n", (res*pwr(pwr(2,n),MOD-2))%MOD);
}

Measured memory_bytes: 21504
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int loop[100010] = {};	//1=S, -1=W
int n;
string str;

bool check(){
	for(int i = 1;i < n;i++){
		if(str[i] == 'o'){
			if(loop[i] == 1){
				loop[i+1] = loop[i-1];
			}else{
				loop[i+1] = -loop[i-1];
			}
		}else{
			if(loop[i] == 1){
				loop[i+1] = -loop[i-1];
			}else{
				loop[i+1] = loop[i-1];
			}
		}
	}
	bool ret = true;
	if(loop[0] == 1){
		if(loop[1] != loop[n-1] && str[0] == 'o') ret = false;
		if(loop[1] == loop[n-1] && str[0] == 'x') ret = false;
	}else{
		if(loop[1] == loop[n-1] && str[0] == 'o') ret = false;
		if(loop[1] != loop[n-1] && str[0] == 'x') ret = false;
	}

	if(loop[n-1] == 1){
		if(loop[0] != loop[n-2] && str[n-1] == 'o') ret = false;
		if(loop[0] == loop[n-2] && str[n-1] == 'x') ret = false;
	}else{
		if(loop[0] == loop[n-2] && str[n-1] == 'o') ret = false;
		if(loop[0] != loop[n-2] && str[n-1] == 'x') ret = false;
	}

	return ret;
}

bool solve(){
	bool ans = false;
	loop[0] = 1;loop[1] = 1;
	ans = check();
	if(ans) return true;

	loop[0] = 1;loop[1] = -1;
	ans = check();
	if(ans) return true;

	loop[0] = -1;loop[1] = 1;
	ans = check();
	if(ans) return true;

	loop[0] = -1;loop[1] = -1;
	ans = check();
	if(ans) return true;

	return false;
}

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

	bool ret = solve();
	if(ret){
		for(int i = 0;i < n;i++){
			if(loop[i] == -1){
				cout << "W";
			}else{
				cout << "S";
			}
		}
		cout << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

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

int main(){
  int n, m, x, y, ans = 0;
  std::cin >> n >> m;
  vector<int> ball(n, 1);
  bool box[n];
  memset(box, 0, sizeof(box));
  box[0] = 1;
  for (int i = 0; i < m; i++) {
    std::cin >> x >> y;
    x--, y--;
    box[y] |= box[x];
    ball[x]--, ball[y]++;
    box[x] &= (ball[x] > 0);
  }
  for (int i = 0; i < n; i++) {
    ans += box[i];
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 768
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b = sc.next().toBigDecimal
  val C = math.toRadians(sc.nextDouble())

  import scala.math.{cos, sin, sqrt}

  val S = a * b * sin(C).toBigDecimal / 2
  val L = a + b + (a.squared + b.squared - 2 * a * b * cos(C).toBigDecimal).sqRoot
  val h = b * sin(C)

  println(f"${S.toDouble}%.8f")
  println(f"${L.toDouble}%.8f")
  println(f"${h.toDouble}%.8f")

  implicit class StringExtends(val s: String) extends AnyVal {
    def toBigDecimal = BigDecimal(s)
  }

  implicit class DoubleExtends(val d: Double) extends AnyVal {
    def toBigDecimal = BigDecimal(d)
  }

  implicit class BigDecimalExtends(val b: BigDecimal) extends AnyVal {
    def squared = b * b

    def sqRoot = sqrt(b.toDouble).toBigDecimal
  }

}

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

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

    int N, M;
    cin >> N >> M;

    P lis[100000];

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        lis[i] = P(b, a);
    }

    sort(lis, lis+M);

    int now = -1;
    int ans = 0;

    for (int i = 0; i < M; i++) {
        if (lis[i].second >= now) {
            now = lis[i].first;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll  N;
    cin>>N;
    ll a,b;
    a=N/100;
    b=N%100;
    ll B=0;
    rep(0,i,a){
        if(B+5<=b){
            B+=5;
        }else if(B+4<=b){
            B+=4;
        }else if(B+3<=b){
            B+=3;
        }else if(B+2<=b){
            B+=2;
        }else if(B+1<=b){
            ++B;
        }
    }
    if(b==B)cout<<1<<endl;
    else cout<<0<<endl;
}

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

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    int N;
    cin >> N;
    vector<bool> answer(N, false);
    for (ll i = 0; i < N; i++) {
        char c;
        cin >> c;
        if (c == 'o') {
            answer[i] = true;
        } else {
            answer[i] = false;
        }
    }
    vector<bool> is_sheep(N, false);
    for (int b = 0; b < 4; b++) {
        fill(is_sheep.begin(), is_sheep.end(), false);
        is_sheep[0] = (bool)(b / 2);
        is_sheep[1] = (bool)(b % 2);
        for (int i = 1; i < N - 1; i++) {
            if (answer[i]) {
                if (is_sheep[i]) {  //same
                    is_sheep[i + 1] = is_sheep[i - 1];
                } else {  //not same
                    is_sheep[i + 1] = not is_sheep[i - 1];
                }
            } else {
                if (is_sheep[i]) {  //not same
                    is_sheep[i + 1] = not is_sheep[i - 1];
                } else {  //same
                    is_sheep[i + 1] = is_sheep[i - 1];
                }
            }
        }
        bool check = false;
        if (answer[N - 1]) {
            if (is_sheep[N - 1]) {  //same
                check = (is_sheep[0] == is_sheep[N - 2]);
            } else {  //not same
                check = (is_sheep[0] == not is_sheep[N - 2]);
            }
        } else {
            if (is_sheep[N - 1]) {  //not same
                check = (is_sheep[0] == not is_sheep[N - 2]);
            } else {  //same
                check = (is_sheep[0] == is_sheep[N - 2]);
            }
        }
        if (not check) {
            continue;
        }
        check = false;
        if (answer[0]) {
            if (is_sheep[0]) {  //same
                check = (is_sheep[N - 1] == is_sheep[1]);
            } else {  //not same
                check = (is_sheep[N - 1] == not is_sheep[1]);
            }
        } else {
            if (is_sheep[0]) {  //not same
                check = (is_sheep[N - 1] == not is_sheep[1]);
            } else {  //same
                check = (is_sheep[N - 1] == is_sheep[1]);
            }
        }
        if (check) {
            for (ll i = 0; i < N; i++) {
                cout << (is_sheep[i] ? 'S' : 'W');
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 384
import numpy as np

N, M=map(int, input().split())
AB=np.array([list(map(int, input().split())) for i in range(N)])

AB=AB[np.argsort(AB[:, 0])]

money=0
cans=0
shop=0
while cans<M:
  if cans+AB[shop, 1]<=M:
    money+=AB[shop, 0]*AB[shop, 1]
    cans+=AB[shop, 1]
  else:
    money+=AB[shop, 0]*(M-cans)
    cans+=AB[shop, 1]
    
  shop+=1
    
print(money)

Measured memory_bytes: 37876
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int H,W,D;
  cin >> H >> W >> D;

  int N = H*W;
  vector<int> x(N),y(N);
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      int a;
      cin >> a;
      a--;
      x.at(a) = j;
      y.at(a) = i;
    }
  }

  vector<int> s(N,0);
  for(int i = D;i < N;i++) {
    s.at(i) = s.at(i-D) + abs(x.at(i) - x.at(i-D)) + abs(y.at(i)-y.at(i-D));
  }

  int Q;
  cin >> Q;

  for(int i = 0;i < Q;i++) {
    int l,r;
    cin >> l >> r;
    l--;
    r--;
    cout << s.at(r) - s.at(l) << endl;
  }

}






Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef long long ll;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)
#define INF 10000000000 //10^10
#define PI 3.141592
#define pb push_back

int main(){
    //内部処理は0indexで行う

    //入力
    int n;
    cin >> n;
    vector<vint> adj(n);
    rep(i,n){
        int u,k;
        cin >> u >> k;
        rep(j,k){
            int v;
            cin >> v;
            adj[u-1].pb(v-1);
        }
    }

    //計算
    vint d(n,-1);
    d[0]=0;
    queue<int> Q;
    Q.push(0);
    while(!Q.empty()){
        int cur=Q.front(); Q.pop();
        rep(i,adj[cur].size()){
            int dst=adj[cur][i];
            if(d[dst]==-1){
                d[dst]=d[cur]+1;
                Q.push(dst);
            }
        }
    }

    //出力
    rep(i,n){
        cout << i+1 << ' ' << d[i] << endl;
    }
}



Measured memory_bytes: 3160
'''
https://atcoder.jp/contests/abc075/tasks/abc075_c?lang=ja
深さ優先探索でも解ける
'''
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    class UnionFind():
        #n個の要素を番号0~n-1で管理する
        #parents:要素の親(1つ上), 要素が根の場合サイズを表す
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n
    
        #要素xの根を返す, その過程で経路圧縮も行う
        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]
    
        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)
            if x == y:
                return
            #それぞれのsizeで比べる
            if self.parents[x] > self.parents[y]:
                x, y = y, x
            self.parents[x] += self.parents[y]
            self.parents[y] = x #根をくっつける(片方を親にする)
    
        #xが属するグループのsize
        def size(self, x):
            return -self.parents[self.find(x)]
    
        #xとyが同じグループかどうか
        def same(self, x, y):
            return self.find(x) == self.find(y)
    
        #xが属するグループの要素全てを返す
        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]
    
        #全ての根の要素を返す
        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]
    
        #各グループの要素を辞書で返す
        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}
    
        #print(uf)
        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    n,m = map(int, input().split())
    edge = [list(map(int, input().split())) for _ in range(m)]
    res = 0
    for i in range(m):
        uf = UnionFind(n)
        for j in range(m):
            if i==j:
                continue
            a,b = edge[j]
            uf.union(a-1,b-1)
        if uf.size(0)!=n:
            res += 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
def binarySearch(key, array)
  left = 0
  right = array.size
  while left < right do
    mid = (left+right)/2
    if array[mid] == key
      return mid
    elsif array[mid] < key
      left = mid + 1
    else
      right = mid
    end
  end
  return -1
end

gets
s = gets.split.map(&:to_i)
gets
t = gets.split.map(&:to_i)
count = 0
t.each do |num|
  if binarySearch(num, s) != -1
    count += 1
  end
end
puts count


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

main() {
    int N; cin >> N;
    int a[N],b[N],c[N];
    bool can=true;
    rep(i,N){
        cin >> a[i] >> b[i] >> c[i];
    }
    rep(i,N){
        int d,e,f;
        if(i==0){d=a[i];e=b[i];f=c[i];}
        else{
        d=a[i]-a[i-1];
        e=abs(b[i]-b[i-1]);
        f=abs(c[i]-c[i-1]);
        }
        if(e+f<=d && (e+f)%2==d%2);
        else {can=false; break;}
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(void) {
    int n;
    std::cin >> n;
    std::vector<int> a;
    long long sum = 0;
    int num;
    for (int i = 0; i < n; i++) {
        std::cin >> num;
        if (num < 0) {
        }
        a.push_back(num);
    }
    std::sort(a.begin(), a.end(), std::greater<int>());
    sum += a.at(0);

    int check = 0;
    int i = 1;
    while (check < n - 2) {
        sum += a.at(i);
        check++;
        if (check < n - 2) {
            sum += a.at(i);

            check++;
        }
        i++;
    }
    std::cout << sum << std::endl;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	vector<long long> a(n), b(n);
	vector<long long> v, w;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n; i++) {
		if(a[i] < b[i]) v.push_back(b[i] - a[i]);
		if(a[i] > b[i]) w.push_back(a[i] - b[i]);
	}
	int ans = v.size();
	long long need = 0;
	for(int i = 0; i < v.size(); i++) {
		need += v[i];
	}
	int siz = w.size();
	sort(w.rbegin(), w.rend());
	/*for(int i = 0; i < v.size(); i++) {
		cerr << "v " << v[i] << endl;
	}
	cerr << endl;
	for(int i = 0; i < w.size(); i++) {
		cerr << "w " << w[i] << endl;
	} 
	cerr << endl << "need " << need << endl;*/
	if(need <= 0) {
		cout << ans << endl;
		return 0;
	}
	for(int i = 0; i < siz; i++) {
		need -= w[i];
		if(need <= 0) {
			cout << ans + i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;	
}


Measured memory_bytes: 2812
# 入力
N=int(input())
tl=list(map(int,input().split()))
M=int(input())

# 和
sm=sum(tl)

al=[]
for i in range(M):
  P,X=map(int,input().split())

  # 変更した場合の変化量を求める
  a=X-tl[P-1]

  # 解答を保存
  al.append(sm+a)

# 出力
for x in al:
  print(x)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
	
	int i,j,tmp,x,y,step;
	
	for(j=0;;j++){
		step=0;
		scanf("%d %d",&x,&y);
		if(x==0&&y==0){
			break;
		}
		if(y>=x){
			tmp=x;
			x=y;
			y=tmp;
		}
		
		for(i=0;;i++){
			x=x%y;
			
			tmp=x;
			x=y;
			y=tmp;
			
			step++;
			if(y==0){
				break;
			}
		}
		printf("%d %d\n",x,step);
	}
	return 0;
}

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

#define INF (1<<31)-1
#define LINF (1LL<<63)-1LL
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int a,b,q;
    cin>>a>>b>>q;

    vector<ll> s(a+1);
    vector<ll> t(b+1);

    s[0] = (1LL<<62);t[0] = (1LL<<62);

    rep(i,a)cin>>s[i+1];
    rep(i,b)cin>>t[i+1];

    s.eb(-(1LL<<62));t.eb(-(1LL<<62));

    rep(i,q){
        ll x;
        cin>>x;

        int p = lower_bound(all(s),x)-s.begin();
        int q = lower_bound(all(t),x)-t.begin();


        ll tmp = LINF;

        rep1(i , max(0,p-3) , min(p+3,a+1)){
            rep1(j, max(0,q-3) , min(q+3,b+1)){
                ll si = s[i];
                ll ti = t[j];

                if(((si==x) || (ti==x))){
                    chmin( tmp , abs(si-x)+abs(ti-x) );
                }else if( (si<x)!=(ti<x) ){
                    chmin( tmp , abs(si-x)+abs(ti-x) + min(abs(si-x),abs(ti-x)) );
                }else{
                    chmin( tmp , max(abs(si-x),abs(ti-x)) );
                }
            }
        }

        cout << tmp << endl;
    }

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 2912
// =================================
//   author: memset0
//   date: 2019.03.21 00:07:31
//   website: https://memset0.cn/
// =================================
#include <bits/stdc++.h>
#define ll long long
#define debug(...) ((void)0)
#ifndef debug
#define debug(...) fprintf(stderr,__VA_ARGS__)
#endif
namespace ringo {
template <class T> inline void read(T &x) {
	x = 0; register char c = getchar(); register bool f = 0;
	while (!isdigit(c)) f ^= c == '-', c = getchar();
	while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
	if (f) x = -x;
}
template <class T> inline void print(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar('0' + x % 10);
}
template <class T> inline void print(T x, char c) { print(x), putchar(c); }

const int N = 2e4 + 10;
int n, a[N], b[N], p[N];

void main() {
	read(n);
	for (int i = 1; i <= n; i++) read(p[i]);
	for (int i = 1; i <= n; i++) a[i] = n * i + 1;
	for (int i = 1; i <= n; i++) b[i] = n * (n - i + 1) + 1;
	for (int i = 1; i <= n; i++) a[p[i]] += i, b[p[i]] += i;
	for (int i = 1; i <= n; i++) print(a[i], " \n"[i == n]);
	for (int i = 1; i <= n; i++) print(b[i], " \n"[i == n]);
}

} signed main() { return ringo::main(), 0; }

Measured memory_bytes: 896