akhauriyash/Code-Regression huggingface dataset:
# ABC 057 C - Digits in Multiplication
# 2020/04/07　20:6-
n = int(input())

def F(a, b):
    A = len(str(a))
    B = len(str(b))
    return max(A, B)

ans = 10**12
for i in range(1, int(n**(1/2))+1):
    j = n / i
    if j%1 == 0:
        j = n // i
        if ans > F(i, j):
            ans = F(i, j)
            
print(ans)

Measured memory_bytes: 3060
object Main extends App {

  override def main(args: Array[String]): Unit = {

    val n = io.StdIn.readLine.toInt

    val v1 = new vector(n, io.StdIn.readLine.split(' ').toList.map(_.toDouble))
    val v2 = new vector(n, io.StdIn.readLine.split(' ').toList.map(_.toDouble))

    val dist = v1.distance(v2);
    
    println(dist._1)
    println(dist._2)
    println(dist._3)
    println(dist._4)
  }

  class vector(val div: Int, val list: List[Double]) {
    def distance(target: vector): (Double, Double, Double, Double) = {
      (distance1From(target),
        distance2From(target),
        distance3From(target),
        distanceInfFrom(target))
    }

    def distance1From(target: vector): Double = {
      list.zip(target.list).map(xyi => Math.abs(xyi._1 - xyi._2)).sum
    }

    def minkowskiDistance(p: Int, target: vector): Double = {
      Math.pow(list.zip(target.list).map(xyi => Math.pow(Math.abs(xyi._1 - xyi._2), p)).sum, 1 / p.toDouble)
    }

    def distance2From(target: vector): Double = minkowskiDistance(2, target)
    def distance3From(target: vector): Double = minkowskiDistance(3, target)

    def distanceInfFrom(target: vector): Double = {
      list.zip(target.list).map(xyi => Math.abs(xyi._1 - xyi._2)).max
    }

  }
}

Measured memory_bytes: 44156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
ll dp[100100][13];
int main() {
    int n;
    cin >> n;
    if(n %2 == 0){
        cout << 0.5000000000 << endl;
    }else{
        double cnt = 0;
        for (int i = 1; i <= n; ++i) {
            if(i %2 == 1) cnt++;
        }
        cout << fixed << setprecision(10) << (cnt/n) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

ERROR_INPUT = 'input is invalid'
OPECODE = ['+', '-', '*']
STACK = []


def main():
    inp = get_input()
    print(calc_stack(li=inp))


def calc_stack(li):
    if li[0] in OPECODE:
        ans = calc(left=STACK[-2], right=STACK[-1], ope=li[0])

        del li[0]
        if not li:
            return ans

        STACK.pop()
        STACK.pop()
        STACK.append(ans)

        return calc_stack(li=li)

    else:
        STACK.append(int(li[0]))
        del li[0]
        return calc_stack(li=li)


def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right


def get_input():
    inp = input().split(' ')
    opecode_count = 0
    operand_count = 0

    for i in inp:
        if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            operand_count += 1

    if opecode_count < 1 or opecode_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    if operand_count < 2 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    return inp


main()

Measured memory_bytes: 5732
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (n, a, b) = listOfInt()

    var ans = 0

    for (i in 1..n) {
        var num = i
        var sum = 0
        while (num > 0) {
            sum += num % 10
            num /= 10
        }
        if (sum in a..b) ans += i
    }

    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 38004
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);++i)

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int n, m, l;
int A[100][100];
int B[100][100];
long long C[100][100];

int main() {
    cin >> n >> m >> l;
    rep(i, n) rep(j, m) cin >> A[i][j];
    rep(i, m) rep(j, l) cin >> B[i][j];

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < l; ++j) {
            for (int k = 0; k < m; ++k) {
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < l; ++j) {
            cout << C[i][j];
            if (j + 1 < l) {
                cout << " ";
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3220
while(h=gets.split[1].to_i)>u=t=0
a=[]
m=(0...h).map{|i|u=0;gets.chars.map{|c|(d="WSEN".index c)&&a<<[u,i,d];u+=1};$_}
while a[0]&&181>t+=1
n=a.map{|i,j,d|[[i,j-1,3],[i-1,j,0],[i,j+1,1],[i+1,j,2]].rotate(d).find{|e,f|m[f][e]!=?#&&a.all?{|k,l|k!=e||l!=f}}}
a=n.zip(a).map{|l,k|i,j,d=l;l ?n.all?{|e,f,g|i!=e||j!=f||d<=g}?l:k[0,2]+[d]:k}.reject{|i,j|m[j][i]==?X}
end
puts t>180?:NA:t
end

Measured memory_bytes: 6120
unittest
{
	assert( [ "3 20", "2 80", "9 120", "16 1" ].parse.expand.solve == 191 );
	assert( [ "3 20", "2 80", "9 1", "16 120" ].parse.expand.solve == 192 );
	assert( [ "1 100000000000000", "50000000000000 1" ].parse.expand.solve == 0 );
	assert( [ "15 10000000000", "400000000 1000000000", "800000000 1000000000", "1900000000 1000000000", "2400000000 1000000000", "2900000000 1000000000", "3300000000 1000000000", "3700000000 1000000000", "3800000000 1000000000", "4000000000 1000000000", "4100000000 1000000000", "5200000000 1000000000", "6600000000 1000000000", "8000000000 1000000000", "9300000000 1000000000", "9700000000 1000000000" ].parse.expand.solve == 6500000000 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nc = input.front.split.to!( long[] );
	auto xvs = new long[ 2 ][ nc[ 0 ] ];
	foreach( ref xv; xvs )
	{
		input.popFront;
		xv = input.front.split.to!( long[] );
	}
	return tuple( nc[ 1 ], xvs );
}

auto solve( long c, long[ 2 ][] xvs )
{
	// 時計回りに食べたときのカロリーの最大値を計算
	auto rfs = new long[ 1 + xvs.length ];		// 片道
	auto rbs = new long[ 1 + xvs.length ];		// 往復
	for( auto i = 0L, t = 0L; i < xvs.length; i++ )
	{
		t += xvs[ i ][ 1 ];
		rfs[ i + 1 ] = max( rfs[ i ], t - xvs[ i ][ 0 ] );
		rbs[ i + 1 ] = max( rbs[ i ], t - xvs[ i ][ 0 ] * 2 );
	}
	
	// 反時計回りに食べたときのカロリーの最大値を計算
	auto lfs = new long[ 1 + xvs.length ];		// 片道
	auto lbs = new long[ 1 + xvs.length ];		// 往復
	for( auto i = 0L, t = 0L; i < xvs.length; i++ )
	{
		t += xvs[ $ - 1 - i ][ 1 ];
		lfs[ i + 1 ] = max( lfs[ i ], t - ( c - xvs[ $ - 1 - i ][ 0 ] ) );
		lbs[ i + 1 ] = max( lbs[ i ], t - ( c - xvs[ $ - 1 - i ][ 0 ] ) * 2 );
	}
	
	// 途中まで食べた後に引き返して反対側を食べたときのカロリーの最大値を計算
	auto ans = 0L;
	foreach( rb, lf, lb, rf; lockstep( rbs, lfs.retro, lbs, rfs.retro ) )
	{
		ans = max( ans, rb + lf, lb + rf );
	}
	return ans;
}


Measured memory_bytes: 7804
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e){ll ans=1;GG(e<0);while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    vc<int> to[N];
    int dep[N];
    int ln,S,T;
    int use[N],ct[N],sum;
    void calc(int x,int fa)
    {
        dep[x]=dep[fa]+1;use[x]=(dep[x]&1?1:-1);sum+=use[x];
        fo(t,0,sz(to[x])-1)
        {
            int y=to[x][t];if(y==fa) continue;
            if(dep[y]) {if(!ln) ln=dep[x]-dep[y]+1,S=x,T=y;}
            else calc(y,x);
        }
    }
    int ans;
    int pp[N],cnt;
    void solve(int x,int fa)
    {
        fo(t,0,sz(to[x])-1)
        {
            int y=to[x][t];if(y==fa or (x==S and y==T) or (x==T and y==S)) continue;
            solve(y,x);use[x]+=use[y];ct[x]+=ct[y];
        }
        if(!ct[x]) ans+=abs(use[x]);
        else pp[++cnt]=use[x]*ct[x];//反转绝对值
    }
    void gg(){puts("-1");exit(0);}
    void main()
    {
        int n=qread(),m=qread();fo(i,1,m){int x=qread(),y=qread();to[x].PB(y);to[y].PB(x);}
        calc(1,0);
        if(m==n-1){if(sum!=0)gg();}
        else if(ln&1)
        {
            if(sum&1) gg();
            ans+=abs(sum/2);use[S]-=sum/2,use[T]-=sum/2;
        }
        else
        {
            if(sum!=0) gg();
            ct[S]++,ct[T]--;
        }
        solve(1,0);
        pp[++cnt]=0;sort(pp+1,pp+cnt+1);fo(i,1,cnt) ans+=abs(pp[i]-pp[(cnt+1)/2]);
        write(ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 46592
#include <iostream>

using namespace std;

int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a % b);
}

int main(){
    int N,X;
    cin >> N >> X;
    int dist = 0;
    int pos_f,dist_f;
    for(int i=0;i<N;i++){
        int pos;
        cin >> pos;
        if(i==0){
            dist = abs(pos-X);
            pos_f = pos;
        }else{
            dist_f = dist;
            dist = abs(pos-pos_f);
            dist = gcd(dist,dist_f);
        }
    }
    cout << dist << endl;
}


Measured memory_bytes: 256
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
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

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [a, b] <- readInteger
  let m = gcd a b
   in print $ solve m

solve m
  | m /= 1 = (+ 1) $ length $ factorize m
  | m == 1 = 1

primes :: Integral a => [a]
primes = map fromIntegral primes'
  where
    primes' = [2, 3, 5] ++ f 5 7 (drop 2 primes')
    f m s (p:ps) = [n | n <- ns, gcd m n == 1] ++ f (m * p) (p * p) ps
      where
        ns = [x + y | x <- [s,s + 6 .. p * p - 2], y <- [0, 4]]

-- 素数判定 --
isPrime :: Integral a => a -> Bool
isPrime n = (n > 1) && isPrime' primes
  where
    isPrime' (x:xs)
      | x * x > n = True
      | rem n x == 0 = False
      | otherwise = isPrime' xs

{- 素因数分解関連 -}
-- 素因数分解
factorize :: Integral a => a -> [(a, Int)]
factorize 1 = [(1, 0)]
factorize n = format $ factorize' n primes
  where
    format ps = [(x, length xs) | xs@(x:_) <- group ps]
    factorize' n ps@(p:ps')
      | p * p > n = [n]
      | rem n p == 0 = p : factorize' (div n p) ps
      | otherwise = factorize' n ps'


Measured memory_bytes: 4732
n , k = map(int, input().split())
ns = str(n)
d = set(list(map(int,input().split())))
s = set([0,1,2,3,4,5,6,7,8,9])
l = s-d
le = len(ns)
ans = 0
c=0
k=0
for i in range(le):
    for j in range(10-n%10-k):
        if n%10+j+k in l:
            ans += n%10+j+k
            if j+k != 0:
                ans=int(ans)
            c=1
            k=0
            break
    if c ==0:
        ans +=min(l)
        k=1
    c=0
    n//=10
    ans/=10
z=set([0])
l2=l-z
if k==1:
    ans+=min(l2)
    ans = int(ans)
for i in range(le):
    ans *=10
    if ans%10 ==0:
        ans+=min(l)
print(int(ans))


Measured memory_bytes: 3188
package main

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

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	var n, t, x, y int
	txy := make([]int, 3)
	clear := true
	check := 0
	fmt.Scan(&n)
	arr := scanStringLine(n)
	for i:=0; i<n; i++ {
		for i, v := range strings.Split(arr[i], " "){
			tmp, err := strconv.Atoi(v)
			if err == nil{
				txy[i] = tmp
			}
		}
		check = (txy[0] - t) - (txy[1] - x) - (txy[2] - y)
		if check%2 != 0 || check<0 {
			clear = false
			break
		}
		t, x, y = txy[0], txy[1], txy[2]
	}
	if clear {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 7168
import sys

N, M = map(int, input().split())

if N == 1 and M == 1:
  print(1)
  sys.exit()

if N == 1:
  print(M - 2)
  sys.exit()
  
if M == 1:
  print(N - 2)
  sys.exit()

print(N * M - (N * 2 + M * 2 - 4))

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


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

	int n;
	cin >> n;
	map<long long, int> mp;
	mp[0] = 1;
	long long ans = 0;
	long long sum = 0;
	for(int i = 0; i < n; i++) {
		int t;
		cin >> t;
		sum += t;
		ans += mp[sum];
		mp[sum]++;
	}
	cout << ans << endl;
	return 0;
}	


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

const int MOD = 1000000007;

// a^n mod を計算する(拡張ユークリッドの互除法)
//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  int n;//10**5
  cin >> n;
  vector<int> a(n);//差の列
  vector<int> b(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    b.at(a.at(i))++;
  }
  int flag = 0;
  for(int i = 1; i < n; i++){
    if(b.at(i)!=0&&b.at(i)!=2){
      flag = 1;
      break;
    }
  }
  if(flag)cout << 0 << endl;
  else cout << modpow(2,n/2,MOD) << endl;
  return 0;
}


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

bool is_prime[1000001];

void sieve() {
  for(int i=0;i<1000001;i++) {
    is_prime[i] = true;
  }
  is_prime[0] = is_prime[1] = false;

  for(int i=2;i*i<1000001;i++) {
    if(is_prime[i]) {
      for(int j=2*i;j<1000001;j+=i) {
        is_prime[j] = false;
      }
    }
  }
}

int main() {
  int n,ans=0;
  sieve();
  while(cin >> n) {
    if(n==0) break;

    for(int i=2;i<=(n+1)/2;i++) {
      if(is_prime[i]) {
        if(is_prime[n-i]) {
          ans++;
        }
        else continue;
      }
      else continue;
    }
    cout << ans << endl;
    ans = 0;
  }
}

Measured memory_bytes: 0
function lcm(a,b) {
    var g = (n, m) => m ? g(m, n % m) : n
    return a * b / g(a, b)
}

function Main(input) {
  input = input.trim();
  input = input.split(" ")
  console.log(lcm(input[1],input[0])) //72
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int x, t;
  	cin >> x >> t;
	if(x <= t) cout << 0 << endl;
	else cout << x-t << endl;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n){
        cin >> p.at(i);
    }
    sort(p.begin(), p.end());

    int sum = p.at(n-1)/2;
    rep(i, n-1){
        sum += p.at(i);
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < (n - 1) / 2; ++i) {
        if (s[i] != s[(n - 1) / 2 - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    string t = s.substr(0, n / 2), u = s.substr(n - n / 2, n / 2);
    reverse(u.begin(), u.end());
    cout << (u == t ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
s = gets.chomp
min = 2*(10**5)

kuro=[]
shiro=[]
kuro_count=0
shiro_count=0
n.times do|i|
  if s[i] == "#" then
    kuro_count+=1 
  end
  if s[(n-1)-i] == "." then
    shiro_count+=1
  end
  kuro << kuro_count
  shiro.unshift(shiro_count)
end
#puts "shiro = #{shiro}"
#puts "kuro  = #{kuro}"

(n-1).times do |i|
  m = shiro[i+1] + kuro[i]
  if min>m then
    min=m
  end
end

#puts "min=#{min}"
puts [min,kuro[n-1],shiro[0]].min




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

using namespace std;
#define rep(i, N) for(int i=0;i<int(N);++i)
#define rep1(i, N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

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

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

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N, K;
    cin >> N >> K;
    vector<bool> used(N, false);
    rep(i,N){
        int d;
        cin >> d;
        rep(i,d){
            int a;
            cin >> a;
            a--;
            used[a] = true;
        }
    }
    int ans = 0;
    rep(i,N){
        if(!used[i])ans++;
    }
    cout << ans << endl;

}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int a;cin>>a;
  cout<<a+a*a+a*a*a<<endl;
  

  return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;

void print_flip(char &c){
  c = (c == 'R' || c == 'L') ? (c == 'R' ? 'L' : 'R') : (c == 'U' ? 'D' :'U');
}

int main(){
  int sx,sy,tx,ty;
  scanf("%d%d%d%d",&sx, &sy, &tx, &ty);

  
  int w,h;
  w = tx - sx;
  h = ty - sy;
  string ans = "";
  rep(i,w) ans += 'R';
  rep(i,h) ans += 'U';
  rep(i,w) ans += 'L';
  rep(i,h) ans += 'D';

  ans += 'D';
  rep(i,w + 1) ans += 'R';
  rep(i,h + 1) ans += 'U';
  ans += 'L';
  ans += 'U';
  rep(i,w + 1) ans += 'L';
  rep(i,h + 1) ans += 'D';
  ans += 'R';

  printf("%s",ans.c_str());
  return 0;
}

Measured memory_bytes: 256
n = int(input())
t = [[0 for _ in range(26)] for _ in range(n)]
for i in range(n):
    s = input()
    for j in range(len(s)):
        t[i][ord(s[j])-97] += 1
ans = [0 for _ in range(26)]
for i in range(26):
    min_c = 50
    for j in range(n):
        min_c = min(min_c, t[j][i])
    ans[i] = min_c

s = ""
for i in range(26):
    for j in range(ans[i]):
        s += chr(97+i)

print(s)

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

int main(){
  int N;
  cin>>N;
  int a[N];
  int n=0,r;
  for(int i=0;i<N;i++){
    cin>>a[i];
    n = max(n,a[i]);
  }
  long long int p=n;
  long long int d=n;
  for(int i=0;i<N;i++){
    long long int d2=abs(2*a[i]-p);
    if(d2 < d){
      d=d2;
      r=a[i];
    }
  }
  cout<<n<<" "<<r<<endl;
}
    


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


#define fi first
#define se second
#define pb push_back
#define ll long long 
const int MAX = 1e5+5;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif




int main(){
	int n,d,inspectors=0,i;
	cin >> n >> d;
	for(i = 1; i <= n ; i++){
		if(i + d < n){
			inspectors++;
			i += (2 * d);
			debug(i);
		}else{
			break;
		}
	}
	if(i <= n)
		inspectors++;
	cout << inspectors << "\n";
}



















Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, K;
  cin >> N >> K;
  vector<lint> P(N);
  REP(i, N) cin >> P[i];
  vector<lint> A(N);
  FOR(i, 1, N) if(P[i] > P[i-1]) A[i] = A[i-1] + 1;
  set<lint> st;
  REP(i, K) st.insert(P[i]);
  lint ans = N-K+1;
  bool mode = false;
  if(A[K-1] >= K-1) mode = true;
  FOR(i, K, N) {
    st.insert(P[i]);
    if(A[i] >= K-1) {
      if(!mode) {
        mode = true;
      } else {
        ans--;
      }
    } else {
      lint mi = *st.begin();
      lint ma = *prev(st.end(), 1);
      if(mi == P[i-K] && ma == P[i]) ans--;
    }
    st.erase(P[i-K]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 12800
#include <cstdio>
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;

ll H, W, K;

const ll MOD = 1e9+7;
ll mod(ll x) {return x % MOD;}

void input() {
    cin >> H >> W >> K;
}

void solve() {
    if (W==1) {
        cout << 1 << endl;
        return;
    }
    struct Source {
        ll l, u, r;
    };
    vector<Source> sources(W);
    for (ll n = 0; n < 1ull << (W-1); n++) {
        bool prev = n & 1;
        bool skip = false;
        for (ll i = 1; i < W-1; i++) {
            bool c = n >> i & 1;
            if (c and prev) {
                skip = true;
                break;
            }
            prev = c;
        }
        if (skip) continue;
        prev = false;
        for (ll i = 0; i < W-1; i++) {
            bool c = n >> i & 1;
            if (c) {
                sources[i].l++;
                sources[i+1].r++;
            }
            if (!c and !prev) {
                sources[i].u++;
            }
            if (!c and i == W-2) {
                sources[i+1].u++;
            }
            prev = c;
        }
    }
    cerr << endl;
    vector<array<ll, 8>> dp(H+1);
    dp[0] = {1, 0, 0, 0, 0, 0, 0, 0};
    for (ll h = 1; h <= H; h++) {
        auto &cdp = dp[h], &pdp = dp[h-1];
        for (ll w = 0; w < W; w++) {
            if (w > 0)
                cdp[w] += mod(pdp[w-1] * sources[w].r);
            cdp[w] = mod(cdp[w]);
            cdp[w] += mod(pdp[w] * sources[w].u);
            cdp[w] = mod(cdp[w]);
            if (w < W-1)
                cdp[w] += mod(pdp[w+1] * sources[w].l);
            cdp[w] = mod(cdp[w]);
        }
        for (auto d : cdp)
            cerr << d << ':';
        cerr << endl;
    }
    ll ans = dp.back()[K-1];
    cout << ans << endl;
}

int main() {
    input();
    solve();
    
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
//        sc.useDelimiter("\n");

        String s = sc.next();
        int n = s.length();
        String s2 = s.substring(0, (n-1)/2);
        String s3 = s.substring((n+3)/2-1);
        pw.println(kaibun(s) && kaibun(s2) && kaibun(s3) ? "Yes" : "No");
        
        pw.flush();
    }

    public static boolean kaibun (String str) {
        int n = str.length();
        for (int i = 0; i < n; i++)
            if (str.charAt(i) != str.charAt(n-1-i)) return false;
        return true;
    }
}

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

int main(void){
	int i,n,min,p;
	int ew[2]={0};
	char s[300001];

	scanf("%d %s",&n,&s);
	min=n;

	for(i=0;i<n;i++){
		if(s[i]=='E'){
			ew[0]++;
		}
	}

	for(i=0;i<n;i++){
		if(s[i]=='E'){
			ew[0]--;
		}
		min=min<ew[0]+ew[1]?min:ew[0]+ew[1];
		if(s[i]=='W'){
			ew[1]++;
		}
	}

	printf("%d\n",min);

	return 0;
}


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

bool in_areap(const int W,const int H,const int x,const int y,const int r) {
  return (0 <= x - r) && (x + r <= W) && (0 <= y - r) && (y + r <= H);
}

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if (in_areap(W,H,x,y,r)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3104
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll                          long long
#define ld                          long double
 
#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second
 
#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define  MN                           INT_MIN
#define  MX                           INT_MAX
 
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	int a;
	cin >> a;
	cout << 3 * a * a << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>

using namespace std;
using ll=long long;

int main()
{
    int A, B, C;
    
    cin >> A >> B >> C;
    
    if (A == B)
    {
        printf("%d\n", C);
    }
    else if (A == C)
    {
        printf("%d\n", B);
    }
    else
    {
        printf("%d\n", A);
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;


int main(){
 int k;cin>>k;
 int n=k/2;
 if(k%2==0)cout<<n*n;
 else cout<<n*(n+1);
 
}


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

int main()
{
	deque<char> deq;
	
	string s;
	cin >> s;
	
	for (char tmp1 : s)
	{
		deq.push_back(tmp1);
	}
	
	int q, reverse_cnt = 0;
	cin >> q;
	
	for (int i = 0; i < q; ++i)
	{
		int t;
		cin >> t;
		
		if (t == 1)
		{
			reverse_cnt++;
		}
		else if (t == 2)
		{
			int f;
			char c;
			cin >> f >> c;
			if (f == 1)
			{
				if (reverse_cnt % 2 == 0)
				{
					deq.push_front(c);
				}
				else
				{
					deq.push_back(c);
				}
			}
			else if (f == 2)
			{
				if (reverse_cnt % 2 == 0)
				{
					deq.push_back(c);
				}
				else
				{
					deq.push_front(c);
				}
			}
		}
	}
	
	if (reverse_cnt % 2 == 1)
	{
		reverse(deq.begin(), deq.end());
	}
	
	for (char tmp2 : deq)
	{
		cout << tmp2;
	}
	
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 896
from collections import defaultdict as dd
from heapq import heappop, heappush

N, K = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(N)]
l.sort(key=lambda x:-x[1])
used = set()
q1 = dd(list)
q2, q3 = [], []

score, kind = 0, 0

for t, d in l[:K]:
    score += d
    if t in used:
        heappush(q3, d)
    else:
        used.add(t)
        kind += 1

for t, d in l[K:]:
    if not t in used:
        heappush(q1[t], -d)
for t in q1.keys():
    d = heappop(q1[t])
    heappush(q2, d)

ans = score + kind*kind
while q2 and q3:
    d1 = heappop(q2)
    d2 = heappop(q3)
    score -= d1+d2
    kind += 1
    ans = max(ans, score + kind*kind)

print(ans)

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

typedef long long int ll;

vector<int> h;
vector<int> ans;

int f(int N, int K){
	if(ans[N] != -1) return ans[N];
	if(N == 0){
		ans[N] = 0;
	}
	else if(N == 1){
		ans[N] = abs(h[1]-h[0]);
	}
	else{
		int m = INT_MAX;
		for(int i = N-1; i >= max(0,N-K); i--)
		{
			int t = abs(h[N]-h[i]) + f(i,K);
			m = min(t,m);
		}
		ans[N] = m;
	}
	
	return ans[N];
}

void solve(){
	int N, K;
	cin >> N >> K;
	
	h.clear(); ans.clear();
	h.resize(N); ans.resize(N);
	for(int i = 0; i < N; i++) ans[i] = -1;
	for(int i = 0; i < N; i++) cin >> h[i];
	
	cout << f(N-1, K) << endl;
}

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

	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}





Measured memory_bytes: 8832
#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <deque>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int k;

const int INF = 10000000;
int dist[100000+10];

int go(void) {
  REP(i, 100000+10) {
    dist[i] = INF;
  }
  deque<pair<int,int> > q;
  q.push_back(make_pair(1, 0));
  dist[1] = 0;
  while(!q.empty()) {
    pair<int,int> cur = q.front(); q.pop_front();
    if(dist[cur.first] < cur.second) {
      continue;
    }
    if(cur.first == 0) {
      break;
    }
    int n10 = (cur.first*10) % k;
    if(cur.second < dist[n10]) {
      q.push_front(make_pair(n10, cur.second));
      dist[n10] = cur.second;
    }
    int n1 = (cur.first+1) % k;
    if(cur.second+1 < dist[n1]) {
      q.push_back(make_pair(n1, cur.second + 1));
      dist[n1] = cur.second+1;
    }
  }
  return dist[0];
}

int main(void) {
  while(~scanf("%d", &k)) {
    int res = 1+go();
    printf("%d\n", res);
  }
  return 0;
}


Measured memory_bytes: 1024
n,m = map(int, input().split())
p,q = float('-inf'),float('inf')
for i in range(m):
  a,b = map(int, input().split())
  if a > p:
    p = a
  if b < q:
    q = b
if (q-p) < 0:
  print(0)
else:
  print(q-p+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ld long double
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define mp map<ll, ll>
#define um unordered_map<ll, ll>
#define st set<ll> 
#define us unordered_set<ll>
#define vt vector<ll>
#define pll pair<ll, ll>
#define fl(i, x, y) for(ll i=x;i<y;++i)
#define flr(i, x, y) for(ll i=x;i>=y;--i)

int main()
{
    ll n;
    cin>>n;
    ll a[n], mn=LLONG_MAX, s=0, s1=0, b[n];
    fl(i, 0, n)
    {
        cin>>a[i];
        a[i]-=(i+1);
        b[i]=a[i];
    }
    sort(b, b+n);
    mn = b[n/2];
    fl(i, 0, n)
    {
        s+=(abs(a[i]-mn));
    }
    fl(i, 0, n)
    {
        s1+=(abs(a[i]+mn));
    }
    cout<<min(s, s1)<<endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.*;
import java.util.Vector;
import java.math.*; 
public class Main {
     Scanner sc = new Scanner(System.in);
	//	System.out.println( );
	
	
	
	void run(){ // kokonikaku
		int a=sc.nextInt();
		int b=sc.nextInt();
		int ans;
		if(a>b)ans=2*a-1;
		else if(a<b) ans=2*b-1;
		else ans=2*a;
		System.out.println(ans);
	}

	
	public static void main(String[] args) {
		new Main().run();
        
    }
}

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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int r = 0; r <= N; ++r) {
    for (int g = 0; g <= N; ++g) {
      int b = (N - R * r - G * g) / B;
      if (r >= 0 && g >= 0 && b >= 0 && R * r + G * g + B * b == N)
        ++ans;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 44;

ll ansone[maxn][maxn][maxn];
ll ansopp[maxn][maxn][maxn][maxn];
bool wasone[maxn][maxn][maxn];
bool wasopp[maxn][maxn][maxn][maxn];
int n;
int gr[maxn][maxn];
char s[maxn];

inline int nxt(int a)
{
	return (a == n - 1 ? 0 : a + 1);
}

inline int prv(int a)
{
	return (a == 0 ? n - 1 : a - 1);
}

ll solveopp(int l1, int r1, int l2, int r2);

ll solveone(int l, int c, int r)
{
	if (wasone[l][c][r]) return ansone[l][c][r];
	wasone[l][c][r] = true;
	ll &curans = ansone[l][c][r];
	
	curans = 0;
	
	if (l == c && c == r)
	{
		curans = 1;
		return curans;
	}
	
	for (int l1 = l; l1 != c; l1 = nxt(l1))
	{
		for (int r1 = r; r1 != c; r1 = prv(r1)) curans += solveopp(l, l1, r1, r) * solveone(nxt(l1), c, prv(r1));
	}
	//if (curans != 0) cout << "solveone " << l << ' ' << c << ' ' << r << ' ' << curans << endl;
	return curans;
}

ll solveopp(int l1, int r1, int l2, int r2)
{
	if (wasopp[l1][r1][l2][r2]) return ansopp[l1][r1][l2][r2];
	wasopp[l1][r1][l2][r2] = true;
	ll &curans = ansopp[l1][r1][l2][r2];
	
	curans = 0;
	
	for (int c1 = l1; ; c1 = nxt(c1))
	{
		for (int c2 = l2; ; c2 = nxt(c2))
		{
			if (gr[c1][c2]) curans += solveone(l1, c1, r1) * solveone(l2, c2, r2);
			//cout << c2 << ' ' << r2 << endl;
			if (c2 == r2) break;
		}
		if (c1 == r1) break;
	}
	//if (curans != 0) cout << "solveopp " << l1 << ' ' << r1 << ' ' << l2 << ' ' << r2 << ' ' << curans << endl;
	return curans;
}

int main()
{
	scanf("%d", &n);
	n *= 2;
	for (int i = 0; i < n; i++)
	{
		scanf("%s", s);
		for (int j = 0; j < n; j++) gr[i][j] = s[j] - '0';
	}
	
	//n = 40;
	//for (int i = 0; i < n; i++)
	//{
		//for (int j = 0; j < n; j++) gr[i][j] = 1;
	//}
	
	ll answer = 0;
	for (int c = 1; c < n; c++) if (gr[0][c])
	{
		answer += solveone(1, c, n - 1);
		//for (int l = 1; l <= c; l++)
		//{
			//for (int r = c; r < n; r++)
			//{
				//answer += solveone(nxt(r), 0, prv(l)) * solveone(l, c, r);
			//}
		//}
	}
	cout << answer << endl;
    return 0;
}


Measured memory_bytes: 30592
#include<iostream>
#include<string>
#include <cmath>
#include <ctype.h>
using namespace std;
char a[10], b[10], c[10];
int main() {
    cin >> a >> b >> c;
    
    cout << (char)toupper(a[0])<< (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

void A_Next_Alphabet(void) {

	char C;
	cin >> C;
	cout << char(C + 1) << flush;
	return;
}

int main(void) {

	A_Next_Alphabet();
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define POW_10_5 100000
#define POW_10_9 1000000000
#define MOD 1000000007
#define INF (numeric_limits<int>::max()/2)
#define int long long

typedef pair<int, int> Pair;
typedef unordered_map<int, int> Hash;

// ---
int K, A, B;

string Ans() {
  if (A/K == B/K && A%K != 0) {
    return "NG";
  } else {
    return "OK";
  }
}

signed main() {
  cin >> K;
  cin >> A >> B;

  auto ans = Ans();

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


Measured memory_bytes: 3132
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int Y = nextInt();
		String ans ="";
		if(Y==1){
			ans="Hello World";
		}else{
			ans=String.valueOf(nextInt()+nextInt());
		}




		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21076
#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> pii;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};

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

	int h, w;
	cin >> h >> w;

	int sr, sc;
	cin >> sr >> sc;
	sr--; sc--;

	int gr, gc;
	cin >> gr >> gc;
	gr--; gc--;

	vector<string> s(h);
	rep(i, h) cin >> s[i];

	int INF = 1e9;
	vector<vector<int>> dist(h, vector<int>(w, INF));
	deque<pii> deq;
	deq.push_back({sr, sc});
	dist[sr][sc] = 0;

	while(!deq.empty()){

		int r = deq.front().first;
		int c = deq.front().second;
		deq.pop_front();

		if(dist[r][c] >= dist[gr][gc]) continue;

		rep(i, 4){
			int nr = r + dr[i];
			int nc = c + dc[i]; 
			if(0 <= nr && nr < h && 0 <= nc && nc < w && s[nr][nc] == '.'){
				if(dist[nr][nc] > dist[r][c]){
					dist[nr][nc] = dist[r][c];
					deq.push_front({nr, nc});
				}
			}
		}

		for(int i = -2; i <= 2; i++){
			for(int j = -2; j <= 2; j++){
				if(i == 0 && j == 0) continue;
				int nr = r + i;
				int nc = c + j;
				if(0 <= nr && nr < h && 0 <= nc && nc < w && s[nr][nc] == '.'){
					if(dist[nr][nc] > dist[r][c] + 1) {
						dist[nr][nc] = dist[r][c] + 1;
						deq.push_back({nr, nc});
					}
				}
			}
		}
	}

	if(dist[gr][gc] == INF){
		cout << -1 << endl;
	}else{
		cout << dist[gr][gc] << endl;
	}

}


Measured memory_bytes: 8664
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> a(n, vector<int>(n, 0));
  REP(i, m){
    int l, r;
    cin >> l >> r;
    a[--l][--r]++;
  }
  vector<vector<int>> sum(n+1, vector<int>(n+1, 0));
  REP(i, n) REP(j, n)sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + a[i][j];

  vector<int> ans(q);
  REP(i, q){
    int p, q;
    cin >> p >> q;
    ans[i] = sum[q][q] - sum[q][p-1] - sum[p-1][q] + sum[p-1][p-1];
  }
  REP(i, q)cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 3328