akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

int main() {
	int R, G, B;
	int K;
	cin >> R >> G >> B >> K;
	for (int i = 0; i < K+1; i++) {
		if (G > R) {
			if (B > G) {
				cout << "Yes";
				return 0;
			}
			else {
				B = B * 2;
			}
		}
		else {
			G = G * 2;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int r, D, x;
  cin >> r >> D >> x;
  rep(i, 0, 10) {
    x = r * x - D;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int k, x;
  cin >> k >> x;
  vi ans;
  for (int i = x-(k-1); i <= x+(k-1); ++i) {
    ans.pb(i);
  }
  showv(ans);
  return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn
object Main extends App {

  val rn = StdIn.readLine().trim.toInt
  case class Card(suit: Char, num: Int){
    override def toString: String = s"$suit$num"
  }
  val ra = StdIn.readLine().trim.split(' ').map{ p =>
    Card(p.charAt(0), p.charAt(1).toString.toInt)
  }
  val ra1 = ra.clone()
  val ra2 = ra.clone()
  
  def isStable(a: Array[Card], after: Array[Card], n: Int): Boolean = {
    (0 until n).foreach{ i =>
      if(a(i).suit != after(i).suit) return false
    }
    true
  }
  
  def bubbleSort(a: Array[Card], n: Int): Array[Card] = {
    (0 until n).foreach{ i =>
      // println(s"bubble($i):" + a.toList)
      (n-1 until i by -1).foreach{ j =>
        if(a(j).num < a(j-1).num){
          val temp = a(j)
          a(j) = a(j-1)
          a(j-1) = temp
        }
      }
    }
    a
  }

  def selectionSort(a: Array[Card], n: Int): Array[Card] = {
    (0 until n).foreach{ i =>
      // println(s"selection($i):" + a.toList)

      var minj = i
      (i until n).foreach{ j =>
        minj = if(a(j).num < a(minj).num) j else minj
      }
      val temp = a(minj)
      a(minj) = a(i)
      a(i) = temp
    }
    a
  }
  
  val rbubble    = bubbleSort(ra1, rn)
  val rselection = selectionSort(ra2, rn)

  //println("ra:" + ra.toList.mkString(" "))
  println(rbubble.toList.mkString(" "))
  println("Stable")

  println(rselection.toList.mkString(" "))
  println(if(isStable(rbubble, rselection, rn)) "Stable" else "Not stable")

}



Measured memory_bytes: 44060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const ll INF = 1e16;

void solver(int N, vector<ll> &A, vector<ll> &B){

    vector<ll> A_copy(N);
    A_copy = A;
    sort(A_copy.begin(), A_copy.end());

    int mid = N/2-1;

    for(int i=0; i<N; ++i){
        if(A.at(i) > A_copy.at(mid)){
            B.at(i) = A_copy.at(mid);
        }
        else{
            B.at(i) = A_copy.at(mid+1);
        }
    }
    return;
}

int main(){

    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; ++i){
        cin >> A.at(i);
    }

    vector<ll> B(N);
    solver(N, A, B);

    for(int i=0; i<N; ++i){
        cout << B.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 7852
x,y=input().split()
l=['A','B','C','D','E','F']
z=0
for i in range(6):
  if l[i]==x==y:
    print('=')
    exit()
  elif l[i]==x:
    print('<')
    exit()
  elif l[i]==y:
    print('>')
    exit()

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"
#define MOD 1000000007

typedef long lint;
typedef pair<lint, lint> P;
bool lessPair(const P& l, const P& r){return l.second < r.second;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    lint A; cin >> A;
    lint B; cin >> B;

    cout << min(A, B) << " " << max(lint(0), min(A,B)-(N-max(A,B))) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int t, cnt_5=0, cnt_7 = 0;

	for (int i = 0; i < 3; i++) {
		cin >> t;
		if (t == 5)
			cnt_5++;
		if (t == 7)
			cnt_7++;
	}

	if (cnt_5 == 2 && cnt_7 == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

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

int main() {
  int D,N;
  cin >> D >> N;
  
  vector<int> hws(N);
  for (int i=0;i < N;i++) {
    cin >> hws.at(i);
  }
  for (int i=0;i < N;i++) {
    D -= hws.at(i);
  }
  if (D<0) {
    cout << "-1" << endl;
  }
  else {
    cout << D << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp;
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        ++mp[a[i]];
        sum += a[i];
    }
    ll q;
    cin >> q;
    vector<pair<ll, ll>> bc(q);
    rep(i, q) {
        ll b, c;
        cin >> b >> c;
        bc[i] = make_pair(b, c);
    }
    rep(i, q) {
        //for (auto p: mp) {
        //    cout << p.first << " " << p.second << endl;;
        //}
        sum += mp[bc[i].first] * (bc[i].second - bc[i].first);
        mp[bc[i].second] += mp[bc[i].first];
        mp[bc[i].first] = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 11388
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl


int main() {
	int N;
	cin >> N;
	wrln(N / 3);
	return 0;
}

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

const int INF =1e9;
const int MOD =1e9+7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
int n;
cin>>n;
cout<<(n+1)%2<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) cout << s[i];
  cout << endl;
}

Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_101_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 S      PIC X(4).
    01 tmp    PIC S9(1).
    01 ans    PIC 9(1).
    01 i      PIC 9(1).
    01 sary1.
        03 sary11 OCCURS 4.
            05 sary PIC X(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT S.

    MOVE S(1:1) TO sary(1).
    MOVE S(2:1) TO sary(2).
    MOVE S(3:1) TO sary(3).
    MOVE S(4:1) TO sary(4).

    MOVE 0 TO tmp.

    PERFORM VARYING i FROM 1 BY 1 UNTIL 4 < i
        IF sary(i) = '+' THEN
            COMPUTE tmp = tmp + 1
        ELSE
            COMPUTE tmp = tmp - 1
        END-IF
    END-PERFORM.

    IF 0 <= tmp THEN
        MOVE tmp TO ans
        DISPLAY ans
    ELSE
        DISPLAY tmp
    END-IF.

    STOP RUN.


Measured memory_bytes: 764
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	string s,t;
	cin >> s >> t;
	vector<string> subs;
	bool ok=false;
	for(int i=0; i<s.length()-t.length()+1; i++){
		for(int j=0; j<t.length(); j++){
			if(s[i+j]!='?' && s[i+j]!=t[j]){
				break;
			}
			if(j+1 == t.length()){
				ok = true;
				string str=s;
				str.replace(i,j+1,t);
				subs.push_back(str);
			}
		}
	}
	if(ok){
		for(int i=0; i<subs.size(); i++){
			replace(subs[i].begin(),subs[i].end(),'?','a');
		}
		sort(subs.begin(),subs.end());
		
		cout << subs[0] << endl;
	}else{
		cout << "UNRESTORABLE" << endl;
	}
	
}


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

using namespace std;

int main(){
  int a,b; cin >> a >> b;
  if(a <= 0 && b >= 0){
    cout << "Zero\n";
    return 0;
  }
  if(b < 0){
    int num = (b%2 - a%2 + 1) % 2;
    if(num % 2 == 0){
      cout << "Positive\n";
    }
    else{
      cout << "Negative\n";
    }
    return 0;
  }
  cout << "Positive\n";
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;


int main(){
    int a,b;
    cin>>a>>b;
    if(a==b)cout<<a+b<<endl;
    else cout<<2*max(a,b)-1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i=0; i<(int)(n); ++i)
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};
 
ll N;
ll A, B;
 
int main(){
  cin >> N >> A >> B;
  ll ans;
  if((B-A) % 2 == 0) {
    ans=(B-A)/2;
  } else {
    if((A-1) < (N-B)){
      // Aを動かす
      ans =  (A-1) + 1 + (B-A - 1) / 2;
    }else {
      ans = (N-B) + 1 +  (B-A - 1) / 2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	ll N;
	cin >> N;
	puts(N*(N - 1) / 2LL);
	
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
map<int,int> me;
int main()
{
	int a,n,out=0;cin>>n;
	rep(i,n){
		cin>>a;me[a]++;
	}
	map<int,int>::iterator it=me.begin();
	while(it!=me.end()){
		int x=(*it).fi,y=(*it).se;
		if(y<x) out+=y;else out+=y-x;
		it++;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


int main()
{
    int64_t x;
    cin >> x;
    int64_t cnt = 0, y = 100;
    while(true){
        y = (int64_t)(y * 1.01);
        cnt++;
        if(y >= x){
            pr(cnt);
            return 0;
        }
        
    }
    return 0;
}



Measured memory_bytes: 3596
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    string c; cin >> c;
    int cntr = 0, cntw = 0;
    rep(i, n) {
        if(c[i] == 'R') ++ cntr;
        else ++ cntw;
    }
    int ret1 = 0, ret2 = 0;
    rep(i, n) {
        if(i < cntr && c[i] == 'W') ++ ret1;
        if(i >= cntr && c[i] == 'R') ++ ret2;
    }
  assert(ret1 == ret2);
    cout << ret1  << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n; cin >> n;
    int amax = 0, amin = 10000;
    rep(i, n) {
        int a; cin >> a;
        amax = max(amax, a);
        amin = min(amin, a);
    }
    cout << amax - amin << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
typedef long long LL;
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define finish(x) {cout<<x<<'\n'; return;}
  
const int MAX = 500005; 
  
struct Query 
{ 
    int l, r, idx; 
}; 
  
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void solve(int arr[], int n, Query queries[], int q) 
{ 
    int bit[MAX]; 
    memset(bit, 0, sizeof(bit)); 
  
    int lvisit[MAX]; 
    MSV(lvisit, -1); 
  
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        if (lvisit[arr[i]] !=-1) 
            update (lvisit[arr[i]] + 1, -1, bit, n); 
  
        lvisit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    for (int i=0; i<q; i++) 
        cout << ans[i] << '\n'; 
} 
  
int main() 
{ 
    int n, q;
    scanf("%d %d", &n, &q);
    int a[n];
    for(int i=0;i<n;i++) scanf("%d", &a[i]);
    
    Query queries[q];
    for(int i=0;i<q;i++) {
        int ql, qr;
        scanf("%d %d", &ql, &qr);
        queries[i].l = ql-1;
        queries[i].r = qr-1;
        queries[i].idx = i; 
    }
    
    sort(queries, queries+q, cmp); 
    solve(a, n, queries, q); 
    return 0; 
}

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

int main(){
    ll N; cin >> N;
    vector<vector<pair<ll,ll>>> G(N+1);
    rep(i, 0, N-1){
        ll v, u, w;
        cin >> v >> u >> w;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }

    ll Q, K;
    cin >> Q >> K;
    ll srt = K;
    vector<ll> d(N+1, 1e18);
    
    /* dijkstra's scope */{
        priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> que;
        que.push({0, srt});
        d[srt] = 0;
        while(!que.empty()){
            auto q = que.top();
            que.pop();
            if(q.first > d[q.second]) continue;
            for(auto g : G[q.second]){
                if(d[g.first] <= q.first + g.second) continue;
                d[g.first] = q.first + g.second;
                que.push({d[g.first], g.first});
            }
        }
    }

    rep(q, 0, Q){
        ll x, y;
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 11120
#include<iostream>
#include<vector>
#include<queue>
#include<utility>

using namespace std;

bool cant[20][20];
int a,b,ans;

int main()
{
	while(cin >> a >> b,a)
	{
		for(int i = 0;i < 20;i++)for(int j = 0;j < 20;j++)
		{
			cant[i][j] = false;
		}
		
		ans = 0;
		int n;
		cin >> n;
		
		for(int i = 0;i < n;i++)
		{
			int x,y;
			cin >> x >> y;
			cant[x-1][y-1] = true;
		}
		
		queue<pair<int,int> > q;
		q.push(make_pair(0,0));
		
		while(!q.empty())
		{
			pair<int,int> tmp = q.front();q.pop();
			
			if(tmp.first == a-1 && tmp.second == b-1)
			{
				ans++;
				continue;
			}
			
			if(cant[tmp.first][tmp.second] == true)
			{
				continue;
			}
			
			if(tmp.first < a-1)
			{
				q.push(make_pair(tmp.first+1,tmp.second));
			}
			
			if(tmp.second < b-1)
			{
				q.push(make_pair(tmp.first,tmp.second+1));
			}
		}
		
		cout << ans << endl;
	}
		

	
	return 0;
}

Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
int main()
{
    string a,b;
    cin>>a>>b;
    int s=0;
    for(int i=0;i<a.length();i++)
        if(a[i]==b[i])
            s++;
    cout<<s<<endl;
//    int n;
//    cin>>n;

    return 0;
}


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

int main() {
  int n,n1;
  cin >> n;
  n1=n%10;
  if(n1==3){
  	cout << "bon" << endl;
  }
  else if(n1==0||n1==1||n1==6||n1==8){
  	cout << "pon" << endl;
  }
  else{
  	cout << "hon" << endl;
  }
}



Measured memory_bytes: 3592
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()
H = inpl()

H.sort()
H.reverse()

print(sum(H[k:]))

Measured memory_bytes: 52908
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{BufWriter, Write};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        s: chars,
    }
    let mut v = vec![];
    for i in 0..s.len() {
        v.push(s[i] as i64 - 48);
    }
    //bit全探索
    let n = s.len() - 1;
    let mut sum = 0i64;
    for bit in 0..(1 << n) {
        let mut num = 0i64;
        for i in 0..n + 1 {
            num = num * 10 + v[i];
            if bit & (1 << i) != 0 {
                sum += num;
                num = 0;
            }
        }
        sum += num;
    }
    puts!("{}\n", sum);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

long longsort(const void *a, const void *b){
	return *(long*)a - *(long*)b;
}

int main(){
	long ans=0,i,N,a[5],min=10000000000000001,minid;
	scanf("%ld",&N);
	for(i=0;i<5;i++){
		scanf("%ld",&a[i]);
		if(min>a[i]){
			min=a[i];
			minid=i;
		}
	}

	ans=(long)(N/a[minid]);
	if(N%a[minid]==0){
		ans=ans-1;
	}
	ans=(long)(ans+5);

	printf("%ld\n",ans);

	return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [chars; n],
        b: [chars; m],
    }
    for ai in 0..(n-m+1) {
        for aj in 0..(n-m+1) {
            let mut found = true;
            for bi in 0..m {
                for bj in 0..m {
                    if b[bi][bj] != a[ai+bi][aj+bj] {
                        found = false;
                    }
                }
            }
            if found {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

const int kMaxN = 100000;
const int kMaxM = NINTH_POWER_OF_TEN;

int N, M;
int A[kMaxN];
int ans = 0;

int B[kMaxN+1];
unordered_map<int, int> h;

signed main() {
  cin >> N >> M;
  REP(i, N) { cin >> A[i]; }

  B[0] = 0;
  ++h[0];
  REP(i, N) {
    B[i+1] = (B[i]+A[i])%M;
    ++h[B[i+1]];
  }

  for (auto it = h.begin(); it != h.end(); ++it) {
    ans += (it->second-1)*(it->second)/2;
  }

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


Measured memory_bytes: 4876
n, *L = map(int, open(0).read().split())
ab = L[:2 * n - 2]
c = sorted(L[2 * n - 2:])
con = [[] for _ in range(n)]
ans = [0] * n
tot = sum(c) - max(c)
for a, b in zip(*[iter(ab)] * 2):
	con[a - 1].append(b - 1)
	con[b - 1].append(a - 1)
vis = [0] * n
q = [0]
vis[0] = 1
while q:
	cur = q.pop()
	ans[cur] = c.pop()
	for nxt in con[cur]:
		if vis[nxt]:
			continue
		q.append(nxt)
		vis[nxt] = 1
print(tot)
print(*ans)


Measured memory_bytes: 6860
#include<bits/stdc++.h>
using namespace std;
vector<string> m;
vector<vector<int>> edge;

void output(int v,int depth){
    if(v!=0){
        for(int i=0;i<depth-1;i++){
            cout<<".";
        }
        cout<<m[v-1]<<endl;
    }
    for(int i=0;i<edge[v].size();i++){
        output(edge[v][i],depth+1);
    }
    return;
}
int main(){    
    int n;
    cin>>n; 
    m.resize(n);
    edge.resize(n+1);    
    for(int i=0;i<n;i++){
        int k;
        cin>>k>>m[i];
        edge[k].push_back(i+1);
    }
    output(0,0);
    return 0;
}

Measured memory_bytes: 3420
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  vector<bool> memo(1000005, true);
  vector<int> cnt(1000005, 0);
  rep(i, n) {
    cnt[a[i]]++;
    int b = 2 * a[i];
    if(cnt[a[i]] == 1) {
      while(b <= 1000000) {
        memo[b] = false;
        b += a[i];
      }
    }
  }
  int ans = 0;
  rep(i, n) {
    if(cnt[a[i]] == 1 && memo[a[i]]) ans++;
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N;
int A[114514];
int B[114514];

int asumisu;
int mizuhasu[271828];

int sintasu(int dachaann) {
	int l = 0, r = asumisu - 1;
	while (l <= r) {
		int m = l + (r - l) / 2;
		if (mizuhasu[m] == dachaann) return m;
		else if (mizuhasu[m] < dachaann) l = m + 1;
		else r = m - 1;
	}
	exit(2);
	return 0;
}

int hanazawakana[271828];

int main(void) {
	int i;
	int hayamisaori;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &A[i], &B[i]) != 2) return 1;
		mizuhasu[i * 2] = A[i];
		mizuhasu[i * 2 + 1] = B[i] + 1;
	}
	qsort(mizuhasu, N * 2, sizeof(*mizuhasu), cmp);
	asumisu = 1;
	for (i = 1; i < N * 2; i++) {
		if (mizuhasu[asumisu - 1] != mizuhasu[i]) {
			mizuhasu[asumisu++] = mizuhasu[i];
		}
	}
	for (i = 0; i < N; i++) {
		hanazawakana[sintasu(A[i])]++;
		hanazawakana[sintasu(B[i] + 1)]--;
	}
	for (i = 1; i < asumisu; i++) {
		hanazawakana[i] += hanazawakana[i - 1];
	}
	hayamisaori = 0;
	for (i = 0; i < asumisu; i++) {
		if (hanazawakana[i] > hayamisaori) hayamisaori = hanazawakana[i];
	}
	printf("%d\n", hayamisaori);
	return 0;
}



Measured memory_bytes: 4220
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}
 
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e4 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readb(n, m);

    cout << n*(n - 1)/2 + m*(m - 1)/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a>=13){
    cout << b << endl;
  }
  else if(a>=6 && a<=12){
    cout << b/2 << endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, int v) {
    seen[v] = true;
    int count = 0;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        count += dfs(G, next_v); // 再帰的に探索
    }
    count++;
    return count;
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);
    }

    // 全頂点が訪問済みになるまで探索
    int max_ = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        max_ = max(max_, dfs(G, v)); // v が未探索なら v を始点とした DFS を行う
    }
    cout << max_ << endl;
}

Measured memory_bytes: 23516
from collections import defaultdict
import sys
sys.setrecursionlimit(10000)


N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

num_dict = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6
}
A.sort(reverse=True)

# dpを計算
dp = defaultdict(lambda: -1e18)
dp[0] = 0

for i in range(2, N+1):
    dp[i] = max([dp[i-num_dict[a]]+1 for a in A])

num_count = dp[N]

out_list = []
res_N = N
for _ in range(num_count):
    for a in A:
        if dp[res_N]-1 == dp[res_N-num_dict[a]]:
            out_list.append(str(a))
            res_N = res_N - num_dict[a]
            break

print(''.join(out_list))


Measured memory_bytes: 4720
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <iomanip>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
int union_find[200000] = {};
vector<int> human[200000];
vector<int> language[200000];
int language_visited[200000] = {};
int union_search(int now){
	if(union_find[now] == now) return now;
	return union_find[now] = union_search(union_find[now]);
}
int union_merge(int a,int b){
	a = union_search(a);
	b = union_search(b);
	union_find[a] = b;
	return 0;
}
int main(){
	int n,m;
	cin >> n >> m;
	REP(i,n){
		int a;
		cin >> a;
		REP(q,a){
			int b;
			cin >> b;
			language[b].push_back(i);
			human[i].push_back(b);
		}
		union_find[i] = i;
	}
	for(int i = 0;i < n;++i){
		for(int q = 0;q < human[i].size();++q){
			if(language_visited[human[i][q]] == 0){
				language_visited[human[i][q]] = 1;
				for(int j = 0;j < language[human[i][q]].size();++j){
					union_merge(i,language[human[i][q]][j]);
				}
			}
		}
	}
	for(int i = 0;i < n;++i){
		if(union_search(i) != union_search(0)){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 15096
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
int a[100], b[100];
signed main() {
	int n,ans=0;
	cin >> n;
	rep(i, n) {
		cin >> a[i] ;
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		if (a[i] > b[i])ans += a[i] - b[i];
	}
	cout << ans << endl;
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;
    string U; cin >> U;
    if (S == U) A--;
    else B--;
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h> // selection sort

#define N 100

int main(){

  int n; // array size
  int a[N]; //array
  int i,j; //loop
  int count = 0;
  
  // array size
  scanf("%d",&n);
  
  // array element
  for(i = 0 ; i < n ; i++){
    scanf("%d",&a[i]);
  }

  //selectionSort
  int minj;
  for(i = 0 ; i < n-1 ; i++){
    minj = i;
    for(j = i ; j < n ; j++){
      if(a[j] < a[minj]){
	minj = j;
      }
    }
    int memo;
    memo = a[i];
    a[i] = a[minj];
    a[minj] = memo;
    if(i != minj) count++;      
  }


// output
  for( i = 0 ; i < n ; i++){
    if(i > 0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",count);

  return 0;

}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define pi pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define mod 1000000007
#define inf 1000000000
using namespace std;
template <class T>
inline void read(T &a)
{static char c;int f=0;
while (((c=getchar())<'0'||c>'9')&&(c!='-'));
if (c=='-') {a=0;f=1;}
else {a=c-'0';}
while ((c=getchar())<='9'&&c>='0') a=(a<<3)+(a<<1)+c-'0';
if (f) a=-a;
}
int a[100005],n,ans=100000000;
int main (){
	int i,j,k;
	scanf ("%d",&n);
	for (i=1;i<=n-i;i++)
	{int a=i,b=n-i,res=0;
	while (a) res+=(a%10),a/=10;
	while (b) res+=(b%10),b/=10;
	if (res<ans) ans=res;
	}
	printf ("%d\n",ans);
	return 0;
}

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

int main() {
  int N, A, B, C, D;
  string s;
  cin >> N >> A >> B >> C >> D >> s;
  A--; B--; C--; D--;
  
  int dotsq = 0;
  int rocksq = 0;
  bool b = false;
  bool P = false;
  for (int i = A; i < max(C,D); i++) {
    if (s[i] == '.') {
      if (i >= B-1 && i <= D+1) dotsq += 1;
      rocksq = 0;
    }
    if (s[i] == '#') {
      dotsq = 0;
      rocksq += 1;
    }
    if (dotsq > 2) b = true;
    if (rocksq > 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  if (C > D) {
    if (b) P = true;
  }
  else P = true;
  
  if (P) cout << "Yes" << endl;
  else cout << "No" << endl;
 }


Measured memory_bytes: 640
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        if(a >= 3200){
            System.out.println(s);
        }else{
            System.out.println("red");
        }
	}
}

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

int main()
{
    int n,i;
    cin >> n;
    vector<int> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    int b,c,d;
    vector<int> l(n,0);
    vector<int> r(n,0);
    for(i = 1;i < n;++i){
        if(i == 1){
            l.at(i) = a.at(0);
        }else{
            if(a.at(i-1) > l.at(i-1)){
                b = a.at(i-1);
                c = l.at(i-1);
            }else{
                b = l.at(i-1);
                c = a.at(i-1);
            }
            d = b%c;
            while(d){
                b = c;
                c = d;
                d = b%c;
            }
            l.at(i) = c;
        }
    }
    for(i = n-2;i >= 0;--i){
        if(i == n-2){
            r.at(i) = a.at(i+1);
        }else{
            if(a.at(i+1) > r.at(i+1)){
                b = a.at(i+1);
                c = r.at(i+1);
            }else{
                b = r.at(i+1);
                c = a.at(i+1);
            }
            d = b%c;
            while(d){
                b = c;
                c = d;
                d = b%c;
            }
            r.at(i) = c;
        }
    }
    vector<int> t(n);
    for(i = 0;i < n;++i){
        if(i == 0){
            t.at(i) = r.at(i);
        }else if(i == n-1){
            t.at(i) = l.at(i);
        }else{
            if(l.at(i) > r.at(i)){
                b = l.at(i);
                c = r.at(i);
        }else{
            b = r.at(i);
            c = l.at(i);
        }
        d = b%c;
        while(d){
            b = c;
            c = d;
            d = b%c;
        }
        t.at(i) = c;
        }
        
    }
    int ans = t.at(0);
    for(i = 1;i < n;++i){
        if(ans < t.at(i)){
            ans = t.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
map<char,bool> arare;
int main(){
  int N;

  cin >> N;

  for(int i = 0;i < N;i++){
    char C; cin >> C;
    arare[C] = true;
  }

  int ans = 0;

  for(auto itr = arare.begin();itr != arare.end();itr++){
    if(itr->second)ans++;
  }

  if(ans == 3)cout << "Three" << endl;
  else cout << "Four" << endl;


}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c,d,e,f,g,h,i,j,z;
	scanf("%d %d %d %d %d %d %d %d %d %d",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
	z=a+b+c+d+e+f+g+h+i+j;
	printf("%d\n",z);
	return 0;
}

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

using namespace std;

#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define item pair<pii,int>

const int N = 1e5 + 7;

int n;
vector<item> l, r;

bool used[N];

bool cmp(item a, item b){
	return (a.fi.se < b.fi.se || (a.fi.se == b.fi.se && a.fi.fi < b.fi.fi));
}

signed main(){
	cin >> n;
	for(int i = 0; i < n; ++i){
		int L, R;
		cin >> L >> R;
		l.push_back({{L, R}, i});
	}
	l.push_back({{0, 0}, n});
	r = l;
	n = l.size();
	sort(begin(l), end(l));
	sort(begin(r), end(r), cmp);
	int ans = 0;
	
	for(int p1 = n - 1, p2 = 0, sl = 0, sr = 0; ; ){
		while(p1 >= 0 && used[l[p1].se]) --p1;
		if(p1 < 0) break;
		used[l[p1].se] = true;
		sl += l[p1].fi.fi;
		--p1;
		
		while(p2 < n && used[r[p2].se]) ++p2;
		if(p2 == n) break;
		used[r[p2].se] = true;
		sr += r[p2].fi.se;
		++p2;
		ans = max(ans, 2 * (sl - sr));
	}
	cout << ans;
}


Measured memory_bytes: 8192
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modPow(ll x,ll n,ll mod){if(n==0)return 1; if(n%2==0)return modPow(x*x,n/2,mod)%mod; return x%mod*modPow(x,n-1,mod)%mod;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    st s; cin >> s;
    Yes(s != "AAA" && s != "BBB");
}



Measured memory_bytes: 3588