akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;




int prime[100002]={};
int Er_N=100001;
void Er(){//Eratosthenes  1:PRIME  0:NOT PRIME
	for(int i = 2; i < Er_N; i++){
		prime[i] = 1;
	}
	int limit_Er_roop=sqrt(Er_N);
	for(int i = 2; i < limit_Er_roop; i++){
		if(prime[i]){
			for(int j = 0; i * (j + 2) < Er_N; j++){
				prime[i *(j + 2)] = 0;
			}
		}
	}
}

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

long long lcm(long long a,long long b){
	long long g=gcd(a,b);
	return a/g*b;
}


int main(){
	int n;
	cin>>n;
	if(n==2){
		cout<<"4 7"<<endl;
		cout<<"23 10"<<endl;
		return 0;
	}
	Er();
	vector<int> prm;
	FOR(i,2,Er_N){
		if(prime[i])prm.PB(i);
	}
	int t=prm.size();
	cerr<<t<<endl;
	LL b[505][505]={};
	FORQ(i,0,n+1){
		FORQ(j,0,n+1){
			b[i][j]=1LL;
		}
	}
	FORQ(i,1,n){
		FORQ(j,1,n){
			if((i+j)%2==0){
				int id1=(i+j-2)/2;
				int id2=2*n-1-(n+(n&1)-i+j-2)/2;
				b[i][j]=1LL*prm[id1]*prm[id2];
			}
		}
	}
	FORQ(i,0,n){
		FORQ(j,0,n){
			if((i+j)%2==1){
				b[i][j]+=1LL*lcm(lcm(b[i-1][j],b[i][j-1]),lcm(b[i+1][j],b[i][j+1]));
			}
		}
	}
	LL mx=0;
	FORQ(i,1,n){
		FOR(j,1,n){
			cout<<b[i][j]<<" ";
			mx=max(mx,b[i][j]);
		}
		cout<<b[i][n]<<endl;
	}
	cerr<<mx<<endl;

    return 0;
}


Measured memory_bytes: 5632
import queue

INF = 1 << 30

s = [-1, -1]
n, s[0], s[1] = map(int, input().split())
s[0] -= 1
s[1] -= 1

g = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

cost = [[INF for j in range(n)] for i in range(2)]

for i in range(2):
    cost[i][s[i]] = 0
    que = queue.Queue(n)
    que.put(s[i])

    while not que.empty():
        now = que.get()
        for j in range(len(g[now])):
            if cost[i][g[now][j]] > cost[i][now] + 1:
                cost[i][g[now][j]] = cost[i][now] + 1
                que.put(g[now][j])

maxi = -1
maxdex = -1
for i in range(n):
    if len(g[i]) == 1 and maxi < cost[1][i] and cost[0][i] < cost[1][i]:
        maxi = cost[1][i]
        maxdex = i

dif = cost[1][maxdex] - cost[0][maxdex]

ans = cost[0][maxdex] + dif - 1
print(ans)

Measured memory_bytes: 83100
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll bg = 100000000007;
#define ff(i,n) for(i=0;i<n;i++) 
ll check (ll x,ll y,ll n,ll m)
{
	if(x>=0 && y>=0 && x<n && y<m)
		return 1;
	return 0;		
}
ll num(ll x,ll y,ll n,ll m)
{
	ll dd = x*m + y;
	return dd;
}
ll sx[4] = {0,1,-1,0};
ll sy[4] = {1,0,0,-1};
int main()
{
    ll kamal;
    kamal = 1;
    while(kamal--)
    {
    	ll i,j,n,b,x=0,m,k;
		cin>>n>>m;
		ll x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		char arr[n][m];
		ff(i,n)
			ff(j,m)
				cin>>arr[i][j];
		vector<vector<pair<ll,ll> > >edge(n*m);
		ff(i,n)
		{
			ff(j,m)
			{
				ff(k,4)
				{
					if(check(i+sx[k],j+sy[k],n,m)==1 && arr[i][j]=='.' && arr[i+sx[k]][j+sy[k]]=='.')
						edge[i*m+j].pb(mp(num(i+sx[k],j+sy[k],n,m),0));	
				}
				ll l;
				for(k=-2;k<=2;k++)
				{
					for(l=-2;l<=2;l++)
					{
						if(check(i+k,j+l,n,m)==1 && arr[i][j]=='.' && arr[i+k][j+l]=='.' && ((abs(k)+abs(l))>1))
							edge[i*m+j].pb(mp(num(i+k,j+l,n,m),1));
					}
				}	
			}	
		}
		x1--;
		y1--;
		x2--;
		y2--;
		ll s = num(x1,y1,n,m) , t = num(x2,y2,n,m);
		vector<ll> d;
		ff(i,n*m)
			d.pb(bg);
		d[s] = 0;
		set<pair<ll, ll> > q;
		q.insert(mp(0,s));
		while (!q.empty()) {
		    ll v = q.begin()->second;
		    q.erase(q.begin());		
		    for (i=0;i<edge[v].size();i++) 
			{
		        ll u = edge[v][i].first;
		        ll w = edge[v][i].second;
		
		        if (d[v] + w < d[u]) {
		            q.erase(mp(d[u],u));
		            d[u] = d[v] + w;
		            q.insert(mp(d[u],u));
		        }
		    }
		}	
		if(d[t]==bg)
			cout<<"-1";
		else	
			cout<<d[t];				    
    }
    return 0;
} 

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

int main() {
  
  int N,K;
  cin >> N >> K;
  
  vector<int> H(N);
  for(int i=0; i<N; i++){
   cin >> H.at(i);  
  }
  
  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());
  
  int64_t count=0;
  int number=0;
  
  while(K>0){
    K--;
    number++;
  }
  
  for(int i=number; i<N; i++){
     count+=H.at(i);
  }
  
  cout << count << endl;
      
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a==b){
    cout << 'a' << " == " << 'b' << endl;
  }
  else if(a > b){
    cout << 'a' << " > " << 'b' << endl;
  }
  else{
    cout << 'a' << " < " << 'b' << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
if s == "zyxwvutsrqponmlkjihgfedcba":
     print(-1)
elif len(s) != 26:
    nokori = set(a) - set(s)
    nokori = sorted(nokori, key=a.index)
    print(s + nokori[0])
else:
    for i in range(1, 27):
        if list(s)[-i] > list(s)[-(i + 1)]:
            break
    T = sorted(list(s)[-i:])
    #print(T)
    for t in T:
        if t > list(s)[-(i + 1)]:
            break
    print("".join(list(s)[:-(i + 1)]) + t)

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

typedef struct {
  int num;
  int P;
  long long int Y;
  int y;
} bigint;

int cmp( const void *p, const void *q ) {
  if(((bigint*)p)->Y - ((bigint*)q)->Y > 0){
    return 1;
  }else{
    return -1;
  }
}

int cmp2( const void *p, const void *q ) {
    return ((bigint*)p)->num - ((bigint*)q)->num;
}

void sixint(int N){
  int i;
  int k[6];

  for(i=5;i>=0;i--){
    k[i]=N%10;
    N=(int)N/10;
  }
  
  for(i=0;i<6;i++){
    printf("%d",k[i]);
  }
}

int main(){
  int N,M,i;
  scanf("%d%d",&N,&M);
  bigint X[M];
  for(i=0;i<M;i++){
    scanf("%d%lld",&X[i].P,&X[i].Y);
    X[i].num=i;
  }
  qsort(X, M, sizeof(bigint), cmp);
  int c_P[N+1];
  for(i=0;i<N+1;i++){
    c_P[i]=1;
  }
  for(i=0;i<M;i++){
    X[i].y = c_P[X[i].P];
    c_P[X[i].P]=c_P[X[i].P]+1;
  }
  qsort(X, M, sizeof(bigint), cmp2 );
  for(i=0;i<M;i++){
    sixint(X[i].P);
    sixint(X[i].y);
    printf("\n");
  }
  return 0;
}


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

using namespace std;

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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; string s;
	cin >> n >> s;
	int ans = 0;
	for(int i = 2; i < n; i++){
		if(s.substr(i-2,3)=="ABC")ans++;
	}
	cout << ans << endl;
}	


Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

s = input()
l = {"MON":1,"TUE":2,"WED":3,"THU":4,"FRI":5,"SAT":6, "SUN":7}
print(7 - (l[s] % 7))




Measured memory_bytes: 6292
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

b = []
n.times do |i|
    b << a[i]
    (i+1).upto(n-1) {|j| b << b[-1] + a[j]}
end

ans = 0
41.downto(0) do |i|
    x = 1 << i
    y = b.select{|e| e & x != 0}
    if y.size >= k
        ans += x
        b = y
    end
end

p ans

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

const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++)
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define lld long double
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;
//vector<vector<ll>> vv(n, vector<ll>(n));

using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if (a * n > b) cout << b << endl;
    else cout << a * n << endl;
}

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

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    ll h, w;
    cin >> h >> w;
    
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }

    ll ans = (h / 2) * w;
    if (h % 2 == 1) {
        ans += (w / 2);
        if (w % 2 == 1)
            ans += 1;
    }

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


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    char S;    /* 入力文字列用 */
 
    
    scanf("%s",&S);          /* 文字列入力 */
 
    if(strcmp(&S, "ABC"))    /* 文字列比較 */
        printf("ABC");    /* 表示 */
    else
        printf("ARC");   /* 表示 */
    return(0);
}

Measured memory_bytes: 2148
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main ()
{
    int64_t a, b, n;
    cin >> a >> b >> n;
    int64_t x = std::min (n, (b - 1));
    cout << (a * x / b) - a * (x / b);
}


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

int main(){
 int a,b;
 cin >> a >> b;
 rep(i,1001){
   if((i*8)/100 == a && (i*10)/100 == b){
     cout << i << endl;
     return 0;
   }
 }
 puts("-1");
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
typedef long long int ll;


int main() {
	int n, a;
	cin >> n >> a;
	YesNo(a >= n % 500);
}

Measured memory_bytes: 256
a=list(input())
A = B = C = ''
if a[0] == a[1] and a[0] == a[2] or a[0] >= a[2] and a[0] == a[1]:
    for _ in range(3):
        A += str(a[0])
    print(A)
else:
    if a[1] >= a[0] :
       a[0] = int(a[0]) + 1
       for i in range(3):
        B += str(a[0])
    
       print(B)

    else:
       for i in range(3):
        C += str(a[0])
    
       print(C)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
int main(){
  int n,a; cin >> n >> a; n %= 500;
  
  if( n <= a){ cout << "Yes" << endl;}
  else{ cout << "No" << endl;}
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<cstdio>
    #include<math.h>
    #include<string>
    #include<algorithm>
    #include<functional>
    #include<vector>
    #include<set>
    #include<map>
    #define INF 999999
    #define EPS 1.0e-6
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef pair<int, P> PP;
     
    int n;
    int t[105];
    int v[105];
    int tt[105];
     
    int main()
    {
    	cin >> n;
    	
    	for (int i = 0; i < n; i++) {
    		cin >> t[i];
    		tt[i+1] = tt[i] + t[i];
    	}
    	for (int i = 0; i < n; i++) {
    		cin >> v[i];
    	}
     
    	double ans = 0;
    	double p = 0;
    	for (double d = 0.0; d <= tt[n]; d += 0.5) {
    		double imin = min(d,tt[n]-d);
    		for (int i = 0; i < n; i++) {
    			double k;
    			if (tt[i] >= d) k = v[i] + (tt[i] - d);
    			else if (tt[i + 1] <= d)k = v[i] + (d - tt[i + 1]);
    			else k = v[i];
    			imin = min(k,imin);
    		}
    		ans += (p + imin) / 4;
    		//cout << imin << endl;
    		p = imin;
    	}
     
    	printf("%lf\n", ans);
     
    	return 0;
    }

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  set<int> b;
  for(int i = n-1; i >= 0; i--) {
    int j = 2;
    int num = 0;
    while((i+1)*j<n+1) {
      if(b.count((i+1)*j)) num++;
      j++;
    }
    if(num%2!=a[i]) {
      b.insert(i+1);
    }
  }
  cout << b.size() << endl;
  for(auto p : b) cout << p << endl;
  return 0;
}

Measured memory_bytes: 10036
#include<iostream>
using namespace std;
int main(){
  int a, b, k = 0;
  while(cin >> a >> b, a||b){
    if(k > 0 and (a or b)) cout << endl;
    int t = 0;
    ++k;
    for(int i = a; i <= b; ++i){
      if(i%4) continue;
      if((not (i%100)) and i%400) continue;
      ++t;
      cout << i << endl;
    }
    if(not t) cout << "NA" << endl;
  }
}



Measured memory_bytes: 3016
#include<iostream>  
#include<cstdio>  
#include<cstring> 
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<cmath>
//#define inf  0x3f3f3f3f3f3f3f3f
#define bit(x) (1<<(x)) 
using namespace std;
const int maxn = int(1e5)+100;
const int mod = 998244353;
const int inf = 2 * int(1e9) + 100;
const double pi = acos(-1);
typedef long long LL;
int main(){
	int a, b;
	while (~scanf("%d%d", &a, &b)) {
		if (a%b) printf("%d\n", a);
		else printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextInt64() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}


func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func (io *Io) PrintBool(b bool, trueS, falseS string) {
	if b {
		io.PrintLn(trueS)
	} else {
		io.PrintLn(falseS)
	}
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func absi(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

type Int64s []int64
func (f Int64s) Len() int {
	return len(f)
}
func (f Int64s) Less(i, j int) bool {
	return f[i] < f[j]
}

func (f Int64s) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}


func abcInt(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func gcdInt(a, b int) int {
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

var (
	io *Io
)

type P struct {
	s string
	p int
	id int
}

type PS []P
func (f PS) Len() int {
	return len(f)
}
func (f PS) Less(i, j int) bool {
	if f[i].s != f[j].s {
		return f[i].s< f[j].s
	}
	return f[i].p > f[j].p
}

func (f PS) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}

const MOD = 1000000007

func solve() {
	n, m := io.NextInt(), io.NextInt()
	a := make([]bool, n + 1)
	for i := 0; i < m; i++ {
		a[io.NextInt()] = true
	}

	t := make([]int, n + 1)
	t[0] = 1
	for i := 0; i < n; i++ {
		if !a[i+1] {
			t[i+1] = (t[i+1] + t[i]) % MOD
		}
		if i+2 <= n && !a[i+2] {
			t[i+2] = (t[i+2] + t[i]) % MOD
		}
	}

	io.PrintLn(t[n])

}


func main() {
	io = NewIo()
	f, err := os.Open("src/input")
	if err == nil {
		io.reader = bufio.NewReader(f)
	}
	defer io.Flush()

	solve()
}

Measured memory_bytes: 4096
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int n, x, count, min, middle;
    while(true){
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0) break;
        count = 0;
        for(min = 1; min < x/3 && min <= n-2;min++){
            for(middle = min+1;middle < x - (min+middle) && middle <= n-1; middle++){
                if(x-(min+middle) <= n) count++;
            }
        }
        printf("%d\n",count);
    }
    return 0;
}



Measured memory_bytes: 2732
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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 (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

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

  //vector<ll> a(m);
  set<ll> a;
  vector<ll> dp(n+1);
  rep(i,m){
    ll tmp;
    cin>>tmp;
    a.insert(tmp);
  }

  dp[0]=1;
  if( a.find(1LL) != end(a) ){
      dp[1]=0;
    }
  else dp[1]=1;

  for(ll i=2;i<n+1;i++){

    if( a.find(i) != end(a) ){
      dp[i]=0;
    }
    else{

      dp[i]=dp[i-1]%mod+dp[i-2]%mod;
      dp[i]%=mod;

    }

  }

  cout << dp[n] << endl;

  return 0;

}


Measured memory_bytes: 5760
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if (b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b != 0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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

int main(void) {
  ll n;
  cin >> n;
  vector<ll> v(n + 1);
  vector<ll> w(n + 1);
  vector<ll> x(n + 1);
  for (ll i = 1; i <= n; i++) {
    cin >> v[i];
    w[i] = 0;
    x[i] = 0;
  }
  ll b = 0;
  for (ll i = n; i >= 1; i--) {
    if ((v[i] == 1 and w[i] % 2 != 1) or (v[i] == 0 and w[i] % 2 != 0)) {
      for (ll j = 1; j * j <= i; j++) {
        if (i % j == 0) {
          w[j]++;
          if (j * j != i)
            w[i / j]++;
        }
      }
      x[i] = 1;
      b++;
    }
  }
  std::cout << b << std::endl;
  for (ll i = 1; i <= n; i++)
    if (x[i] == 1)
      std::cout << i << " ";

  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 5504
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

int f(int n){
    int sum = 0;
    while(n>0){
        sum += n%10;
        n/=10;
    }
    return sum;
}

void Main(){
    int N, D;
    cin >> N >> D;
    vec<vec<int> > X(N, vec<int>(D));
    REP(i, N){
        REP(j, D){
            cin >> X[i][j];
        }
    }
    int cnt=0;
    REP(i, N){
        FOR(j, N, i+1){
            ll sum = 0;
            REP(k, D){
                sum += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            ll n = sqrt(sum);
            if(sum == n*n){
                cnt++;
            }
        }
    }
    cout << cnt << el;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,q,k,d;
  cin>>n>>q>>k>>d;
  k--;d--;
  
  const int MAX = 60;
  while(q>=MAX){
    cout<<(k&1)<<"\n";
    k/=2;
    q--;
  }

  using I = __int128;
  I N=n,Q=q,K=k,D=d;

  I X=((D+0)*(I(1)<<Q)-K+N-1)/N;
  I Y=((D+1)*(I(1)<<Q)-K+N-1)/N;

  if(X==Y){
    cout<<-1<<endl;
    return 0;
  }

  for(int i=0;i<q;i++){
    int b=int((X>>i)&1)^(k&1);
    k/=2;
    k+=(n/2)*int((X>>i)&1);
    cout<<b<<"\n";
  }
  assert(k==d);
  
  cout<<flush;
  return 0;
}



Measured memory_bytes: 3216
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

int main(void) {
    int n, a, b;
    cin >> n;
    cin >> a;
    cin >> b;
    cout << (n*a < b ? n*a : b) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
     
     
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		char[][] map = new char[m][];
		for(int i = 0; i < m; i++ ) {
			map[i] = sc.next().toCharArray();
		}
		int[][] Map = new int[m][n];
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < n; j++) {
				if(map[i][j] == 'O') {
					Map[i][j] = 1;
				}
				else if(map[i][j] == 'I') {
					Map[i][j] = 2;
				}
			}
		}
		String A = sc.next();
		String B = sc.next();
		char AA1 = A.charAt(0);
		char AA2 = A.charAt(1);
		char BB1 = B.charAt(0);
		char BB2 = B.charAt(1);
		int A1 = 0;
		int A2 = 0;
		int B1 = 0;
		int B2 = 0;
		if(AA1 == 'O') {
			A1 = 1;
		}
		else if(AA1 == 'I') {
			A1 = 2;
		}
		if(AA2 == 'O') {
			A2 = 1;
		}
		else if(AA2 == 'I') {
			A2 = 2;
		}
		if(BB1 == 'O') {
			B1 = 1;
		}
		else if(BB1 == 'I') {
			B1 = 2;
		}
		if(BB2 == 'O') {
			B2 = 1;
		}
		else if(BB2 == 'I') {
			B2 = 2;
		}
		
		int ck = 0;
		int[][][] count = new int[m][n][3];
		for(int i = 0; i < m-1; i++) {
			for(int j = 0; j < n-1; j++) {
				int a1 = Map[i][j];
				int a2 = Map[i][j+1];
				int b1 = Map[i+1][j];
				int b2 = Map[i+1][j+1];
				int cunt = 0;
				if(a1 == A1) cunt++;
				if(a2 == A2) cunt++;
				if(b1 == B1) cunt++;
				if(b2 == B2) cunt++;
				if(cunt == 4) {
					for(int k = 0; k < 3; k++) {
						count[i][j][k]--;
						count[i][j+1][k]--;
						count[i+1][j][k]--;
						count[i+1][j+1][k]--;
					}
					count[i][j][a1]++;
					count[i][j+1][a2]++;
					count[i+1][j][b1]++;
					count[i+1][j+1][b2]++;
					ck++;
				}
				else if(cunt == 3) {
					if(a1 != A1) {
						count[i][j][A1]++;
					}
					else if(a2 != A2) {
						count[i][j+1][A2]++;
					}
					else if(b1 != B1) {
						count[i+1][j][B1]++;
					}
					else {
						count[i+1][j+1][B2]++;
					}
				}
			}
		}
		int max = 0;
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < n; j++) {
				for(int k = 0; k < 3; k++) {
				max = Math.max(count[i][j][k], max);
				}
			}
		}
		System.out.println(ck + max);
		
		
	}
}

Measured memory_bytes: 91296
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define MOD (1000000007ll)
#define l_ength size

int N,ans[555][555],t[555][555];

int solve(int x, int y){
	if(x > N || y == 0){
		return 0;
	}else if(ans[x][y] < 0){
		ans[x][y] = solve(x,y-1) + solve(x+1,y) - solve(x+1,y-1) + t[x][y];
	}
	return ans[x][y];
}

int main(void){
	int M,Q,i,l,r,p,q;
	fill(t[0],t[555],0);
	fill(ans[0],ans[555],-1);
	cin >> N >> M >> Q;
	for(i=0; i<M; ++i){
		cin >> l >> r;
		++t[l][r];
	}
	for(i=0; i<Q; ++i){
		cin >> p >> q;
		cout << (solve(p,q)) << endl;
	}
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;


int main() {
	int X;
	cin >> X;
	for (int i = X;; ++i) {
		if (i < 2) continue;
		else if (i == 2) {
			cout << i << endl;
			return 0;
		}
		else if (i % 2 == 0) continue;

		double sqrtNum = sqrt(i);
		bool x = false;
		for (int j = 3; j <= sqrtNum; j += 2)
		{
			if (i % j == 0)
			{
				x = true;
				break;
			}
		}
		if (x) {
			continue;
		}
		cout << i << endl;
		return 0;
	}
}

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


//unionfind
//init: union_find name(size)

class union_find{
private:
    //根にはグループの要素数に-1をかけたもの、それ以外には根の値
    //初期値は-1
    vector<int> uni;
public:
    //Constructer
    //uniを必要なサイズで初期化する、初期値は―1
    union_find(int unisize) : uni(unisize,-1){}

    //引数aの根を求める、なければaを根として返す
    int root(int a){
        if(uni[a] < 0) return a;
        return uni[a] = root(uni[a]);  
    }

    //頂点aとbを繋ぐ関数unite
    //戻り値：
    //  元々同じグループであればfalse
    //  連結に成功すればtrue
    bool unite(int a, int b){
        //a, bにそれぞれが属するグループの根を入れる
        //uni[a], uni[b]がa, bがそれぞれが属するグループのサイズになる
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a,b); //bの方を大きいものにする
        uni[a] += uni[b];
        uni[b] = a; //大きい方のグループに属するものの親を小さいものの根にする(rootが高速で動くようになる)
        return true;
    }
    //頂点aとbが同じグループかを調べる
    bool isConnected(int a, int b){
        return root(a) == root(b);
    }
    //頂点aを含むグループの頂点数を調べる
    int unisize(int a){
        return -uni[root(a)];
    }
    //グループ数を調べる
    int group_num(void){
        int num = 0;
        int s = uni.size();
        for(int i = 0; i < s; i++) if(uni[i] < 0) num++;
        return num;
    }
};

int main(){
    int n,m; cin >> n >> m;
    vector<int> p(n); rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    union_find u(n);
    int x,y;
    rep(i,m){
        cin >> x >> y;
        x--; y--;
        u.unite(x, y);
    }
    int ans = 0;
    rep(i,n){
        if(p[i] == i) ans++;
        else if(u.isConnected(i,p[i])) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,K,x;cin>>N>>K;
  int ans=0;
  REP(i,0,N){
    cin>>x;
    ans+=2*min(abs(x),abs(K-x));
  }
  print(ans);

}


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

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define is insert
#define er erase

using namespace std;

const int MAX_N = 1e5 + 1;
const ll MAX_LOG = 63;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(TASK".in", "r", stdin);
        //freopen(TASK".out", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

int n;
int k;

ll ans;

ll a[MAX_N];

vector<ll> sums;

bool getBit(ll x, ll ind)
{
    return ((x >> ind) & 1ll) == 1ll;
}

int solve()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i)
    {
        ll sum = 0;
        for (int j = i; j <= n; ++j)
        {
            sum += a[j];
            sums.pb(sum);
        }
    }
    for (ll i = MAX_LOG; i >= 0; --i)
    {
        ll cnt = 0;
        for (ll it : sums)
        {
            if (getBit(it, i))
            {
                cnt++;
            }
        }
        if (cnt >= k)
        {
            vector<ll> cv;
            for (ll it : sums)
            {
                if (getBit(it, i))
                {
                    cv.pb(it);
                }
            }
            sums = cv;
        }
    }
    ans = sums[0];
    for (ll it : sums)
    {
        //cerr << it << endl;
        ans = ans & it;
    }
    cout << ans;
    return 0;
}




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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll MAX_N = 1e12;
  ll n, p;
  cin >> n >> p;

  map<ll, ll> prime;
  set<ll> s;
  ll now = p;
  for(ll i = 2; i <= sqrt(p); i++){
    while(now % i == 0){
      prime[i] += 1;
      s.insert(i);
      now /= i;
    }

  }

  prime[now] += 1;
  s.insert(now);

  ll ans = 1;
  auto it = s.begin();
  while(it != s.end()){
    ll num = *it;
    ans *= pow(num, prime[num]/n);
    it++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int i,j;
        String str;
        int h,w;
        while((h=scan.nextInt())!=0){
            w=scan.nextInt();
            for(i=0;i<h;i++){
                if(i%2==0){
                    for(j=0;j<w;j++){
                        if(j%2==0)System.out.printf("#");
                        else System.out.printf(".");
                    }
                }else{
                    for(j=0;j<w;j++){
                        if(j%2==0)System.out.printf(".");
                        else System.out.printf("#");
                    }
                }
                System.out.printf("\n");
            }
            System.out.println();
        }
   }
}


Measured memory_bytes: 60140
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N,R=0,flg=0;
	cin >> N;
	vector<int> L(N);
	for (int i=0; i<N; i++){
		cin >> L.at(i);
	}
	sort(L.begin(),L.end());

	for (int i=0; i<N-2; i++){
		for (int j=i+1; j<N-1; j++){
			flg = 0;
			for (int k=j+1; k<N; k++){
				if (L.at(k) < L.at(i) + L.at(j)){
					R++;
				}
				else {
				flg = 1;
				}
				if ((flg == 1) && (k != N-1)){
					if (L.at(k) != L.at(k+1)){
						break;
					}
				}
			}
		}
	}
	
	cout << R << endl;	
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N;
int ok(int num) {
   int cnt = 0;
   for (int i = 1; i <= N; i++) {
      if (num % i == 0) cnt++;
   }
   return cnt;
}

int main() {
   cin >> N;
   int cnt = 0;
   for (int i = 1; i <= N; i++) {
      if (ok(i) == 8 && (i&1)) {
         cnt++;
      }
   }
   cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
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; }
const int INF = 1001001000;
const int MOD = 1000000007;
bool E[2005][2005];
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int main() {
    long long L,R;cin >> L >> R;
    long long ans = 114514;
    if(R-L > 2019){
        cout << 0 << endl;
        return 0;
    }
    else {
        for(long long i = L;i<=R;i++){
            for(long long j = L;j<=R;j++){
                if(i >= j) continue;
                ans = min(ans,(i*j)%2019);
            }
        }
    }
    cout << ans << endl;
    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N;
    while(cin >> N){
        string S; cin >> S;
        int pos = -1;
        int res = 0;
        while(true){
            pos = S.find("ABC", pos+1);
            if(pos == string::npos) break;
            ++res;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define MAXN 1000100
#define ll long long
#define inf 1000000000
int n, m, sum, a[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d",&a[i]), sum += a[i];
	if(sum > n) printf("-1\n");
	else printf("%d\n",n-sum);
	
	return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long long Int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (1000000000+7)
int main() {
    int n, m; cin >> n >> m;
    if (abs(n-m) >= 2) {
        cout << 0 << endl;
        return 0;
    }
    Int np = n, mp = m;
    if (n > m) {
        np = m;
        mp = n;
    }
    Int npp = np, mpp;
    np--;
    while (np >= 1) {
        npp = (Int)(((npp%MOD) * (np%MOD)) %MOD);
        np--;
    }
    //cout << npp << endl;
    if (n == m) {
        cout << (Int)(((Int)((npp % MOD) * (npp % MOD)) * 2) % MOD) << endl;
    }
    else {
        mpp = (Int)(((Int)(npp % MOD) * (mp % MOD)) % MOD);
        cout << (Int)((Int)(npp % MOD) * (mpp % MOD) % MOD) << endl;
    }
}


Measured memory_bytes: 3524
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include<iostream>
using namespace std;
int main(void)
{
    int n,k;
    string s;
    scanf("%d %d",&n,&k);
    cin>>s;
    s[k-1]+=32;
    cout<<s<<endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for ( int i=0; i<n; i++ ) {
		cin >> v[i];
		v[i]--;
	}
	int ans=0;
	for ( int i=0; i<n; i++ ) {
		if ( v[i]==i ) {
			if ( i<n-1 ) 
			{
				swap(v[i],v[i+1]);
			}
			ans++;
		}
	}
	cout << ans << '\n';
	return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    scanf("%d",&n);
    vector<int> a(n,0);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    map<int,ll> m;
    ll res=0;
    for(int i=0;i<n;i++)
    {
        if(m.find(a[i]-i)!=m.end()) res+=m[a[i]-i];
        m[-a[i]-i]++;
    }
    printf("%lld\n",res);
    return 0;
}


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

int pot(int a, int b) {
    int ans = 1;
    for(int i = 0; i < b; i++) {
        ans *= a;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    int d, n;
    cin >> d >> n;
    if(n == 100) {
        cout << pot(100, d + 1) + pot(100, d) << endl;
    }
    else {
        cout << n * pot(100, d) << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
 
  // 入力文字を全連結
  string allIn;
  for (int i = 0; i < h; i++) {
    string in;
    cin >> in;
    allIn = allIn + in;
  } 
  //cout << allIn << endl;
  
  // マス数
  int S = allIn.size();
  
  // .のマスに対して周囲の#数を算出して置換
  for (int i = 0; i < S; i++) {
    //cout << i << "回目" << endl;
    char mat = allIn.at(i);
    if (mat != '.') {
      continue;
    }
    //#数
    int j = 0;
    // 周囲の文字変数
    char leftupper = 'X';
    char middleupper = 'X';
    char rightupper = 'X';
    char left = 'X';
    char right = 'X';
    char leftlower = 'X';
    char middlelower = 'X';
    char rightlower = 'X';
    // 文字取得
    //cout << "upper" << endl;
    if (i >= w) {
      middleupper = allIn.at(i-w);
      if (w != 1) {
        if ((i+1)%w != 1) { 
          leftupper = allIn.at(i-w-1);
        }
        if ((i+1)%w != 0) { 
          rightupper = allIn.at(i-w+1);
        }
      }
    }
    //cout << "middle" << endl;
    if (w != 1) {
      if ((i+1)%w != 1) { 
        left = allIn.at(i-1);
      }
      if ((i+1)%w != 0) { 
        right = allIn.at(i+1);
      }
    }
    //cout << "lower" << endl;
    if (i < w*(h-1)) {
      middlelower = allIn.at(i+w);
      if (w != 1) {
        if ((i+1)%w != 1) {
          leftlower = allIn.at(i+w-1);
        }
        if ((i+1)%w != 0) { 
          rightlower = allIn.at(i+w+1);
        }
      }
    }
    //cout << leftupper << middleupper << rightupper << left << right << leftlower << middlelower << rightlower << endl;
    if (leftupper == '#') {
      j += 1;
    }
    if (middleupper == '#') {
      j += 1;
    }
    if (rightupper == '#') {
      j += 1;
    }
    if (left == '#') {
      j += 1;
    }
    if (right == '#') {
      j += 1;
    }
    if (leftlower == '#') {
      j += 1;
    }
    if (middlelower == '#') {
      j += 1;
    }
    if (rightlower == '#') {
      j += 1;
    }
    char c = 'Z';
    if (j == 0) {
      c = '0';
    }
    if (j == 1) {
      c = '1';
    }
    if (j == 2) {
      c = '2';
    }
    if (j == 3) {
      c = '3';
    }
    if (j == 4) {
      c = '4';
    }
    if (j == 5) {
      c = '5';
    }
    if (j == 6) {
      c = '6';
    }
    if (j == 7) {
      c = '7';
    }
    if (j == 8) {
      c = '8';
    }
    // 代入
    allIn.at(i) = c;  
  }
  // 出力
  for (int i = 0; i < S; i++) {
    cout << allIn.at(i);
    if ((i+1)%w == 0) {
      cout << endl;
    }
  }
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B)
    cout << C << endl;
  else if(B==C)
    cout << A << endl;
  else
    cout << B << endl;
}

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

class Point {
    int x;
    int y;

    Point( int y, int x ) {
	this.y = y;
	this.x = x;
    }
}

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	while ( true ) {
	    final int height = stdin.nextInt();
	    final int width = stdin.nextInt();
	    stdin.nextLine();
	    if ( width == 0 && height == 0 ) {
		break;
	    }

	    char[][] map = new char[height][];
	    for ( int c = 0; c < height; c++ ) {
		map[c] = stdin.nextLine().toCharArray();
	    }

	    boolean[][] visited = new boolean[height][width];

	    int count = 0;
	    for ( int c = 0; c < height; c++ ) {
		for ( int r = 0; r < width; r++ ) {
		    if ( !visited[c][r] ) {
			dfs( visited, map, c, r );
			count++;
		    }				  
		}
	    }
	    System.out.println( count );
	}
	
    }

    static final int[] dx = { 1, 0, -1, 0 };
    static final int[] dy = { 0, -1, 0, 1 };
    
    static void dfs ( boolean[][] visited, char[][] map, int y, int x ) {
	final Stack<Point> stack = new Stack<Point>();
	stack.push( new Point( y, x ) );
	
	while ( !stack.isEmpty() ) {
	    final Point p = stack.pop();
	    visited[p.y][p.x] = true;
	    for ( int i = 0; i < dx.length; i++ ) {
		final int ny = p.y + dy[i];
		final int nx = p.x + dx[i];
		
		if ( 0 <= ny && ny < visited.length && 0 <= nx && nx < visited[0].length && 
		     !visited[ny][nx] && map[p.y][p.x] == map[ny][nx] ) {
		    stack.push( new Point(ny, nx) );
		}	    
	    }
	}	
    }    
}

Measured memory_bytes: 24712
import math
for _ in range(int(input())):
  x1,y1,x2,y2,x3,y3=map(float,input().split())
  a,b,c=2*(x2-x1),2*(y2-y1),x1**2-x2**2+y1**2-y2**2
  aa,bb,cc=2*(x3-x1),2*(y3-y1),x1**2-x3**2+y1**2-y3**2
  x,y=(b*cc-bb*c)/(a*bb-aa*b),(c*aa-cc*a)/(a*bb-aa*b)
  print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))


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

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

    string t;
    bool isTrue = false;
    for (int l = 0; l < s.length() / 2; ++l)
    {
        t += s.at(l);
        if (t + t == s)
        {
            isTrue = true;
            cout << "Yes" << endl;
            break;
        }
    }
    if (!isTrue)
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String args[]){
    Scanner nine = new Scanner(System.in);
    int number1 = nine.nextInt();
    int number2 = nine.nextInt();

    if(1<=number1 && number1<=9 && 1<=number2 && number2<=9){
      int answer = number1*number2;
      System.out.println(answer);
    }else{
      System.out.println("-1");
    }
  }
}


Measured memory_bytes: 22740