akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[3*N];
        for(int i=0;i<3*N;i++) a[i]=sc.nextLong();
        PriorityQueue<Long> pq1 = new PriorityQueue<>(); //pq1中始终保持N个元素
        long sum1=0;
        for(int i=0;i<=N-1;i++) {
            pq1.add(a[i]);
            sum1+=a[i];
        }
        long[] sumL = new long[3*N];
        sumL[N-1]=sum1;
        for(int i=N;i<=2*N-1;i++){// sumL[i]表示取a[i]为最后一个元素时的first-half的和
            if(a[i]>pq1.peek()){
                long temp = pq1.poll();
                pq1.add(a[i]);
                sumL[i]=sumL[i-1]+a[i]-temp;
            }
            else{
                sumL[i]=sumL[i-1];
            }
        }
        myC mC = new myC();
        PriorityQueue<Long> pq2 = new PriorityQueue<>(16,mC);
        long sum2 = 0;
        long[] sumR = new long[3*N];
        for(int i=3*N-1;i>=2*N;i--){//pq2中始终保持N个元素
            sum2 += a[i];
            pq2.add(a[i]);
        }
        sumR[2*N]=sum2;
        for(int i=2*N-1;i>=N;i--){
            if(a[i]<pq2.peek()){
                long temp = pq2.poll();
                pq2.add(a[i]);
                sumR[i]=sumR[i+1]+a[i]-temp;
            }
            else sumR[i]=sumR[i+1];
        }
        long ans = Long.MIN_VALUE;
        for(int i=N-1;i<=2*N-1;i++){
            ans = Math.max(ans,sumL[i]-sumR[i+1]);
        }
        System.out.println(ans);

    }
    static class myC implements Comparator<Long>{
        public int compare(Long a, Long b){
            long o1=a;
            long o2=b;
            if(o1==o2) return 0;
            else if(o1>o2) return -1;
            else return 1;
        }
    }
}


Measured memory_bytes: 97560
use num::integer::gcd;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {in_k: i64};
    let mut count: i64 = 0;

    for a in 1..=in_k {
        for b in 1..=in_k {
            let g = gcd(a, b);

            for c in 1..=in_k {
                count += gcd(g, c);
            }
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 2160
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	double a;
	cin >> a;
	printf("%.12f %.12f\n", a * a * M_PI, a * 2 * M_PI);
}


Measured memory_bytes: 3292
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long
unsigned ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  if(b%2==1){
    unsigned ll tmp = digitpower(a,(b-1)/2);
    tmp*=tmp;
    tmp*=a;
    return (tmp);
  }else{
    unsigned ll tmp = digitpower(a,(b)/2);
    tmp*=tmp;
    return (tmp);
  }
}
ll digitpower2(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  if(b%2==1){
    ll tmp = digitpower2(a,(b-1)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    tmp*=a;
    return (tmp)%d9_7;
  }else{
    ll tmp = digitpower2(a,(b)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    return (tmp)%d9_7;
  }
}
int main(void){
  ll n,k;
  cin>>n;
  vector<unsigned ll> a(n);
  int sizemax=0;
  rep(i,n){
    unsigned ll tmp;
    cin>>tmp;
    a[i]=tmp;
  }
  vl digs(60,0);
  rep(i,n){
    rep(j,60){

      if(digitpower(2,j) - (a[i] & (ll)digitpower(2,j))==0){
        digs[j]++;
      }else{
        //cout<<a[i]<<" "<<(ll)digitpower(2,j)<<" "<< ((ll)digitpower(2,j) - (ll)a[i] & (ll)digitpower(2,j))<<endl;
      }
    }
  }
  rep(i,60){
    digs[i]=((n-digs[i])*digs[i])%d9_7;
  }
  ll next=0;
  ll ans=0;
  rep(i,60){
    digs[i]+=next;
    ans+=digitpower2(2,i)*(digs[i]%2);
    next=digs[i]/2;
    ans%=d9_7;
  }
  ans+=next*digitpower2(2,60);
  ans%=d9_7;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
vector <string> ve;
int main(){
    string s;
    cin>>s;
    int a=0,b=0,c=0;
    for(int i=0;i<s.length();i++) {
        if(s[i]=='a') a++;
        else if(s[i]=='b') b++;
        else c++;
    }
    int x=min(min(a,b),c),y=max(max(a,b),c);
    if(y-x>1) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


Measured memory_bytes: 512
import sys
inp = int(input())
lst = list(map(int,input().split()))
sum = 1
if 0 in lst:
    print(0)
    sys.exit(0)
else:
    num = 1;
    for i in range(inp):
        num *= lst[i]
        if num > 10 ** 18:
            print("-1")
            sys.exit()
    print(num)

Measured memory_bytes: 21780
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N)
  {
    cin >> a[i];
    a[i] --;
  }
  int ans = 0;
  int count = 0;
  rep(i,N+1)
  {
    int ans2 = ans;
    ans = a[ans2];
    count ++;
    if(ans==1)
    {
      cout << count << endl;
      return 0;
    }
    if(count==N)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define mod 1000000007
#define pb push_back
#define po pop_back
#define f(i,x,n) for(ll i=x; i<n; i++)
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)),x.resize(distance(x.begin(),unique(all(x))))
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// #define inf 100000000000000
using namespace std;
ll arr[100000][3];
ll dp[100000][3];
ll max(ll a, ll b)
{
    return (a>b)?a:b;
}
int main()
{
    ll n;
    cin>>n;
    
    f(i,0,n)
    {
        f(j,0,3)
        cin>>arr[i][j];
    }
    f(i,0,3)
    {
        dp[0][i]=arr[0][i];
    }
    f(i,1,n)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
    }
    
    ll res = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<res;
    
    
    
  return 0;
}

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

int N,maxW;
long long dp[102][100002];
struct asdfklj{
    long long val,w;
}arr[102];

long long knapsack(int i, int current){
    if(current==0)return 0;
    if(current<0 || i==N)return INT_MAX;
    long long &ret=dp[i][current];
    if(ret!=-1)return ret;
    return ret = min(arr[i].w+knapsack(i+1,current-arr[i].val), knapsack(i+1,current));
}

int main(){
    scanf("%d%d",&N,&maxW);
    memset(dp,-1,sizeof(dp));
    for(int i=0; i<N; i++)scanf("%I64d%I64d",&arr[i].w,&arr[i].val);
    for(int i=100000;;i--)
        if(knapsack(0,i)<=maxW)
            printf("%d",i),exit(0);
}


Measured memory_bytes: 80000
import Control.Monad
import Control.Applicative

computeScore x = foldr sumScore (0,0) x where
    sumScore [a,b] (c,d) = case (compare a b) of
        LT -> (c, d+3)
        EQ -> (c+1, d+1)
        GT -> (c+3, d)

myPrint (c,d) = putStrLn $ show c ++ " " ++ show d

main = do
    turns <- read <$> getLine
    cards <- replicateM turns $ words <$> getLine
    myPrint $ computeScore cards

Measured memory_bytes: 4508
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

ll mmax(ll a, ll b){
    if(a > b) return a;
    else return b;
}

int main(){
    ll n; cin >> n;
    ll t, a; cin >> t >> a;
    rep(i,n-1){
        ll tt, aa; cin >> tt >> aa;
        ll left = 0, right = (1e18)/mmax(tt,aa);
        while(right-left > 1){
            ll mid = (left + right)/2;
            if(tt*mid >= t && aa*mid >= a) right = mid;
            else left = mid;
        }
        t = tt*right; a = aa*right;
    }
    cout << t+a << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    map<char, int> cnt;
    rep(i, 3){
        cnt[s[i]]++;
    }

    if(cnt.size() == 3){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		System.out.println(String.format("%.5f", r*r*Math.PI) + " " + String.format("%.5f", 2*r*Math.PI));	
	}
}

Measured memory_bytes: 28468
#!python3


def f(n):
    for i in range(3, int(n**.5), 2):
        if n % i == 0:
            return False

    return True


def resolve():
    X = int(input())

    if X <= 3:
        print(X)
        return

    if X % 2 == 0:
        X += 1

    import sys

    for i in range(X, sys.maxsize, 2):
        if f(i):
            print(i)
            break

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
N,C=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(N)]
x=[[0]*(C+1) for _ in range(3)]
for i in range(N):
    for j in range(N):
        x[(i+j+2)%3][c[i][j]]+=1

from itertools import permutations
ans=1<<32
for ch in permutations(range(1,C+1),3):
    ans1=0
    for i in range(3):
        for j in range(1,C+1):
            ans1+=x[i][j]*d[j-1][ch[i]-1]
    ans=min(ans,ans1)
print(ans)


Measured memory_bytes: 44636
n = int(input())

count = 0

for i in range(6):                                                                                             
    if n >= 10**i and n < 10**(i+1):                                                                           
        for j in range(i+1):                                                                                   
            if j % 2 == 1:                                                                                     
                if j == 1:                                                                                     
                    count += 9                                                                                 
                else:                                                                                          
                    count += 10**j - 10**(j-1)                                                                 
        if i % 2 == 0:                                                                                         
            count += n - 10**i + 1                                                                             
                                                                                                               
        break                                                                                                  

print(count)

Measured memory_bytes: 3060
fun main(args:Array<String>):Unit{
    val line1 = readLine()!!.trim().split(' ').map(String::toInt)
    val n = line1[0]
    val timeLimit = line1[1]
    var result = 1001
    for(i in 1..n){
        val line = readLine()!!.trim().split(' ').map(String::toInt)
        val c = line[0]
        val t = line[1]
        if(t<=timeLimit){
            if(c<result)result=c
        }
    }
    if(result<=1000) println(result) else println("TLE")
}

Measured memory_bytes: 36372
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define debug(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

const int MAX_N = 7 + 100000;
///----------------------------------------------
char str[MAX_N];
int main() {

	///read
	scanf(" %s",str); int len=strlen(str);

	///work
	int ans=0;
	rep(i,1,len) {
		ans+=str[i]!=str[i-1];
	}

	///print
	printf("%d",ans);



}


Measured memory_bytes: 384
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

nmax=50
graph=[[False]*nmax for _ in range(nmax)]
visited=[False]*nmax

def dfs(n,v):
  visited[v]=True
  for v2 in range(n):
    if graph[v][v2]==False:
      continue
    if visited[v2]:
      continue
    dfs(n,v2)

def main():
  n,m=LI()
  a=[]
  b=[]
  for _ in range(m):
    _a,_b=LI()
    a.append(_a-1)
    b.append(_b-1)
    graph[_a-1][_b-1]=True
    graph[_b-1][_a-1]=True

  ans=0
  for i in range(m):
    graph[a[i]][b[i]]=False
    graph[b[i]][a[i]]=False

    for j in range(n):
      visited[j]=False

    dfs(n,j)

    bridge=False
    for j in range(n):
      if visited[j]==False:
        bridge=True
    if bridge:
      ans+=1

    graph[a[i]][b[i]]=True
    graph[b[i]][a[i]]=True

  return ans

# main()
print(main())


Measured memory_bytes: 5464
eval"N,M,R,*C="+`dd`.split*?,;X=C.shift R;E=(r=0..N).map{[9e9]*-~N};C.each_slice(3){|a,b,c|E[a][b]=E[b][a]=c};r.each{|i|r.each{|j|r.each{|k|(E[j][k]>x=E[j][i]+E[i][k])&&E[j][k]=x}}};p X.permutation.map{|x|x.each_cons(2).map{|a,b|E[a][b]}.inject:+}.min

Measured memory_bytes: 21416
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n , k ;
  	cin >> n >> k;
  	int rem = max(0 , n - k);
  	long long sum = 0;
  	long long a[n];
  	for(int i = 0 ; i < n ;i++)
      cin >> a[i];
  	sort(a , a + n);
  	for(int i = 0 ; i < rem ; i++)
      sum += a[i];
  	cout << sum << endl;
 	return 0; 
}

Measured memory_bytes: 1792
import java.util.*;

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

		flg[1] = true;
		for(int i=1;i<=1000000;i++){
			if(flg[i]){
				if(i*2<=1000000) flg[i*2] = true;
				if(i*3<=1000000) flg[i*3] = true;
				if(i*5<=1000000) flg[i*5] = true;
			}
		}

		while(true){
			int m=sc.nextInt();
			if(m == 0) break;
			int n=sc.nextInt();

			int ans = 0;
			for(int i=m;i<=n;i++) if(flg[i]) ans++;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 13000
///
// File:  d.go
// Author: ymiyamoto
//
// Created on Tue Apr  3 00:22:08 2018
//
package main

import (
	"fmt"
)

type edge struct {
	from, to, weight int
}

var N, M int
var graph [][]int
var dist []edge

func main() {
	fmt.Scan(&N, &M)

	graph = make([][]int, N)
	for i := range graph {
		graph[i] = make([]int, N)
		for j := range graph[i] {
			graph[i][j] = 1 << 30
		}
	}

	dist = make([]edge, M)
	for i := 0; i < M; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		a--
		b--
		dist[i].from = a
		dist[i].to = b
		dist[i].weight = c
		graph[a][b] = c
		graph[b][a] = c
	}

	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if graph[i][j] > graph[i][k]+graph[k][j] {
					graph[i][j] = graph[i][k] + graph[k][j]
				}
			}
		}
	}

	count := 0
	for i := range dist {
		d := dist[i]
		if graph[d.from][d.to] < d.weight {
			count++
		}
	}
	fmt.Println(count)
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint {
  ll v;
  mint(ll v = 0) : v((v % MOD + MOD) % MOD) {}
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return (mint)0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

void solve() {
  int n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  vl c(n + 1);
  rep(i, n) c[i + 1] += c[i] + a[i];
  mint ans = 0;
  rep(i, n) {
    ans += ((mint)a[i] * (c[n] - c[i + 1]));
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 6336
n,m,x,y=map(int,input().split())
n_lst=list(map(int,input().split()))
m_lst=list(map(int,input().split()))
flag=0
n_max=max(n_lst)
m_min=min(m_lst)

for i in range(x+1,y+1):
    if n_max<i<=m_min:
        flag=1
print('No War') if flag==1 else print('War')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x;
    cin >> x;
    ll kam = 100;
    for(int i = 0; i < 2e5; i++){
        if(kam >= x) return cout << i, 0;
        kam = kam / 100 + kam;
    }

    return 0;

}


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

using namespace std;

typedef long long ll;

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#endif
    ll ans = 0;
    int n;
    cin >> n;
    n *= 3;
    deque <int> q;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        a[i] = x;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for (auto c : a)
    {
        q.push_back(c);
    }
    while (q.size() > 0)
    {
        q.pop_front();
        ans += q.front();
        q.pop_front();
        q.pop_back();
    }
    cout << ans << '\n';
}


Measured memory_bytes: 2688
N = int(input())
L = list(map(int, input().split()))

cnt = 0
for i in range(N):
  for j in range(i + 1, N):
    for k in range(j + 1, N):
      a = L[i]
      b = L[j]
      c = L[k]
      if a == b or b == c or c == a:
        continue
      if a + b <= c or b + c <= a or c + a <= b:
        continue
      cnt += 1
print(cnt)

Measured memory_bytes: 9196
from bisect import bisect_left, bisect_right
br, bl = bisect_right, bisect_left
n = input()
a = sorted([int(x) for x in raw_input().split()])
b = sorted([int(x) for x in raw_input().split()])
c = sorted([int(x) for x in raw_input().split()])
ans = 0
for bi in b:
	ans += (bl(a, bi) * (n - br(c, bi)))
print ans

Measured memory_bytes: 61212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,i,x,t,s;
  s=0;
  cin>>N>>K;
  for(i=0; i<N; i++){
    cin>>x;
    if(x>=K){
      t=x-K;
    }
    else{
      t=K-x;
    }
    
    if(t<x){
      s+=t*2;
    }
    else{
      s+=x*2;
    }
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
counter=[0]*(10**6+1)
l=sorted(l)
for i in l:
    counter[i]+=1
    if counter[i]<2:
        for j in range(2*i,10**6+1,i):
            counter[j]+=2
print(counter.count(1))

Measured memory_bytes: 32068
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define Y first
#define X second
#define INF 1 << 30
#define EPS 1e-10

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

map<pi, int>ma;
vector<pi>pic, star;
int m, n;

int check(int y, int x){
  rep(i, m){
    pi a = star[i];
    if(!ma.count(MP(a.Y + y, a.X + x))) return 0;
  }
  return 1;
}

int main(){
  while(scanf("%d", &m) && m){
    ma.clear();
    pic.clear();
    star.clear();
    int x, y;
    rep(i, m){
      scanf("%d%d", &x, &y);
      star.PB(MP(y, x));
    }
    scanf("%d", &n);
    rep(i, n){
      scanf("%d%d", &x, &y);
      pic.PB(MP(y, x));
      ma[MP(y, x)] = 1;
    }

    rep(i, n){
      pi a = star[0], b = pic[i];
      if(!check(b.Y - a.Y, b.X - a.X)) continue;
      printf("%d %d\n", b.X - a.X, b.Y - a.Y);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1264
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

long long  lcm(long long x,long long y){
  long long mindata,maxdata;
  mindata=min(x,y);
  maxdata=max(x,y);
  while(maxdata%mindata!=0){
    long long temp;
    temp=maxdata%mindata;
    maxdata=mindata;
    mindata=temp;
  }
  return x*(y/mindata);
}


int main(){
  ll N;
  cin>>N;
  ll T[200];
  for(int i=0;i<N;i++){
    cin>>T[i];
  }
  if(N==1){
    cout<<T[0]<<endl;
    return 0;
  }
  ll ans=lcm(T[0],T[1]);
  for(ll i=2;i<N;i++){
    if(ans%T[i]!=0) ans=lcm(ans,T[i]); 
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int cnt = 0;
	rep(i, n - 1) {
		if (s[i] != s[i + 1]) cnt++;
	}
	cout << cnt << endl;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  long n;
  cin >> n;
  cout << (n + 1000 - 1) / 1000 * 1000 - n << endl;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="Sunny"){
    cout << "Cloudy" << endl;
  }else if(s=="Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
  return 0;
}

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

int main(void)
{
    char str[201], sub[201];
    int i, j, m, h, len;
    
    while (1) {
        scanf("%s", str);
        
        if ( strcmp(str, "-") == 0)
            break;
        
        scanf("%d", &m);
        for ( i=0; i<m; ++i) {
            scanf("%d", &h);
            
            len = strlen(str);
            for ( j=0; j<h; ++j)
                sub[j] = str[j];
            for ( j=h; j<len; ++j)
                str[j-h] = str[j];
            for ( j=len-h; j<len; ++j)
                str[j] = sub[j-len+h];
        }
        printf("%s\n", str);
    }
    
    return 0;
}


Measured memory_bytes: 2036
#!/usr/bin/env python3
n = int(input())
s = list(input())
s = list(map(lambda x: ord(x), s))
for i in range(len(s)):
    if s[i] + n > 90:
        s[i] = s[i] + n - 90 + 64
    else:
        s[i] = s[i] + n
s = list(map(lambda x: chr(x), s))
print(''.join(s))


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, k;
string s, ans;
int st;
deque<int> q;

bool isDone() {
    return (int)q.size() == n && st == ((n & 1) ^ 1);
}

int main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    cin >> s;
//    s = string(n, 'A');
//    mt19937 mt(123);
//    forn(i, n) {
//        s[i] = mt() % 2 ? 'A' : 'B';
//    }
    st = (s[0] == 'A' ? 0 : 1);
    for (int beg = 0; beg < n; ) {
        int end = beg + 1;
        while (end < n && s[beg] == s[end]) {
            ++end;
        }
        q.push_back(end - beg);
        beg = end;
    }
    while (k && !isDone()) {
        --k;
        if (st == 0) {
            st = 1;
            if (q.front() == 1) {
                q.pop_front();
                ++q[0];
            } else {
                --q[0];
                q.push_front(1);
            }
        } else {
            st ^= 1;
            if (q.front() == 1) {
                q.pop_front();
                st ^= 1;
            } else {
                --q[0];
            }
            if (st ^ (q.size() & 1)) {
                ++q.back();
            } else {
                q.push_back(1);
            }
        }

        assert((int)q.size() <= n);
//        if (1) {
//            ans = "";
//            int st = ::st;
//            for (int x : q) {
//                char c = st ? 'B' : 'A';
//                forn(i, x) {
//                    ans += c;
//                }
//                st ^= 1;
//            }
//            cerr << ans << endl;
//        }
    }
    ans = "";
    for (int x : q) {
        char c = st ? 'B' : 'A';
        forn(i, x) {
            ans += c;
        }
        st ^= 1;
    }
    if (n % 2 == 1 && k % 2 == 1) {
        assert(ans[0] == 'A');
        ans[0] = 'B';
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1944
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    K,N=pin()
    A=lispin()
    temp=K
    for i in range(0,N):
        temp=min(temp,max(abs(A[i-1]-A[i]),K-abs(A[i]-A[i-1])))
    print(temp)
        
#%%submit!
resolve()

Measured memory_bytes: 26420
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long k = sc.nextLong();
    sc.close();

    if (a > k) {
      System.out.println(String.format("%d %d", a - k, b));
    } else {
      long nokori = k - a;
      System.out.println(String.format("%d %d", 0, Math.max(b - nokori, 0)));
    }
  }
}

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

int main(){

	int n, a, b;

	while(cin >> n){
		if( n == 0)break;
		int a_ten = 0, b_ten = 0;
		for(int i = 0; i<n; i++){
			cin >> a >> b;
			if(a == b) {
				a_ten = a_ten + a;
				b_ten = b_ten + b;
			}
			else if (a < b) b_ten = b_ten + a + b;
			else a_ten = a_ten + a + b;
				
		}

		cout << a_ten << " " << b_ten <<endl;
			
	}


	return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	int as=0,bs=0;
	for(int i=0;i<n;i++){
		string a,b;
		cin >> a >> b;
		if(a>b) as+=3;
		else if(a<b) bs+=3;
		else {
			as++;
			bs++;
		}
	}
	cout << as << " " << bs << endl;
	return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, 3, sizeof(int), cmpint);
	if (a[0] + a[1] == a[2]) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/math/constants/constants.hpp>

int main(){
    using namespace std;
    double pi = boost::math::constants::pi<double>();
    unsigned long N, L;
    cin >> N >> L;
    vector<unsigned long> T(N);
    copy_n(istream_iterator<unsigned long>(cin), N, T.begin());
    double x{0}, y{0};
    vector<double> C(N), S(N);
    transform(T.begin(), T.end(), C.begin(), [&pi, &L](auto t){return cos(pi * t / L);});
    transform(T.begin(), T.end(), S.begin(), [&pi, &L](auto t){return sin(pi * t / L);});
    for(long i = 1; i < N; ++i)for(long j = 0; j < i; ++j){
        long t = N + 2 * (j - i);
        x += t * (C[i] * C[j] - S[i] * S[j]);
        y += t * (C[i] * S[j] + C[j] * S[i]);
    }
    unsigned long t = N * (N - 1) * (N - 2) / 6;
    x /= t;
    y /= t;
    cout << setprecision(15) << fixed << endl;
    cout << x << " " << y << endl;
    return 0;
}

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

int main(){
    int a,b;
    char op;
    cin >> a >> op >> b;
    if(op == '+') cout << a+b << endl;
    else cout << a-b << endl;

    return 0;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    char c;
    cin >> c;
    if(c=='a' || c=='i' || c=='u' || c=='e' || c== 'o')
        cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define For(i,n) for(int i=0;i<n;i++)
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long int
#define ld long double
#define fio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define vpi vector<pair<int,int> >
#define vv vector<int>
#define MAXN 3005
int dp[MAXN][MAXN];
int n;
// void fun(int I , int id)
// {
//     if(id==0)return 1;
// 	if(dp[I][id]!=)
//     int t;
// 	if (str[id] == '>')
// 	{
// 		t = sum(n, id - 1) - sum(I-1,id-1);
// 	}
// 	else{
//        t=sum(I-1,id-1);
// 	}
// 	return t;
// }





int32_t main()
{

	fio;

	cin >> n;
	string str;
	cin >> str;
	int nn = 0;
	// for(int i=1;i<=n;i++)
	// 	nn+=fun(i,n-1)
	// nn=fun(i,n-1);
	// cout<<nn;

	if (str[0] == '>')
	{
		dp[0][1] = 1;
		dp[0][2] = 1;
	}
	else {
		dp[0][2] = 1;

	}

	for (int i = 1; i < n - 1; i++)
	{
		for (int j = 1; j <= i + 2; j++)
		{
			if (str[i] == '<')
			{
				dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1]) % mod;
			}
			else {

				dp[i][j] = (dp[i][j - 1] + (dp[i - 1][i + 1] - dp[i - 1][j - 1]) + mod) % mod;
			}
		}
	}
	cout << dp[n - 2][n];

}


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

int main(){
    int n,k;
    cin >>n>>k;
    int a[n];
    rep(i,n){
        cin >>a[i];
    }
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        int mi = INT_MAX;
        for(int j=1;(j<=k && i-j>=0);j++){
            mi=min(mi,dp[i-j]+abs(a[i]-a[i-j]));
        }
        dp[i]=mi;
    }
    cout << dp[n-1] <<endl;
    
    return 0;
}

Measured memory_bytes: 1024
import kotlin.Long as Num

const val mod=1000000007

fun modpow(n:Num,p:Num=mod-2L):Num=when {
	p==0L->1L
	p%2==1L->n*modpow(n,p-1)%mod
	else-> {
		val d=modpow(n,p/2)
		d*d%mod
	}
}

fun nCr(n:Num,r:Num):Num {
	if(n-r<r)
		return nCr(n,n-r)
	var res=1L
	for(i in n-r+1..n) {
		res*=i
		res%=mod
	}
	for(i in 2..r) {
		res*=modpow(i)
		res%=mod
	}
	return res
}

fun main(args:Array<String>) {
	abc000X()
}

fun abc000X() {
	val (n,a,b)=readLine()!!.split(" ").map {it.toLong()}

	val t=modpow(2,n)
	val u=nCr(n,a)
	val v=nCr(n,b)
	println((t+mod*2-1-u-v)%mod)
}


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



int main()
{
    int N;
    cin >> N;
    vector<long long> a(N);
    for( int i = 0; i < N; ++i ) cin >> a[i];


    // dp[i][j]: Taro のターンで数列が a[i]~a[j] のときの X-Y
    long long dp[3000][3000] = {};
    for( int i = 0; i < N; ++i ) dp[i][i] = a[i];
    for( int i = N-2; i >= 0; --i ){
        for( int j = i+1; j < N; ++j ){
            dp[i][j] = max( a[i]-dp[i+1][j], a[j]-dp[i][j-1] );
        }
    }
    cout << dp[0][N-1] << endl;
    
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	map<string, int> mp;
	string str;
	while(n--){
		cin >> str;
		mp[str]++;
	}
	cout << "AC" << " x " << mp["AC"] << endl;	
	cout << "WA" << " x " << mp["WA"] << endl;
	cout << "TLE" << " x " << mp["TLE"] << endl;
	cout << "RE" << " x " << mp["RE"] << endl;
}


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

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]){
    cout << "Yes" << endl;
  }
  else if(s[1] == s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] A = new int[N];

        Comparator<int[]> comparator = new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return Integer.compare(o2[0], o1[0]);
            }
        };
        PriorityQueue<int[]> queue = new PriorityQueue<int[]>(comparator);

        long ans = 0L;
        for (int i=0;i<N;i++) {
            A[i] = Integer.parseInt(sc.next());
            ans+=A[i];
            int[] add_array = {A[i]-A[i]/2, A[i]};
            queue.add(add_array);
        }

        while (!queue.isEmpty()) {
            if (M<=0) {
                break;
            }
            // System.out.println(ans);
            int[] rem = queue.remove();
            // System.out.println(Arrays.toString(rem));
            ans-=rem[0];
            int[] add_array = {rem[1]-rem[0]-(rem[1]-rem[0])/2, rem[1]-rem[0]};
            queue.add(add_array);
            M--;
        }
        System.out.println(ans);
    }
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);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 pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    constexpr int N_MAX = 100;
    constexpr int W_MAX = 100000;
    int N, W;
    int w[N_MAX];
    int v[N_MAX];
    cin >> N >> W;
    REP(i, N) cin >> w[i] >> v[i];

    ll dp[N_MAX + 1][W_MAX + 1];
    REP(i, N + 1) dp[i][0] = 0;
    REP(j, W + 1) dp[0][j] = 0;

    FOR(i, 1, N + 1) {
        FOR(j, 1, W + 1) {
            dp[i][j] = dp[i - 1][j];
            if (j - w[i - 1] >= 0) {
                amax(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}



Measured memory_bytes: 79104
#include <iostream>
#include <stdio.h>
#include <map>

using namespace std;

int print_not_exist_card(string mark, map<int, bool> cards) {
    for(int i = 1; i <= 13; i++) {
        if(!cards[i]) {
            printf("%s %d\n", mark.c_str(), i);
        }
    }
}

int main() {
    map<int, bool> S, H, C, D;
    for(int i = 1; i <= 13; i++) {
        S[i] = false;
        H[i] = false;
        C[i] = false;
        D[i] = false;
    }

    int n;
    cin >> n;

    for(int i = 0; i < n; i++) {
        string mark;
        int number;
        cin >> mark >> number;
        if (mark == "S") {
            S[number] = true;
        } else if(mark == "H") {
            H[number] = true;
        } else if(mark == "C") {
            C[number] = true;
        } else if(mark == "D") {
            D[number] = true;
        }
    }

    print_not_exist_card("S", S);
    print_not_exist_card("H", H);
    print_not_exist_card("C", C);
    print_not_exist_card("D", D);
    
    return 0;
}


Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,a,n,c=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a);
        if(a!=i)c++;
        if(c>2){
            printf("NO");
            break;
        }
    }
    if(c<3)printf("YES");
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	h := getNextInt(scanner)
	w := getNextInt(scanner)

	ga := makeInts(h, w)
	gb := makeInts(h, w)

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			ga[i][j] = getNextInt(scanner)
		}
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			gb[i][j] = getNextInt(scanner)
		}
	}

	gab := makeInts(h, w)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			gab[i][j] = absint(ga[i][j] - gb[i][j])
		}
	}

	min := 100
	var dp [81][81][200]uint64
	dp[0][1][min] = 1
	dp[1][0][min] = 1

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			for v := 0; v < min*2; v++ {
				if gab[i][j] == 0 {
					dp[i+1][j+1][v] = dp[i+1][j+1][v] | dp[i+1][j][v] | dp[i][j+1][v]
					continue
				}
				div := gab[i][j]/64 + 1
				shift := gab[i][j] % 64
				if v-div >= 0 && v-div < min*2 {
					dp[i+1][j+1][v] |= dp[i][j+1][v-div] >> uint(64-shift)
					dp[i+1][j+1][v] |= dp[i+1][j][v-div] >> uint(64-shift)
				}
				if v-div+1 >= 0 && v-div+1 < min*2 {
					dp[i+1][j+1][v] |= dp[i][j+1][v-div+1] << uint(shift)
					dp[i+1][j+1][v] |= dp[i+1][j][v-div+1] << uint(shift)
				}

				if v+div >= 0 && v+div < min*2 {
					dp[i+1][j+1][v] |= dp[i][j+1][v+div] << uint(64-shift)
					dp[i+1][j+1][v] |= dp[i+1][j][v+div] << uint(64-shift)
				}
				if v+div-1 >= 0 && v+div-1 < min*2 {
					dp[i+1][j+1][v] |= dp[i][j+1][v+div-1] >> uint(shift)
					dp[i+1][j+1][v] |= dp[i+1][j][v+div-1] >> uint(shift)
				}
			}
		}
	}

	ans := math.MaxInt32
	for v := min * 64; v < min*2*64; v++ {
		if dp[h][w][v/64]>>uint(v%64)&1 > 0 {
			ans = v - min*64
			break
		}
	}
	for v := min * 64; v >= 0; v-- {
		if dp[h][w][v/64]>>uint(v%64)&1 > 0 {
			if ans > min*64-v {
				ans = min*64 - v
			}
			break
		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

func makeInts(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func absint(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
	int T = 86400;
	VI ts(T);

	int n = in();
	int t = 0;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		(t += a) %= T;
		ts[t]++;
		(t += b) %= T;
	}

	rep(i, T) ts.PB(ts[i]);


	int T2 = T * 2;
	VI sums(T2 + 1);
	partial_sum(ALL(ts), sums.begin() + 1);

	int M = 10800;
	int ans = 0;
	rep(i, T) {
		int sum = sums[i + M + 1] - sums[i];
		MAXUD(ans, sum);
	}

	cout << ans << endl;

    return 0;
}



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

using namespace std ;

const int MAX = 10 ;

int arr[MAX] ;
int n , m , q ;
int dp[MAX][1<<MAX][1<<MAX] ;
vector< vector< array<int , 3> > >v(MAX) ;

int solve(int idx , int mask1 , int mask2 , int cur)
{
	if(idx == n)
		return 0 ;
	int &ret = dp[idx][mask1][mask2] ;
	if(ret != -1)
		return ret ;
	int sum = 0 ;
	for(auto &i : v[idx])
	{
		int a = i[0] , c = i[1] , d = i[2] ;
		int y = (1 << (a+1)) - 1 ;
		int x = __builtin_popcount((y & mask1)) ;
		int cnt = 0 ;
		int now = -1 ;
		for(int k = 0 ; k < 10 ; ++k)
		{
			if((mask2 & (1 << k)))
			{
				cnt++ ;
				if(cnt == x)
				{
					now = k ;
					break ;
				}
			}
		}
		if(cur-now == c)
			sum += d ;
	}
	ret = solve(idx+1 , mask1 , mask2 , cur) ;
	for(int i = cur+1 ; i < m && idx < n-1 ; ++i)
		ret = max(ret , solve(idx+1 , mask1 | (1 << (idx+1)) , mask2 | (1 << i) ,i)) ;
	ret += sum ;
	return ret ;
}

int main()
{
	memset(dp , -1, sizeof(dp)) ;
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m>>q ;
	for(int i = 0 ; i < q ; ++i)
	{
		int a , b , c , d ;
		cin>>a>>b>>c>>d ;
		--a , --b ;
		v[b].push_back({a,c,d}) ;
	}
	int ans = -1e9 ;
	for(int i = 0 ; i < m ; ++i)
		ans = max(ans , solve(0 , 1 , 1 << i , i)) ;
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 44560