akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();
        string A, T, G, C;
        A = "A";
        T = "T";
        G = "G";
        C = "C";
        int Count = 0;
        List<int> max = new List<int>();
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i].ToString() == A || S[i].ToString() == T || S[i].ToString() == G || S[i].ToString() == C)
            {
                Count++;
                if (i == S.Length - 1) max.Add(Count);
            }
            else
            {
                max.Add(Count);
                Count = 0;
            }
        }
        int Longest = max[0];
        for (int j = 1; j < max.Count; j++)
        {
            if (Longest < max[j]) Longest = max[j];
        }
        Console.WriteLine(Longest);
    }
}

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

int main(){

  int n[5];

  while(cin >> n[0], n[0]){

    for(int i=1;i<5;i++) cin >> n[i];

    int a = 0,b = 0,c = 0;

    for(int i=0;i<5;i++){
      if(n[i] == 1) a++;
      else if(n[i] == 2) b++;
      else if(n[i] == 3) c++;
    }

    if(a && b && c){
      for(int i=0;i<5;i++) cout << 3 << endl;
    }

    else if((!a && !b) || (!b && !c) || (!a && !c)){
      for(int i=0;i<5;i++) cout << 3 << endl;
    }

    else if(!c){
      for(int i=0;i<5;i++) cout << n[i] << endl;
    }

    else if(!a){
      for(int i=0;i<5;i++) cout << n[i]-1 << endl;
    }

    else if(!b){
      for(int i=0;i<5;i++){
	if(n[i] == 3) cout << 1 << endl;
	else if(n[i] == 1) cout << 2 << endl;
      }
    }

  }
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {

    /* チェックリスト
     * intの範囲を超えていないか
     * TLEしそうな処理の有無
     */
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.nextLine());
        List<Long> longs = new ArrayList<>();
        for(long i = 1; true; i++){
            if(n % i == 0){
                longs.add(i);
            }
            if(i >= n / i){
                break;
            }
        }
        long min = -1;
        for(Long l : longs){
            long x = l;
            long y = n / l;
            long test = (x - 1) + (y - 1);
            if(min != -1) {
                if (min > test) {
                    min = test;
                }
            }else{
                min = test;
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n,m,k,a,ans=0;
  bool res[35][35]={false},all;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>k;
    for(int j=0;j<k;j++){
      cin>>a;
      res[i][a] = true;
    }
  }

    for(int j=1;j<=m;j++){
      all=true;
      for(int i=0;i<n;i++){
	if(!(res[i][j]))
	  all=false;
      }
      ans+=all;
    }

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


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if (x == y){
            System.out.println("a == b");
        }else if (x > y){
            System.out.println("a > b");
        }else {
            System.out.println("a < b");
        }

    }

}


Measured memory_bytes: 26152
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n, m, q, a[50], b[50], c[50], d[50];
    cin >> n >> m >> q;
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }

    function<int (int, int, vi)> dfs = [&](int i, int num, vi x) {
        if(i == n) {
            int res = 0;
            rep(ii, q) {
                if(b[ii] == n and x[a[ii]] + c[ii] == num) {
                    res += d[ii];
                }
            }
            return res;
        }
        int res = 0;
        while(num <= m) {
            int h = 0;
            rep(ii, q) {
                if(b[ii] == i && x[a[ii]] + c[ii] == num) {
                    h += d[ii];
                }
            }
            x[i] = num;
            res = max(res, dfs(i+1, num++, x) + h);
        }

        return res;
    };

    vi x(n, -1);
    cout << dfs(0, 1, x) << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (true) {
            int H = input.nextInt();
            int W = input.nextInt();
            if (H == 0 && W == 0) break;
            for (int i = 1; i <= H; i++) {
                char[] cs = new char[W];
                for (int j = 1; j <= W; j++) {
                    cs[j-1] = ((j + i) % 2 == 0) ? '#' : '.';
                }
                System.out.println(cs);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 21196
def resolve():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]
    ab = sorted(ab, key=lambda x:x[1])
    now = 0
    for i in range (n):
        if now + ab[i][0] > ab[i][1]:
            print("No")
            return None
        else:
            now += ab[i][0]
    print("Yes")
    
resolve()

Measured memory_bytes: 55176
#include <iostream>
#include <cmath>

using namespace std;

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

  int T, A;
  cin >> T >> A;

  int min = 0;
  double AT[1001];
  for (int i = 0; i < N; i++) {
    int H;
    cin >> H;
    AT[i] = (double)T - (double)H * 0.006;
    if (abs(AT[i] - (double)A) < abs(AT[min] - (double)A))
      min = i;
  }

  cout << min + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
a=0
if A==0:
    print(0)
elif B==0:
    print(N)
else:
    if N%(A+B)>=A:
        x=A*(N//(A+B))+A
        print(x)
    else:
        x=A*(N//(A+B))+(N%(A+B))
        print(x)

Measured memory_bytes: 3064
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
long long ans[16],way[9][2]={{0,0},{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}},H,W,a,b;
int n;
map<long long,int> ma;
int main()
{
	scanf("%lld%lld%d",&H,&W,&n);
	ans[0]=(H-2)*(W-2);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a,&b);
		for(int j=0;j<9;j++)
		{
			long long nea=a+way[j][0];
			long long neb=b+way[j][1];
			if(nea>=H||neb>=W||nea<2||neb<2) continue;
			ans[ma[nea*W+neb]]--;
			ans[++ma[nea*W+neb]]++;
		}
	}
	for(int i=0;i<10;i++)
		printf("%lld\n",ans[i]);
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n;
  cin >> n;

  map<string, int> memo;

  REP(i, n) {
    string s;
    cin >> s;

    memo[s]++;
  }
  ll maxv = 0;
  for (const auto& e : memo) {
    int v = e.second;
    if (v > maxv) maxv = v;
  }
  for (auto it = memo.begin(); it != memo.end(); it++) {
    if (it->second == maxv) {
      cout << it->first << "\n";
    }
  }
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

template <typename T>
void scanInt(T &x) {
    bool neg = false;
    register int c = getchar_unlocked();
    x = 0;
    for (; (c < 48 || c > 57) && (c != '-'); c = getchar_unlocked());
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; c > 47 && c < 58; c = getchar_unlocked())
        x = (x << 1) + (x << 3) + c - 48;
    if (neg)
        x *= -1;
}

template <typename T>
void printInt(T n) {
    if (n < 0) {
        n = -n;
        putchar_unlocked('-');
    }
    int i = 21;
    char output_buffer[21];
    do {
        output_buffer[--i] = (n % 10) + '0';
        n /= 10;
    } while (n);
    do {
        putchar_unlocked(output_buffer[i]);
    } while (++i < 21);
}

bool isOddNo(int n) {
    int Count = 0;
    while (n > 0) {
        n /= 10;
        Count++;
    }
    return Count & 1;
}

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

    int n, Count = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
        if (isOddNo(i))
            Count++;
    cout << Count << endl;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(x,n);
  Vi dp(x+1, INF);
  dp[0] = 0;
  REP(i,n) {
    IN2(a,b);
    REP(j,x){
      z = min(j+a, x);
      dp[z] = min(dp[z], dp[j]+b);
    }
  }
  OUT(dp[x]);
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

using ll = long long;

#define INF 2e9; //Integer Infinity
#define LINF 2e18; //Long Long Integer Infinity
#define MOD 1000000007; //Too Large Pure Number
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)//Loop i to n(i=0)
#define all(x) (x).begin(),(x).end();//for sort
#define dump(x) cout << #x << " = " << (x) << endl;//for debug 
#define YES(b) cout << ((n)?"YES":"NO") << endl;//print "YES" or "NO"
#define Yes(b) cout << ((n)?"Yes":"No") << endl;//print "Yes" or "No"

#define PI 3.141592653589793;

int main(void) {
	int n,out=0;
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		if (i < 10 || (i >= 100 && i <= 999) || (i >= 10000 && i <= 99999))out++;
	}
	cout << out << endl;
	return 0;
}

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

using namespace std;

int main(){
    int n; cin >> n;
    int alice = 0, bob = 0;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    for(int i = 0; i < n; ++i){
        if(i%2 == 0) alice += a[i];
        else bob += a[i];
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  cout << (1000-n%1000)%1000 << ln;
  return 0;
}

Measured memory_bytes: 3632
from math import factorial
from math import sqrt
def nCr(n,r):
    a=1
    x=n
    while(x!=n-r):
      a*=x
      x-=1
    b=1
    x=r
    while(x!=0):
      b*=x
      x-=1
    return a//b

INF=10**9+7
N,m=map(int,input().split())


sum=1
yd = {}
i = 2
while m != 1:
  while m % i == 0:
    if i in yd:
      yd[i] += 1
    else:
      yd[i] = 1
    m //= i
  i += 1
for b in yd.values():
    sum*=nCr(N-1+b,b)
    sum%=INF
print(sum)


Measured memory_bytes: 40044
#define CPP17
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#ifdef CPP17
#include <variant>
#endif

// Yay!!
#define endl codeforces

// macros for iterator
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

// alias
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

// variadic min/max
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }

// variadic chmin/chmax
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

// multi demension array
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

#ifdef CPP17
// fill container
template <typename T, typename F, typename... Args> 
void fill_seq(T &t, F f, Args... args) { if constexpr (std::is_invocable<F, Args...>::value) { t = f(args...); } else { for (ssize_t i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); } }
#endif

// make multi dimension vector
template <typename T> vec<T> make_v(ssize_t sz) { return vec<T>(sz); }
template <typename T, typename... Tail> auto make_v(ssize_t hs, Tail&&... ts) { auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); return vec<decltype(v)>(hs, v); }

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


int main() {
    std::string s;
    std::cin >> s;
    for (char c : s) {
        if (c == '?') std::cout << 'D';
        else std::cout << c;
    }
    std::cout << "\n";
    return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string A, B;
    cin >> A >> B;
    
    if (A.size() > B.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    if (A.size() < B.size()) {
        cout << "LESS" << endl;
        return 0;
    }
    rep(i, A.size()) {
        if (A[i] > B[i]) {
            cout << "GREATER" << endl;
            return 0;
        }
        if (A[i] < B[i]) {
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int s, w;
    cin >> s >> w;
    
    if(w < s)
        cout << "safe\n";
    else
        cout << "unsafe\n";
    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pp pair<ll,ll>
#define fore(i,n) for(ll i=0;i<n;i++)
#define vi vector<ll>
using namespace std;
const ll mod=998244353;
ll power(ll a,ll b)
{
if(b==0)
return 1;
else if(b==1)
{
return a;
}
else if(b&1)
{
return (a%mod * power((a%mod * a%mod)%mod,b/2)%mod)%mod;
}
else
{
return power((a%mod * a%mod)%mod,b/2)%mod;
}
}
 
void solve()
{
   int h,w,k;
   cin>>h>>w>>k;
   char arr[h][w];
   fore(i,h)fore(j,w)cin>>arr[i][j];
   int ans=0;
   for(int l=0;l<(1<<h);l++)
   {
       for(int m=0;m<(1<<w);m++)
       {
            int cnt=0;
           for(int i=0;i<h;i++)
           {
              
               for(int j=0;j<w;j++)
               {
                   if(!(1 & (l>>i)) && !(1 & (m>>j)) && arr[i][j]=='#')
                   {
                       cnt++;
                   }
               }
              
           }
           if(cnt==k)ans+=1;
       }
   }
   cout<<ans<<endl;
}
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

solve();
 
}

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

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  
  cout << a[2]*10+a[1]+a[0] << endl;
}


Measured memory_bytes: 3588
n= int(input())
a= [list(map(int, input().split())) for i in range(n-1)]

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

for i in range(n-1):
    x=min(a[i][0],a[i][1])
    y=max(a[i][0],a[i][1])
    ans-=x*(n-y+1)
print(ans)

Measured memory_bytes: 102816
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntMap.Strict as IntMap
import Control.Monad
import Control.Monad.ST

type Weight = Int
type Tree = IntMap.IntMap (U.Vector (Int,Weight))

buildTree :: U.Vector (Int,Int,Weight) -> IntMap.IntMap (U.Vector (Int,Weight))
buildTree edges = runST $ do
  let insert' key val m = do
        case IntMap.lookup key m of
          Nothing -> do
            vec <- UM.new 1
            UM.write vec 0 val
            return $ IntMap.insert key (1, vec) m
          Just (len, vec) -> do
            vec' <- if len < UM.length vec then return vec else UM.grow vec len
            UM.write vec' len val
            let !len' = len+1
            return $ IntMap.insert key (len', vec') m
      adjust (len, mvec) = do
        vec <- U.unsafeFreeze mvec
        return (U.take len vec)
  m <- U.foldM' (\m (u,v,w) -> insert' v (u,w) m >>= insert' u (v,w)) IntMap.empty edges
  mapM adjust m

main = do
  n <- readLn
  edges <- U.replicateM (n-1) $ do
    [u,v,w] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (u-1, v-1, w)
  let tree :: Tree
      tree = buildTree edges
  let result = U.create $ do
        vec <- UM.replicate n (-1)
        -- white: 0, black: 1
        let dfs !i !color = do
              x <- UM.read vec i
              when (x == -1) $ do
                UM.write vec i color
                let Just t = IntMap.lookup i tree
                U.forM_ t $ \(j,w) -> do
                  dfs j ((color + w) `rem` 2)
        dfs 0 0
        return vec
  U.mapM_ print result


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


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

struct edge {int to; ll cost; };

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

ll GCD(ll a, ll b){
  if(b==0) return a;
  else return GCD(b, a%b);
}

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}

int main(){
  string s;
  cin >> s;
  int tmp = 0;
  for(int i=0; i<s.length(); i++){
    tmp += s[i]-'0';
  }
  string ans;
  if(tmp%9==0) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#ifdef TEST
#include <mytest.h>
#else
#define open(...) 0
#define print(...) 42
#endif // TEST
using namespace std;
const int N = 2e5 + 5;
vector<int> G[N];
int ti, in[N], out[N];
void dfs(int u, int fa) {
  in[u] = ++ti;
  for (int v : G[u])
    if (v != fa) dfs(v, u);
  out[u] = ti;
}
int b[N];
int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m, u, v, x, y;
  cin >> n >> m;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);
  while (m--) {
    cin >> x >> y;
    b[in[x]] += y;
    b[out[x]+1] -= y;
  }
  for (int i = 1; i <= n; i++) {
    b[i] += b[i-1];
  }
  for (int i = 1; i <= n; i++) {
    if (i > 1) cout << ' ';
    cout << b[in[i]];
  }
  return 0;
}


Measured memory_bytes: 25088
#include <stdio.h> 
#include <math.h>
int main(void)
{
	int num ,x[1000],y[1000],i;
	double z1 =0, z2 = 0, z3 = 0, z =0,A;

	scanf("%d",&num);
	
	
	for(i=0;i<num;i++)
	{
		scanf("%d",&x[i]);
	}
	
	
	for(i=0;i<num;i++)
	{
		scanf("%d",&y[i]);
	}
	
	
	for(i=0;i<num;i++)
	{
			A = y[i] - x[i];

			if(A<0)
			{
				A = A*(-1);
			}
			
			z1 = z1 + A;		
			z3 = z3 + A * A  * A;	
		
			z2 = z2 + (x[i] - y[i]) *  (x[i] - y[i]);

		
		
		
			
		if(x[i]<y[i])
		{
			if(z<y[i] - x[i])
			{
				z =y[i] - x[i];
			}
		}
		if(x[i]>y[i])
		{
			if(z<x[i] -y[i])
			{
				z = x[i] -y[i];
			}
		}
			
			
		
		
	
	}
	
	printf("%f\n%f\n%f\n%f\n",z1,sqrt(z2),pow(z3,1.0/3.0),z);


	return 0 ;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};

ll dp[100][4][4][4];

int main(){

  int n;
  cin >> n;
  FILLl(dp,100,0);
  REP(i,4)REP(j,4)REP(k,4)dp[2][i][j][k] = 1;
  dp[2][0][2][1] = dp[2][0][1][2] = dp[2][2][0][1] = 0;
  for(int i = 3;i < n;i++){
    REP(j,4){
      REP(k,4){
        REP(l,4){
          if(j == 0 && k == 2 && l == 1)continue;
          if(j == 0 && k == 1 && l == 2)continue;
          if(j == 2 && k == 0 && l == 1)continue;
          REP(m,4){
          if(j == 0 && k == 2 && m == 1)continue;
          if(j == 0 && l == 2 && m == 1)continue;
          dp[i][j][k][l] = (dp[i][j][k][l] + dp[i-1][k][l][m])%MOD;
          }
        }
      }
    }
  }
  ll res = 0;
  REP(i,4)REP(j,4)REP(k,4)(res += dp[n-1][i][j][k]) %= MOD;
  res = (MOD+res-dp[n-1][0][2][1]-dp[n-1][0][1][2]-dp[n-1][2][0][1])%MOD;
  cout << res << endl;




  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] min = new int[M];
		int[] max = new int[M];

		for(int i=0;i<M;i++) {
			min[i] = sc.nextInt();
			max[i] = sc.nextInt();
		}

		Arrays.sort(min);
		Arrays.sort(max);

		if(max[0] - min[M-1]<0) System.out.print(0);

		else if(max[0] - min[M-1]>=0) System.out.print(max[0]-min[M-1]+1);




}

}

Measured memory_bytes: 72512
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=998244353;

const ll INF=1e9;

int main(){
    ll a,b;
    cin >> a >> b;
    if(a*b<=0) cout << "Zero" << endl;
    else if(abs(a-b)%2==0 && a<0 && b<0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  char[] S = sc.next().toCharArray();
	  
	  String output = "Good";
	  for(int i = 0; i < S.length-1; i++) {
		  if(S[i] == S[i+1]) {
			  output = "Bad";
			  break;
		  }
	  }
	  System.out.println(output);
	  
  }
}


Measured memory_bytes: 23892
mod = (1e9 + 7).to_i
def rec(n, p, m)
  return 1 if p == 0
  return (n * rec(n, p - 1, m)) % m if p % 2 != 0
  (rec(n, p / 2, m) ** 2) % m
end

def combination(n, r, m)
  x = ((n - r + 1)..n).to_a.inject(1) { |acc, a| acc * a % m }
  y = (1..r).to_a.inject(1) { |acc, a| acc * a % m }
  (x * rec(y, m - 2, m)) % m
end

n, a, b = gets.chomp.split(' ').map(&:to_i)
arr = [combination(n, a, mod), combination(n, b, mod), 1]
result = arr.inject(rec(2, n, mod)) do |acc, x|
  acc = acc - x
  acc >= 0 ? acc : acc + mod
end
puts result

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a * b) / 2 == (a * b + 1) / 2) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);


            String str = sc.nextLine();
            if (str.charAt(2) == str.charAt(3) && str.charAt(4) == str.charAt(5)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

}

Measured memory_bytes: 22868
fn main() {
    proconio::input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
        mut t: [usize; d],
        m: usize,
        dq: [(usize, usize); m],
    }

    for i in 0..m {
        t[dq[i].0 - 1] = dq[i].1;
        let v = calc(d, &c, &s, &t);
        println!("{}", v[d - 1]);
    }
}

fn sum_di(di: usize,
    prev: i64,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    t: usize,
    last_d: &Vec<usize>,
) -> i64 {
    let mut v = prev + s[di][t - 1];
    for i in 0..26 {
        v -= c[i] * ((di + 1 - last_d[i]) as i64);
    }
    v
}

fn calc(d: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    t: &Vec<usize>,
) -> Vec<i64> {
    let mut last_d = vec![0; 26];

    let mut prev = 0;
    let mut v = vec![0; 365];
    for di in 0..d {
        last_d[t[di] - 1] = di + 1;
        prev = sum_di(di, prev, &c, &s, t[di], &last_d);
        v[di] = prev;
    }
    v
}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	int a[50], b[50], c[50];
	int ans = 0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		a[i]--;
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	for(int i=0;i<n-1;i++){
		cin >> c[i];
	}
	for(int i=0;i<n-1;i++){
		ans += b[i];
		if(a[i]+1==a[i+1]){
			ans += c[a[i]];
		}
	}
	ans += b[n-1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n,m,k;
    cin >> n >> m >> k;
    vector<long>a(n);
    vector<long>b(m);
    vector<long>Sa(n);
    vector<long>Sb(m);
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<m;i++)cin >> b[i];

    Sa[0] = a[0];
    for(int i=1;i<n;i++){
        Sa[i] = Sa[i-1] + a[i];
    }
    Sb[0] = b[0];
    for(int i=1;i<m;i++){
        Sb[i] = Sb[i-1] + b[i];
    }
    
    long ans = 0;

    ans = (long)(upper_bound(Sb.begin(),Sb.end(),k) - Sb.begin());
    for(int i=0;i<n;i++){
        long tmp = 0;
        if(Sa[i] <= k){
            tmp += i+1;
            tmp += (long)(upper_bound(Sb.begin(),Sb.end(),k-Sa[i]) - Sb.begin());
            
        }else break;

        if(tmp > ans) ans = tmp;
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 9592
/*input
3
1 2 1
*/
#include <bits/stdc++.h>
using namespace std;
bitset<2000 * 2000 + 5>bit; 
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int sum = 0;
	bit[0] = 1;
	for(int i = 1; i<=n; i++)
	{
		int num;
		cin >> num;
		bit = bit | (bit << num);
		sum += (num);
	}
	sum = (sum + 1)/2;
	for(int i = sum; i<=4000000; i++)
	{
		if(bit[i])
		{
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 2176
N = int(input())
for h in range(1, 3500):
    for n in range(1, 3500):
        a = N * h * n
        b = 4 * h * n - N * n - N * h 
        if b != 0:
            if a // b > 0 and a % b == 0:
                print(h, n, a // b)
                exit()

Measured memory_bytes: 40808
/*
この問題はatcoderのABC_046：Aである（AtCoDeerくんとペンキ）
このコードは多分配列の扱い方に対するエラーが発生中
数字のカウント方法わからぬ！！
*/
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int count = 1;
    if(a == b && b == c && a == c){
      System.out.println(count);
    }
    else if(a == b || b == c || a == c){
      count++;
      System.out.println(count);
    }
    else{
      count = count + 2;
      System.out.println(count);
    }
  }
}


Measured memory_bytes: 20564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int N = int.Parse(line);
            line = Console.ReadLine();
            string[] strs = line.Split(' ');
            var dict = new Dictionary<int, int>();
            for(int i = 0; i < N; i++)
            {
                var tmp = int.Parse(strs[i]);
                if (!dict.ContainsKey(tmp))
                {
                    dict.Add(tmp, 1);
                }
                else dict[tmp]++;
            }
            line = Console.ReadLine();
            int Q = int.Parse(line);

            long result = 0;
            foreach (var kvp in dict)
            {
                result += kvp.Key * (long)kvp.Value;
            }
            for (int i = 0; i < Q; i++)
            {
                line = Console.ReadLine();
                strs = line.Split(' ');
                var tmp1 = int.Parse(strs[0]);
                var tmp2 = int.Parse(strs[1]);
                if (dict.ContainsKey(tmp1))
                {
                    result = result - tmp1 * (long)dict[tmp1] + tmp2 * (long)dict[tmp1];
                    if (dict.ContainsKey(tmp2))
                    {
                        dict[tmp2] += dict[tmp1];
                    }
                    else
                    {
                        dict.Add(tmp2, dict[tmp1]);
                    }
                    dict.Remove(tmp1);
                }
                Console.WriteLine(result);
            }
        }
    }
}


Measured memory_bytes: 54432
import heapq
import math
import sys
input = sys.stdin.readline


def main():
    N, H = map(int, input().split())
    a_max = 0
    B = []
    for _ in range(N):
        a, b = map(int, input().split())
        a_max = max(a, a_max)
        B.append(-b)
    heapq.heapify(B)

    cnt = 0
    while H>0:
        if len(B)==0 or a_max >= B[0]*(-1):
            cnt += math.ceil(H/a_max)
            break
        else:
            cnt += 1
            H += heapq.heappop(B)
    
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7188
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int x,a;
  cin>>x>>a;
  if(x<a){
    cout<<0<<endl;
  }else{
    cout<<10<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int a, b;
  string s;
  cin >> a >> b >> s;
  if(s.size() != a + b + 1){
    cout << "No" << endl;
    return 0;
  }
  REP(i, s.size()){
    if(i == a){
      if(s[i] != '-'){
	cout << "No" << endl;
	return 0;
      }
    }else{
      int tmp = s[i] - '0';
      if(tmp <= -1||10<= tmp ){
	cout << "No" << endl;
	return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int a, b;

int main(){
  cin >> a >> b;
  if (b < 0) {
    cout << ((b - a) % 2 == 1 ? "Positive" : "Negative") << endl;
  } else if (a > 0) {
    cout << "Positive" << endl;
  } else {
    cout << "Zero" << endl;
  }

  return 0;
}


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

using namespace std;

int n;
int x , a[1200];
int ans;
void work () {
	int i;
	scanf ( "%d%d" , &n , &x );
	for ( i = 1 ; i <= n ; i++ ) scanf ( "%d" , &a[i] );
	sort ( a + 1 , a + n + 1 );
	for ( i = 1 ; i < n ; i++ ) {
		if ( x >= a[i] ) {
			ans++;
			x -= a[i];
		}
	}
	if ( x == a[n] ) ans++;
	printf ( "%d\n" , ans );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int N, y, s, z, x;
    cin >> N;
    y = N;
    s = 0;
    z = 1;
    rep(i,  8){
        z *= 10;
        x = (N % z) / (z / 10);
        s += x;
      if(x == N){break;}
        N = N - (N % z);
    }
    if(y % s == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D,i,j,k,l,dis,tance,ans;
  ans=0;dis=0;tance=0;
  cin>>N>>D;
  vector<vector<int>> X(N,vector<int>(D));
  for(i=0;i<N;++i){
    for(j=0;j<D;++j){
      cin>>X.at(i).at(j);
    }
  }
  for(i=0;i<N;++i){
    for(j=i+1;j<N;++j){
      tance=0;
      for(k=0;k<D;++k){
        dis=abs(X.at(i).at(k)-X.at(j).at(k));
        tance=tance+dis*dis;
      }
      for(l=0;l<=tance;++l){
        if(l*l==tance){
          ans=ans+1;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}
    

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

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}

const int maxn=3e5+10000;
int h,w,m;
int H[maxn],L[maxn],X[maxn],Y[maxn];

int main()
{
	h=read(),w=read(),m=read();
	int maxh=0,maxl=0,cnt1=0,cnt2=0;
	for(int i=1;i<=m;i++)
	{
		X[i]=read(),Y[i]=read();
		int x=X[i],y=Y[i];
		H[x]++;L[y]++;
		if(maxh<H[x]) {cnt1=1; maxh=max(maxh,H[x]);}
		else if(maxh==H[x]) ++cnt1;
		if(maxl<L[y]) {cnt2=1; maxl=max(maxl,L[y]);}
		else if(maxl==L[y]) ++cnt2;
	}
	int cnt=cnt1*cnt2;
	for(int i=1;i<=m;i++)
	{
		if(H[X[i]]==maxh && L[Y[i]]==maxl)
			cnt--;
	}
	if(cnt==0) printf("%d\n",maxh+maxl-1);
	else printf("%d\n",maxh+maxl);
	return 0;
}

Measured memory_bytes: 8420
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// 5min
int main(void){
  int x, y;
  int ans = 0;

  scanf("%d%d", &x, &y);

  ans = x + y / 2;

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


Measured memory_bytes: 128
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var N = NK[0];
        var K = NK[1];
        var RSP = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var R = RSP[0];
        var S = RSP[1];
        var P = RSP[2];
        var sum = 0L;
        var T = Console.ReadLine().ToCharArray();
      
        for(int i = 0; i < N; i++){
          if(i < K){
            if(T[i] == 'r'){
              sum += P;
            }else if(T[i] == 's'){
              sum += R;
            }else if(T[i] == 'p'){
              sum += S;
            }
          }else if(T[i] == T[i-K]){
            T[i] = 'o';
          }else if(T[i] != T[i-K]){
            if(T[i] == 'r'){
              sum += P;
            }else if(T[i] == 's'){
              sum += R;
            }else if(T[i] == 'p'){
              sum += S;
            }
          }
       //   Console.WriteLine(sum);
        }


        Console.WriteLine(sum);
      
    }
  
    static List<long> SieveOfEratosthenes(long N){
  var Primes = new List<long>();
  if(N > 0){
    var IsPrime = new bool[N+1];
    for(long i = 0;i <= N ;i++){
      IsPrime[i] = true; 
    }
    //0と1は消しておく
    IsPrime[0] = false;
    IsPrime[1] = false;
    for(long i = 2; i <= (long)Math.Sqrt(N);i++){
      if(IsPrime[i]){
        long j = i*2;
        for(long k = j;k <= N;k+=i){
          IsPrime[k] = false;
        }
      }
    }
    for(long i = 1;i <= N ;i++){
      if(IsPrime[i]){
        Primes.Add(i);
      }
    }
  }
  return Primes;
}

}


Measured memory_bytes: 13664
#include <stdio.h>
char a[3][3];
int main(){
	char c;
	for(int i=0;i<3;++i){
		for(int j=0;j<3;++j){
			scanf("%c",&a[i][j]);
			if(j==2) scanf("%c",&c);
		}
	}
	printf("%c%c%c\n",a[0][0],a[1][1],a[2][2]);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
const int N = 1e5 + 10;
 
int a[N] , b[N] , f[N] , sz[N] , xorsuma , xorsumb , _a[N] , _b[N] , n , cnt;
 
int F(int x) {
	if (f[x] != x) {
		f[x] = F(f[x]);
	}
	return f[x];
}
 
int main() {
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) {
		scanf("%d",a + i);
 
		_a[i] = a[i];
		xorsuma ^= a[i];
	}
 
	for (int i = 1; i <= n; i++) {
		scanf("%d",b + i);
		_b[i] = b[i];
		xorsumb ^= b[i];
	}
	n++;
	_a[n] = a[n] = xorsuma;
	_b[n] = b[n] = xorsumb;
 
	sort(_a + 1 , _a + 1 + n);
	sort(_b + 1 , _b + 1 + n);
 
	for (int i = 1; i <= n; i++) {
		if (_a[i] != _b[i]) {
			return puts("-1") , 0;
		}
	}
	cnt = unique(_a + 1 , _a + 1 + n) - _a - 1;
 
	for (int i = 1; i <= n; i++) {
		a[i] = lower_bound(_a + 1 , _a + 1 + cnt , a[i]) - _a;
		b[i] = lower_bound(_a + 1 , _a + 1 + cnt , b[i]) - _a;
	}
 
	for (int i = 1; i <= cnt; i++) f[i] = i , sz[i] = 1;
 
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] != b[i]) {
			ans ++;
			int fathera = F(a[i]) , fatherb = F(b[i]);
			if (fathera != fatherb) {
				sz[fathera] += sz[fatherb];
				f[fatherb] = fathera;
			}
		}
	}
	for (int i = 1; i <= cnt; i++) {
		if (sz[F(i)] == 1) {
			continue;
		} else if (F(i) == i && sz[F(i)] > 1) {
			ans ++;
		}
	}
	if (sz[F(a[n])] != 1) ans --;
 
	cout<<ans<<endl;
	return 0;
}

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

int32_t main() {
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    int n, x, t; cin >> n >> x >> t;
    cout << ((n + x - 1) / x * t) << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);

    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;++i) {
      cin >> a[i];
    }
    reverse(a.begin(), a.end());

    vector<int> dp(n, MOD);
    dp[0] = a[0];
    for(int i=1;i<n;++i) {
      int pos = upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
      dp[pos] = a[i];
    }


    int ans = lower_bound(dp.begin(), dp.end(), MOD) - dp.begin();
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main (){
  lint N,M,sum,ans = 0,op_x = -1,op_y = -1,op_z = -1;
  cin >> N >> M;
  vector<lint> x(N),y(N),z(N),SUM(N);
  rep(i,0,N){cin >> x[i] >> y[i] >> z[i];}
  
  rep(j,0,8){
    sum = 0;
    if(j%4 == 0){op_x *= -1;}
    if(j%2 == 0){op_y *= -1;}
    op_z *= -1;
    rep(i,0,N){
      SUM[i] = op_x*x[i] + op_y*y[i] + op_z*z[i];
    }
    sort(SUM.begin(),SUM.end());
    reverse(SUM.begin(),SUM.end());
    rep(i,0,M){
      sum += SUM[i];
    }
    ans = max(sum,ans);
  }
  co(ans);
}

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

char str[3][15];

int main() {

	int i;

	for (i = 0; i < 3; i++) {
		scanf(" %s",str[i]);
	}

	if (str[0][strlen(str[0]) - 1] == str[1][0] && str[1][strlen(str[1]) - 1] == str[2][0]) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int input() {int a;cin>>a;return a;}

int n,a[50],memo,hoge;

signed main() {
    cin >> n;
    rep(i,n) {
        cin >> a[i];
        if (!i) memo = a[i], hoge = 1;
        if (abs(memo) < abs(a[i])) memo = a[i],hoge = i+1;
    }
    cout << n*2-1 << endl;
    if (memo < 0) {
        rep(i,n) cout << hoge << " " << i+1 << endl;
        for(int i=n-2;i>=0;i--) cout << i+2 << " " << i+1 << endl;
    } else {
        rep(i,n) cout << hoge << " " << i+1 << endl;
        rep11(i,n) cout << i << " " << i+1 << endl;
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
ab=[]
for i in range(n):
    x=xl[i][0]
    l=xl[i][1]
    a=x-l
    b=x+l
    ab.append([a,b])
ab.sort(key=lambda x:x[1])
B=-float("inf")
cnt=0
for i in range(n):
    a=ab[i][0]
    b=ab[i][1]
    if a>=B:
        cnt+=1
        B=b
print(cnt)


Measured memory_bytes: 70364