akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {

  long n,k;
	scanf("%ld %ld", &n, &k);
	char s[n+1];
	scanf("%s", s);
	long zero_list[n][2];
	long cur = 0;
	for (long i = 0; i < n; i++) {
		if (i == 0 && s[i] == '0') {
			zero_list[cur][0] = i;
		}
		if (i != 0 && s[i] == '0' && s[i-1] == '1') {
			zero_list[cur][0] = i;
		}
		if (i == n-1 && s[i] == '0') {
			zero_list[cur][1] = i;
			cur++;
		}
		if (i != n-1 && s[i] == '0' && s[i+1] == '1') {
			zero_list[cur][1] = i;
			cur++;
		}
	}
	if (k >= cur) {
		printf("%ld\n", n);
		return 0;
	}
	long max = zero_list[k][0];
	long length;
	for (long i = k+1; i < cur; i++) {
		length = zero_list[i][0]-zero_list[i-k-1][1]-1;
		if (length > max) {
			max = length;
		}
	}
	length = n-zero_list[cur-k-1][1]-1;
	if (length > max) {
		max = length;
	}
	printf("%ld\n", max);

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	vector <int> vec( N );
	rep( i, 0, N )  cin >> vec[ i ];
	sort_desc( vec );
	int alice = 0;
	int bob = 0;
	rep( i, 0, N ){
		if (i % 2 == 0)
			alice += vec[ i ];
		else
			bob += vec[ i ];
	}
	cout << abs( alice - bob ) << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h> 

using namespace std;
int main(){
	int A, B, C, D;
	int area1, area2;
	scanf("%d%d%d%d", &A, &B, &C, &D);
	area1 = A*B;
	area2 = C*D;
	if(area1>area2){
		printf("%d\n", area1);
	}else{
		printf("%d\n", area2);
	}
	return 0;
}

Measured memory_bytes: 256
N=parse(Int,readline())
D=Dict{String,Int}()
for i=1:N
	s=readline()
	D[s]=get(D,s,0)+1
end
M=parse(Int,readline())
for i=1:M
	s=readline()
	D[s]=get(D,s,0)-1
end
ans=0
for (k,v)=D
	ans=max(ans,v)
end
println(ans)


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

typedef struct Node {
  long key;
  struct Node *p, *l, *r;
} N;

N *root, *NIL;

void insert(long k) {
  N *y = NIL;
  N *x = root;
  N *z;
    
  z = (N *)malloc(sizeof(N));
  z->key = k;
  z->l = z->r = NIL;
    
  while (x != NIL) {
    y = x;
    if (z->key < x->key) x = x->l;
    else x = x->r;
  }
  z->p = y;
    
  if (y == NIL) root = z;
  else if (z->key < y->key) y->l = z;
  else y->r = z;
}

N* find(N *x, long k) {
  while (x != NIL && k != x->key) {
    if (k < x->key) x = x->l;
    else x = x->r;
  }
  return x;
}

void inorder(N *u) {
  if (u == NIL) return;
  inorder(u->l);
  printf(" %ld", u->key);
  inorder(u->r);
}

void preorder(N *u) {
  if (u == NIL) return;
  printf(" %ld", u->key);
  preorder(u->l);
  preorder(u->r);
}

void print() {
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
}

int main() {
  long n, i, x;
  char st[20];
  scanf("%ld", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", st);
    scanf("%ld", &x);
    if (st[0] == 'f') {
      if (find(root, x) != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if (st[0] == 'i') insert(x);
    else if (st[0] == 'p') print();
  }
  return 0;
}



Measured memory_bytes: 20612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;

#define endl "\n"

int d[N];

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>d[i];
	sort(d+1,d+n+1);
	int l=d[n>>1],r=d[(n>>1)+1];
	cout<<r-l<<endl;
	return 0;
}

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

int main()
{
    int i;
    cin>>i;
    if(i>=1||i<=100)
    {
   if(i%1==0&&(i/1>=1&&i/1<=9))
    cout<<"Yes";
   else if(i%2==0&&(i/2>=1&&i/2<=9))
    cout<<"Yes";
    else if(i%3==0&&(i/3>=1&&i/3<=9))
    cout<<"Yes";
    else if(i%4==0&&(i/4>=1&&i/4<=9))
    cout<<"Yes";
    else if(i%5==0&&(i/5>=1&&i/5<=9))
    cout<<"Yes";
    else if(i%6==0&&(i/6>=1&&i/6<=9))
    cout<<"Yes";
    else if(i%7==0&&(i/7>=1&&i/7<=9))
    cout<<"Yes";
    else if(i%8==0&&(i/8>=1&&i/8<=9))
    cout<<"Yes";
    else if(i%9==0&&(i/9>=1&&i/9<=9))
    cout<<"Yes";
     else
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long int ll;

int p[1001000];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	for(int i=2;i<=1e6;i++){
		if(p[i]==0){
			for(int j=i+i;j<=1e6;j+=i){
				p[j]=1;
			}
		}
	}
	int x; cin >> x;
	for(int i=x;i<=1e6;i++)
	{
		if(p[i]==0){
			cout << i << endl;
			return 0;
		}
	}
}

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

#define FOR(a,b,c) for (int a=(b);a<(c);++a)
#define REP(i,n) FOR(i,0,n)
#define ll long long
#define pii pair<int,int>
#define x first
#define y second
#define pb push_back
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;
int n,d;

bool ok(ll x,ll y){
	if (x*x+y*y<=(ll)d*d) return 1;
	return 0;
}

int main(){
	scanf ("%d%d",&n,&d);
	int sol=0;
	REP(i,n){
		int x,y;
		scanf ("%d%d",&x,&y);
		if (ok(x,y)) sol++;
	}
	printf ("%d\n",sol);
	
	
	return 0;
}


Measured memory_bytes: 3812
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
long long  INF=1'0000'0000'0000'0000'00;
using namespace std;

int main(){


unsigned long long x,y;
cin>>x>>y;

int ans=1;
while(x<=y){
    x*=2;
    ans++;
}
ans--;
cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

    int n, m, q;
    cin >> n >> m >> q;
    using P = pair<int, int>;
    vector<P> vp(m);
    rep(i, 0, m) {
        cin >> vp[i].first >> vp[i].second;
    }
    vector<vector<int> > memo(n + 1, vector<int>(n + 1));

    for (int i = 1; i <= n; ++i) {
        vector<int> rs;
        for (auto e : vp) {
            if (e.first >= i) {
                memo[i][e.second]++;
            }
        }
        for (int j = 1; j < n; ++j) {
            memo[i][j + 1] += memo[i][j];
        }
    }

    while (q--) {
        int p, q;
        cin >> p >> q;
        cout << memo[p][q] << endl;
    }

    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	int ans = INF;
	int idx = lower_bound(a.begin(), a.end(), 0) - a.begin();
	for(int i = 1; i <= k; i++){
		if(idx + i > n) continue;
		int tmp = a[idx + i - 1];
		int left = k - i;
		if(idx < left) continue;
		if(left) tmp += abs(a[idx - left]) * 2;
		ans = min(ans, tmp);
	}
	for(int i = 1; i <= k; i++){
		if(idx < i) continue;
		int tmp = abs(a[idx - i]);
		int right = k - i;
		if(idx + right > n) continue;
		if(right) tmp += a[idx + right - 1] * 2;
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdouble;


int main(int argc, char *argv[]) {

  double a,b,x;
  cin >> a >> b >> x;
  double border = a*b/2.0*a;
  double angle;
  double c;
  if(x<=border){
    c = x/a/b*2;
    angle = atan(b/c);
  }else{
    x -= border;
    c = x/a/a*2;
    angle = atan((b-c)/a);
  }

  angle = angle * 180 / M_PI;
  cout << fixed << setprecision(10);
  cout << angle << endl;
  
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, money, kabu int
	money = 1000
	fmt.Scan(&n)
	var a []int
	for i := 0; i < n; i++ {
		var b int
		fmt.Scan(&b)
		a = append(a, b)
	}
	a = append(a, 0)

	for i := 0; i < n; i++ {
		if a[i] < a[i+1] && kabu == 0 {
			kabu = money / a[i]
			money = money % a[i]
		} else if a[i] > a[i+1] {
			money = money + kabu*a[i]
			kabu = 0
		}
		// fmt.Printf("kabu: %d\n", kabu)
		// fmt.Printf("money: %d\n", money)
	}

	fmt.Println(money)
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
 
 
using namespace std;
 
 
const int MOD = 1e9 + 7;
const int N = 1e3;
const long long INF = 1e9;
 
 
int dp[3 * N + 1][3 * N + 1];


int main() {
    string a, b;
    cin >> a >> b;
    int n = a.length(), m = b.length();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i - 1] == b[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string ans = "";
    int x = n, y = m;
    while (x && y) {
        if (a[x - 1] == b[y - 1]) {
            ans += a[x - 1];
            x--, y--;
        } else
            dp[x - 1][y] > dp[x][y - 1] ? x-- : y--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}


Measured memory_bytes: 35456
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin(N);

    //vll X(N);
    //REP(i,N) cin(X.at(i));
    REP(i,50000){
        int ans = i*1.08;
        if(ans == N){
            cout << i << endl;
            return 0;
        }
    }



    //出力
    cout << ":(" << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) {
    const T INF = numeric_limits<T>::max();
    using P     = pair<T, int>;
    int n       = G.size();
    vector<T> d(n, INF);
    vector<int> b(n, -1);
    priority_queue<P, vector<P>, greater<P>> q;
    d[s] = 0;
    q.emplace(d[s], s);
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (auto &e : G[v]) {
            int u = e.first;
            T c   = e.second;
            if (d[u] > d[v] + c) {
                d[u] = d[v] + c;
                b[u] = v;
                q.emplace(d[u], u);
            }
        }
    }
    return d;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;
    vl u(m), v(m), a(m), b(m);
    for (int i = 0; i < m; ++i) {
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        u[i]--, v[i]--;
    }
    vector<vector<pair<int, ll>>> edgesyen(n);
    vector<vector<pair<int, ll>>> edgessnuuk(n);

    for (int i = 0; i < m; ++i) {
        edgesyen[u[i]].emplace_back(v[i], a[i]);
        edgesyen[v[i]].emplace_back(u[i], a[i]);
        edgessnuuk[u[i]].emplace_back(v[i], b[i]);
        edgessnuuk[v[i]].emplace_back(u[i], b[i]);
    }
    vl distyen   = dijkstra(s, edgesyen);
    vl distsnuuk = dijkstra(t, edgessnuuk);
    vl ret(n, 1e15);
    priority_queue<ll, vl, greater<ll>> pq;
    for (int i = n - 1; i >= 0; --i) {
        pq.push(distyen[i] + distsnuuk[i]);
        ret[i] -= pq.top();
    }
    for (int i = 0; i < n; ++i) {
        cout << ret[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 23804
import sys
readline = sys.stdin.readline

N = int(readline())
ans = 0

for i in range(N):
    ans += (i+1)*(N-i)

for _ in range(N-1):
    u, v = map(int, readline().split())
    if v < u:
        u, v = v, u
    u -= 1
    v -= 1
    ans -= (u+1)*(N-v)

print(ans)

Measured memory_bytes: 73852
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

const ll mod = 1e9 + 7;

int main() {
    string S;
    cin >> S;

    ll cnt0 = 0, cnt1 = 1;
    for(char c : S) {
        (cnt0 *= 3) %= mod;
        if(c == '1') {
            (cnt0 += cnt1) %= mod;
            (cnt1 *= 2) %= mod;
        }
    }

    cout << (cnt0 + cnt1) % mod << endl;
    return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
from collections import Counter, deque

INF = float('inf')

""" Input
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
D = [int(input()) for _ in range(N)]
"""

def main():
    N = int(input())
    word_length = N // 2
    S = input().rstrip()

    if S[:word_length] == S[word_length:]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL K; cin >> K;
  LL cnt = 0;
  priority_queue<LL, vector<LL>, greater<LL>> que;

  for (LL i = 1; i < 10; ++i) {
    que.push(i);
  }
  LL v = -1;
  while (cnt != K) {
    v = que.top(); que.pop();
//    cout << v << endl;
    LL a = v % 10;
//    cout << "push :" << 10 * v + a << endl;
    que.push(10LL * v + a);
    if (a > 0) {
//      cout << "push :" << 10 * v + a-1 << endl;
      que.push(10LL * v + a - 1);
    }
    if (a < 9) {
      que.push(10LL * v + a + 1);
//      cout << "push :" << 10 * v + a+1 << endl;
    }
    ++cnt;
  }
  cout << v << endl;
}


Measured memory_bytes: 2420
def cross3(a, b, c):
    return (b[0] - a[0])*(c[1] - a[1]) - (b[1] - a[1])*(c[0] - a[0])
for line in open(0).readlines():
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    p1 = (x1, y1); p2 = (x2, y2); p3 = (x3, y3); pp = (xp, yp)
    if cross3(p1, p2, p3) < 0:
        p1, p2 = p2, p1
    if cross3(p1, p2, pp) > 0 and cross3(p1, pp, p3) > 0 and cross3(p2, p3, pp) > 0:
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int h[N], dp[N];
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  for (int i = 2; i < N; i++) {
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[N-1];
}

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

using namespace std;

typedef long long ll;

int main(){
    int a, b;
    cin>>a>>b;
    for(ll i=(ll)min(a, b);i<1e10+10;i+=(ll)min(a, b)){
        if(i%max(a, b)==0){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cmath>
#include <iomanip>  // std::setprecision
using namespace std;


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

  double T = M + H * 60;
  double thetaA = T * 2 * M_PI / (12 * 60);
  double thetaB = T * 2 * M_PI / 60;
  double ax = A * cos(thetaA);
  double ay = A * sin(thetaA);
  double bx = B * cos(thetaB);
  double by = B * sin(thetaB);

  cout << setprecision(11) << sqrt( pow(ax - bx, 2) + pow(ay - by, 2)) << endl;

  return 0;
}

Measured memory_bytes: 4068
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int     ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;


ll ch(ll ar[],ll n,ll x)
{
    ll ans=0;

    for(ll i=0; i<n; i++)
    {
        ans+=(ar[i]+x-1)/x-1;
    }
    return ans;


}



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    ll ar[n];
    for(ll i=0; i<n; i++)
    {
        cin>>ar[i];
    }
    ll l=1,r=1e9+10,m;
    while(l<r)
    {
        m=(l+r)/2;
        if(ch(ar,n,m)<=k)
        {
            r=m;
        }
        else
        {
            l = m+1;
        }

    }
    cout<<r<<nn;




}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***

*/





Measured memory_bytes: 5200
use std::io;


fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let input = read_line().split_whitespace().map(|x|x.parse::<i64>().unwrap()).collect::<Vec<i64>>();
    let N = input[0];
    let R = input[1];

    let K = 100 * (10-N);
    if N >= 10 {
        println!("{}",R);
    }else{
        println!("{}",R+K);
    }
}

Measured memory_bytes: 4352
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

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

  int n, m, cnt = 0;
  cin >> n >> m;

  vector<int> vec(n);
  vector<bool> ok(n,true);
  REP(i,n) cin >> vec[i];

  REP(j,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(vec[a] <= vec[b]) ok[a] = false;
    if(vec[a] >= vec[b]) ok[b] = false;
  }
  REP(i,n) if(ok[i]) cnt++;
  cout << cnt << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;


int main()
{
    ll n,k;
    cin >> n >> k;
    vector<pair<int,int> > p(n);
    for(int i = 0; i < n; i++){
        ll a,b;
        cin >> a >> b;
        p[i] = make_pair(a,b);
    }
    sort(p.begin(),p.end());
    ll cnt = 0;
    for(int i = 0; i < n; i++){
        cnt += p[i].second;
        if(cnt >= k){
            cout << p[i].first;
            break;
        }
    }
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();
		
		int len = S.length();
				
		int left = 0, right = 0;
		int addLeft = 0, addRight = 0;
		for(int i=0;i<len;i++) {
			if(S.charAt(i)=='(') {
				left++;
			}else {
				right++;
			}
			int leftLack = Math.max(0,right - left);
			addLeft += leftLack;
			left += leftLack;
		}
		
		addRight = Math.max(0, left-right);
		
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<addLeft;i++) {
			sb.append('(');
		}
		sb.append(S);
		for(int i=0;i<addRight;i++) {
			sb.append(')');
		}		
		
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 22612
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int LEN = 20;
LL memo[LEN+1][2][2];
int d[2*LEN+1];
vector<int> valid[LEN+1][2][2];
int s;
LL dp(int i, int e, int c)
{
	if(!(0 <= e && e <= 1))
		return 0;
	if(memo[i][e][c]!=-1)
		return memo[i][e][c];
	if(i==s-i-1)
		return memo[i][e][c] = c+d[i]==10*e ? 10 : 0;
	if(i+1==s-i-1)
	{
		int ans = 0;
		for(int y = 0; y <= 9; y++)
		{
			if(i==0 && y==0)
				continue;
			int x9 = 9*y+10*d[i+1]+d[i]+c-100*e;
			if(x9%9==0 && 0 <= x9/9 && x9/9 <= 9)
			{
				ans++;
				valid[i][e][c].push_back(x9/9);
			}
		}
		return memo[i][e][c] = ans;
	}
	LL ans = 0;
	for(int x = 0; x <= 9; x++)
	{
		int y = (x+d[i]+c)%10;
		if(i==0 && y==0)
			continue;
		int c_ = (x+d[i]+c)/10;
		int e_ = 10*e+x-(y+d[s-i-1]);
		ans += dp(i+1,e_,c_);
		if(dp(i+1,e_,c_) > 0)
		 	valid[i][e][c].push_back(x);
	}
	return memo[i][e][c] = ans;
}
int n[2*LEN+1];
int count = 0;
void reconstruct(int i, int e, int c)
{
	if(!(0 <= e && e <= 1))
		return;
	if(i > s-i-1)
	{
		//cout<<(++count)<<": ";
		for(int j = s-1; j >= 0; j--)
			cout<<n[j];
		cout<<endl;
		return;
	}
	if(i==s-i-1)
	{
		for(int x = 0; x <= 9; x++)
		{
			n[i] = x;
			reconstruct(i+1,e,c);
		}
	}
	for(const int& x : valid[i][e][c])
	{
		int y = (x+d[i]+c)%10;
		int c_ = (x+d[i]+c)/10;
		int e_ = 10*e+x-(y+d[s-i-1]);
		n[i] = x;
		n[s-i-1] = y;
		reconstruct(i+1,e_,c_);
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	memset(d,0,sizeof d);
	int D; cin >> D;
	//cout<<D<<endl;
	int len;
	for(len = 0; D > 0; len++, D/=10)
		d[len] = D%10;

	LL ans = 0;
	for(s = len; s <= 2*LEN; s++)
	{
		memset(memo,-1,sizeof memo);
		ans += dp(0,0,0);
		// if(dp(0,0,0) > 0)
		// {
		// 	cout<<dp(0,0,0)<<endl;
		// 	reconstruct(0,0,0);
		// }
	}
	cout<<ans<<endl;

	cout<<flush;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

struct Info{
	int hour,minute;
};

int main(){

	int N,M;
	Info info[220];

	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		scanf("%d %d",&info[i].hour,&info[i].minute);
	}

	scanf("%d",&M);

	for(int i = 0; i < M; i++){
		scanf("%d %d",&info[N+i].hour,&info[N+i].minute);
	}

	for(int i = 1; i <= N+M-1; i++){
		for(int k = N+M-1; k >= i; k--){
			if(info[k].hour < info[k-1].hour)swap(info[k],info[k-1]);
			else if(info[k].hour == info[k-1].hour && info[k].minute < info[k-1].minute)swap(info[k],info[k-1]);
		}
	}

	int pre_hour = info[0].hour,pre_minute = info[0].minute;

	printf("%d:%02d",info[0].hour,info[0].minute);

	for(int i = 1; i <= N+M-1;i++){
		if(pre_hour != info[i].hour || pre_minute != info[i].minute){
			printf(" %d:%02d",info[i].hour,info[i].minute);
			pre_hour = info[i].hour;
			pre_minute = info[i].minute;
		}
	}
	printf("\n");


    return 0;
}

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	string s;
	string t;
	cin >> s >> t;

	int cnt = 0;
	for (int i = 0; i < sz(s); i++) {
		if (s[i] == t[i]) cnt++;
	}

	out(cnt);

	return 0;
}

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

static const int INF = 1 << 30;

class DPsolver {

private:
  const int numNode;
  std::vector<std::vector<int>> parentList;
  std::vector<int> dp;
  std::vector<bool> finished;
  template <class T> inline void chmax(T &a, const T &b) {
    if (a < b)
      a = b;
  }

public:
  DPsolver(const int n) : numNode{n} {
    parentList.assign(1 + numNode, {});
    dp.assign(1 + numNode, -INF);
    finished.assign(1 + numNode, false);
  }

  void setEdge(const int fromNode, const int toNode) {
    assert(1 <= fromNode and fromNode <= numNode);
    assert(1 <= toNode and toNode <= numNode);
    parentList[toNode].push_back(fromNode);
  }

  void solve() {
    for (int i = 1; i <= numNode; ++i)
      evalDP(i);
  }

  int evalDP(const int i) {
    assert(1 <= i and i <= numNode);
    if (finished[i])
      return dp[i];
    if (parentList[i].empty()) {
      dp[i] = 0;
      finished[i] = true;
      return dp[i];
    }
    for (auto j : parentList[i]) {
      assert(1 <= j and j <= numNode);
      chmax(dp[i], evalDP(j) + 1);
    }
    finished[i] = true;
    return dp[i];
  }

  int getMax() {
    int result = -1;
    for (auto v : dp)
      chmax(result, v);
    return result;
  }
};

int main() {
  int numNode;
  int numEdge;
  std::cin >> numNode >> numEdge;
  assert(2 <= numNode and numNode <= 1.0e+5);
  assert(1 <= numEdge and numEdge <= 1.0e+5);
  DPsolver solver(numNode);
  for (int e = 1; e <= numEdge; ++e) {
    int fromNode;
    int toNode;
    std::cin >> fromNode >> toNode;
    assert(1 <= fromNode and fromNode <= numNode);
    assert(1 <= toNode and toNode <= numNode);
    solver.setEdge(fromNode, toNode);
  }
  solver.solve();
  std::cout << solver.getMax() << std::endl;
  return 0;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

bool solve(ll w, ll h, ll K) {
    rep(i, w+1) rep(j, h+1) {
        ll w1 = i;
        ll h1 = j;
        ll w2 = w - w1;
        ll h2 = h - h1;
        if (w1 * h1 + w2 * h2 == K) return true;
    }
    return false;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll w, h, K; cin >> w >> h >> K;
    cout << vector<string>{"No", "Yes"}[solve(w, h, K)] << endl;
}


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

using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define all(vec) vec.begin(),vec.end()
#define ff first
#define ss second
#define inf 4e18
#define MOD 1000000007
#define pb push_back
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for2(low,high,k) for(int j=low;j<high;j+=k)
#define rev(high,low,k) for(int i=high;i>=low;i-=k) 

int main(){
	fast;
	string s,t;
	cin>>s>>t;
	int i;
	for (i=0;i<s.size();i++){
		if (s[i]!=t[i]) break;
	}
	if (i==s.size()) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
using namespace std;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		vector<int> a(n);
		rep(i,0,n) cin>>a[i];
		int MAX=a[0];
		rep(i,0,n){
			int sum=0;
			rep(j,i,n){
				sum+=a[j];
				MAX=max(MAX,sum);
			}
		}
		o(MAX);
	}
}

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

int main()
{
  int n,K;
  cin >> n >> K;
  int a[n],dp[n];
  
  for(int i=0; i<n; i++)
  {
   	cin >> a[i]; 
  }
  dp[0] = 0;
//   for (int i=1; i<K && i<n; i++)
//   {
//     dp[i] = abs(a[i-1]-a[i]);
//   }
  for(int i=1; i<n; i++)
  {
    //   cout << i << endl;
        int an = INT_MAX;
        dp[i] = an;
        for (int k=1; k<=K && (i-k >= 0); k++)
        {
            // cout << (i-k) << " " << dp[i] << endl;
        	dp[i] = min(dp[i],(dp[i-k]+abs(a[i]-a[i-k])));
        }
        // cout << endl;
  }
  cout << dp[n-1] << endl;
  return 0;
}


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

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

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

  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; i++) {
    int order = 0;
    scanf("%d", &order);
    A.at(i) = make_pair(i + 1, order);
  }

  sort(A.begin(), A.end(), compare_by_second);

  for (auto p : A) {
    cout << p.first << " ";
  }
  return 0;
}


Measured memory_bytes: 1536
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let s = read_as_string().chars().collect::<Vec<char>>();
    let n = s.len() + 1;

    let mut v = vec![0; n];
    let mut acc: u64 = 0;

    for i in 1..n {
        if s[i - 1] == '<' {
            acc += 1;
        } else {
            acc = 0;
        }
        v[i] = acc;
    }
    acc = 0;
    for i in (0..n - 1).rev() {
        if s[i] == '>' {
            acc += 1;
        } else {
            acc = 0;
        }
        v[i] = cmp::max(v[i], acc);
    }
    println!("{}", v.into_iter().sum::<u64>());
}


Measured memory_bytes: 10996
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int find_(int x,vector<int> &v){
    if(v[x]<0) return x;
    v[x]=find_(v[x],v);
    return v[x];
}

int same_(int a,int b,vector<int> &v){
    if(find_(a,v)==find_(b,v)) return 1;
    return 0;
}

void union_(int a,int b,vector<int> &v){
    if(same_(a,b,v)) return;
    int a_p=find_(a,v),b_p=find_(b,v);
    if(a_p>b_p) swap(a_p,b_p);
    v[a_p]+=v[b_p]; v[b_p]=a_p;
}

void print_v(vector<int> v){
    rep(i,v.size()) cout<<v[i]<<" ";
    cout<<endl;
}

int main() {
    int n,m,ans=0; cin>>n>>m;
    vector<pp> bridges(m);
    rep(i,m){
        int a,b; cin>>a>>b;
        a--; b--;
        bridges[i]=mk(a,b);
    }
    rep(i,m){
        vector<int> v(n,-1);
        rep(j,m){
            if(i==j) continue;
            int a,b;
            tie(a,b)=bridges[j];
            union_(a,b,v);
        }
        int a,b;
        tie(a,b)=bridges[i];
        if(same_(a,b,v)==0) ans++;
    }
    cout<<ans<<endl;
}

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

int main(){
  int n; 
  cin >> n;
  vector<int>a(n);
  for(int i = 0; i < n; i++)cin >> a[i];
  int ans = 0;
  bool even = true;
  while(even == true){
    for(int i = 0; i < n; i++){
      if(a[i]%2 != 0)even =false;
    }

    if(even == true){
      for(int i = 0; i < n; i++)a[i] /= 2;
      ans += 1;
    }

  }
  cout << ans << endl;
}


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

int main()
{
    long long int a,b,sum;
    cin >> a >> b;

    sum = a + b ;

    if(sum % 2 == 1)
    {
        cout << "IMPOSSIBLE" ;
    }
    else
    {
        sum = sum / 2 ;
        cout << sum;
    }
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    readln;
    auto vs = readln.split.to!(double[]);
    sort(vs);
    double w = vs[0];
    foreach (v; vs[1..$]) {
        w = (w+v)/2;
    }
    writefln("%.10f", w);
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,x,y) for(int i=(x);i<(y);i++)
#define rrep(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//?????§??¬?´???°
int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

signed main() {
	for (int x, y; cin >> x >> y&&x;) {
		if (x < y)swap(x, y);
		int cnt = 0;
		while (y) {
			cnt++;
			int xx = x;
			x = y;
			y = xx%y;
		}
		cout << x << " " << cnt << endl;		
	}
	return 0;
}

Measured memory_bytes: 2996
#include <iostream>

using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a<b) for(int i=0; i<b; i++) cout << a; 
    else for(int i=0; i<a; i++) cout << b; 
    cout << endl; 
    return 0;
}

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

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

vector<int> a(n);
vector<int> b(n);

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

long long int cnt=0;
long long int ans=0;

for(int i=n-1;i>=0;i--){
if((a[i]+cnt)%b[i]!=0){
ans+=b[i]-(a[i]+cnt)%b[i];
cnt+=b[i]-(a[i]+cnt)%b[i];
}}

cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
buttons = []
n.times do
  buttons.push(gets.to_i)
end
current_p = 1
next_p = 0
count = 0
(n + 1).times do
  if current_p == 2
    puts count
    exit
  elsif current_p == 0
    puts "-1"
    exit
  end
  count += 1
  next_p = buttons[current_p - 1]
  buttons[current_p - 1] = 0
  current_p = next_p
end

Measured memory_bytes: 2996
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}


#pragma endregion


static char s[200001], t[200001];

	int main(void) {
		int i,len,cnt=0;


		scanf("%s %s", s,t);
		len = strlen(s);
		for (i = 0; i < len; i++) {
			if (s[i] == t[i])continue;
			cnt++;
		}

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

		return 0;
	}







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

int n, m, num, max1, max2, ans, a[100005];

int main() {
	max1 = max2 = ans = 0;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = n; i; i--) {
		max1 = max(a[i], max1);
		num = max(max1 - a[i], num);
	}
	for (int i = n; i; i--) {
		max2 = max(a[i], max2);
		if (max2 - a[i] == num)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
N, x = list(map(int, input().split()))
a_list = list(map(int, input().split()))

ans = 0
total = 0

a_list.sort()

for i, a in enumerate(a_list):
    total += a

    if x < total:
        break
            
    elif i == len(a_list) - 1 and x > total:
        None
        
    else:
        ans += 1
    
print(ans)

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

typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    mf_graph<ll> graph(N * M + 2);
    rep(i, N) {
        rep(j, M) {
            if (S[i][j] == '#') continue;
            if ((i + j) % 2) {
                graph.add_edge(i * M + j, N * M + 1, 1);
            } else {
                graph.add_edge(M * N, i * M + j, 1);
                int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
                rep(k, 4) {
                    int nx = i + dx[k], ny = j + dy[k];
                    if (nx < 0 || nx >= N || ny < 0 || ny >= M) continue;
                    if (S[nx][ny] == '.') {
                        graph.add_edge(i * M + j, nx * M + ny, 1);
                    }
                }
            }
        }
    }
    cout << graph.flow(N * M , N * M + 1) << "\n";
    auto edges = graph.edges();
    for (auto e : edges) {
        if (e.from == N * M || e.to == N * M + 1 || e.flow == 0) continue;
        int i0 = e.from / M, j0 = e.from % M;
        int i1 = e.to / M, j1 = e.to % M;
        if (i0 + 1 == i1) {
            S[i0][j0] = 'v';
            S[i1][j1] = '^';
        }
        if (i0 - 1 == i1) {
            S[i0][j0] = '^';
            S[i1][j1] = 'v';
        }
        if (j0 + 1 == j1) {
            S[i0][j0] = '>';
            S[i1][j1] = '<';
        }
        if (j0 - 1 == j1) {
            S[i0][j0] = '<';
            S[i1][j1] = '>';
        }
    }
    rep(i, N) cout << S[i] << "\n";
}

Measured memory_bytes: 6392
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem C


if __name__ == '__main__':
    n = int(input())
    dp = [0] + [100001 for _ in range(n + 1)]

    # See:
    # https://www.youtube.com/watch?v=I-8BnRkq6Ow
    for i in range(1, n + 1):
        power = 1

        while power <= i:
            dp[i] = min(dp[i], dp[i - power] + 1)
            power *= 6

        power = 1

        while power <= i:
            dp[i] = min(dp[i], dp[i - power] + 1)
            power *= 9

    print(dp[n])


Measured memory_bytes: 4632
def main():
    N = int(input())
    s = input()
    cnt = {"R": 0, "B": 0}
    for c in s:
        cnt[c] += 1
    if cnt["R"] > cnt["B"]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
r,c=map(int,input().split())
L = [[0 for j in range(c)] for i in range(r)]
for j in range(r):
    L[j]=list(map(int,input().split()))
    L[j].append(sum(L[j]))
S = [0 for j in range(c+1)]
for j in range(c+1):
    for i in range(r):
        S[j]+=L[i][j]
L.append(S)
for i in range(r+1):
    for j in range(c+1):
        if j<c:
            print("{} ".format(L[i][j]),end="")
        else:
            print("{}".format(L[i][j]))


Measured memory_bytes: 6224