akhauriyash/Code-Regression huggingface dataset:
s=list(input())
n=len(s)
ans=[]
if n==1:
  if s.pop() in list('ATCG'):
    print(1)
    exit()

for i in range(n-1):
  for j in range(i+1,n+1):
    part=set(s[i:j])
    flag=True
    for p in part:
      if p not in list('ATGC'):
        flag=False
        break
    if flag==True:
      ans.append(len(s[i:j]))
#print(ans)
if ans:
  print(max(ans))
else:
  print(0)

Measured memory_bytes: 38384
#n=[input() for _ in range(int(input()))]
#m=[input() for _ in range(int(input()))]
n1=int(input())
n=[input() for i in range(n1)]
m1=int(input())
m=[input() for i in range(m1)]
#print(n)
#print(m)
l=list(set(n))
#print(l)
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))
#print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long t,k;
	cin>>t;
	cin>>k;
	long long a[t]={0},b[t]={0};
	
	for(long long i=0;i<t;i++){
		cin>>a[i];
		if(i==0){
			b[i]=0;
		}
		else if(i==1){
			b[i]=(abs(a[1]-a[0]));
			
		}
		else if((i+1)<=k){
			long long z=(abs(a[i]-a[0]));
			long long minimum=0;
			for(long long j=i-1;j>=0;j--)
			{
				long long y=(abs(a[i]-a[j]))+b[j];
			   if(j==(i-1)){
			   	minimum=y;
			   }	
			   else if(y<minimum){
			   	minimum=y;
			   }
			}
			b[i]=min(minimum,z);
		}
		else{
			long long mini=0;
			long long l=k;
			long long j=(i-1);
			while(l--){
				long long x=(abs(a[i]-a[j]))+b[j];
				if(j==(i-1)){
					mini=x;
				}
				else{
					if(x<mini){
						mini=x;
					}
				}
				j--;
			}
			b[i]=mini;
		}
	}
	cout<<b[t-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 2e5 + 9;



int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s,t;
	cin >> s >> t;
	int ans = 0;
	for(int i=0; i < s.length(); i++){
        if( s[i] != t[i] ) ++ans;
	}
	cout << ans;


}


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

int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  int a = 0;
  int b = 0;
  for(int i = 0; i < n; i++) {
    cin >> c.at(i);
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  for(int i = 0; i < n;) {
    a += c.at(i);
    i++;
    if(i < n) {
      b += c.at(i);
      i++;
    } else {
      break;
    }
  }
  cout << a - b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
#include <climits>

int N,M,a[55],b[55];

using namespace std;

int main()
{
	int count[55];
	cin >> N >> M;
	for(int i = 0;i<M;i++){
		cin >> a[i] >> b[i];
	}
	for(int i = 0;i<N;i++){
		count[i] = 0;
		for(int j = 0;j<M;j++){
		if(a[j] == i+1 || b[j] == i+1){count[i]++;}
		}
		cout << count[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c, i, x;

	scanf("%d%d%d", &a, &b, &c);
	
	i = 0;
	
	for (x = a; x <= b; x++){
		if (c % x == 0) i++;
	}
	printf("%d\n", i);
	
	return 0;
}



Measured memory_bytes: 2144
s = input()
q = int(input())
for _ in range(q):
    x = input().split()
    a, b = int(x[1]), int(x[2])
    if x[0] == 'print':
        print(s[a:b+1])
    if x[0] == 'reverse':
        s = s[:a] + ''.join(reversed(s[a:b+1])) + s[b+1:]
    if x[0] == 'replace':
        s = s[:a] + x[3] + s[b+1:]

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

int main(){
	char st[300000];
	scanf("%s", st);
	string ent=st;
	int n=ent.size();
	int count=0; char last=ent[0];
	for(int i=1; i<n; i++){
		if(ent[i]==last){
			count++;
			if(last=='0')
				last='1';
			else
				last='0';
		}
		else{
			last=ent[i];
		}
	}
	cout << count << endl;
}

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

int main() {
  int A , B ;
  cin >> A >> B ;
  
  if ((A % 3 == 0) || (B % 3 == 0) || ((A + B) % 3 == 0)){
    cout << "Possible" << endl;
  }
  else {
    cout <<"Impossible"<< endl;
  }
}




Measured memory_bytes: 256
N = int(input())
lsA = list(map(int,input().split()))
x1_2 = 0
for i in range(N):
    if i % 2 == 0:
        x1_2 += lsA[i]
    else:
        x1_2 -= lsA[i]
x1 = x1_2//2
lsx = [x1]
for i in range(N):
    lsx.append(lsA[i]-lsx[i])
lsx2 = [str(2*lsx[i]) for i in range(N)]
print(' '.join(lsx2))

Measured memory_bytes: 25860
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new java.util.Scanner(System.in);
		while (sc.hasNext()) {
			int n = sc.nextInt();
			int count = 0;
			for (int a = 0; a < 10; a++) {
				for (int b = 0; b < 10; b++) {
					for (int c = 0; c < 10; c++) {
						for (int d = 0; d < 10; d++) {
							if (a + b + c + d == n) {
								count++;
							}
						}
					}
				}
			}
			System.out.println(count);
		}

	}

}

Measured memory_bytes: 26672
# 5_C
while(True):
    H,W=map(int,input().split())
    if H ==0 and W ==0:
        break
    h=0
    while(h<H):
        if h%2 == 0:
            for i in range(W):
                if i%2 ==0:
                    print("#",end='')
                else:
                    print(".", end='')
            print()
        else:
            for i in range(W):
                if i%2 ==0:
                    print(".", end ='')
                else:
                    print("#", end='')
            print()
        h+=1
    print()
    


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

int main()
{
	int m[10];
	for (int i=0; i<10; ++i)
		cin >> m[i];
	sort(m, m+10);
	for (int i=9; i>6; --i)
		cout << m[i] << '\n';
	return 0;
}

Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var inputs = new int[n + 1,3];
            inputs[0,0] = 0;
            inputs[0,1] = 0;
            inputs[0,2] = 0;

            for (int i = 1;i <= n; i++)
            {
                var txy = Console.ReadLine().Split().Select(int.Parse).ToArray();
                inputs[i, 0] = txy[0];
                inputs[i, 1] = txy[1];
                inputs[i, 2] = txy[2];

            }

            var ans = "Yes";
            for(int i = 0; i < n ; i++)
            {
                var dt = inputs[i + 1,0] - inputs[i,0];
                var distance = Math.Abs(inputs[i + 1,1] - inputs[i,1]) + Math.Abs(inputs[i + 1,2] - inputs[i,2]);

                if(distance > dt)
                {
                    ans = "No";
                    break;
                }

                if (distance % 2 != dt % 2)
                {
                    ans = "No";
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 47912
import java.util.*;
public class Main {
  	static int mod = 1000000007;
  static int size = 200001;
	static long[] fac = new long[size];
	static long[] finv = new long[size];
	static long[] inv = new long[size];
	static int INF = Integer.MAX_VALUE;
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 整数の入力
	int N = sc.nextInt();
  int[] B = new int[N-1];
  int[] A = new int[N];
  int i=0;
  int sum=0;
  for(i=0;i<N-1;i++){
    B[i]=sc.nextInt();
  }
  A[0]=B[0];
  for(i=1;i<N-1;i++){
    if(B[i]>B[i-1]){
    	A[i]=B[i-1];
    }else{
    	A[i]=B[i];   
    }
  }
  A[N-1]=B[N-2];
  for(i=0;i<N;i++){
    sum=sum+A[i];
  }

    System.out.println(sum);



} 

 //fac, inv, finvテーブルの初期化、これ使う場合はinitComb()で初期化必要
	public static  void initComb(){
		fac[0] = finv[0] = inv[0] = fac[1] = finv[1] = inv[1] = 1;
		for (int i = 2; i < size; ++i) {
			fac[i] = fac[i - 1] * i % mod;
			inv[i] = mod - (mod / i) * inv[(int) (mod % i)] % mod;
			finv[i] = finv[i - 1] * inv[i] % mod;
		}
	}
 
	//nCk % mod
	public static long comb(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
		return fac[n] * finv[k] % mod * finv[n - k] % mod;
	}
 
	//n! % mod
	public static long fact(int n){
		return fac[n];
	}
 
	//(n!)^-1 with % mod
	public static long finv(int n){
		return finv[n];
	}
  
}

Measured memory_bytes: 26068
#include <bits/stdc++.h>
#define ABS(x) ((x) >= 0 ? (x) : -(x))


using namespace std;



int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int x;
    cin >> x;
    cout << 1 - x;
}


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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    string S, T;
    cin >> S >> T;

    int ans = 0;
    REP(i, 3) {
        if (S[i] == T[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import math
n, y = map(int, input().split())

for i in range(n + 1):
    for j in range(n - i + 1):
        k = n - i - j
        if i * 10000 + j * 5000 + k * 1000 == y:
            print(i, j, k)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 9176
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long[][] a = new long[4][3];
        a[0][0] = sc.nextLong();
        a[1][0] = sc.nextLong();
        a[2][0] = sc.nextLong();
        a[3][0] = sc.nextLong();
        a[0][1] = a[0][0] *8;
        a[1][1] = a[1][0] *4;
        a[2][1] = a[2][0] *2;
        a[3][1] = a[3][0];
        a[0][2] = 4;
        a[1][2] = 2;
        a[2][2] = 1;
        a[3][2] = 0;
        Arrays.sort(a, (x, y) -> Long.compare(x[1], y[1]));
        long n = sc.nextLong();
        long ans = 0;
        if(a[0][2] == 0){
            ans += Math.floorDiv(n, 2l) * a[0][0];
            if(n % 2 != 0){
                ans += a[1][0] * a[1][2];
            }
        }else{
            ans = n * a[0][0] * a[0][2];
        }
        System.out.println(ans);
        sc.close();
    }

}


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

using namespace std;

typedef long long int lli;

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

    string s, t;

    cin >> s >> t;

    cout << (s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]) << endl;

    return 0;
}


Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store,no-stack-protector")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "#" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double;  using ui = uint_fast32_t;
using ll = int_fast64_t; using ul = uint_fast64_t;

// -----------------------------------------------------------------------------

void solve() {
    int r; cin >> r;
    ld MATH_PI = 6.28318530717958623200;
    cout << MATH_PI * r << '\n';
}

// -----------------------------------------------------------------------------

int main() {
    fast_io; cout_precision;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }
}


Measured memory_bytes: 3772
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int n;  cin >> n;
    int a[n]; rep(i,n) cin >> a[i];

    int ans = 0;
    rep(i,n) {
        while (a[i] % 2 == 0) {
            ++ans;
            a[i] /= 2;
        }
    }
    out(ans);




    
    return 0;
}






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

int main () {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    vector<int> count(N);
    for (int i = 0; i < N; i++) {
        count.at(A.at(i) - 1)++;
    }
    sort(count.begin(), count.end());

    int ans = 0;
    for (int i = 0; i < N - K; i++) {
        ans += count.at(i);
    }
    cout << ans << endl;
}

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

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  ll k = s.size()/2;
  ll p = 0;
  re(i, s.size()) if(s[i]=='p') p++;
  std::cout << k - p << '\n';
  return 0;
}


Measured memory_bytes: 760
import java.util.Scanner;

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

        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int z = scanner.nextInt();

        System.out.println(z + " " + x + " " + y);
    }
}

Measured memory_bytes: 22228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int result(char p1, char p2)
{
    return (p1 == p2 ? 0 : (p1 == 'p' ? 1 : -1));
}

int main(void)
{
    string s;
    cin >> s;
    int N = s.size();
    int ans = 0;
    lpn(i, N) ans += result((i % 2 ? 'p' : 'g'), s[i]);
    cout << ans << endl;
    return 0;
}

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

long long calc(int n, const vector<int>& options, const vector<int>& c, const vector<array<int, 26>>& s) {
  long long score(0);
  vector<int> last(26, -1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 26; ++j) {
      score -= c[j] * (i - last[j]);
    }
    score += s[i][options[i]] + c[options[i]] * (i - last[options[i]]);
  }
  return score;
}
int main() {
  int n;
  cin >> n;
  vector<int> c(26);
  vector<array<int, 26>> s(n);
  
  vector<int> last(26, -1);
  
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1);
    for (int j = 0; j < 26; ++j) {
      neg -= c[j] * (i - last[j]);
    }
    //cout << neg << 'n' << endl;
    int max_score = -1e9;
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    //cout << test + 1 << endl;
    options[i] = test;
    //cout << test + 1 << ' ' << max_score << endl;
    last[test] = i;
  }
  //cout << total << endl;
  for (int t = 1; t <= 1000; ++t) {
    int dd = rand() % n;
    int dt = options[dd];
    int tt = rand() % 26;
    while (tt == dt) tt = rand() % 26;
    options[dd] = tt;
    long long ns = calc(n, options, c, s);
    //if (t == 100) cout << 'n' << ns << endl;
    if (ns > total) {
      total = ns;
    } else {
      options[dd] = dt;
      //cout << "not changed" << total << endl;
    }
  }
  for (const int& i: options) cout << i + 1 << endl;
  //cout << total << endl;
  return 0;
}

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

int memo[110][100];
int mat[110][2];

int dfs(int l, int r) {
    if (l + 1 >= r) return 0;
    if (memo[l][r]) return memo[l][r];

    int mi = 1000000007;
    for (int i = l + 1; i < r; ++i) {
        mi = min(mi, dfs(l, i) + dfs(i, r) + mat[l][0] * mat[i][0] * mat[r - 1][1]);
    }
    return memo[l][r] = mi;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> mat[i][0] >> mat[i][1];
    }
    cout << dfs(0, n) << "\n";
    return 0;
}

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



using namespace std;


int n,m,x;
int c[15];
int a[15][15];

int b;

long mini= LONG_MAX;

int u[15];


int main() {

  cin >> n >> m >> x;
  
  for(int i=0 ; i<n ; i++){
    cin >> c[i];
    for(int j=0 ; j<m ; j++){
      cin >> a[i][j];
    }  
  }



  for(int bit=0 ; bit < (1<<n) ; ++bit){


    int sum = 0;

    for(int i=0 ; i<m ; i++)
      u[i]=0;
  
    for(int i=0 ; i<n ; i++){


      /*
      if(bit & (1<<i))
	cout << '1';
      else
	cout << '0';
      */
     
      
      //cout << (bit && (1<<i))<<' ';
      if(bit & (1<<i)){
	sum += c[i];
	if(sum > mini)
	  break;
	  

	for(int j=0 ; j<m ; j++){
	  u[j] += a[i][j];
	}
      }
      
    }


    // cout << "  ";
    /*
    for(int i=0 ; i<m ; i++)
      cout << u[i]<<' ';
    */
    bool accept = true;
    
    for(int i=0 ; i<m ; i++){
      if(u[i]<x){
	accept=false;
	break;
      }
    }

    //cout << " accept:"<<accept<<" cost"<<sum;
    if(accept){
      if(sum < mini)
	mini = sum;
	 
    }

  }

 
  
  cout <<(mini!=LONG_MAX ? mini:-1)<<endl;

  


  
  
  
  return 0;
}


  


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

#define LINE_BUF_SIZE 256

int main(){

    int i,j,k;
    char line[LINE_BUF_SIZE];
    int N;
    char v[3];

    for(i=0;i<3;i++){
         fgets(line,sizeof(line),stdin);
         v[i]=line[i];
    }

    printf("%c%c%c",v[0],v[1],v[2]);

    return 0;

}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in",,"r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
	return f*sum;
}
const int Mx=2000,N=5010,Mod=1e9+7;
int a[200010],b[200010],f[N][N],fac[200010],fai[200010],inv[200010],n,ans;
int C(int p,int q){return 1ll*fac[p]*fai[q]%Mod*fai[p-q]%Mod;}
int main(){
	n=gi();
	for(int i=1;i<=n;i++)a[i]=gi(),b[i]=gi(),f[-a[i]+Mx+1][-b[i]+Mx+1]++;fac[0]=inv[0]=inv[1]=fai[0]=1;
	for(int i=1;i<=200000;i++)fac[i]=1ll*fac[i-1]*i%Mod;
	for(int i=2;i<=200000;i++)inv[i]=1ll*(Mod-Mod/i)*inv[Mod%i]%Mod;
	for(int i=1;i<=200000;i++)fai[i]=1ll*fai[i-1]*inv[i]%Mod;
	for(int i=1;i<=2*Mx+1;i++)
		for(int j=1;j<=2*Mx+1;j++)
			f[i][j]=((f[i][j]+f[i-1][j])%Mod+f[i][j-1])%Mod;
	for(int i=1;i<=n;i++)ans=(ans+f[a[i]+Mx+1][b[i]+Mx+1])%Mod;
	for(int i=1;i<=n;i++)ans=(ans-C(2*(a[i]+b[i]),2*a[i])+Mod)%Mod;
	printf("%d\n",1ll*ans*fai[2]%Mod);
	return 0;
}


Measured memory_bytes: 83712
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
 int A1=sc.nextInt();
 int A2=sc.nextInt();
 int A3=sc.nextInt();
 
 if(A1+A2+A3>=22){
System.out.println("bust");
}else{
System.out.println("win");
}
}
}


Measured memory_bytes: 23892
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let N = read int
    let S = (read string).ToCharArray()

    let mutable cnt = 0
    for i = 0 to 999 do
        let c = [| i / 100; (i / 10) % 10; i % 10 |]
        seq {
            let mutable f = 0
            for j = 0 to N - 1 do
                if int S.[j] = (int '0' + c.[f]) then
                    f <- f + 1
                if f = 3 then yield ()
        }
        |> fun s ->
            if not (Seq.isEmpty s) then cnt <- cnt + 1

    printfn "%i" cnt
    0

Measured memory_bytes: 14300
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main(){
	int n,m,W;
	cin>>n>>m>>W;
	vvi b(n,vi());
	REP(i,n){
		int k;
		cin>>k;
		REP(j,k){
			int w;
			cin>>w;
			b[i].push_back(w);
		}
	}

	int ans=0;
	for(int i=n-1;i>m-1;i--){
		if(b[i].size()){
			ans=i-m+1;
			break;
		}
	}
	for(int i=n-1;i>0;i--){
		sort(ALL(b[i]));
		while(b[i].size()){
			int remain=W;
			while(1){
				vi::iterator it=upper_bound(ALL(b[i]),remain);
				if(it==b[i].begin()){
					break;
				}
				it--;
				b[i-1].push_back(*it);
				remain-=*it;
				b[i].erase(it);
			}
			ans++;
			if(b[i].size()){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1608
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
b_i = 0
t = 1
for i in range(len(b)):
    t = 1
    while t == 1:
        num = a[i] - b[i]
        if num >= 0:
            ans = ans + b[i]
            num = 0
            break
        else:
            ans = ans + a[i]
            num = abs(num)
            b_i = num
            num = a[i+1] - b_i

            if num <= 0:
                ans = ans + a[i+1]
                a[i+1] = 0
                t = 0
            else:
                ans = ans + b_i
                a[i+1] = num
                t = 0

print(ans)

Measured memory_bytes: 18752
a = int(input())
count = 0
b = a / 100
reserch_1 = b // 1
if (reserch_1 == 1):
    a = a - 100
    count = count + 1

c = a /10
reserch_2 = c // 1
if (reserch_2 == 1):
    a = a - 10
    count =count + 1

reserch_3 = a // 1
if(reserch_3 == 1):
    count =count + 1
print(count)
    

Measured memory_bytes: 9028
//package com.company;
import java.util.*;
import java.io.*;
import java.lang.*;


public class Main {

    public static void main(String[] args) {
	// write your code here

      //  System.out.println("Hello World");
        // System.out.println("This is my first package ");
        Scanner s=new Scanner(System.in);
        long a=s.nextLong();
        long b=s.nextLong();
        long c=s.nextLong();
        long d=s.nextLong();

        long res=0,max=0;
        res=Integer.MIN_VALUE;
        max=Integer.MIN_VALUE;
     /*   for(long i=a;i<=b;i++)
        {
            for(long j=c;j<=d;j++)
            {
                max=i*j;
                res=Math.max(max,res);
            }
        }*/
      long p,q,r,st;
      
      if(a>0 && b>0 && c>0 && d>0)
      {
         p=a*c;
       q=b*d;
       res=Math.max(p,q);
        
      }
      else  if(a<0 && b<0 && c<0 && d<0)
      {
         p=a*c;
       q=b*d;
     res=Math.max(p,q);
        
      }
        else
      {
          p=a*c;
       q=b*d;
          r=a*d;
          st=b*c;
          r=Math.max(r,st);
      p=Math.max(p,q);
          res=Math.max(p,r);
        
      }
      
      
      
      
     
     // res=Math.max(r,res);
        System.out.println(res);



    }
}


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

using namespace std;
int cnt[100100];

int main()
{
    int n,k;  cin >> n >> k;
    int q;  cin >> q;  int Q = q;
    while(q--){
        int x;  cin >> x;
        cnt[x]++;
    }
    for(int i = 1;i<=n;i++){
        cout << ((k - (Q - cnt[i])) <= 0 ? "No" : "Yes") << '\n';
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int a[2000],n;
int search(int i,int x,int m){
  int v,w;
  if(x==m)return 1;
  if(i>=n+1)return 0;
  v=search(i+1,x,m)||search(i+1,x+a[i],m);


  // printf("x%d %d %d\n",x,v,i);
  return v;
}

int main(){
  int q,i,j=0,x=0,m;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(search(j,x,m)==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;


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



Measured memory_bytes: 3632
N, M = map(int, input().split())

A_list = [0]*M
B_list = [0]*M
res_list = [0]*M

for i in range(M):
  A, B = map(int, input().split())
  A_list[i] = A
  B_list[i] = B

parent_ids = list(range(N+1))
counts = [1]*(N+1)

def get_parent(i, parent_ids):
  add_list = []
  while True:
    if i == parent_ids[i]:
      break
    add_list.append(i)
    i = parent_ids[i]
  for c in add_list:
    parent_ids[c] = i
  return i

def set_parent(i, j, parent_ids, counts):
  parent_ids[i] = j
  counts[j] += counts[i]
  
def sq(n):
  return n*(n-1)//2
res_list[-1] = sq(N)

for i in range(M-1, 0, -1):
  A = A_list[i]
  B = B_list[i]
  
  ap = get_parent(A, parent_ids)
  bp = get_parent(B, parent_ids)
  a_cnt = counts[ap]
  b_cnt = counts[bp]
  
  if ap != bp:
    res_list[i-1] = res_list[i] + sq(a_cnt) + sq(b_cnt) - sq(a_cnt+b_cnt)
    set_parent(ap, bp, parent_ids, counts)
  else:
    res_list[i-1] = res_list[i]
  
  
for i in range(M):
  print(res_list[i])

Measured memory_bytes: 58328
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int MOD = 1e9+7;

const int MAX = 1000000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  COMinit();
  int x,y;
  long long  ans = 0;
  cin >> x >> y;
  if(2*y-x < 0 || 2*x-y < 0) ans = 0;
  else if((2*y-x)%3 != 0 || (2*x-y)%3 != 0) ans = 0;
  else{
    int s = (2*x-y)/3;
    int t = (2*y-x)/3;
    ans = COM(s+t,s);
  }
  cout << ans << endl;
}
    
  

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C;
  char x, y;
  cin >> A >> x >> B >> y >> C;
  if(A > 2019) {
    cout << "TBD" << endl;
  }
  else if ((A == 2019) && (B >= 5)) {
    cout << "TBD" << endl;
  }
  else {
    cout << "Heisei" << endl;
  }
}

Measured memory_bytes: 3600
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
ll mul(ll a, ll b)
{
    return(((a%mod)*(b%mod))%mod);
}
ll modexp(ll b, ll e){
	ll res = 1;
	for(; e; b = b * b % mod, e >>= 1) if(e & 1) res = res * b % mod;
	return res;
}
ll modinv(ll a){
    ll x=mod-2;
	return modexp(a,x);
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	din(t);
	unordered_map<string,ll> mp;
	while(t--)
	{
	    string s;
        in(s);
        mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}


Measured memory_bytes: 3660
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

vector<int> to[2005];
int dis[2005][2005];
int ans[2005];

int main(){
    int n,x,y;
    cin >> n>> x>>y;
    x--;y--;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int p=abs(i-x)+abs(j-y)+1;
            if(p<j-i){
                ans[p]++;
            }else{
                ans[j-i]++;
            }
        }
    }
    rep2(i,n-1){
        cout<<ans[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b, c, d;
  string s;
  bool rock = false;
  bool ans = false;
  cin >> n >> a >> b >> c >> d >> s;

  a--;
  b--;
  c--;
  d--;
  if(c>d){
    bool exchange = false;
    for (int i = b; i <= d;i++){
      if(s[i]=='.'){
        if(s[i-1]=='.'&&s[i+1]=='.'){
          exchange = true;
        }
      }
    }
    for (int i = a; i <= c;i++){
      if(s[i]=='#'&&s[i+1]=='#'){
        rock = true;
      }
    }
    if(rock){
      ans = false;
    }else{
      ans = exchange;
    }
  }else {
    for (int i = a; i <= c;i++){
      if(s[i]=='#'&&s[i+1]=='#'){
        rock = true;
      }
    }
    for (int i = b; i <= d;i++){
      if(s[i]=='#'&&s[i+1]=='#'){
        rock = true;
      }
    }
    ans = !(rock);
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3724
#include<stdio.h>
#define NUM 1000000

int main(void){
	int prime[NUM] = {0};
	int n[30];
	int i, j, k, num = 0;

	i = 0;
	while (scanf("%d", &n[i]) != EOF&&i < 30)
		i++;

	for (j = 2; j < NUM; j++){
		for (k = 2 * j; k < NUM; k += j){
			prime[k] = 1;
		}
	}

	for (j = 0; j < i; j++){
		for (k = 2; k <= n[j]; k++){
			if (prime[k] == 0)
				num++;
		}
		printf("%d\n", num);
		num = 0;
	}

	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  int n;
  cin >> n;
  
  vi a(n);
  int ans = 0;
  rep(i, 0, n){
    cin >> a[i];
    if(i%2 == 0 && a[i]%2 == 1)
      ans++;
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while ( x->left != NIL ) x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while ( u != NIL && k != u->key ) {
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node *y = x->parent;
  while ( y != NIL && x == y->right ) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y;  // 削除する対象
  Node *x;  // yの子

  // 削除する節点を決める
  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if ( y->left != NIL )
    x = y->left;
  else
    x = y->right;

  if ( x != NIL )
    x->parent = y->parent;

  if ( y->parent == NIL ) {
    root = x;
  } else {
    if ( y == y->parent->left )
      y->parent->left = x;
    else
      y->parent->right = x;
  }

  if ( y != z )
    z->key = y->key;

  free(y);
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key )
      x = x->left;
    else
      x = x->right;
  }

  z->parent = y;
  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key )
      y->left = z;
    else
      y->right = z;
  }
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    cin >> com;
    if ( com[0] == 'f' ) {
      scanf("%d", &x);
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com == "insert" ) {
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com == "delete" ) {
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 21924
n, m = map(int, input().split())

A = []
b = []
result  = []

for i in range(0, n):
    A.append(input().split())
for i in range(0, m):
    b.append(input())

for i in range(0, n):
    temp = 0
    for j in range(0, m):
        temp += int(A[i][j]) * int(b[j])
    result.append(temp)

for i in result:
    print(i)


Measured memory_bytes: 6260
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=(a+d-1)/d;
  int y=(b+c-1)/b;
  if(x>=y)
  cout<<"Yes\n";
  else
  cout<<"No\n";
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
	int main()
{
	int a,b,c;
	cin>>a>>b>>c;

	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	if(a>b) swap(a,b);

	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}


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

int main() {
  
  string s;
  cin >> s;
  
  int cnt0 = 0,cnt1 = 0,n = s.size();
  
  for ( int i = 0; i < n; i++){
    if ( s[i] == '0' ){
      cnt0++;
    }else if ( s[i] == '1' ){
      cnt1++;
    }
  }
  
  if ( n == 1 || n == cnt0 || n == cnt1 ){
    cout << 0 << endl;
  }else{
    cout << min(cnt0,cnt1) * 2 << endl;
  }
  
}


Measured memory_bytes: 3736
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N;
        ArrayList<Integer> a = new ArrayList<Integer>();
        int count = 0;
        int temp;

        N = sc.nextInt();

        for(int i = 0; i < N; i++){
            a.add(sc.nextInt());
        }

        for(int i = 0; i < N; i++){
            for(int j = 1; j < N; j++){
                if(a.get(j - 1) > a.get(j)){
                    temp = a.get(j - 1);
                    a.set(j - 1, a.get(j));
                    a.set(j, temp);
                    count++;
                }
            }
        }

        for(int i = 0; i < a.size(); i++){
            System.out.print(a.get(i));
            if(i != a.size() - 1) System.out.print(" ");
        }
        System.out.println("\n" + count);

        sc.close();
    }
}


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

int main(void) {
    int n,k;
    cin >> n >> k;
    long long a[20];
    for(int i=0; i<n; i++) cin >> a[i];

    long long ans=1e18;
    for(int bit = 0; bit<(1<<n-1); bit++){
        if(__builtin_popcount(bit) != k-1) continue;
        long long s=0;
        long long h=a[0];
        bool flag = true;

        for(int i=1; i<n; i++){
            if(((bit >> i-1) & 1)){
                if(a[i]>h){
                    h=a[i];
                } else {
                    s += h+1-a[i];
                    h += 1;
                }
            } else {
                if (a[i]>h) {
                    flag = false;
                    break;
                }
            }
        }
        if(flag) ans = min(ans,s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
-- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Monad.Primitive
import           Control.Applicative
import           Debug.Trace
import           Text.Printf

main = do
  n <- readLn :: IO Int
  xs <- getIntVector
  print $ solve n xs

solve :: Int -> VU.Vector Int -> Int
solve n xs = min (VU.foldl' (\n m -> n + ((m - p)^2)) 0 xs) (VU.foldl' (\n m -> n + ((m - p')^2)) 0 xs)
  where
    p = (`div` n) $  VU.sum xs
    p' = (+1) . (`div` n) $  VU.sum xs

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons
getInt = readLn :: IO Int
getInt2Tuple = (\vec -> (vec VU.! 0, vec VU.! 1)) <$> getIntVector
getInt3Tuple = (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2)) <$> getIntVector


Measured memory_bytes: 508
from collections import defaultdict
import sys, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, M = read_int()

job_dict = defaultdict(lambda: list())
for i in range(N):
    d, r = read_int()
    job_dict[d].append(-r)

hq = []
heapq.heapify(hq)

def solve():
    ans = 0
    for i in range(1, M + 1):
        for j in job_dict[i]:
            heapq.heappush(hq, j)
        if hq:
            ans += - heapq.heappop(hq)
    return ans

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 33140
N=int(input())
K=int(input())
XN=list(map(int,input().split()[:N]))

ret=0
for i in range(N):
    if XN[i] < (K/2):
        ret+= XN[i]*2
    else:
        ret+= 2*(K-XN[i])
print(ret)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vivi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for(int i(a); i < b; ++i)
#define SZ(x) ((int)(x).size()

int main(int argc, char **argv){
    ll X, current(100), count(0);
    cin >> X;
    while(current < X){
        count++;
        current = (current * 1.01);
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef vector<int> VI;

int n, m, k, q;
int a[200010], b[200010], l[200010];
int f[100010], s[100010], t[100010];

VP node1[100010];
int fast[100010];
priority_queue<PII, VP, greater<PII> > que;

VP node2;
VI node3[100010];

void dijk()
{
  memset(fast, -1, sizeof fast);
  
  for(int i = 0; i < k; i++){
    que.push(MP(0, f[i]));
  }

  while(!que.empty()){
    PII now = que.top();
    que.pop();

    if(fast[now.S] == -1){
      fast[now.S] = now.F;
      
      for(auto p:node1[now.S]){
	que.push(MP(now.F + p.F, p.S));
      }
    }
  }
}

struct union_find
{
  int parent[100010];

  void reset()
  {
    for(int i = 1; i <= n; i++){
      parent[i] = i;
    }
  }

  int top(int x)
  {
    return parent[x] == x ? x : (parent[x] = top(parent[x]));
  }

  bool bond(int x, int y)
  {
    if(top(x) == top(y)){
      return false;
    }
    else{
      parent[top(x)] = top(y);
      return true;
    }
  }
} uf;

struct lcm_tree
{
  int depth[100010], parent[100010][20], mn[100010][20];
  
  void dfs(int now, int prev, int nowdep)
  {
    depth[now] = nowdep;
    parent[now][0] = prev;
    
    if(nowdep >= 1){
      mn[now][0] = fast[prev];
    }
    for(int i = 1; i < 20; i++){
      if(parent[now][i - 1] != -1){
	parent[now][i] = parent[parent[now][i - 1]][i - 1];
	mn[now][i] = min(mn[now][i - 1], mn[parent[now][i - 1]][i - 1]);
      }
    }

    for(auto p:node3[now]){
      if(p != prev){
	dfs(p, now, nowdep + 1);
      }
    }
  }

  int solve(int x, int y)
  {
    int ret = min(fast[x], fast[y]);
    
    if(depth[x] > depth[y]){
      swap(x, y);
    }

    for(int i = 0; i < 20; i++){
      if(depth[y] - depth[x] & 1 << i){
	ret = min(ret, mn[y][i]);
	y = parent[y][i];
      }
    }

    if(x == y){
      return ret;
    }

    for(int i = 19; i >= 0; i--){
      if(parent[x][i] != parent[y][i]){
	ret = min(ret, min(mn[x][i], mn[y][i]));
	x = parent[x][i];
	y = parent[y][i];
      }
    }

    return min(ret, mn[x][0]);
  }
} lcm;

  
int main()
{
  scanf("%d%d%d%d", &n, &m, &k, &q);
  for(int i = 0; i < m; i++){
    scanf("%d%d%d", &a[i], &b[i], &l[i]);
  }
  for(int i = 0; i < k; i++){
    scanf("%d", &f[i]);
  }
  for(int i = 0; i < q; i++){
    scanf("%d%d", &s[i], &t[i]);
  }

  for(int i = 0; i < m; i++){
    node1[a[i]].PB(MP(l[i], b[i]));
    node1[b[i]].PB(MP(l[i], a[i]));
  }

  dijk();
  

  for(int i = 0; i < m; i++){
    node2.PB(MP(min(fast[a[i]], fast[b[i]]), i));
  }
  sort(node2.begin(), node2.end(), greater<PII>());

  uf.reset();
  for(auto p:node2){
    if(uf.bond(a[p.S], b[p.S])){
      node3[a[p.S]].PB(b[p.S]);
      node3[b[p.S]].PB(a[p.S]);
    }
  }
  
  
  memset(lcm.parent, -1, sizeof lcm.parent);
  memset(lcm.mn, -1, sizeof lcm.mn);
  lcm.dfs(1, -1, 0);

  for(int i = 0; i < q; i++){
    printf("%d\n", lcm.solve(s[i], t[i]));
  }
  
  return 0;
}

Measured memory_bytes: 39280
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++) cin>>h[i];
  int ans=1,m=h[0];
  for(int i=1;i<n;i++){
    if(h[i]>=m) ans++;
    m=max(m,h[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
 
int main() {
  int N,Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<string> t(Q);
  vector<string> d(Q);
  for(int i=0;i<Q;i++){
    cin >> t[i] >> d[i];
  }
  
  int pos_l=0;
  int pos_r=N-1;
  for(int i=Q-1;i>=0;i--){
    if(d[i]=="R"){
      if(pos_l-1>=0){
        if(s[pos_l-1]==t[i][0])
          pos_l--;
      }
      if(s[pos_r]==t[i][0])
        pos_r--;
    }else{
      if(pos_r+1<N){
        if(s[pos_r+1]==t[i][0])
          pos_r++;
      }
      if(s[pos_l]==t[i][0])
        pos_l++;
    }
  }
  
  
  cout<<pos_r-pos_l+1<<endl;
  return 0;
}

Measured memory_bytes: 22276
#include <stdio.h>

int table[8] = {0, 1, 2, 3, 5, 7, 8, 9};

int main(void) {
	int id;
	int b[20];
	int i,n;
	while(scanf("%d\n", &id) == 1) {
		if(!id) break;
		
		n = 0;
		while(id > 0) {
			b[n] = id % 8;
			id = id / 8;
			n++;
		}
		
		if((id % 8) != 0) {
			b[n] = id;
			n++;
		}
		
		for(i=n-1;i>=0;i--) {
			printf("%d", table[b[i]]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 608
n=int(input())
l=tuple(map(int,input().split()))
ret=[]
ll=[0]*n
ans=0
for i in range(n,0,-1):
    s=l[i-1]
    for j in range(2,n//i+1):
        s-=ll[j*i-1]
        s%=2
    ll[i-1]=s
    ans+=s
    if s:ret.append(i)
print(ans)
if ans:print(*ret,sep=" ")

Measured memory_bytes: 14032
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      long n = sc.nextLong();
      List<long[]> factors = new ArrayList<>();
      for(long i = 2; i * i <= n; i++) {
        long cnt = 0;
        while(n % i == 0) {
          cnt++;
          n /= i;
        }
        if(cnt != 0)
          factors.add(new long[]{i, cnt});
      }
      if(n != 1)
        factors.add(new long[]{n, 1});

      long res = 0;
      for(long[] ts : factors) {
        long t = ts[1];
        long i = 1; 
        while(t >= i) {
          res++;
          t -= i;
          i++;
        }
      }
      System.out.println(res);
  }
}

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

int main(){
//srandom((unsigned long)time(NULL));

long long n;
cin>>n;
vector<long long> r;
for(long long i=0;i<n;i++){
    long long x;
    cin>>x;
    r.emplace_back(x);
}
long long ans=r[1]-r[0];
long long mx=r[1];
long long mn=r[0];
if(n==2){
  cout<<ans<<endl;
  return 0;
}
for(long long i=1;i<n;i++){
  ans=max(ans,r[i]-mn);
  mn=min(mn,r[i]);
}
cout<<ans<<endl;

return 0;
}




Measured memory_bytes: 4944