akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int R;
	cin >> R;
	printf("%.18f\n", acos(-1) * 2 * R);
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> b(n - 1,0);
    int ans = 0;
    rep(i,n - 1) {
        cin >> b[i];
    }

    ans += b[0];
    ans += b[n - 2];

    for(int i = 0; i < n - 2; i++) {
        ans += min(b[i], b[i + 1]);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	map<int,int> hsh;
	int n,cnt=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		hsh[x]++;
	}
	for(auto it=hsh.begin();it!=hsh.end();it++){
		if((it->second)%2)
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main(){
  int n, m, a, i;
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&a);
    n -= a;
  }
  if(n<0){
    printf("-1");
  }
  else{
    printf("%d",n);
  }
}

Measured memory_bytes: 1724
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
   int n;
   cin >> n;
   int k=1,c=0;
   while(n>0){
       c+=k;
       k*=2;
       n/=2;
   }
   cout << c << endl;
   
  
   return 0;
}




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

int main(){
    ll N;
    cin >> N;
    int s = sqrt(N);
    for(int i=s+1;i>0;i--){
        if(N%i==0){
            cout << (N/i-1)+(i-1) << endl;
            break;
        }
    }

}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, fr, ba;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> s;
  ll st = n, en = -1;
  rep(i, n) {
    if (s[i] == '(') {
      st = i;
      break;
    }
    cnt++;
  }
  rep(i, cnt) fr += "(";

  cnt = 0;
  rrrep(i, n - 1, 0) {
    if (s[i] == ')') {
      en = i;
      break;
    }
    cnt++;
  }
  rep(i, cnt) ba += ")";

  cnt = 0;
  rrep(i, st, en + 1) {
    if (s[i] == '(')
      cnt++;
    else
      cnt--;
    if (cnt < 0) {
      cnt = 0;
      fr += "(";
    }
  }
  if (cnt >= 1) {
    rep(i, cnt) ba += ")";
  }

  cout << fr << s << ba << "\n";
  return 0;
}

Measured memory_bytes: 256
n=input()
n=int(n)
a=input().split()
a=[int(i) for i in a]
z=[i if i>0 else i*-1 for i in a]
count=0
for i in a:
    if i<0:
        count+=1
if count%2==0:
    print(sum(z))
else:
    m=min(z)*2
    print(sum(z)-m)



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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    ll n,k,c;
    cin >> n >> k;
    for(c = 0; n > 0; n/=k, c++);
    cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL n;
  cin>>n;
  LL ma=0;
  for(LL i = 0;i*i<=n;++i){
    ma=i*i;
  }
  cout<<ma<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;
int main() {
	int N, p, ans, count[100001];
	scanf("%d", &N);
	for (int i = 0; i < 100001; i++) {
		count[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &p);
		count[p]++;
	}
	ans = 0;
	for (int i = 1; i < 100000; i++) {
		if (ans < count[i - 1] + count[i] + count[i + 1]) {
			ans = count[i - 1] + count[i] + count[i + 1];
		}
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author bcools
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] bells = new int[]{in.nextInt(), in.nextInt(), in.nextInt()};

            Arrays.sort(bells);
            out.println(bells[0] + bells[1]);


        }

    }
}



Measured memory_bytes: 21716
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int l = stdIn.nextInt();
        int a = l % 2019;
        int r = stdIn.nextInt();
        int b = r % 2019;
        boolean flag = false;
        
        for(int i = l; i <= r; i++){
            if(i % 2019 == 0){
                flag = true;
                break;
            }
        }
        
        if(a > b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        
        int min = 2018;
        
        if(a == b || flag == true){
            min = 0;
        }else{
            for(int i = a; i <= b - 1; i++){
                for(int j = a + 1; j <= b; j++){
                    if((i * j) % 2019 < min){
                        min = (i * j) % 2019;
                    }
                }
            }
        }
        
        
        System.out.println(min);
    }
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int k;
    cin >> k;
    int64_t res = 0;
    for (int i = 1; i <= k; ++i) {
    	for (int j = 1; j <= k; ++j) {
    		for (int x = 1; x <= k; ++x) {
    			res += __gcd(i, __gcd(j, x));
    		}
    	}
    }
    cout << res << '\n';
}

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

int n,m,d,x;
int A[101];
int main(){
  int i;
  cin >> n >> d >> x;
  for(i=0;i<n;i++)cin >> A[i];
  for(i=0;i<n;i++){
    x += d / A[i];
    if(d%A[i] != 0 )x++;
  }
  cout << x << endl;
    
  

  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio
	int x;
	cin>>x;

	if(x>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);

int main(){
	fastio()
	int N;cin>>N;
	string s;cin>>s;
	if(s.length()<=N){cout<<s; return 0;}
	string ans = s.substr(0,N);
	ans += "..."; cout<<ans;
	
	
	
	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int h, w;
char s[60][60];
int dx[3] = { -1,0,1 };
int dy[3] = { -1,0,1 };

int main()
{
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (s[i][j] != '#') {
				int cou = 0;
				for (int k = -1; k <= 1; k++) {
					for (int l = -1; l <= 1; l++) {
						if (s[i + k][j + l] == '#')cou++;
					}
				}
				s[i][j] = (char)(cou+'0');
			}
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cout<< s[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
        #pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize("unroll-loops")
         
        #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
         
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        const double eps = 1e-9;
         
        mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
        
        signed main()
        {
        	int n,k;
        	cin>>n>>k;
        	int p=n%k;
        	cout<<min(p,k-p);
		}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int mod=1000000007;
int main(){
   int n;
   cin>>n;
   vector<int>a(n);
   rep(i,n) cin>>a.at(i);
   int ans=0;
   int x=0;
   rep(i,n){
       ans=((ll)ans+(ll)a.at(i)*x)%mod;
       x=(x+a.at(i))%mod;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }


void solve(void)
{
  int D;
  ull G;
  cin >> D >> G;
  
  vector<pair<int, ull>> P(D);
  for(int i = 0; i < D; ++i)
  {
    cin
      >> P[i].first
      >> P[i].second;
  }
  
  vector<ull> res{};
  res.reserve(2048);
  ull it = 1 << D;
  while(it)
  {
    pair<int, ull> score{};
    for(int i = 0; i < D; ++i)
    {
      if(it & 1 << i)
      {
        score.first += P[i].first;
        score.second += P[i].first * (i + 1) * 100 + P[i].second;
      }
    }

    if(score.second >= G)
    {
      res.push_back(score.first);
    }
    else
    {
      int p = -1;
      for(int i = D - 1; i >= 0; --i)
      {
        if(!(it & 1 << i))
        {
          p = i;
          break;
        }
      }
      if(p != -1)
      {
        auto sc = (p + 1) * 100;
        auto num = ((G - score.second) + (sc - 1)) / sc;
        if(num <= P[p].first)
        {
          score.first += num;
          score.second += sc * num;
          assert(score.second >= G);
          res.push_back(score.first);
        }
      }
    }
    --it;
  }

  auto ans = boost::min_element(res);
  cout << *ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 400000
int a, b, c, d, e, cntB = 0, cntF =0;
int query[N];
int pushBack(void);
int randomAccess(void);
int popBack(void);
int main(void){
     scanf("%d", &a);
     e = 1;
     for (int i=0; i<a; i++){
          scanf("%d", &b);
          if (b == 0) pushBack();         
          else if (b == 1) randomAccess();
          else if (b == 2) popBack();
     }
     return 0;
}
int pushBack(void){
     scanf("%d%d", &d, &c);
     //printf("%d%d\n", d,c);
     if (cntB == 0 && d==1 && e==1){query[cntB]=c;  e=0; /*printf("query cntB %d\n", query[cntB]);*/return 0;}
     if (cntF == 0 && d==1 && e==1){query[cntF]=c; cntF--; e=0; return 0;}
     if (d == 0) { if (cntF == 0) cntF = 399999; else cntF--; query[cntF] = c; /*printf("query cntF %d\n", query[cntF]);*/}
     else if (d == 1) { if (cntB == 399999) cntB = 0; else cntB++; query[cntB] = c; /*printf("query cntB %d\n", query[cntB]);*/}
     //printf("cntF%d cntB%d\n", cntF, cntB);
     return 0;
}
int randomAccess(void){
     scanf("%d", &c);
     //printf("p=%d\n", c);
     //if (cntF==cntB){printf("%d\n", query[cntF]); return 0;}
     if (cntF+c>399999){printf("%d\n", query[(cntF+c)-400000]); return 0;}
     printf("%d\n", query[(cntF+c)]);
     return 0;
}
int popBack(void){
     scanf("%d", &d);
     //if (cntB == cntF){query[cntB]=0; return 0;}
     if (d == 0) { query[cntF] = 0; if (cntF == 399999) cntF = 0; else cntF++; }
     else if (d == 1) {query[cntB] = 0; if (cntB == 0) cntB = 399999; else cntB--;}
     return 0;
}


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

int main()
{
    
    string S;
    cin >> S;
    
    string str = "";
    
    int count = 0;
    for (int i = 1; i < S.size()-1; i++) {
        count++;
    }

    cout << S[0] << count << S[S.size()-1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    l = [0]
    d = 0
    for a in A:
        d += a
        l.append(d)
    c = 0
    for a in l:
        if a <= M:
            c += 1

    return c

print(solve())

Measured memory_bytes: 3060
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Algorithms.Intro as VA
main=print.solve.map((\[a,b]->(a,b)).unfoldr(B.readInt.B.dropWhile isSpace)).B.lines=<<B.getContents
solve((n,m):ab)=fst.V.foldr f(0,maxBound)$V.modify VA.sort$V.fromList ab
f(a,b)(k,i)=if i<b then (k,i) else (k+1,a)

Measured memory_bytes: 11860
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 100000;
int N, M;

vector<pair<int, int> > ab_pairs;

void solve() {
    // bの昇順にならべかえる
    sort(ab_pairs.begin(), ab_pairs.end());

    int before_removed = 0;
    int sum = 0;
    int a, b;
    for (int i = 0; i < M; i++) {
        a = ab_pairs[i].second, b = ab_pairs[i].first;
        if (before_removed >= a && before_removed < b) {
            continue;
        }
        before_removed = b - 1;
        sum++;
    }

    printf("%d\n", sum);
}

int main() {
    cin >> N >> M;
    int a, b;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        ab_pairs.emplace_back(make_pair(b, a));
    }
    solve();
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#include <map>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N;
ll a[200200];
int main(){
  cin >> N;
  rep(i,N){
    cin >> a[i];
  }
  for(int i=N-1;i>=0;i-=2){
    if(i == N-1) cout << a[i];
    else cout << " " <<  a[i];
  }
  if(N%2 == 0){
    for(int i=0;i<N;i+=2){
      cout << " " << a[i];
    }
  }
  else{
    for(int i=1;i<N;i+=2){
      cout << " " << a[i];
    }
  }
  cout << endl;
}


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



int main() {
  long H;
  int N;
  int ans = 0;
  int t = 0;
  
  cin >> N >> H;
  for(int i=0;i<N-1;++i){
    long h; cin >> h;
    if(h <= H){
      t++;
    }else{
      if(t > ans){
        ans = t;
      }
      t = 0;
    }
    H = h;
  }

  if(t > ans){
    ans = t;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
 
#define MOD 1000000007
void init();
void solve();

signed main()
{
    init();
    solve();
}

void init()
{
	int N;
	cin >> N;
	int res = INT_MAX;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		res = min(a+b, res);
	}
	cout << res << endl;
}

void solve()
{
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> l(N);
  vector<int> r(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> l[i] >> r[i];
    sum += r[i]-l[i] +1;
  }
  cout << sum << endl;
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int N, X; cin >> N >> X;
    vector<int> m(N);
    int sum = 0, cnt = 0;
    for (int i = 0; i < N; i++) {
        cin >> m.at(i);
        sum += m.at(i);
        cnt++;
    }
    sort(m.begin(), m.end());
    while (sum + m.at(0) <= X) {
        sum += m.at(0);
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc123/tasks/abc123_a
function setUp(input) {
  input = input.split("\n");
  a = Number(input[0]);
  b = Number(input[1]);
  c = Number(input[2]);
  d = Number(input[3]);
  e = Number(input[4]);
  k = Number(input[5]);
  list = [a, b, c, d, e];
  main();
}
function main() {
  var falseFlag = false;
  for (var i = 0; i < 5; i++) {
    for (var j = i + 1; j < 5; j++) {
      if (Math.abs(list[i] - list[j]) > k) {
        falseFlag = true;
      }
    }
  }
  console.log(falseFlag ? ':(' : 'Yay!');
}

setUp(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
//id:miiifa (AOJ,PEどちらも)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
// #ifdef DEBUG 

class datast{
    public:
        deque<int> A;
        datast(){
        }
        void judge(string s){
            int x;
            if(s=="insert") {
                cin >> x;
                insert(x);
            }
            else if(s=="delete") {
                cin >> x;
                del(x);
            }
            else if(s=="deleteFirst") deleteFirst();
            else if(s=="deleteLast") deleteLast();
        }
        void insert(int x){
            A.push_front(x);
        }
        void del(int x){
            REP(i,A.size()){
                if(A[i]==x){
                   A.erase(A.begin() + i); 
                   break; 

                } 
            }
        }
        void deleteFirst(){
            A.pop_front();
        } 
        void deleteLast(){
            A.pop_back();
        }
        void disp(){
            REP(i,A.size()){
                cout << A[i]<< ((i!=A.size()-1)?" ":"\n");
            }
        }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string com;
    int n,val;
    cin >> n;
    datast ds= datast();
    REP(i,n){
        cin >> com;
        ds.judge(com);
        // ds.disp();
    }
    ds.disp();
    return 0;
}


Measured memory_bytes: 7028
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n,m = map(int, sys.stdin.readline().split())
    l= [list(map(int,list(sys.stdin.readline().split()))) for i in range(n)]
    c=0
    if n ==1:
        print(l[0][0])
    else:
        for i in range(1,m+1):
            flag = 0
            for j in range(n):
                if i not in l[j][1:]:
                    flag = 1
            if flag == 0:
                c+=1
        print(c)


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n;
  cin >> n;
  
  unordered_map<string,int> list;
  
  string s;
  rep(i,n){
    cin >> s;
    list.insert({s,1});
  }
  
  cout << list.size() << endl;
}



Measured memory_bytes: 17692
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0 ; i < n ; i++) {
            p[i] = sc.nextInt();
        }
        int min = 10000000;
        int count = 0;
        for (int i = 0 ; i < n ; i++) {
            if (p[i] < min) {
                count++;
                min = p[i];
            }
        }
        System.out.println(count);
    }

}


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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/*------------------------------↓ここからコード↓----------------------------------*/
void solve(){
    int N;
    cin >> N;
    string stone;
    cin >> stone;
    int left, right;
    left = 0;
    right = N-1;
    int ans = 0;
    while(left < right){
        if(stone[left] == 'R'){
            left++;
        }
        if(stone[right] == 'W'){
            right--;
        }
        if(stone[left] == 'W' && stone[right] == 'R'){
            ans++;
            left++;
            right--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int main()
{
    boost;
    ll n,i,j,x,t,m;
    cin>>n>>m>>x;
    n=max(n,m);
    ll ans=ceil(x*1.0/n);
    cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N;
long long A[100005];

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	long long ret = 0;

	for(int i = 0; i < N; i++){
		ret += A[i]/2;
		if(A[i]%2 == 1 && A[i+1] > 0){
			A[i+1]--;
			ret++;
		}
	}
	cout << ret << endl;

}

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

signed main(void)
{
	set<int> st;
	int n, i;
	cin >> n;
	st.insert(n);
	i = 1;
	while(true)
	{
		if (n % 2 == 0) n = n / 2;
		else n = 3 * n + 1;
		if (!st.count(n))
			st.insert(n);
		else
			break;
		i++;
	}
	cout << i + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadText().ToCharArray();
            if (N[0] == N[1] && N[1] == N[2])
            {
                return "Yes";
            }
            else if (N[1] == N[2] && N[2] == N[3])
            {
                return "Yes";
            }
            return "No";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 25884
#include <bits/stdc++.h>
#define int long long
using namespace std;


signed main() {
  int N, M;
  cin >> N >> M;
  
  int ans = 0;
  if( M >= N*2 ){
    ans += N;
    M -= 2*N;
    ans += M / 4;
    cout << ans << endl;
  }else{
    ans += M / 2;
    cout << ans << endl;
  }
  
}


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

int main(){
    vector<bool> num(10, false);
    char x;
    char y = 'a';
    for (int i = 0; i < 4; i++){
        cin >> x;
        if (x == y) {
            cout << "Bad" << endl;
            exit(0);
        }
        y = x;
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
struct edge
{
    int n,nxt,v;
    edge(int n,int nxt,int v)
    {
        this->n=n;
        this->nxt=nxt;
        this->v=v;
    }
    edge(){}
}e[200010];
int head[100010],ecnt=-1;
void add(int from,int to,int v)
{
    e[++ecnt]=edge(to,head[from],v);
    head[from]=ecnt;
}
int q[200100],l=100000,r=100000;
int dis[100100];
int main()
{
    memset(head,-1,sizeof(head));
    memset(dis,0x3f,sizeof(dis));
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i)
    {
        add(i,(i+1)%n,1);
        add(i,i*10%n,0);
    }
    q[++r]=1;
    dis[1]=1;
    while(l<r)
    {
        int x=q[++l];
        for(int i=head[x];~i;i=e[i].nxt)
            if(dis[e[i].n]>dis[x]+e[i].v)
            {
                dis[e[i].n]=dis[x]+e[i].v;
                if(e[i].v)
                    q[++r]=e[i].n;
                else
                    q[l--]=e[i].n;
            }
    }
    printf("%d\n",dis[0]);
    return 0;
}


Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_125
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            int[] lefts = new int[n];
            lefts[0] = array[0];
            for(int i = 1; i < n ; i++)
            {
                lefts[i] = GCD(lefts[i - 1], array[i]);
            }
            int[] rights = new int[n];
            rights[n - 1] = array[n - 1];
            for(int i = n - 2; i >= 0; i--)
            {
                rights[i] = GCD(rights[i + 1], array[i]);
            }

            int res = Max(lefts[n - 2], rights[1]);
            for (int i = 1; i < n - 1; i++)
            {
                res = Max(res, GCD(lefts[i - 1], rights[i + 1]));
            }
            WriteLine(res);
        }

        static int GCD(int a, int b)
        {
            if (b > a)
            {
                int temp = b;
                b = a;
                a = temp;
            }
            int c = b;
            do
            {
                c = a % b;
                a = b;
                b = c;
            } while (c > 0);
            return a;
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

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

int main(void) {
  int n;
  cin >> n;
  cout << (n * 800) - ((n / 15) * 200) << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder09_09
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                string[] txy = Console.ReadLine().Split(' ');
                int t = int.Parse(txy[0]);
                int x = int.Parse(txy[1]);
                int y = int.Parse(txy[2]);
                if (t < x + y || t % 2 != (x + y) % 2)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 15160
N = int(input())
s = 0
for i in range(1, N):
  for j in range(i + 1, N + 1):
    if i + j + (N % 2) != N + 1:
      s+=1
print(s)
for i in range(1, N):
  for j in range(i + 1, N + 1):
    if i + j + (N % 2) != N + 1:
      print(i, j)


Measured memory_bytes: 42992
import java.io.*;
import java.util.Scanner;
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int n = 0;
		int r = 0;
		int answer = 0;
		
		while(in.hasNextInt()){
		    n = in.nextInt();
		    r = in.nextInt();
		    if (n>=1 && n<=10) {
		        if(r>=0 && r<=4111){
		            answer = (100)*(10-n) + r;
		            System.out.println(answer);
		        }
		    }else if (n>10){
		        answer=r;
		        System.out.println(answer);
		    } 
		    
		}
	}
}

Measured memory_bytes: 27068
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << (m == n ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts, OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

solve s t i n = if drop i s == take (n-i) t then i
                else solve s t (i+1) n

main = do
  [n] <- getInts
  s <- getLine
  t <- getLine
  print $ n + solve s t 0 n 


-- util
getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

substr :: Int -> Int -> B.ByteString -> B.ByteString
substr b l s = B.take l $ B.drop b s


Measured memory_bytes: 508
using System;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine();
        if (input == "Sunny")
        {
            Console.WriteLine("Cloudy");
        }
        else if (input == "Cloudy")
        {
            Console.WriteLine("Rainy");
        }
        else if (input == "Rainy")
        {
            Console.WriteLine("Sunny");
        }
    }
}


Measured memory_bytes: 11092
from collections import Counter
abc = list(map(int, input().split()))

ans = 0
m = max(abc)
for i in range(len(abc)):
    count = (m-abc[i])//2
    ans += count
    abc[i] = abc[i]+2*count

abc = Counter(abc)

if len(abc)==1:
    print(ans)
else:
    key = [k for k, v in abc.items() if v == 2][0]
    if key == m:
        print(ans+2)
    else:
        print(ans+1)


Measured memory_bytes: 9460
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

n = int(input())
uvw = [ list(myinput()) for _ in range(n-1) ]

g = [ [] for _ in range(n) ]
for i in range(n-1):
    u = uvw[i][0] - 1
    v = uvw[i][1] - 1
    w = uvw[i][2]
    g[u].append([v,w])
    g[v].append([u,w])
# print(g)

def bfs(g):
    ls_ans = [-1] * n
    ls_ans[0] = 0
    q = deque()
    q.append(0)
    while q:
        node = q.popleft()
        ls = g[node]
        # print(ls)
        for i in range(len(ls)):
            child = ls[i][0]
            weight = ls[i][1]
            if ls_ans[child]!=-1:
                pass
            elif ls_ans[node]==0 and weight%2==0:
                ls_ans[child] = 0
                q.append(child)
            elif ls_ans[node]==0 and weight%2==1:
                ls_ans[child] = 1
                q.append(child)
            elif ls_ans[node]==1 and weight%2==0:
                ls_ans[child] = 1
                q.append(child)
            elif ls_ans[node]==1 and weight%2==1:
                ls_ans[child] = 0
                q.append(child)
            else:
                print("error")
        # print(ls_ans)
    return ls_ans

ls_ans = bfs(g)
# print(ls_ans)

for i in range(n):
    print(ls_ans[i])

Measured memory_bytes: 100952
import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		int top = 0;
		String s;
		int stack[] = new int[101];
		
		while (scan.hasNext()) {
			s = scan.next();
			
			if (isNum(s)) {
				stack[top + 1] = Integer.parseInt(s);
				top++;
			} else if (top >= 2) {
				switch (s) {
				case "+":
					stack[top - 1] = stack[top - 1] + stack[top];
					top--;
					break;
				case "-":
					stack[top - 1] = stack[top - 1] - stack[top];
					top--;
					break;
				case "*":
					stack[top - 1] = stack[top - 1] * stack[top];
					top--;
					break;
				default:
					break;
				}
			}
		}
		scan.close();
		System.out.println(stack[top]);
		
	}
	
	public static boolean isNum( String str) {
		java.util.regex.Pattern pattern 
		= java.util.regex.Pattern.compile("^[0-9]*$");
		java.util.regex.Matcher matcher
		= pattern.matcher(str);
		
		return matcher.matches();
	}
}



Measured memory_bytes: 27084
v, e = map(int, input().split())
G = [[float('inf') for _ in range(v)] for i in range(v)]
for i in range(v):
    G[i][i] = 0
# print(G)
dist = [[float('inf') for i in range(v)] for j in range(v)]
for _ in range(e):
    s, t, d = map(int, input().split())
    dist[s][t] = d
for i in range(v):
    dist[i][i] = 0
# print(G)
for k in range(v):
    for i in range(v):
        for j in range(v):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) 
            if i == j and dist[i][j] < 0:
                print('NEGATIVE CYCLE')
                exit()
ans = [["INF"]*v for _ in range(v)]
for i in range(v):
    for j in range(v):
        if dist[i][j] != float('inf'):
            ans[i][j] = dist[i][j]
for i in range(v):
    print(*ans[i])




Measured memory_bytes: 6944
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
	int n;
	cin >> n;
	ll topNum = 0;
	ll linNum = 0;
	ll ans = 0;
	// n-1行2列の行列
	vector<vector<int>> line(n-1, vector<int>(2));
	rep(i, n - 1) {
		rep(j, 2) {
			cin >> line.at(i).at(j);
		}
	}
	// 頂点の数をかぞえる
	rep(i, n) {
		topNum = topNum + ((ll)n - (ll)i)* ((ll)i + 1);
	}
	// 辺の数を数える
	rep(i, n - 1) {
		// u < vの時
		if (line.at(i).at(0) < line.at(i).at(1)) {
			linNum = linNum + (ll)(line.at(i).at(0)) * (ll)(n - (line.at(i).at(1)) + 1);
		}
		// u > vの時
		else {
			linNum = linNum + (ll)(line.at(i).at(1)) * (ll)(n - (line.at(i).at(0)) + 1);
		}
	}
	ans = topNum - linNum;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14340
n = int(input())
a = list(map(int, input().split()))
d = {}
for key in a:
  d[key] = d.get(key, 0) + 1
sum = 0
for key in d:
  sum += d[key]*(d[key]-1)//2
for i in range(n):
  print(sum - d[a[i]] + 1)

Measured memory_bytes: 26524
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll x;
    cin >> x;
    if (x < 1200)
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ARC" << endl;
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int gv[105];
    cin>>n;
    for(int i=0;i<n;i++) cin>>gv[i];
    int flag=1;
    int cnt=0;
    while(flag){
        flag=0;
        for(int j=n-1;j>0;j--){
            if(gv[j]<gv[j-1]){
                swap(gv[j],gv[j-1]);
                flag=1;
                cnt++;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<gv[i];
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3100