akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        vi v(7,0);
        rep(i,n){
            int gotiusa_is_a_god_especially_tiya;
            cin>>gotiusa_is_a_god_especially_tiya;
            if(gotiusa_is_a_god_especially_tiya>=60)gotiusa_is_a_god_especially_tiya=60;
            v[gotiusa_is_a_god_especially_tiya/10]++;
        }
        rep(i,7)cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, w;std::cin >> n >> w;
  vll W(n), V(n);
  re(i, n) std::cin >> W[i] >> V[i];
  ll dp[n+1][n+1][4*(n+1)];
  re(i, n+1) re(j, n+1) re(k, 4*(n+1)) dp[i][j][k] = (i==0&&j==0?0:-1000000000000000000);
  rep(i, 1, n+1){
    rep(j, 0, n+1){
      rep(k, 0, 4*(n+1)){
        dp[i][j][k] = max(dp[i-1][j][k], dp[i][j][k]);
        if(k<(W[i-1]-W[0])||j==0) continue;
        dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k-(W[i-1]-W[0])] + V[i-1]);
      }
    }
  }
  ll ans = 0;
  re(i, n+1)re(j, n+1)re(k, 4*(n+1))if(j*W[0]+k<=w) ans = max(ans, dp[i][j][k]);
  std::cout << ans << '\n';
  return 0;
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int w[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.next());
                sum += w[i];
            }

            int b = sum;
            int b_pre = 0;
            for (int i = 0; i < n; i++) {
                b_pre += w[i];
                b = Math.min(b, Math.abs(b_pre - (sum - b_pre)));
            }
            out.println(b);
        }

    }
}



Measured memory_bytes: 23764
using System;

namespace ABC077_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            long max = 1;
            for (var i = 0; i <= n; i++)
            {
                var squ = i * i;
                if (squ > n)
                {
                    max = i - 1;
                    break;
                }
            }
            Console.WriteLine(max * max);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e8;
typedef pair<int,int> P;

int main(){
  ll N;cin>>N;
  ll a,b=-1;
  REP(i,0,N){
    cin>>a;
    if(a<b){
      print("No")
      return 0;
    }
    if(a-1>=b)a--;
    b=a;
  }
  print("Yes")
  return 0;
}


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

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


Measured memory_bytes: 3608
import scala.collection.mutable
import scala.io.StdIn._

object Main extends App {
  val n = readInt
  val nodes = Array.fill(n){Nil: List[(Int, Int)]}
  for (_ ← 1 until n){
    val Array(s, t, w) = readLine.trim.split(' ').map(_.toInt)
    nodes(s) ::= (t, w)
    nodes(t) ::=(s, w)
  }
  val queue = mutable.Queue(0)
  val distanceFromZero = Array.fill(n){-1}
  distanceFromZero(0) = 0
  while (queue.nonEmpty) {
    val current = queue.dequeue()
    for ((next, distance) ← nodes(current) if distanceFromZero(next) == -1) {
      distanceFromZero(next) = distanceFromZero(current) + distance
      queue.enqueue(next)
    }
  }
  val a = distanceFromZero.indices.maxBy(distanceFromZero)
  val distanceFromFurthestA = Array.fill(n){-1}
  distanceFromFurthestA(a) = 0
  queue.enqueue(a)
  while (queue.nonEmpty) {
    val current = queue.dequeue()
    for ((next, distance) ← nodes(current) if distanceFromFurthestA(next) == -1) {
      distanceFromFurthestA(next) = distanceFromFurthestA(current) + distance
      queue.enqueue(next)
    }
  }
  val b = distanceFromFurthestA.indices.maxBy(distanceFromFurthestA)
  val distanceFromFurthestB = Array.fill(n){-1}
  distanceFromFurthestB(b) = 0
  queue.enqueue(b)
  while(queue.nonEmpty) {
    val current = queue.dequeue()
    for ((next, distance) ← nodes(current) if distanceFromFurthestB(next) == -1) {
      distanceFromFurthestB(next) = distanceFromFurthestB(current) + distance
      queue.enqueue(next)
    }
  }
  for (i ← 0 until n){
    println(math.max(distanceFromFurthestA(i), distanceFromFurthestB(i)))
  }
}



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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 2e5 + 5;
int arr[MAX], dp[MAX];

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

	int n;
	cin >> n;

	int ans = 0;
	fori(i, 1, n + 1) {
		cin >> arr[i];
		dp[arr[i]] = dp[arr[i] - 1] + 1;
		ans = max(ans, dp[arr[i]]);
	}

	cout << n - ans << '\n';

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  rep(i, n-1) {
    if(i+1 == p[i]) {
      ans++;
      swap(p[i], p[i+1]);
    }
  }
  if(n == p[n-1]) ans++;
  out(ans);
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		char[] si = str.toCharArray();
		int count = 0;

		for (int i = 0; i < si.length; i++) {
			if(si[i]== '1') {
				count++;
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 21716
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm> 
using namespace std;
typedef long long ll;
const int MAX=100010;
ll A[MAX],B[MAX],C[MAX];
int main(){
	ll N,sum=0,x=0,y=0;cin>>N;
	for(int i=1;i<=N;i++)cin>>A[i];
	for(int i=1;i<=N;i++)cin>>B[i];
	for(int i=1;i<=N;i++)cin>>C[i];
	sort(A+1,A+N+1);sort(B+1,B+N+1);sort(C+1,C+N+1);
		for(int i=1;i<=N;i++){
			while(A[x+1]<B[i]&&x+1<=N)
				x++;
			while(C[y+1]<=B[i]&&y+1<=N)
				y++;
			sum+=x*(N-y);
		}
		cout<<sum<<endl;
		return 0;
}

Measured memory_bytes: 2560
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def solve():
    n = getN()
    S = getS()
    rev = 0
    ans = 1
    for c in S:
        if c == "W":
            if rev == 0:
                print(0)
                return
            if rev % 2 == 0:
                ans *= rev
                ans %= MOD
                rev -= 1
            else:
                rev += 1
        else:
            if rev % 2 == 1:
                ans *= rev
                ans %= MOD
                rev -= 1
            else:
                rev += 1
    # print(ans)
    if rev == 0:
        print((ans * kaijyo(n)[-1]) % MOD)
    else:
        print(0)

def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 80460
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    string s;
    cin >> s;
    string a = "";
    int n = s.length();
    rep(i,n) if(s[i]!='x') a+=s[i];
    
    rep(i, int(a.length())/2) if(a[i] != a[int(a.length())-1-i]){
        cout << -1 << endl;
        return 0;
    }
    
    int ans = 0;
    rep(i,n/2){
        //cout << s[i] << " " << s[n-1-i] << endl;
        if(s[i] == s[n-1-i]) continue;
        else if(s[i] == 'x') ans++, n++;
        else ans++, n--, i--;
    }
    
    cout << ans << endl;
    
    
    
    
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (ll i = 0;i < (a);++i)
#define FOR(i,a,b) for (ll i = (a);i < (b); ++i)
#define FORR(i,a,b) for (ll i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    ll n,p;
    ll answer = 1;
    cin >> n>> p;

    if (n == 1) {
        cout << p << endl;
        return 0;
    }
    
    vector<pair<ll,ll>> prime = prime_factorize(p);

    REP(i,prime.size()){
        if(prime[i].second >= n)answer = answer*pow(prime[i].first,(prime[i].second/n));
    }

    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 4040
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  vector<string>s(n);
  for(i=0; i<n; i++){
    cin >> s.at(i);
  }
  sort(s.begin(),s.end());
  int cnt=n;
  for(i=0; i<n-1; i++){
    int j=i+1;
    if(s.at(i)==s.at(j)){
      cnt--;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 9524
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

A = ri()
B = ri()
if(A == B):
    print("EQUAL")
else:
    print("GREATER" if A>B else "LESS")

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}

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

ll fpb(ll a, ll b) { return b == 0? a: fpb(b, a%b); }

int TC;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> TC;
	while (TC--) {
		ll A, B, C, D;
		cin >> A >> B >> C >> D;
		if (A < B) cout << "No\n";
		else if (D < B) cout << "No\n";
		else {
			ll mnm = min(1+D-B, C+1-B);
			ll gcd = fpb(B, D);
			ll cek = mnm/gcd*gcd;
			ll diff = A%gcd;
			cek += diff;
			if (cek-gcd >= mnm) cek -= gcd;
			if (cek < 0) cout << "No\n";
			else cout << "Yes\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Atcoder
{
    class Program
    //    ABC128 A - Apple Pie
    {
        private static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Restaurant[] rest = new Restaurant[n];

            for (var i = 0; i < n; i++)
            {
                var sp = Console.ReadLine().Split(' ');
                rest[i].o = i+1;
                rest[i].s = sp[0];
                rest[i].p = int.Parse(sp[1]);
            }

            rest = rest.OrderBy(x => x.s).ThenByDescending(x => x.p).ToArray();

            for (var i = 0; i < n; i++)
            {
                Console.WriteLine(rest[i].o);
            }

        }
    }
    public struct Restaurant
    {
        public int o;
        public string s;
        public int p;

        public Restaurant(int o, string s, int p)
        {
            this.o = o;
            this.s = s;
            this.p = p;
        }
    }
}


Measured memory_bytes: 13536
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <queue>
typedef long long LL;

struct Data {
  int x;
  int y;

  bool operator<(const auto &right) const {
    if (x == right.x) return y < right.y;
    else              return x < right.x;
  }
};

int main() {
  int N; std::cin >> N;
  std::vector<Data> d(N);
  std::vector<bool> b(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> d[i].x >> d[i].y;
    b[i] = false;
  }

  std::sort(d.begin(), d.end());

  std::map<std::pair<int, int>, int> m;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (i == j) continue;
      int diff_x, diff_y;
      diff_x = d[j].x - d[i].x;
      diff_y = d[j].y - d[i].y;

      auto p = std::make_pair(diff_x, diff_y);
      ++m[p];
    }
  }

  int vmax = 0;
  int p = -1, q = -1;
  for (auto a : m) {
    if (vmax < a.second) {
      p = a.first.first;
      q = a.first.second;
      vmax = a.second;
    }
  }
//  std::cout << p << " " << q << " " << std::endl;

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (b[i]) continue;
    ++cnt;
    bool found = true;
    int i2 = i;
    while (found) {
      found = false;
      for (int j = i2 + 1; j < N; ++j) {
        int diff_x, diff_y;
        diff_x = d[j].x - d[i2].x;
        diff_y = d[j].y - d[i2].y;

        if (diff_x == p && diff_y == q) {
          found = true;
          i2 = j;
          b[j] = true;
          break;
        }
      }
    }
  }

  std::cout << cnt << std::endl;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	char s[30];
	map<char,ll> m;
	ll cnt=1;
	cin >> s;
	for(ll i=0;s[i];i++){
		m[s[i]]++;
		cnt++;
		if(m[s[i]]==2){
			cout << -1 << endl;
			return 0;
		}
	}
	for(char c='z';c>='a';c--){
		if(m[c]==0){
			s[cnt]=c;
			cnt++;
		}
	}
	if(next_permutation(s,s+cnt)) cout << s << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

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

int main()
{
        int N;
        cin >> N;
        vector<int> vec(N + 1);
        for (int i = 0; i < N; i++)
        {
                cin >> vec[i];
        }

        int a = 0, cnt = 0;

        for (int i = 0; i < N; i++)
        {
                a = max(a, vec[i]);
                if (a == vec[i])
                {
                        cnt++;
                }
        }
        cout << cnt << endl;

        return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 18:36:13 2020

@author: NEC-PCuser
"""
n = int(input())
l = list(map(int, input().split()))
dic_gusu = {}
dic_kisu = {}

for i in range(0, n):
    if (i % 2 == 0):
        if (l[i] in dic_gusu):
            dic_gusu[l[i]] += 1
        else:
            dic_gusu[l[i]] = 1
    if (i % 2 == 1):
        if (l[i] in dic_kisu):
            dic_kisu[l[i]] += 1
        else:
            dic_kisu[l[i]] = 1
dic_kisu = sorted(dic_kisu.items(), key = lambda x : x[1])
dic_gusu = sorted(dic_gusu.items(), key = lambda x : x[1])

count = 0
if (len(dic_kisu) == 1 and len(dic_gusu) == 1 and dic_kisu[len(dic_kisu) - 1][0] == dic_gusu[len(dic_gusu) - 1][0]):
    count = n // 2
elif (dic_kisu[len(dic_kisu) - 1][0] != dic_gusu[len(dic_gusu) - 1][0]):
    for i in range(0, len(dic_kisu) - 1):
        count += dic_kisu[i][1]
    for i in range(0, len(dic_gusu) - 1):
        count += dic_gusu[i][1]
else:
    for i in range(0, len(dic_kisu)):
        count += dic_kisu[i][1]
    for i in range(0, len(dic_gusu)):
        count += dic_gusu[i][1]
    count_tmp = count
    count_ans = count_tmp - dic_kisu[len(dic_kisu) - 1][1] - dic_gusu[len(dic_gusu) - 2][1] 
    count_ans2 = count_tmp  - dic_kisu[len(dic_kisu) - 2][1] - dic_gusu[len(dic_gusu) - 1][1]
    count = min([count_ans, count_ans2])    
        
print(count)

Measured memory_bytes: 17688
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n;
    cin >> n;
    vector<ll>ans(4,0);
    for(int i=0;i<n;i++){
        string t;
        cin >>t;
        if(t=="AC")ans.at(0)++;
        if(t=="WA")ans.at(1)++;
        if(t=="TLE")ans.at(2)++;
        if(t=="RE")ans.at(3)++;
    }
    cout<<"AC x "<<ans.at(0)<<endl;
    cout<<"WA x "<<ans.at(1)<<endl;
    cout<<"TLE x "<<ans.at(2)<<endl;
    cout<<"RE x "<<ans.at(3)<<endl;
}
    



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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;

ll fact[100010];

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

	ll n,m;
	cin >> n >> m;

	fact[1] = 1;
	FOR(i,2,100001){
		fact[i] = (fact[i-1]* i) % MOD;
	}

	ll ans;
	if(m == n){
		ans = (2*((fact[n] * fact[n]) % MOD)) % MOD;
	}else if(m == n-1 || m == n+1){
		ans = (fact[n] * fact[m]) % MOD;
	}else{
		ans = 0;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	double n;
	cin >> n;
	double ans = n * n * n / 27.0;
	cout << fixed << setprecision(9) << ans;
	return 0;
}

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

int main(){
	ll N,M;
	cin >> N >> M;
	vector<ll> A(N),sum(N+1,0);
	for(int i=0;i<N;i++) cin >> A[i];
	sort(A.begin(),A.end());
	for(int i=1;i<=N;i++)sum[i] = sum[i-1] + A[i-1];

	ll ok=0,ng=300000,ans=0;
	while(ng-ok>1){
		ll mid = (ng+ok)/2;
		ll num = 0;
		ll anst = 0;
		ll ind = N;
		for(int i=0;i<N;i++){
			while( ind>0 && (A[ind-1] >= mid-A[i]) )ind--;
			num += N - ind;
			anst += (sum[N]-sum[ind])+A[i]*(N-ind);
		}
		if(num >= M){
			ok = mid;
			ans = anst - (num-M) * ok;
		}else{
			ng = mid;
		}
	}
	cout << ans << endl;
}


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

int main() {
  string a;
  cin>>a;
  if(a=="hi"||a=="hihi"||a=="hihihi"||a=="hihihihi"||a=="hihihihihi"){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;


int main() {
   string s;
   cin>>s;
   if(s.size() == 2)
        cout<<s<<endl;
   else if(s.size() == 3)
        cout<<s[2]<<s[1]<<s[0]<<endl;
    return 0;


}


Measured memory_bytes: 256
import itertools
import math
n = int(input())
l = list(itertools.permutations(range(n)))
X = []
Y = []
for i in range(n):
  x,y = map(int,input().split())
  X.append(x)
  Y.append(y)
result = []
for i in l:
  #print(i)
  d = 0
  for j in range(int(len(i))-1):
    d += math.sqrt((X[i[j]]-X[i[j+1]])**2 + (Y[i[j]]-Y[i[j+1]])**2)
    #print(d)
  result.append(d)
print(sum(result)/len(result))




Measured memory_bytes: 46704
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, X; cin >> N >> X;
	vector<int>L(N);
	for (int i = 0;i < N;i++) {
		cin >> L[i];
	}

	int cnt = 1,sum = 0;
	for (int i = 0;i < N;i++) {
		sum += L[i];
		if (sum <= X) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>

struct Vector2D {
	double x, y;

	Vector2D() : x(0.0), y(0.0) {}
	Vector2D(double init_x, double init_y) : x(init_x), y(init_y) {}
	Vector2D& operator-=(const Vector2D& rhs)
	{
		x -= rhs.x;
		y -= rhs.y;
		return *this;
	}
};

Vector2D operator-(const Vector2D& lhs, const Vector2D& rhs)
{
	return Vector2D(lhs) -= rhs;
}

int main()
{
	Vector2D p1, p2, p3, pp;
	while (std::cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y >> pp.x >> pp.y) {
		// p3-based vectors
		Vector2D r1(p1 - p3), r2(p2 - p3), rp(pp - p3);

		// rp = a1 * r1 + a2 * r2
		double det = r1.x * r2.y - r2.x * r1.y;
		double a1 = ( r2.y * rp.x - r2.x * rp.y) / det;
		double a2 = (-r1.y * rp.x + r1.x * rp.y) / det;

		if (a1 > 0 && a2 > 0 && a1 + a2 < 1.0) {
			std::cout << "YES" << std::endl;
		} else {
			std::cout << "NO" << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1220
x = input()
y = x.split(" ")
y = [int(z) for z in y]
c = 0
while c < 2:
    for z in range(0,2):
        if y[z] > y[z+1]:
            tmp = y[z+1]
            y[z+1] = y[z]
            y[z] = tmp
    c = c + 1
print("%d %d %d" % (y[0], y[1], y[2]))

Measured memory_bytes: 7752
// D - Flipping Signs
#include <bits/stdc++.h>
using namespace std;

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

	long long sum = 0;
	int mini = 1e9, minus_count = 0;

	for(int i=0; i<N; ++i){
		int a; cin>>a;
		if(a<0){ a = -a; ++minus_count; }
		mini = min(mini, a);
		sum += a;
	}

	if(minus_count%2) sum -= mini*2;
	cout<< sum <<endl;
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: map(fn, input().split())
gete = lambda fn: fn(input())

def main():
	n=gete(int)
	dp=[[0]*3 for _ in range(n+1)]
	
	
	for i in range(n):
		a,b,c = map(int, input().split())
		dp[i+1][0] = max(dp[i][1], dp[i][2]) + a
		dp[i+1][1] = max(dp[i][2], dp[i][0]) + b
		dp[i+1][2] = max(dp[i][0], dp[i][1]) + c
		
	print(max(dp[n][0],dp[n][1],dp[n][2]))
	
	
	
if __name__ == "__main__":
	main()

Measured memory_bytes: 59500
#include <bits//stdc++.h>
using namespace std;
typedef long long int ll;
int main(void) {
	int a, b;
	cin >> a >> b;
	for (int i = 1;i <= 510000;i++) {
		if (floor(i * 2 / 25) == a && floor(i * 1 / 10) == b) {
			cout << i << endl;
			break;
		}
		if (i == 510000)
			cout << -1 << endl;
	}
}

Measured memory_bytes: 256
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for Ai in A:
    d = 0
    for a, b in zip(Ai, B):
        d += a * b
    d += C
    if d > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

const MOD: u64 = 1_000_000_000 + 7;

fn main() {
    input! {
        n: usize,
        A: [u64; n],
    }
    let mut ans: u64 = 0;
    let mut sums: u64 = A.iter().sum();
    for i in 0..n {
        sums -= A[i];
        ans += A[i] * (sums % MOD) % MOD;
        ans %= MOD;
    }

    println!("{}", ans % MOD);
}


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

int dis0[100005], dis1[100005];

struct edge {
    int to, next;
} eg[200010];
int head[100005], tot = 0;

void init() {
    memset(head, 0xff, sizeof(head));
    tot = 0;
}

void addedge(int from, int to) {
    eg[tot] = {to, head[from]};
    head[from] = tot++;
}

void dfs(int u, int pa, int* d) {
    if(pa != -1) d[u] = d[pa] + 1;
    else d[u] = 0;
    for(int i = head[u]; i != -1; i = eg[i].next) {
        int to = eg[i].to;
        if(to != pa) {
            dfs(to, u, d);
        }
    }
}

int main() {
    int n;
    scanf("%d", &n);
    init();
    for(int i = 0; i < n - 1; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        addedge(u, v);
        addedge(v, u);
    }
    dfs(1, -1, dis0);
    dfs(n, -1, dis1);
    int lcnt = 0, rcnt = 0;
//    for(int i = 1; i <= n; ++i) {
//        printf("%d %d\n", dis0[i], dis1[i]);
//    }
    for(int i = 1; i <= n; ++i) {
        if(dis0[i] <= dis1[i]) ++lcnt;
        else ++rcnt;
    }
//    printf("%d %d\n", lcnt, rcnt);
    if(lcnt > rcnt) {
        puts("Fennec");
    } else {
        puts("Snuke");
    }
    return 0;
}


Measured memory_bytes: 7680
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Vaibhav Pal
 */

#include <bits/stdc++.h>

using namespace std;

struct CDiceAndCoin {

    void solve(istream& in, ostream& out) {
        int n,k;
        in>>n>>k;
        double ans=0;
        for(int i=1;i<=n;i++){
            long long x=i,y=0;
            while(x<k){
                x<<=1;
                y++;
            }
            ans+=pow(0.5,y);
        }
        ans/=n;
        out<<fixed<<setprecision(12)<<ans<<"\n";
    }
};


int main() {
	CDiceAndCoin solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <numeric>
#include <iostream>
#include <sstream>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <string>
#include <bitset>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <set>
#include <algorithm>
#include <tuple>
#include <sstream>

using namespace std;

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; for (auto& e : a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; for (auto& e : a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; for (auto& r : a) { for (auto& e : r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; for (auto& e : a) { cerr << e.field << " ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

#define forn(a, e) for (int a = 0; a < (int)e; a++)
#define forr(a, s, e) for (int a = s; a < (int)e; a++)

using i64 = long long;

template<typename T>
using Pair = array<T, 2>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    i64 n;
    while (cin >> n) {
        vector<int> a(n);
        vector<int> b(n);
        vector<int> c(n);
        forn(i, n) cin >> a[i];
        forn(i, n) cin >> b[i];
        forn(i, n - 1) cin >> c[i];

        i64 ans = 0;
        forn(i, n - 1) {
            ans += b[a[i] - 1];
            if (a[i + 1] - a[i] == 1) {
                ans += c[a[i] - 1];
            }
        }
        ans += b[a.back() - 1];
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <string.h>
int main(void) {
    int s;
    scanf("%d",&s);
    int seq[4];

    int i,c;
    int flag = 0;
    int tmp = s;
    int tmp2;
    for(i=0;i<4;i++){
        tmp2 = tmp;
        tmp = tmp/10;
        c = tmp2%10;
        seq[i] = c;
        if(i>0) {
            if(seq[i] == seq[i-1]) {
                flag = 1;
            }
        }
    }
    if(flag==1)
        printf("Bad\n");
    else
        printf("Good\n");

    return 0;
}

Measured memory_bytes: 128
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

N,M = MAP()
G = [MAP() for _ in range(M)]

l = 0
r = 10**5+1
for a,b in G:
	if a>l: l=a
	if b<r: r=b

#print(l,r)
print(r-l+1 if r>= l else 0)

Measured memory_bytes: 21164
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;


int32_t main(){
    FAST;
    int a,b;  cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;

    return 0;
}


Measured memory_bytes: 256
import collections

n, k = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
nums = collections.Counter(A)

l = len(nums)

if l <= k:
    print(0)
    quit()


ans = 0
for c in sorted(nums.values()):
    ans += c
    l -= 1
    if l <= k:
        break
print(ans)


Measured memory_bytes: 32564
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
bool ABC167F_order(pll const& lhs, pll const& rhs)
{
	// first:  open
	// second: close

	int lhs_sign = 0;
	if (lhs.first > lhs.second)
		lhs_sign = 1;  // more open
	else if (lhs.first < lhs.second)
		lhs_sign = -1;  // more close

	int rhs_sign = 0;
	if (rhs.first > rhs.second)
		rhs_sign = 1;
	else if (rhs.first < rhs.second)
		rhs_sign = -1;

	if (lhs_sign != rhs_sign)
		return lhs_sign > rhs_sign;

	if (lhs_sign >= 0)
		return lhs.second < rhs.second;  // use the smallest close at the first (because the restriction is toughest at the first)
	else
		return lhs.first > rhs.first;  // leave the smallest open for the last (because the restriction is toughest at the last)
}

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

	int n;
	cin >> n;
	vector<pll> num_live_open_and_close(n);
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		for (auto it = s.begin(); it != s.end(); it++)
		{
			if (*it == '(')
			{
				num_live_open_and_close[i].first++;
			}
			else  // *it==')'
			{
				if (num_live_open_and_close[i].first > 0)
					num_live_open_and_close[i].first--;
				else
					num_live_open_and_close[i].second++;
			}
		}
	}

	sort(num_live_open_and_close.begin(), num_live_open_and_close.end(), ABC167F_order);

	ll level = 0;
	for (auto it = num_live_open_and_close.begin(); it != num_live_open_and_close.end(); it++)
	{
		level -= it->second;
		if (level < 0)
		{
			cout << "No" << "\n";
			return 0;
		}
		level += it->first;
	}
	if (level == 0)
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 18752
#include <stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int a[n];
  int b[n+1];
  int i;
  
   for(i=0;i<n-1;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n+1;i++){
    b[i]=0;
  }
  
  for(i=0;i<n-1;i++){
    b[a[i]]=b[a[i]]+1;
  }
  for(i=1;i<n+1;i++){
    printf("%d\n",b[i]);
  }
  return 0;
}


Measured memory_bytes: 3272
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	cin >> n;
	while (n--) {
		vvi win(10000);
		string s;
		cin >> s;
		int cnt = 0;
		REP(i, s.length()) {
			if (s[i] == '[') {
				cnt++;
				continue;
			}
			if (s[i] == ']') {
				int res=0;
				SORT(win[cnt]);
				if (win[cnt].size() > 1) {
					REP(i, win[cnt].size() / 2 + 1)
						res += win[cnt][i];
				}
				else
					res = win[cnt][0];
				win[cnt - 1].push_back(res);
				win[cnt].clear();
				cnt--;
				continue;
			}
			int res = 0;
			while (isdigit(s[i])) {
				res *= 10;
				res += s[i]-'0';
				i++;
			}
			win[cnt].push_back(res/2+1);
			i--;
		}
		cout << win[0][0] << endl;
	}
}

Measured memory_bytes: 3388
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;

void main(){
    auto as=readln.chomp.array;
    auto bs=readln.chomp.array;
    auto cs=readln.chomp.array;

    auto turn=0;
    while(true){
        final switch(turn){
            case 0:
                if(!as.any){
                    writeln("A");return;
                }
                turn=int(as[0]-'a');
                as=as[1..$];
                break;
            case 1:
                if(!bs.any){
                    writeln("B");return;
                }
                turn=int(bs[0]-'a');
                bs=bs[1..$];
                break;
            case 2:
                if(!cs.any){
                    writeln("C");return;
                }
                turn=int(cs[0]-'a');
                cs=cs[1..$];
                break;
        }
    }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


ll flow[MX+5];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    rp(i,n){
      ll x;
      cin >> x;
      x+=2;
      flow[x-1]++;
      flow[x]++;
      flow[x+1]++;
    }
    // rp(i,13) cout <<flow[i]<<" ";
    sort(flow,flow+100004);

    cout << flow[100003]<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

using namespace std;

struct Cd{
	int n;
	char w;
	bool f;
};

bool comp(const Cd& c1, const Cd& c2)
{
	return c1.n < c2.n;
}

bool func(vector<Cd> vec)
{
	int l = vec.size();
	bool f = true;
	if(l == 0){
		return true;
	} else if(l%3 != 0){
		return false;
	}
	sort(vec.begin(), vec.end(), comp);
	
	if(vec[0].n == vec[1].n && vec[0].n == vec[2].n){
		vec[0].f = vec[1].f = vec[2].f = false;
	}
	if(l > 3){
		if(vec[l-1].n == vec[l-2].n && vec[l-1].n == vec[l-3].n){
			vec[l-1].f = vec[l-2].f = vec[l-3].f = false;
		}
	}
	
	for(int i = 0; i < l; i++){
		if(vec[i].f){
			vec[i].f = false;
			int c = 1;
			for(int j = i+1; j < l; j++){
				if(vec[i].n+c == vec[j].n && vec[j].f){
					vec[j].f = false;
					c++;
					if(c == 3){
						break;
					}
				}
			}
			if(c == 1){
				for(int j = i+1; j < l; j++){
					if(vec[i].n == vec[j].n && vec[j].f){
						vec[j].f = false;
						c++;
						if(c == 3){
							break;
						}
					}
				}
			}
			if(c < 3){
				f = false;
				break;
			}
		}
	}
	
	return f;
}

int main()
{
	int n;
	
	while(cin>>n && n){
		int a[10];
		Cd c;
		
		while(n--){
			vector<Cd> g, r, b;
			for(int i = 0; i < 9; i++){
				cin >> a[i];
			}
			for(int i = 0; i < 9; i++){
				cin >> c.w;
				c.n = a[i];
				c.f = true;
				if(c.w == 'R'){
					r.push_back(c);
				} else if(c.w == 'B'){
					b.push_back(c);
				} else {
					g.push_back(c);
				}
			}
			
			if(func(r) && func(g) && func(b)){
				cout << 1 << endl;
			} else {
				cout << 0 << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll long long
#define f(n)  for(int i=0;i<n;i++) 
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define all(v)   v.begin(),v.end()  
void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main ()
{
  speed();
   ll int r,d,n;
    cin>>r>>d>>n;
    ll int a[11];
    a[0]=n;
    for(ll int i=1;i<11;i++){
        a[i]=(r*a[i-1])-d;
    }
    for(ll int i=1;i<11;i++){
        cout<<a[i]<<endl;
    }
 return 0;
}

Measured memory_bytes: 256
num = list(map(int, input().split()))

loop = [0]

for i in loop:
  if num[0] < num[1]:
    difference = abs(num[0] - num[1])
    if difference > num[0]:
      break
    else:
      num[0] = difference
      break
  elif num[1] == 1:
    num[0] = 0
    break
  elif num[1] == 0:
    break
  if i == 0:
    num[0] = num[0] % num[1]
  num[0] = abs(num[0] - num[1])
  loop.append(i+1)

print(num[0])

Measured memory_bytes: 3064
#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> d1(n), d2(n);
  rep(i,n)cin >> d1[i] >> d2[i];
  int c=0, m=0, cnt=0;
  rep(i, n){
    if (d1[i] == d2[i]){
      c++;
      continue;
    }else{
      m = max(c, m);
      c = 0;
    }
  }
  m = max(c, m);
  if (m >= 3) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636