akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;

namespace AtCoder
{
    public class Program
    {



        public static void Main(string[] args)
        {

           var s= Console.ReadLine();
            var ss = s.OrderBy(x => x);
            var sss = "";
            foreach(var i in ss)
            {
                sss += i;
            }
            var t = Console.ReadLine();
            var tt = t.OrderBy(x => x).Reverse();
            var ttt = "";
            foreach(var i in tt)
            {
                ttt += i;
            }
 
            Write(String.Compare(sss,ttt)<0? "Yes":"No");


         }

        private static void Read2Ints(out int a, out int b)
        {
            var temp = ReadInts();
            a = temp[0];
            b = temp[1];
        }
        private static void Read3Ints(out int a, out int b, out int c)
        {
            var temp = ReadInts();
            a = temp[0];
            b = temp[1];
            c = temp[2];
        }

        private static void Write(IEnumerable<string> target, string sep = " ") { Console.WriteLine(string.Join(sep, target)); }
        private static void Write(IEnumerable<double> target, string sep = " ") { Console.WriteLine(string.Join(sep, target)); }
        private static void Write(IEnumerable<long> target, string sep = " ") { Console.WriteLine(string.Join(sep, target)); }
        private static void Writeints(IEnumerable<int> target, string sep = " ") { Console.WriteLine(string.Join(sep, target)); }
        private static void Write<T>(T str) { Console.WriteLine(str); }
        private static string[] ReadStrings() { return Console.ReadLine().Split(' '); }
        private static int ReadInt() { return int.Parse(Console.ReadLine()); }
        private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        private static int[] ReadInts() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        private static double[] ReadDoubles() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }

    }

}

Measured memory_bytes: 13664
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  string s;
  cin >> s;
  int ans = 1000;
  bool f = true;
  REP(i,(int)s.length() - 1) if(s[i] != s[i+1]) f = false;
  if(f){
    cout << 0 << endl;
    return 0;
  }
  REP(i,26){
    char c = (char)('a' + i);
    string t[2] = {};
    t[0] = s;
    int len = s.length();
    REPS(i,len-1){
      REP(j,(int)t[0].length()-1){
        if(t[0][j] == c || t[0][j+1] == c) t[1] += c;
        else t[1] += t[0][j];
      }
      bool flag = true;
      REP(j,(int)t[1].length()){
        if(t[1][j] != c){
          flag = false;
          break;
        }
      }
      if(flag){
        ans = min(i,ans);
        break;
      }
      t[0] = t[1];
      t[1] = "";
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
D1 = []
D2 = []

for _ in range(N):
  a, b = map(int, input().split())
  D1.append(a)
  D2.append(b)

for i in range(N-2):
  if D1[i:i+3] == D2[i:i+3]:
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 9184
# https://atcoder.jp/contests/agc032/tasks/agc032_b
# 完全グラフからどの辺を減らそうかって考えるとわかる

N = int(input())
ans = set()
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        ans.add((i, j))

if N & 1:  # 奇数
    N -= 1

for k in range(N // 2):
    i = k + 1
    j = N - k
    ans.remove((i, j))
print(len(ans))
for i, j in ans:
    print(i, j)


Measured memory_bytes: 74296
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, A):
    ans = []
    X = []
    for i in range(H):
        for j in range(W) if i % 2 == 0 else range(W-1, -1, -1):
            X.append((i, j))

    for i in range(len(X)-1):
        x, y = X[i]
        if A[x][y] % 2 == 0:
            continue
        A[x][y] -= 1

        x1, y1 = X[i+1]
        A[x1][y1] += 1
        ans.append((x, y, x1, y1))

    for r in A:
        error_print(r)
    print(len(ans))
    for a, b, c, d in ans:
        print(a+1, b+1, c+1, d+1)


def main():
    H, W = read_int_n()
    A = [read_int_n() for _ in range(H)]
    slv(H, W, A)


if __name__ == '__main__':
    main()


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

int getMinCost(int n, vector<int> &h, vector<int> &cost) {
  if(cost[n]!=-1) return cost[n];
  if(n==0) return 0;
  if(n==1) {
    cost[n] = abs(h[n]-h[n-1]);
    return cost[n];
  }
  else {
    cost[n] = min(getMinCost(n-1, h, cost)+abs(h[n]-h[n-1]),getMinCost(n-2,h,cost)+abs(h[n]-h[n-2]));
    return cost[n];
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  vector<int> cost(n,-1);
  for(int i=0; i<n; i++) cin >> h[i];
  cout << getMinCost(n-1, h, cost) << endl;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        String Sa = scan.next();
        String Sb = scan.next();
        String Sc = scan.next();
        
        char isNext = 'a';//次のターンは誰か、格納
        char cnt;
        
        while( Sa.length() != 0 || Sb.length() != 0 || Sc.length() != 0 ){
          if( isNext == 'a' && Sa.length() >= 1){
            isNext = Sa.substring(0, 1).charAt(0);
            Sa = Sa.substring(1, Sa.length() );
          }
          else if( isNext == 'a' && Sa.length() == 0 )break;
          
          else if( isNext == 'b' && Sb.length() >= 1){
            isNext = Sb.substring(0, 1).charAt(0);
            Sb = Sb.substring(1, Sb.length() );
          }
          else if( isNext == 'b' && Sb.length() == 0 )break;
          
          else if( isNext == 'c' && Sc.length() >= 1){
            isNext = Sc.substring(0, 1).charAt(0);
            Sc = Sc.substring(1, Sc.length() );
          }
          else if( isNext == 'c' && Sc.length() == 0 )break;
        }
        
        if( isNext == 'a' && Sa.length() == 0)System.out.println("A");
        else if( isNext == 'b' && Sb.length() == 0)System.out.println("B");
        else if( isNext == 'c' && Sc.length() == 0)System.out.println("C");
        
	  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, a, N) for(int i = a; i < N; i++)

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 2);
    A[0] = 0;
    A[N + 1] = 0;
    rep(i, 1, N + 1) cin >> A[i];

    ll sum = 0;
    rep(i, 1, N + 2) sum += abs(A[i] - A[i - 1]);
    rep(i, 1, N + 1) {
        cout << (ll)(sum - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i - 1])) << endl;
    }
}

Measured memory_bytes: 1664
use std::io;
use std::cmp;


/// https://beta.atcoder.jp/contests/abc074/tasks/abc074_b
fn main() {
    let _ = read_one::<usize>();
    let k = read_one::<isize>();
    let x = read::<isize>();
    let ans = x.iter().fold(0, |sum, a| sum + cmp::min(a, &(a - k).abs()) * 2);
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(){
    int N;
    int res;
    vector<int> vp(200020);

    // int64_t vp[100010];
    // string res;
    // int64_t vp_xor = 0ll;
    int max1, max2;
    max1 = -1;
    max2 = -1;

    cin >> N;
    for (int i=0; i<N; i++){
        cin >> vp.at(i);
        if (max1 <= vp.at(i)){
            max2 = max1;
            max1 = vp.at(i);
        }
        if ((max1 > vp.at(i)) && (max2 <= vp.at(i))){
            max2 = vp.at(i);
        }
    }

    for (int i=0; i<N; i++){
        if (vp.at(i) == max1) cout << max2 << endl;
        else cout << max1 << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Ent = new Scanner(System.in);
        String pred = Ent.next();
        String actual = Ent.next();
        char arr1[] =  pred.toCharArray();
        char arr2[] =  actual.toCharArray();
        int numero = 0;
        for (int i = 0; i < arr1.length; i++) {
            if(arr1[i] == arr2[i]){
                numero++;
            }
        }
        System.out.println(numero);
    }
}


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

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

int main() {
  ll n, ans = 0, a, even = 0;
  unordered_map<ll, ll> mp;
  cin >> n;
  rep(i, n) scanf("%d", &a), mp[a]++;

  for (auto m : mp) {
    if (m.second > 1 && m.second % 2 == 0) even++;
    ans++;
  }

  cout << (even % 2 == 0 ? ans : ans - 1) << endl;
  return 0;
}


Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
int main(){
        vector<set<int>>v(26);
        int n;
        cin>>n;
        string s;
        cin>>s;
        for(int i=0;i<int(s.size());i++){
            v[s[i]-'a'].insert(i);
        }
        int r;
        cin>>r;
        while(r--){
            int a;
            cin>>a;
            if(a==2){
                int l,r;
                cin>>l>>r;
                int ans=0;
                l--;
                r--;
                for(int i=0;i<26;i++){
                     auto lower = v[i].lower_bound(l);
                     if(v[i].end()!=lower && *lower<=r){
                         ans++;
                     }
                }
               cout<<ans<<endl;
            }
            else{
                 int l;
                 char ch;
                 cin>>l;
                 cin>>ch;
                 l--;
                 if(s[l]!=ch){
                 v[s[l]-'a'].erase(l);
                 v[ch-'a'].insert(l);
                 s[l]=ch;
                }
            }
        }
}


Measured memory_bytes: 24196
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
ll power(ll a,ll b){return b?power(a*a%2019,b/2)*(b%2?a:1)%2019:1;}


int main(){FIN


 
    string s; cin>>s;

    ll n=s.size();
    map<ll,ll> mp;
    ll count=0;
    ll dig;
    FORR(i,n-1,0){

        if(i==n-1) dig=s[i]-'0';
        else dig += power(10,count)*(s[i]-'0');

        mp[dig%2019]++;
        dig%=2019;
        count++;
    }

    mp[0]++;
    ll ans=0;
    for(auto p:mp){
        ll m = p.second;
        ans+=m*(m-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3744
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

N = ii()
A = [ii() for i in range(N)]

A.sort()
u1, u2 = [], []
l1, l2 = [], []
for i in range(N):
    if i < N//2:
        l1.append(A[i])
    else:
        u1.append(A[i])

    if i < (N+1)//2:
        l2.append(A[i])
    else:
        u2.append(A[i])

if N%2:
    ans = max(
        (2*sum(u1)-u1[0]-u1[1]) - 2*sum(l1),
        2*sum(u2) - (2*sum(l2)-l2[-1]-l2[-2])
    )
else:
    ans = (2*sum(u1)-u1[0]) - (2*sum(l1)-l1[-1])

print(ans)

Measured memory_bytes: 15920
#include <stdio.h>


int main(void)
{
	int j,k;
	char *s;
	
	fscanf(stdin, "%d %d", &j,&k);
	
	if (j == k)       s = "==";
	else if (j < k)   s = "<";
	else              s = ">";
	
	fprintf(stdout, "a %s b", s);
	fputc('\n', stdout);
	
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define sort_be(a) sort(a.begin(), a.end());
#define reverse_be(a) reverse(a.begin(), a.end());
#define vi vector<int>
#define vvii(a, b, c) vector<vector<int>> a(b, vector<int>(c));
using namespace std;
using ll = long long;
int main(){
    ll k, a, b;
    cin >> k >> a >> b;
    cout << max(k + 1 , ((k - a + 1) / 2) * (b - a) + a + (k - a + 1) % 2) << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
	long long  x,y;
	scanf("%lld%lld",&x,&y);
	//printf("%lld   %lld",x,y);
	long long w=y;
	int anc=0;
	for(long long i=x;i<=w/2;i=i*2)
	{
		//printf("%lld\n",i);
		anc++;
	}
	printf("%d\n",anc+1);
	return 0;
 } 

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n,m;
map<string,ll> cnt;

int main(){
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        cnt[s]++;
    }
    cin >> m;
    rep(i,m){
        string s;
        cin >> s;
        cnt[s]--;
    }
    ll ans = 0;
    for(auto it = cnt.begin();it != cnt.end();it++){
        ans = max(ans, it -> second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int n,k;
bool f[10];

bool judge(int n)
{
    int k;
    while(n>0){
        k=n%10; n/=10;
        if(f[k]==1)
            return 0;
    }
    return 1;
}

int main(void)
{
    memset(f,0,sizeof(f));
    scanf("%d%d",&n,&k);
    for(int i=0;i<k;i++){
        int t;
        scanf("%d",&t);
        f[t]=1;
    }
    
    while(1){
        if(judge(n)){
            printf("%d\n",n);
            return 0;
        }
        n++;
    }
    return 0;
}

Measured memory_bytes: 128
def execute(N, L):
    c = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
                if judge(L[i], L[j], L[k]):
                    c += 1

    return c

def judge(a, b, c):
    if a==b or b==c or c==a:
        return False
    if a+b > c and b+c > a and a+c >b:
        return True
    else:
        return False

if __name__ == '__main__':
    N = int(input())
    L = list(map(int, input().split()))

    print(execute(N, L))

Measured memory_bytes: 9184
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main(void) {
	int R;
	cin >> R;
	cout << 2 * R * 3.1415 << endl;


	return 0;
}


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

using namespace std;

int main() {
  int d, g;
  cin >> d >> g;
  vector<int> p(d), c(d);
  for (int i = 0; i < d; i++) {
    cin >> p[i] >> c[i];
  }

  int ans = 1003;
  for (int bit = 0; bit < (1 << d); bit++) {
    int score = 0, cnt = 0;
    for (int i = 0; i < d; i++) {
      if ((bit >> i) & 1) {
        score += 100 * (i + 1) * p[i] + c[i];
        cnt += p[i];
      }
    }
    for (int i = d - 1; i >= 0; i--) {
      if (score >= g) {
        break;
      }
      if (((bit >> i) & 1) != 1) {
        for (int j = 0; j < p[i]; j++) {
          cnt++;
          score += 100 * (i + 1);
          if (score >= g) {
            break;
          }
        }
      }
    }
    ans = min(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int,int> pii;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;


void solve(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> hw(h);
    rep(i,h) cin >> hw[i];
    
    int ans = 0;
    for(int i = 0; i < (1<<h);i++){
        for(int j = 0; j < (1<<w); j++){
            int c = 0;
            for(int ii = 0; ii < h; ii++){
                for(int jj = 0; jj < w; jj++){
                    if (hw[ii][jj] == '#'){
                        
                        if (((i>>ii)&1 )== 0){
                            if (((j>>jj)&1) == 0){
                                c++;
                                
                            }
                        }
                    }
                }
            }
            if (c==k) ans++;
        }
    }
    cout << ans;
}

int main(){
    int T;
    T = 1;
    while(T--){
        solve();
        cout << endl;
    }
}






Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
 
using namespace std;

 ll mod=1e9+7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

ll expo2(ll base,ll exponent)
{
	ll ans=1;
	while(exponent!=0)
	{
		if(exponent & 1) ans=(1LL*ans*base);
		base=(1LL*base*base);
		exponent>>=1;
	}
	return ans;
}

vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

vector<ll> g[200005];
vector<ll>vis(200005,0);
void dfs(ll node,ll &cur)
{
	cur++;
	vis[node]=1;
	for(auto x:g[node])
	{
		if(!vis[x])
			dfs(x,cur);
	}
}


int main()
{
    
    // #ifndef ONLINE_JUDGE
    //     freopen ("data.in","r",stdin);
    //     freopen ("E.out","w",stdout);
    // #endif
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // Sieve();
    int tests=1;
    // cin>>tests;
    while(tests--)
    {	
    	ll i,j,n,m,a,b;
    	cin>>n>>m;
    	set<pair<ll,ll>>st;
    	rep(i,0,m-1)
    	{
    		cin>>a>>b;
    		if(st.find({a,b})!=st.end() || st.find({b,a})!=st.end()) continue;
    		st.insert({a,b});
    		g[a].pb(b);
    		g[b].pb(a);
    	}
    	ll ans=0;
    	for(i=1;i<=n;i++)
    	{
    		if(vis[i]) continue;
    		ll cur=0;
    		dfs(i,cur);
    		ans=max(ans,cur);
    	}
    	cout<<ans;
    }
    	return 0;
    
}

Measured memory_bytes: 45492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int bit[100010];
int n,q;
void range_add(int loc,int x){
    while(loc){
        bit[loc]+=x;
        loc-=loc&-loc;
    }
}
int get(int loc){
    int res=0;
    while(loc<=n){
        res+=bit[loc];
        loc+=loc&-loc;
    }
    return res;
}
int main(){
    cin >> n >> q;
    for(int i=0;i<q;i++){
        int query;cin >> query;
        if(query==0){
            int s,t,x;cin >> s >> t >> x;
            range_add(t,x);
            range_add(s-1,-x);
        }
        else{
            int i;cin >> i;
            cout << get(i) << endl;
        }
    }
    return 0;
}


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

int main(){
long long x,k,d;
cin >> x >> k >>d;

long long y = abs(x);
long long a =1;
long long ans =0;

a = y/d;
y -= min(a,k)*d;

if(a>=k) ans = y;
else {
  if((k-a)%2==0){
    ans = y;
  }
  else{
    ans = abs(y-abs(d));
  }
}

cout << ans <<endl;

}

Measured memory_bytes: 3632
#include <iostream>
#define MAX_N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;

int G[MAX_N][MAX_N];
int status[MAX_N];
int d[MAX_N];
int f[MAX_N];
int time_count, n;

void dfs_visit(int v) {
  d[v] = ++time_count;
  status[v] = GRAY;
  for (int i = 1; i <= n; i++) {
    if (G[v][i] && status[i] == WHITE) dfs_visit(i);
  }

  f[v] = ++time_count;
  status[v] = BLACK;
}

void dfs() {
  for (int i = 0; i < n; i++) {
    status[i] = WHITE;
  }

  time_count = 0;
  int i;
  for (i = 1; i <= n; i++) {
    if (status[i] == WHITE) {
      dfs_visit(i);
    }
  }
}

void init() {
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      G[i][j] = 0;
    }
  }
}

int main() {
  init();
  cin >> n;
  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      G[u][v] = 1;
    }
  }

  dfs();

  for (int i = 1; i <= n; i++) {
    cout << i << ' ' << d[i] << ' ' << f[i] << endl;
  }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 300005;

ll l[N], c[N];

int main(){
	fastio;
	int h,w,m;
	cin >> h >> w >> m;
	vector<ii> v(m);
	ll max_line = 0, max_row = 0;
	for(int i = 0; i < m; i++){
		cin >> v[i].fst >> v[i].snd;
		l[v[i].fst]++;
		c[v[i].snd]++;
		max_line = max(max_line, l[v[i].fst]);
		max_row = max(max_row, c[v[i].snd]);
	}
	ll qtl = 0, qtr = 0;
	for(int i = 0; i < N; i++){
		if(l[i] == max_line) qtl++;
		if(c[i] == max_row) qtr++;
	}
	ll total = qtl*qtr;
	for(int i = 0; i < m; i++){
		if(l[v[i].fst] == max_line and c[v[i].snd] == max_row)
			total--;
	}
	if(total > 0) cout << max_line + max_row << '\n';
	else cout << max_line + max_row - 1 << '\n';
	return 0;
}


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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'


void pre(){

}

ll n;
vector<ll> tree[maxs];
ll sz[maxs];
ll c[maxs];
vector<ll> ans;
ll cnt[maxs];
ll all;

ll get(ll n){
    return n*(n-1)/2;
}

void dfs(ll s,ll p){
    sz[s] = 1;
    ll bfr = cnt[c[s]];
    for(auto d : tree[s]){
        if(d!=p){
            ll pre = all - cnt[c[s]];
            dfs(d,s);
            sz[s] += sz[d];
            ll next = all - cnt[c[s]];
            ans[c[s]] -= get(next-pre);
        }
    }
    cnt[c[s]] = bfr + sz[s];
    all++;
}

void solve(){
    cin >> n;
    for(ll i=1;i<=n;i++){
        cin >> c[i];
    }
    for(ll i=0;i<n-1;i++){
        ll s,d;
        cin >> s >> d;
        tree[s].pb(d);
        tree[d].pb(s);
    }

    ans = vector<ll>(n+1,get(n));
    dfs(1,-1);

    for(ll i=1;i<=n;i++){
        ll rem = n-cnt[i];
        ans[i] -= get(rem);
    }

    for(ll i=1;i<=n;i++){
        ans[c[i]]++;
    }

    for(ll i=1;i<=n;i++){
        cout << ans[i] << endl;
    }

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin >> T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int answer;
  answer=0;
  for(int count = 0; count <4; count = count + 1){
    if(S[count]=='+'){
      answer = answer+1;
    }else{
      answer = answer-1;
    }
  }
  cout << answer <<  endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

string hoge(string& s, string& t) {
	if (s.length() > t.length()) return s;
	else if (s.length() < t.length()) return t;
	else if (s > t) return s;
	else return t;
}

int main() {
	for (;;) {
		int W, H; cin >> W >> H;
		if (W == 0) break;
		vector<string> C(H);
		for (int i = 0; i < H; i++) cin >> C[i];
		vector< vector<string> > dp(H, vector<string>(W));
		for (int i = H - 1; i >= 0; i--)
			for (int j = W - 1; j >= 0; j--) {
				if (C[i][j] >= 'A' && C[i][j] <= 'Z') continue;
				string s;
				if (i + 1 < H) s = hoge(s, dp[i + 1][j]);
				if (j + 1 < W) s = hoge(s, dp[i][j + 1]);
				dp[i][j] = C[i][j] + s;
			}
		string s;
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++) {
				while (dp[i][j].length() > 0 && dp[i][j][0] == '0')
					dp[i][j].erase(dp[i][j].begin());
				s = hoge(s, dp[i][j]);
			}
		cout << s << endl;
	}
}

Measured memory_bytes: 1340
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		sc.close();

		int Hh = 0;
		Hh = H - h;
		int Ww = 0;
		Ww = W - w;
		int ans = 0;
		ans = Hh * Ww;
		System.out.println(ans);


	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const ll INF=2e15;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false); 

    int a,b;
    cin >> a >> b;
    vector<vector<char>> u(50,vector<char>(100,'#'));
    vector<vector<char>> d(50,vector<char>(100,'.'));
    int r=0,c=0;
    rep(i,a-1) {
        u[r][c]='.';
        c+=2;
        if (c==100) {
            c=0;
            r+=2;
        }
    }
    r=49,c=0;
    rep(i,b-1) {
        d[r][c]='#';
        c+=2;
        if (c==100) {
            c=0;
            r-=2;
        }
    }
    cout << 100 << ' ' << 100 << endl;
    rep(i,50) {
        rep(j,100) cout << u[i][j];
        cout << endl;
    }
    rep(i,50) {
        rep(j,100) cout << d[i][j];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>

int main()
{
	unsigned long long A, B, K;
	std::cin >> A >> B >> K;




	if (A < K) {
		// K回やってA枚がゼロになった
		K -= A;

		if (B < K) {
			// 残りK'回やってB枚がゼロになった
			std::cout << 0 << " " << 0 << std::endl;
		}
		else {
			// 残りK'回やってB枚に足りなかった
			std::cout << 0 << " " << B - K << std::endl;
		}
	}
	else {
		// K回やってA枚に足りなかった
		std::cout << A - K << " " << B << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

#define o5 100100
#define o12 1000000000000

ll n, m;
vector<ll> G[o5];

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

    ll a, b, tmp;
    cin >> n >> m;
    for (ll i = 0; i < m; i++)
    {
        cin >> a >> b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);
    }

    // bfs
    queue<ll> Q;
    vector<ll> source(n, -1);
    Q.push(0);
    while (!Q.empty())
    {
        tmp = Q.front();
        Q.pop();
        for (ll j = 0; j < G[tmp].size(); j++)
        {
            a = G[tmp][j];
            if (source[a] == -1)
            {
                Q.push(a);
                source[a] = tmp;
            }
        }
    }
    source[0] = 0;
    bool possible = find(source.begin(), source.end(), -1) == source.end();
    if (possible)
    {
        cout << "Yes" << endl;
        for (ll i = 1; i < n; i++)
        {
            cout << source[i] + 1 << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 12976
#include<iostream>

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    if(n == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }else if(n == 23){
        cout << "Christmas Eve Eve" << endl;
    }else if(n == 24){
        cout << "Christmas Eve" << endl;
    }else{
        cout << "Christmas" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,ans=0;
	cin>>n;
	for(ll i=1;i<n;i++){
		ll now=n-i;
		if(i==now||now<i){
			break;
		}
		ans++;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

using namespace std;

long long power(int x, int y){
  long long n = 1;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}

int log(int x, int y){
  int cnt = 0;
  while(y > 1){
    y /= x;
    cnt++;
  }
  return cnt;
}

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<int> a(1,1);
  for(int i = 1; i < n; i++){
    if(s.at(i) == s.at(i-1))
      a.at(a.size()-1)++;
    else
      a.push_back(1);
  }
  
  int cnt = n-a.size();
  if(s.at(0) == 'L')
    cnt--;
  if(s.at(s.size()-1) == 'R')
    cnt--;
  
  if(k == 1){
    if(s.at(0) == 'L' || s.at(s.size()-1) == 'R')
      cnt += 3;
    else
      cnt += 2;
    k --;
  }
  
  else {
    if(s.at(0) == 'L'){
      cnt += 3;
      k--;
    }
    if(s.at(s.size()-1) == 'R'){
      cnt += 3;
      k--;
    }
  }
  
  cnt = min(n-1, cnt+2*k);
  
  cout << cnt << endl;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    int sumdigit = 0;
    int ans = 0;
    rep(i, N) {
        sumdigit = 0;
        int tmp = i+1;
        while(tmp > 0) {
            sumdigit += tmp % 10;
            tmp /= 10;
        }
        if (A <= sumdigit && sumdigit <= B) ans += i+1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n;
  cin >> n;
  vl a(n);
  ll now = 0;
  rep (i, n) {
    cin >> a[i];
    now ^= a[i];
  }
  vl b;
  rep (i, n) {
    ll mask = 1;
    while ((mask & a[i]) == 0) {
      mask <<= 1;
    }
    b.push_back((mask << 1) - 1);
  }
  sort(all(b));
  int ans = 0;
  rrep (i, n) {
    if (now == 0) break;
    ll mask = 1LL << 50;
    int cnt = 50;
    while ((mask & now) == 0) {
      mask >>= 1;
      cnt--;
    }
    mask <<= 1;
    mask--;
    if (mask == b[i]) {
      ans++;
      now ^= mask;
    }
  }
  if (now != 0) {
    cout << -1 << endl;
  }
  else {
    cout << ans << endl;
  }
}


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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int max = -10000000;
    int min = 10000000;
    int64_t sum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a.at(i));
        if (a.at(i) >= max) {
            max = a.at(i);
        }
        if (a.at(i) <= min) {
            min = a.at(i);
        }
        sum += a.at(i);
    }
    printf("%d %d %lld\n", min, max, sum);
}


Measured memory_bytes: 3240
#include<stdio.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(i=0; i<n; i++)

int main(void)
{
	int h, a, i=0;
	scanf("%d%d", &h, &a);
	while(h > 0){
		h -= a;
		i++;
	}
	printf("%d", i);
	return 0;
}

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int N = 0;
    rep(i, a){
        N++;
        if(i >= k)   break;
    }
    rep(j, b){
        if(j >= (k - a))   break;
    }
    
    rep(m, c){
        if(m > (k - a - b))   break;
        N--;
    }
    
    cout << N << endl;
}

Measured memory_bytes: 3572
import heapq

class PrioritySet(object):
    def __init__(self):
        self.heap = []
        self.set = set()

    def add(self, pri, d):
        if not d in self.set:
            heapq.heappush(self.heap, (pri, d))
            self.set.add(d)

    def get(self):
        pri, d = heapq.heappop(self.heap)
        self.set.remove(d)
        return (pri, d)

X, Y, Z, K = map(int, input().split())
As = map(int, input().split())
As = sorted(As, reverse=True)
Bs = map(int, input().split())
Bs = sorted(Bs, reverse=True)
Cs = map(int, input().split())
Cs = sorted(Cs, reverse=True)

count = 0
h = PrioritySet()
h.add(-sum([As[0], Bs[0], Cs[0]]), (0, 0, 0))
while True:
    m, ii = h.get()
    ai, bi, ci = ii
    print(-m)
    count += 1
    if count == K:
        break

    if ai + 1 < len(As):
        h.add(-sum([As[ai+1], Bs[bi], Cs[ci]]), (ai+1, bi, ci))
    if bi + 1 < len(Bs):
        h.add(-sum([As[ai], Bs[bi+1], Cs[ci]]), (ai, bi+1, ci))
    if ci + 1 < len(Cs):
        h.add(-sum([As[ai], Bs[bi], Cs[ci+1]]), (ai, bi, ci+1))

Measured memory_bytes: 4468
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		int A[]=new int[N];
		int sum[][]=new int[M][2];
		int z=0,x=0,y=0,max=0;
		long ans=0;
		while(z<N){
			A[z]=stdIn.nextInt();
			z++;
		}z=0;
		Arrays.sort(A);
		while(z<M){
			sum[z][1]=stdIn.nextInt();
			sum[z][0]=stdIn.nextInt();
			z++;
		}z=0;
		Arrays.sort(sum, (a, b) -> Long.compare(a[0], b[0]));
		while(z<N){
			if(x!=M)
				if(A[z]<sum[M-x-1][0]&&y==0){
					y=sum[M-x-1][1];
					x++;	
				}
			if(x==0)
				max=1;
			if(A[z]>=sum[M-x-max][0]||y==0)
				ans+=A[z];
			else{
				ans+=sum[M-x-max][0];
				y--;
			}
			max=0;
			z++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 100416
class Baseball:

	def __init__(self, score = 0):
		self.inning = Inning()
		self.game_score = score

	# def get_game_score(self):
	# 	return self.game_score

	def change(self):
		del self.inning
		self.inning = Inning()

	def batting(self, event):
		if event == 'HIT':
			self.inning.hit()
		elif event == 'HOMERUN':
			self.inning.homerun()
		elif event == 'OUT':
			self.inning.out()
		else:
			print('Error')

	def check_outcnt(self):
		return bool(self.inning.get_outcnt() != 3)

	# def update_score(self):
	# 	self.game_score += self.inning.get_score()

	def run(self):
		while self.check_outcnt():
			self.batting(input())
		# self.update_score()
		print(self.inning.get_score())
		self.change()


class Inning:

	def __init__(self, score = 0, outcnt = 0):
		self.base = Base()
		self.score = score
		self.outcnt = outcnt

	def hit(self):
		self.score += self.base.update(1)

	def homerun(self):
		self.score += self.base.update(4)
		self.base.clear()

	def out(self):
		self.outcnt += 1

	def get_outcnt(self):
		return self.outcnt

	def get_score(self):
		return self.score


class Base:
	def __init__(self):
		self.runner = [0, 0, 0]
	
	def update(self, num):
		score = 0
		for _ in range(num):
			score += self.runner.pop(0)
			self.runner.append(1)
		return score

	def clear(self):
		self.runner = [0, 0, 0]

def main():
	game = Baseball()
	for _ in range(int(input())):
		game.run()

if __name__ == '__main__':
	main()


Measured memory_bytes: 5600
import sys
from itertools import product

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    d, g = map(int, input().split())
    PC = []
    for i in range(d):
        p, c = map(int, input().split())
        PC.append([(i + 1) * 100, p, c])

    res = f_inf
    for pattern in product([0, 1], repeat=d):
        score = 0
        cnt = 0
        remain = []
        for idx, p in enumerate(pattern):
            if p == 1:
                point, num, bonus = PC[idx]
                score += point * num + bonus
                cnt += num
            else:
                remain.append(PC[idx])

        if score >= g:
            res = min(res, cnt)
        else:
            remain = sorted(remain, key=lambda x: x[0], reverse=True)
            diff = g - score
            for point, num, bonus in remain:
                if diff <= point * (num - 1):
                    cnt += diff // point + (1 if diff % point else 0)
                    res = min(res, cnt)
                    break
                else:
                    cnt += num - 1
                    score += point * (num - 1)

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	ll N; cin >> N;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	multiset<ll, greater<ll>> S;
	for (int i = 0; i < N; i++) {
		auto p = S.upper_bound(a[i]);
		if (p != S.end()) S.erase(p);
		S.insert(a[i]);
	}
	cout << S.size() << endl;

	return 0;
}

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

int N;
int x[MAX_N];
int y[MAX_N];
// int N = 3;
// int x[] = {0, 1, 0};
// int y[] = {0, 0, 1};

int main() {
    
    cin >> N;
    rep(i, N) {
        cin >> x[i] >> y[i];
    }
    vector<int> target;
    rep(i, N) {
        target.push_back(i);
    }

    double total_dist = 0;
    int total_count = 0;

    // 順列
    do {
        total_count++;
        int target_arr[N];
        for (int i = 0; i < target.size(); i++) {
            // printf("%d ", target[i]);
            target_arr[i] = target[i];
        }
        // printf("\n");

        for (int i = 0; i <= target.size() - 2; i++) {
            double calc_x = pow((x[target_arr[i]] - x[target_arr[i + 1]]), 2);
            double calc_y = pow((y[target_arr[i]] - y[target_arr[i + 1]]), 2);
            double dist = pow(calc_x + calc_y, 0.5);
            // cout << dist << endl;
            total_dist += dist;
        }
        // cout << endl;
    } while (next_permutation(target.begin(), target.end()));

    cout << std::setprecision(10) << total_dist / total_count << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args){

        int n = sc.nextInt();
        int t = sc.nextInt();
        int[][] ab = new int[n][2];
        for (int i=0; i<n; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            ab[i][0] = a;
            ab[i][1] = b;
        }

        Arrays.sort(ab, (c1, c2)->c1[0]-c2[0]);

//        System.out.println(ab[0][1]);


        PriorityQueue<int[][]> pq = new PriorityQueue<>();
        
        int[] dp = new int[t];
        
        int max = 0;
        
        for (int i=0; i<n; i++){
            int a = ab[i][0];
            int b = ab[i][1];
            max = Math.max(max, dp[t-1]+b);
            
            for (int j=t-1; j>=0; j--){
                if (j>=a){
                    dp[j] = Math.max(dp[j], dp[j-a]+b);
                }
            }
        }
        System.out.println(max);


    }
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 100005
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll _; cin >> _; while(_--)
#define endl "\n"
#define flush fflush(stdout);

int main(){

    fast

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll x1 = a*c;
    ll x2 = a*d;
    ll x3 = b*c;
    ll x4 = b*d;

    x1 = max(x1,x2);
    x1 = max(x1,x3);
    x1 = max(x1,x4);
    cout << x1 << endl;

}


//    cout << fixed << setprecision(12);


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

int main()
{
  int n;
  int check[4][3][10]={0};

  cin >> n;

  int i,a,b,c,d;
  for(i=0;i<n;i++){
    cin >> a >> b >> c >> d;
    check[a-1][b-1][c-1] += d;
  }

  for(i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++)
	cout << " " << check[i][j][k];
      cout << endl;
    }
    if(i!=3){
      for(int l=0;l<20;l++)
	cout << "#";
      cout << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3100
// 2013/06/14 Tazoe

#include <iostream>
using namespace std;

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

	for(int i=0; i<n; i++){
		int Y, M, D;
		cin >> Y >> M >> D;

		int sum = 0;

		for(int j=Y+1; j<1000; j++){
			if(j%3==0){
				sum += 200;
			}
			else{
				sum += 195;
			}
		}

		for(int j=M+1; j<=10; j++){
			if(Y%3==0||j%2==1){
				sum += 20;
			}
			else{
				sum += 19;
			}
		}

		if(Y%3==0||M%2==1){
			sum += 20-(D-1);
		}
		else{
			sum += 19-(D-1);
		}

		cout << sum << endl;
	}

	return 0;
}

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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class B81 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    REP(x,1,10) {
	        REP(y,1,10) {
	            if (x * y == N) {
	                out << "Yes" << "\n";
	                return;
	            }
	        }
	    }
	    out << "No" << "\n";
	}
};


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


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<vector<ll> > lis(n, vector<ll>(2, 0));
    REP(i, 0, n){
        cin >> lis[i][0] >> lis[i][1];
    }
    sort(ALL(lis), [](auto &x, auto &y){return x[1]<y[1];});
    ll time = 0;
    REP(i, 0, n){
        if(time+lis[i][0] > lis[i][1]){
            cout << "No" << endl;
            return 0;
        }else{
            time += lis[i][0];
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 11136