akhauriyash/Code-Regression huggingface dataset:
//Counting Sort (keisuu)

#include <stdio.h>
#include <stdlib.h>
#define NMAX 2000001
#define KMAX 10000

// NMAX youso count
// KMAX youso size

int main() {
	unsigned int *A,*B;
	int C[KMAX+1];
	int i,length;


	//init
	for(i=0;i<=KMAX;i++){
		C[i]=0;
	}


	//input
	scanf("%d",&length);

	A=malloc(sizeof(int) * length+1);
	B=malloc(sizeof(int) * length+1);

	//input
	for(i=1;i<=length;i++){
		scanf("%d",&A[i]);
	}


	for(i=1;i<=length;i++){
		C[A[i]]++;
	}

	for(i=1;i<=KMAX;i++){
		C[i]=C[i]+C[i-1];
	}

	for(i=length;i>=1;i--){
		B[C[A[i]]]=A[i];
		C[A[i]]--;
	}

	for(i=1;i<=length;i++){
		printf("%d",B[i]);
		if(i!=length){
			printf(" ");
		}
	}
	printf("\n");

	return 0;
}



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

int main()
{

	int a,b,c,d;
	cin >> a >> b >> c >> d;

	for (;;)
	{
		c-=b;
		if (c<=0)
		{
			cout << "Yes" << endl;
			return 0;
		}

		a-=d;
		if (a<=0)
		{
			cout << "No" << endl;
			return 0;
		}
	}

}






Measured memory_bytes: 3636
<?php

$is_honban = 1;

if ($is_honban) {
  //----------------------------------------------------------------------------------
  // Input for honban
  //----------------------------------------------------------------------------------
  $sc = new Scanner();
  $n = $sc->nextInt();
  $a = $sc->nextInt();
  $b = $sc->nextInt();
} else {
  //----------------------------------------------------------------------------------
  // Input for test
  //----------------------------------------------------------------------------------
  error_reporting(E_ERROR | E_WARNING | E_PARSE);

  $n = 100;
  $a = 4;
  $b = 16;
}



//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

$ans = 0;

for ($i = 1; $i <= $n; $i++) {
  $keta_sum = 0;
  for ($j = 0; $j < strlen($i); $j++) {
    $keta_sum += substr($i, $j, 1);
  }
  if ($keta_sum >= $a && $keta_sum <= $b) { $ans += $i; }
//echo $keta_sum."\n";
}



//----------------------------------------------------------------------------------
// Output
//----------------------------------------------------------------------------------
out::println($ans);



//----------------------------------------------------------------------------------
// Ref: https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
//----------------------------------------------------------------------------------
class Scanner {
  private $arr = array();
  private $count = 0;
  private $pointer = 0;
  public function next() {
    if($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext() {
    return $this->pointer < $this->count;
  }
  public function nextInt() {
    return (int)$this->next();
  }
  public function nextDouble() {
    return (double)$this->next();
  }
}

class out {
  public static function println($str = "") {
    echo $str . PHP_EOL;
  }
}

?>


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct q{
    int f,i,j,k;
};
vector<q> v;
void p(int f,int i,int j,int k){
    v.push_back(q{f,i,j,k});
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    p(0,0,1,100);
    p(1,2,100,100);
    fr(i,29) p(0,100+i,100+i,101+i);
    ifr(i,30){
        p(1,0,0,10000);
        fr(j,i) p(0,10000,100+j,10000);
        p(0,10000,1000,10000);
        p(1,10000,0,200+i);
        p(0,200+i,300+i,300+i);
        fr(j,i) p(0,300+i,300+i,300+i);
        p(0,1000,300+i,1000);
    }
    ifr(i,30){
        p(1,0,0,10000);
        fr(j,i) p(0,10000,100+j,10000);
        p(0,10000,1001,10000);
        p(1,10000,1,400+i);
        p(0,400+i,500+i,500+i);
        fr(j,i) p(0,500+i,500+i,500+i);
        p(0,1001,500+i,1001);
    }
    fr(i,30) fr(j,30){
        p(0,200+i,400+j,10000);
        p(1,100,10000,10000);
        fr(k,i+j) p(0,10000,10000,10000);
        p(0,2,10000,2);
    }
    printf("%zu\n",v.size());
    for(auto[f,i,j,k]:v){
        if(f==0) printf("+ %d %d %d\n",i,j,k);
        if(f==1) printf("< %d %d %d\n",i,j,k);
    }/*
    ll a[200000]={};
    cin>>a[0]>>a[1];
    for(auto[f,i,j,k]:v){
        if(f==0)a[k]=a[i]+a[j];
        if(f==1) a[k]=a[i]<a[j];
        if(f==2) cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<'\n';
    }
    cout<<a[2]<<'\n';*/
}

Measured memory_bytes: 3836
n=int(input())
a=sorted(map(int,input().split()))[::-1]
i=0
while i<n and a[i]>i:i+=1
j=i
while j<n and a[j]>=i:j+=1
print('SFeicrosntd'[(a[i-1]-i)&1 or (j-i)&1::2])


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

int main() {
  string str; cin >> str;
  
  string checked = "";
  string ans = "yes";
  for(int i = 0; i < str.size(); i++) {
    char temp = str.at(i);
    if(checked.find(temp) != string::npos) {
		ans = "no";
        break;
    }
    checked += temp;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int ar[n];
	for(int i=0;i<n;i++) {
		cin>>ar[i];
	}
	int dp[n];
	for(int i=0;i<n;i++) {
		dp[i] = 0;
	}
	dp[1] = abs(ar[1]-ar[0]);
	for(int i=2;i<n;i++) {
		dp[i] = min(dp[i-1] + abs(ar[i]-ar[i-1]),dp[i-2] + abs(ar[i]-ar[i-2]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 4324
import java.util.Scanner;

public class Main {
	
	static int mod = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		String s1 = sc.next();
		String s2 = sc.next();
		
		char [][]c = new char [n][2];
		
		for(int i = 0 ; i < n ;i++) {
			c[i][0] = s1.charAt(i);
			c[i][1] = s2.charAt(i);
		}
		
		long []sum = new long [n];
		boolean low = false;
		
		if(c[0][0] == c[0][1]) {
			sum[0] = 3;
		}
		else {
			sum[0] = 6;
			low = true;
		}
		for(int i = 1 ; i < n ; i++) {
			
			if(c[i][0] == c[i-1][0]) {
				continue;
			}
			if(c[i][0] == c[i][1]) {
				sum[i] = low ? 1 : 2;
				if(sum[i]== 1) low = false;
			}
			else {
				sum[i] = low ? 3 : 2;
				low = true;
			}
		}
		
		
		long ans = 1L;
		
		for(int i = 0 ; i < n ;i++) {
			if(sum[i] == 0) continue;
			ans = ans * sum[i] % mod;
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 22996
using System;

class Atcoder04
{
    public static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int h = int.Parse(Console.ReadLine());

        int areadouble = (a + b) * h;
        int area = areadouble / 2;
        Console.WriteLine(area);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main()
{
 	long long x;
  	cin>>x;
  	long long ans1 = -1;
  	long long ans2 = -1;
  	for (long long a = -220;a<221;a++){
      for (long long b = -220;b<221;b++){
        long long val = a*a*a*a*a - b*b*b*b*b;
        if (val==x){ans1 = a;ans2 = b;}
      }
    }
  	cout<<ans1<<" "<<ans2<<endl;
}

Measured memory_bytes: 3640
N=input()
A,B=map(int,raw_input().split())
P=map(int,raw_input().split())

import numpy as np
P=np.array(P)

print min(len(np.where(P<=A)[0]),len(np.where((P>A) & (P<=B))[0]),len(np.where(P>B)[0]))


Measured memory_bytes: 19528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N_MAX 200000

int cmpfunc( const void * n1, const void * n2 )
{
    if (*(int *)n1 < *(int *)n2){
        return 1;
    }
    else if (*(int *)n1 > *(int *)n2){
        return -1;
    }
    else {
        return 0;
    }
}


int main()
{
    int k, n;
    int a[N_MAX], a_dis[N_MAX];
    scanf("%d%d",&k,&n);
    for ( int i=0; i<n; i++ ) scanf("%d",&a[i]);
    
    a_dis[0] = a[0] - a[n-1] + k;
    for ( int i=1; i<n; i++ ) a_dis[i] = a[i] - a[i-1];
    
    qsort( a_dis, n, sizeof(a_dis[0]), cmpfunc );
    
    int total = 0;
    for ( int i=1; i<n; i++ ){
        total += a_dis[i];
    }
    printf("%d\n", total);
}


Measured memory_bytes: 2428
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <cstring>

using namespace std;

int main()
{
    int n;
    cin>>n;
    char str[n];
    int i,j;
    int num=0;
    for(i=0;i<n;i++)
        cin>>str[i];
    char sub[4]={'A','B','C','\0'};
    for(i=0;i<=n-3;i++)
    {
        for(j=0;j<3;j++)
            if(str[i+j]!=sub[j])
                break;
        if(j==3)
            num++;
    }
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

const double PI = acos(-1.0);
int main() {
    double A, B, H, M;
    while (cin >> A >> B >> H >> M) {
        double hour_theta = (H * 60 + M) / 720 * (PI * 2);
        double minute_theta = M / 60 * (PI * 2);
        double theta = abs(hour_theta - minute_theta);
        double res = sqrt(A*A + B*B - 2.0*A*B*cos(theta));
        cout << fixed << setprecision(10) << res << endl;
    }
}

















Measured memory_bytes: 4192
import Control.Applicative

f :: [Int] -> [Int]
f [x] = [x]
f (x:y:z)
    | x < y = y : f (x:z)
    | otherwise = x : f (y:z)

g [] = []
g xs = y : g ys
  where (y:ys) = reverse $ f xs 

main :: IO ()
main = do
  s <- map read . words <$> getLine
  putStrLn $ unwords $ map show (g s)


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
#define PP std::pair<LL,LL>
int N;
LL a[5010];
LL d[5010];
LL x;
LL ans = 1000000000000000000;
int main() {
	std::cin >> N >> x;
	for (int i = 1; i <= N; i++) {
		std::cin >> a[i];
		a[i + N] = a[i];
		d[i] = 1 << 30;
	}
	for (int i = 0; i <= N; i++) {
		LL sum = i * x;
		for (int j = 1; j <= N; j++) {
			d[j] = std::min(d[j], a[j + N - i]);
			sum += d[j];
		}
		ans = std::min(ans, sum);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-1):
    if p[i] - 1 == i:
        count += 1
        p[i] ,p[i + 1] = p[i + 1], p[i]
if p[n - 1] - 1 == n - 1:
    count += 1
print(count)

Measured memory_bytes: 20500
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#define fr(i,b,e) for(int i=(b); i<(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;

int chk(vector<int> a){
    int n=a.size();
    fr(i,0,n){
        cout << a.at(i);
    }
    cout << endl;
}

int gcd(int a,int b){ //a>b
    int tmp=a%b;
    a=b;
    b=tmp;
    if(b!=0){
        return gcd(a,b);
    }else{
        return a;
    }
}

ll power(ll a,ll n){
    if(n==1){
        return a;
    }
    else if(n&1==1){
        --n;
        return power(a,n)*a;
    }else{
        n=n>>1;
        return power(a,n)*power(a,n);
    }
}

int main(void){
    int k;
    int n;
    cin >> n >> k;
    double prob=0.00000000;
    fr(i,1,n+1){
        int j=i;
        double pw=1.0000000;
        while(j<k){
            j=j*2;
            pw=pw/(double)2.0;
        }
        prob=prob+pw/(double)n;
    }
    cout << setprecision(10) << prob << endl;
}


Measured memory_bytes: 256
def bubble_sort(A,N,M):
    flag = 1
    while flag:
        flag = 0
        for i in range(N-1,0,-1):
            if A[i] < A[i-1]:
                tmp = A[i]
                tmp2 = M[i]
                A[i] = A[i-1]
                M[i] = M[i-1]
                A[i-1] = tmp
                M[i-1] = tmp2
                flag = 1
    return M

def choice_sort(A,N,M):
    for i in range(N):
        top = A[i]
        tp = M[i]
        mini = min(A[i:])
        if top > mini:
            tmp = top
            tmpIndex = A[i:].index(mini) + i
            A[i] = mini
            A[tmpIndex] = tmp
            M[i] = M[tmpIndex]
            M[tmpIndex] = tp
    return M

time = int(input())
nums = list(input().split(" "))
numnum = []
for i in nums:
    numnum.append(list(i)[1])
numnum2 = numnum.copy()
memo = []
for i in range(time):
    memo.append(i)
memo2 = memo.copy()

bubble_order = bubble_sort(numnum,time,memo)
answer = ""
for i in bubble_order:
    answer += str(nums[i])
    answer += ' '
print(answer[:-1])
print("Stable")

choice_order = choice_sort(numnum2,time,memo2)
answer2 = ""
for i in choice_order:
    answer2 += str(nums[i])
    answer2 += ' '
print(answer2[:-1])


if answer[:-1] == answer2[:-1]:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;

int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	vector<vector<int>> edit(s1.size() + 1, vector<int>(s2.size() + 1, INF));
	edit[0][0] = 0;
	for (int i = 1; i <= s1.size(); i++)
		edit[i][0] = i;
	for (int i = 1; i <= s2.size(); i++)
		edit[0][i] = i;

	for (int i = 0; i < s1.size(); i++) {
		for (int j = 0; j < s2.size(); j++) {
			edit[i + 1][j + 1] = s1[i] == s2[j] ? min(edit[i][j], min(edit[i][j + 1] + 1, edit[i + 1][j] + 1)) : min(edit[i][j] + 1, min(edit[i][j + 1] + 1, edit[i + 1][j] + 1));
		}
	}
	cout << edit[s1.size()][s2.size()] << endl;
	return 0;
}

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

using namespace std;

int main()
{
  string s;
  int temp;
  int arr[30]={0};
  cin>>s;
  for(int i=0;i<4;i++)
  {
    temp=s[i]-'A';
    arr[temp]++;
  }
  int flag=0;
  for(int i=0;i<26;i++)
  {
    if(arr[i]==2)flag++;
  }
  if(flag==2)
  cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 384
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = lr()
b = lr()
if sum(b) > sum(a):
    print(-1)
else:
    p = []
    m = []
    for i in range(n):
        if a[i] > b[i]:
            p.append(a[i]-b[i])
        elif a[i] < b[i]:
            m.append(b[i]-a[i])
    p.sort(reverse=True)
    t = sum(m)
    ans = 0
    total = 0
    for num in p:
        if total < t:
            total+=num
            ans+=1
        else:
            break
    print(ans+len(m))

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

int gcd(int a, int b) {
    int d = 1;
    if (b != 0) {
        d = gcd(b, a % b);
    } else {
        return a;
    }
    return d;
}

using namespace std;
using ll = long long;
int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll mulOfC = B/C - (A-1)/C;
    ll mulofD = B/D - (A-1)/D;
    ll gcdOfCD = ll(gcd(C, D));
    ll lcmOfCD = C*D / gcdOfCD;
    ll muloflcm = B/(lcmOfCD) - (A-1)/(lcmOfCD);
    ll ans = (B - A + 1) - (mulOfC + mulofD - muloflcm);
    cout << ans << "\n";
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr int mod = 1000000007;
constexpr int inf = 1e9;
int n, k, a, d;
int main(){
	cin>>n>>k;
	vector<int> e;
	vector<vector<int> > snuke(n, e);
	for(int snack = 0; snack < k; ++snack){
		cin>>d;
		for(int i = 0; i < d; ++i){
			cin>>a;
			a--;
			snuke[a].push_back(snack);
		}
	}
	int u = 0;
	for(auto x : snuke){
		if(x.size() == 0)u++;
	}
	cout<<u<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_N = 1005;

int N, E[MAX_N][MAX_N], V[MAX_N][MAX_N], f = 0;

void init(){
  memset(E, 0, sizeof(E));
  E[0][0] = V[0][0];
  FOR(i, 1, N) E[i][0] = E[i - 1][0] + V[i][0];
  FOR(i, 1, N) E[0][i] = E[0][i - 1] + V[0][i];
  FOR(y, 1, N)
    FOR(x, 1, N)
    E[y][x] = V[y][x] + E[y - 1][x] + E[y][x - 1] - E[y - 1][x - 1];
}

bool check(int Y1, int X1, int Y2, int X2){
  int cnt = E[Y2][X2];
  if(X1 - 1 >= 0) cnt -= E[Y2][X1 - 1];
  if(Y1 - 1 >= 0) cnt -= E[Y1 - 1][X2];
  if(X1 - 1 >= 0 && Y1 - 1 >= 0) cnt += E[Y1 - 1][X1 - 1];
  return (cnt == 0 ? true : false);
}

int solve(){
    for(int i = N - 1; i > 0; --i) REP(y, N - i) REP(x, N - i) if(check(y, x, y + i, x + i)) return i + 1;
    return (int)f;
}

int main() {
  while(scanf("%d", &N) && N){
    f = 0;
    REP(i, N){
      string s; cin >>s;
      REP(j, s.length()){
        V[i][j] = (s[j] == '*' ? 1 : 0);
        if(V[i][j] == 0) f = 1;
      }
    }
    init();
    cout <<solve() <<endl;
  }
  return 0;
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#include <atcoder/dsu>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const long INF = 1e15;
using namespace std;
using namespace atcoder;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,Q; cin >> N >> Q;
    dsu d(N);
    rep(i,Q) {
        int t,u,v;
        cin >> t >> u >> v;
        if(t) {
            if(d.same(u,v)){
                cout << 1 << "\n";
            } else {
                cout << 0 << "\n";
            }
        } else {
            d.merge(u,v);
        }
    }
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int max1 = 0;
	int ans = 0;
	for(int i=0;i<n;i++){
	    int x;
	    cin >> x;
	    ans += x;
	    if(x>max1) max1 = x;
	}
	if(ans-max1 > max1) cout << "Yes" <<endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] A = new int[n];
		int q=0;
		for(int i=0; i<n; i++){
			A[i] = sc.nextInt();
		}
		q = partition(A, 0, n-1);
		for(int i=0; i<n-1; i++){
			if(i==q){
				System.out.print("[" +A[i] + "] ");
			}else{
				System.out.print(A[i] + " ");
			}
		}
		System.out.println(A[n-1]);
	}
	
	static int partition(int[] A, int p, int r){
		int x = A[r];
		int i = p-1;
		int tmp;
		for (int j = p; j<r; j++){
			if(A[j] <= x){
				i++;
				tmp = A[i];
				A[i] = A[j];
				A[j] = tmp;
			}
		}
		tmp = A[i+1];
		A[i+1] = A[r];
		A[r] = tmp;
		return i+1;
	}
}



Measured memory_bytes: 73536
import math
N, D = map(int, input().split())
X = [input().split() for i in range(N)]
cnt = 0
for i in range(N):
    d = math.sqrt(pow(int(X[i][0]), 2) + pow(int(X[i][1]), 2))
    if d <= D:
        cnt += 1
print(cnt)


Measured memory_bytes: 67648
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 11111111111;
const int c_mINF = -11111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };

int main() {
	int N, D;
	scanf("%d%d", &N, &D);
	int X[10][10];
	for (int i = 0; i < N; i++)
		for (int j = 0; j < D; j++)
			scanf("%d", &X[i][j]);

	int beki[200];
	for (int i = 0; i < 200; i++)beki[i] = i * i;


	int count = 0;
	for (int i = 0; i < N; i++)
		for (int j = 1; i + j < N; j++) {
			int dis = 0;
			for (int k = 0; k < D; k++) 
				dis += (X[i][k] - X[i+j][k])*(X[i][k] - X[i+j][k]);
			for (int k = 0; k < 200; k++)
				if (dis == beki[k]) {
					//printf("i=%d,j=")
					count++;

				}
		
		}
	printf("%d", count);



}


/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 0) {
            System.out.println(0);
            return;
        }
        n = -n;
       // int[] a = new int[n];
       List<Integer> list = new ArrayList<>();
       while (n != 0) {
           int a =Math.abs(n % 2);
           list.add(a);
           n = (int) Math.floor((double) n / (-2));
       }
       String s = "";
       for (int i = 0 ; i < list.size(); i++) {
           s += list.get(list.size()- i - 1);
       }

           System.out.println(s);
    }

}


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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin >> d.at(i);
    }
    int n=N/2;
    sort(d.begin(),d.end());
    int ans=d[n]-d[n-1];
    cout << ans << endl;
}

Measured memory_bytes: 640
// Problem Code: abc170_d

#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int not_divisible(int N, vector<int>& A) {
	int cnt = 0, limit = *max_element(A.begin(), A.end());
	vector<bool> mark(limit + 1);
	unordered_map<int, int> freq;

	for (int x: A)
		freq[x]++;
	sort(A.begin(), A.end());

	for (int i = 0; i < N; i++) {
		if (mark[A[i]])
			continue;
		for (int x = A[i]; x <= limit; x += A[i])
			if (x % A[i] == 0)
				mark[x] = true;
		cnt += freq[A[i]] == 1;
	}

	return cnt;
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	cout << not_divisible(N, A);
	return 0;
}

Measured memory_bytes: 12124
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int X = rd_int();
  wt_L(10-X/200);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// {
//   int X = rd_int();
//   wt(10-X/200);
// }


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

int main(){

    vector<int> a(3,0);for(int i=0;i<3;++i)cin >> a.at(i);

    sort(a.begin(),a.end());

    int sum=0;
    for(int i=1;i<3;++i){
        sum+=a.at(i)-a.at(i-1);
    }

    cout << sum << endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vb visited;
vvl adj;

ll search(ll i) {
	if(visited[i])
		return 0;

	visited[i] = true;
	ll count = 1;

	for(auto a:adj[i]) {
		count += search(a);
	}

	return count;
}

int main() {
	cin.sync_with_stdio(0);

	ll n, m;
	cin >> n >> m;

	visited = vb(n);
	adj = vvl(n);

	FOR(i,0,m) {
		ll a, b;
		cin >> a >> b;
		a--, b--;

		adj[a].pb(b);
		adj[b].pb(a);
	}


	ll res = 0;
	FOR(i,0,n) {
		res = max(res, search(i));
	}

	cout << res << endl;
}


Measured memory_bytes: 20404
N = int(input())
ps = list(map(int,input().split()))
sort_ps = sorted(ps)
tmp = ps.copy()
c = False
if ps == sort_ps:
  print("YES")
else:
  for x in range(len(ps)):
    for y in range(x+1,len(ps)):
      tmp[x], tmp[y] = tmp[y], tmp[x]
      if tmp == sort_ps:
        c = True
      tmp = ps.copy()
  print('YES' if c == True else 'NO')


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

int main() {

  int N;
  cin >> N;
  int AA;
  AA=N;

  int x=0 , y=0;

  while(N>0){
    x = N%10;
    N = (N-x)/10;
    y = x + y;

  }
  
  if(AA%y==0){
    cout << "Yes" ;
  }
  else{
    cout << "No" ;
  }
}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())

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

	int N; cin >> N;
	int K; cin >> K;
  vector<int> a(N);
	map<int, int> mp;

	REP(i, N) {
		cin >> a[i];
		mp[a[i]]++;
  }

  if(K >= mp.size()) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> counts(mp.size());
  int index = 0;
  for (auto p: mp) {
    counts[index] = p.second;
    index++;
  }
  sort(counts.begin(), counts.end());

  int ans = 0;
  REP(i, mp.size() - K) {
    ans += counts[i];
  }

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


Measured memory_bytes: 11264
def main():
    H, W = map(int,input().split())

    A = [[False for _ in range(W)] for _ in range(H)]

    Q = []
    for y in range(H):
        S = input()
        for x, s in enumerate(S):
            if s == "#":
                Q.append((y, x))
                A[y][x] = True

    ans = 0
    while Q:
        ans += 1
        NQ = []
        for y, x in Q:
            if x > 0 and A[y][x-1] == False:
                A[y][x-1] = True
                NQ.append((y,x-1))
            if x < W-1 and A[y][x+1] == False:
                A[y][x+1] = True
                NQ.append((y,x+1))
            if y > 0 and A[y-1][x] == False:
                A[y-1][x] = True
                NQ.append((y-1, x))
            if y < H-1 and A[y+1][x] == False:
                A[y+1][x] = True
                NQ.append((y+1,x))
        if NQ:
            Q = NQ
        else:
            break

    print(ans-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 106856
def main():
    S = input()
    dic = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
           'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    print(dic[(dic.index(S) + 1) % 26])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
    
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll count(ll x)
{
	ll y=0;
	rep(i,0,22)
	{
		if(x & (1<<i))
		y++;
	}
	return y;
}
ll dp[1<<22],a[22][22];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	cout<<setprecision(12)<<fixed;
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,k,l,m,first,last,n,x,y;
    	cin>>n;
    	rep(i,0,n)
    	{
    		rep(j,0,n)
    		cin>>a[i][j];
		}
		dp[0]=1;
		rep(mask,0,1<<n)
		{
			x=count(mask);
			rep(y,0,n)
			{
				if(a[x][y]==1 && (mask & (1<<y))==0)
				{
					m = mask | (1<<y);
					dp[m]+=dp[mask];
					dp[m]=dp[m]%mod;
				}
			}
		}
		cout<<dp[(1<<n)-1];
	}
	return 0;
}

Measured memory_bytes: 18688
#include <stdio.h>
#include <stdbool.h>

int main(void){
	unsigned int k, a, b, i;
	bool res = false;
	scanf("%d", &k);
	printf("");
	scanf("%d %d", &a, &b);
	if(k > 1000 && a > 1000 && b > 1000) return 0;
	i = a;
	do{
		if(i % k == 0) res = true;
	}while(i++ < b);
	if(res) printf("OK\n");
	else printf("NG\n");
	return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int K;
  cin>>K;
  VL X;
  rep(i,999){
    ll tmp=i+1;
    X.pb(tmp);
    rep(j,12){
      tmp=tmp*10+9;
      X.pb(tmp);
    }
  }
  sort(all(X));
  VL S;
  S.pb(X[X.size()-1]);
  double M=(double)X[X.size()-1]/(double)135;
  rep(i,X.size()-1){
    if(X[X.size()-2-i]==X[X.size()-1-i]) continue;
    ll tmp=X[X.size()-2-i];
    int sum=0;
    while(tmp>0){
      sum+=tmp%10;
      tmp/=10;
    }
    if((double)X[X.size()-2-i]/(double)sum<=M){
      S.pb(X[X.size()-2-i]);
      M=(double)X[X.size()-2-i]/sum;
    }
  }
  sort(all(S));
  rep(i,K) cout<<S[i]<<endl;
}

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

int main(){
    string S;
    cin >> S;
    ll N=S.length();
    vector<ll> c(N,0);

    ll i=0;
    while(i<N){ //RRRLLL
        ll j=i+1;
        ll Ridx=i;
        ll Lidx=j;

        bool isL=false;
        bool r=false;
        while(!r){
            if((j > N-1)){
                r=true;
                if(!isL){
                    Ridx = j-2;
                    Lidx = j-1;
                }
                
            }else if((S[j]=='R') && isL){
                r=true;
            }

            if((S[j]=='L') && !isL){
                isL=true;
                Ridx = j-1;
                Lidx = j;
            }
            j++;
        }
        j = j-1;

        // RRRLLL i -> j
        for(ll k=i;k<j;k++){
            ll dR = Ridx-k;
            if(dR%2==0){
                c[Ridx]++;
            }else{
                c[Lidx]++;
            }
        }
        i=j;
    }

    for(ll i=0;i<N;i++){
        cout << c[i] << ' ';
    }
    cout << endl;
    return 0;
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);


void go(){
	int a,b,k;cin>>a>>b>>k;
	int ans=0;
	for(int i=max(a,b);i>=0;i--) {
		if(b%i==0&&a%i==0) {
			k--;
		}
		if(k==0) {
			ans=i;
			break;
		}
	}
	cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl

#define nl cout<<"\n"
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007

//write your function here
void fun()
{

}


int32_t main()
{
    IOS;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    //start code from here
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    nl;


}

Measured memory_bytes: 3608
S = input()
S = list(S)
N = len(S)
change = ['1','0']

count = 0
for i in range(1,N):
    if S[i] == S[i-1]:
        count += 1
        idx = int(S[i])
        S[i] = change[idx]
        
print(count)
    
    

Measured memory_bytes: 3956
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];

    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    int count = 0;
    int max = h[0];

    for (int i = 0; i < n; i++) {
      if (max-1 > h[i]) {
        count++;
        continue;
      }
      max = Math.max(max,h[i]);
    }

    // System.out.println(count);

    if (count == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

}


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

int main() {
  int K, X;
  cin >> K >> X;
  for(int i;i < 2*K-1; i++){
    if(i == 2*K-2){
      cout << X - K + 1 + i << endl;
    }
    else{
      cout << X - K + 1 + i << ' ';
    }
  }
}


Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
count=0
goukei=0
for i in range(N):
    goukei=0
    A=list(map(int,input().split()))
    for j in range(M):
        goukei+=B[j]*A[j]
    if goukei+C>0:
        count+=1



print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int l, r;
  cin >> l >> r;

  if (floor(l / 2019.0) < floor(r / 2019.0))
  {
    cout << 0 << endl;
    return 0;
  }

  l = l % 2019;
  r = r % 2019;

  int res = (l * (l + 1)) % 2019;
  for (int i = l; i <= r - 1; i++)
  {
    for (int j = l + 1; j <= r; j++)
    {
      if ((i * j) % 2019 < res)
      {
        res = (i * j) % 2019;
      }
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 256
##https://atcoder.jp/contests/dp/tasks/dp_a

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

H = list(map(int, input().split()))
F = [0]*N#それぞれに対する回答を格納する箇所
C = [0]*N#Nに飛ぶ時の最小コストの格納

F[0] = 1
F[1] = 1
C[0] = 0
C[1] = abs(H[0] - H[1])

for i in range(2, N):
    if C[i-2] + abs(H[i] - H[i-2]) > C[i-1] + abs(H[i] - H[i-1]):
        F[i] = F[i-1]
        C[i] = C[i-1] + abs(H[i] - H[i-1])
    elif C[i-2] + abs(H[i] - H[i-2]) < C[i-1] + abs(H[i] - H[i-1]):
        F[i] = F[i-2]
        C[i] = C[i-2] + abs(H[i] - H[i-2])
    else:
        F[i] = F[i-2] + F[i-1]
        C[i] = C[i-2] + abs(H[i] - H[i-2])        
print(C[N-1])


Measured memory_bytes: 466376
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		
		Scanner in = new java.util.Scanner(System.in);
		for(int i=1; i<=5; i++) {
			int x = in.nextInt();
			if(x == 0) {
				System.out.println(i);
				break;
			}
		}
		
		in.close();
	}
}


Measured memory_bytes: 35816
N[]={ 6, 14, 18, 10,  2,  9, 22, 15,  1, 17, 23,  7,  3,  5, 21, 19,  0, 13, 20, 11,  4,  8, 16, 12};
E[]={13, 17,  9,  5,  8, 21, 14,  1, 16, 22,  6,  0,  4, 20, 18,  2, 12, 23, 10,  3, 11, 19, 15,  7};
R[]={ 3,  0,  1,  2,  7,  4,  5,  6, 11,  8,  9, 10, 15, 12, 13, 14, 19, 16, 17, 18, 23, 20, 21, 22};
a;
d;
char s[9];
main(c)
{
	for(;c-48&&scanf("%s",s);a+=d/4+1)
	{
		if((c=*s)<60)
			a&&printf("%d\n",a),
			a=d=0;
		if(c=='N')d=N[d];
		if(c=='S')d=N[N[N[d]]];
		if(c=='E')d=E[d];
		if(c=='W')d=E[E[E[d]]];
		if(c=='R')d=R[d];
		if(c=='L')d=R[R[R[d]]];
	}
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
// 1 - JUMP or 2- JUMP
int c[99999];
int solve(int idx,vector<int>&a,int &n)
{
	if(idx == n-1)
	{
		return 0;
	}
	if(idx >= n)
	{
		return INT_MAX;
	}
	if(c[idx] != -1)
	{
		return c[idx];
	}
	int ans=INT_MAX;
	if(idx+2 < n)
	{
		ans=min(ans,abs(a[idx] - a[idx+2]) + solve(idx+2,a,n));
	}
	if(idx+1 < n)
	{
		ans=min(ans,abs(a[idx] - a[idx+1]) + solve(idx+1,a,n));
	}
	return c[idx]=ans;
}
int32_t main()
{
//  c_p_c();
  int n;
  cin >> n;
  memset(c,-1,sizeof(c));
  vector <int> a(n);
  for(int i=0;i<n;i++)
  {
  	cin >> a[i];
  }
  cout<<solve(0,a,n);
  return 0;
}



Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

ll dp[51][5001];
ll Kokan[51][2];
ll Nedan[102];
ll Jikan[102];
vector<P> d[51];
int main(){
    ll N,M,S; cin>>N>>M>>S;
    rep(i,51) rep(j,5001) dp[i][j]=INF;
    if(S>=5000) S=5000;
    rep(i,M){
        ll U,V,A,B; cin>>U>>V>>A>>B;
        U--; V--;
        d[U].pb(mp(V,i));
        d[V].pb(mp(U,i));
        Nedan[i]=A;
        Jikan[i]=B;
    }
    rep(i,N) cin>>Kokan[i][0]>>Kokan[i][1];
    dp[0][S]=0;
    P_queue Q;
    Q.push(mp(0,S));
    vec ans(N,INF);
    ll count=0;
    while(!Q.empty()){
        ll A=Q.top().first, P=Q.top().second/10000, Money=Q.top().second%10000;
        //cout<<A<<' '<<P<<' '<<Money<<endl;
        if(ans[P]>A) {ans[P]=A; count++;}
        if(count==N) break;
        Q.pop();
        ll x=Money+Kokan[P][0];
        if(x>=5000) x=5000;
        if(Money!=5000) if(A+Kokan[P][1]<dp[P][x]) {dp[P][x]=A+Kokan[P][1]; Q.push(mp(A+Kokan[P][1],P*10000+x));}
        rep(i,d[P].size()){
            ll saki=d[P][i].first, Ned=Nedan[d[P][i].second], Jik=Jikan[d[P][i].second];
            if(Money-Ned>=0) if(A+Jik<dp[saki][Money-Ned]) {dp[saki][Money-Ned]=A+Jik; Q.push(mp(A+Jik,saki*10000+(Money-Ned)));}
        }
        
    }
    REP(i,1,N) cout<<ans[i]<<endl;

}

Measured memory_bytes: 9324
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int n;
	string s, t, str[4] = {"SS", "SW", "WS", "WW"};
	cin >> n >> s;
	t.resize(s.size());
	//t[s.size()] = 0;
	rep(_i, 0, 4) {
		t[0] = str[_i][0];
		t[1] = str[_i][1];
		rep(i, 1, s.size() + 1) {
			t[(i+1) % s.size()] = ((s[i % s.size()] == 'o') ^ (t[(i-1) % s.size()] == 'S') ^ (t[i % s.size()] == 'S')) ? 'S' : 'W';
		}
		if (t[0] == str[_i][0] && t[1] == str[_i][1]) {
			puts(t.c_str());
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int n; cin>>n;
    vector<string> blue(n); for(int i=0; i<n; i++) cin>>blue.at(i);
    int m; cin>>m;
    vector<string> red(m); for(int i=0; i<m; i++) cin>>red.at(i);
    int ans=0;
    for(int i=0; i<n; i++){
        int num=0;
        for(int j=0; j<n; j++){
            if(blue.at(i) == blue.at(j)){
                num++;
            }
        }
        for(int j=0; j<m; j++){
            if(blue.at(i) == red.at(j)){
                num--;
            }
        }
        ans = max(num,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256