akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  for (LL s = 1; s * (s - 1) / 2 <= n; ++s) {
    if (s * (s - 1) == 2 * n) {
      cout << "Yes\n";
      cout << s << '\n';
      vector<vector<int>> g(s);
      for (int i = 0, it = 0; i < s; ++i) {
        for (int j = 0; j < i; ++j)
          g[i].push_back(it), g[j].push_back(it++);
      }
      for (int i = 0; i < s; ++i)  {
        cout << g[i].size() << ' ';
        for (int j = 0; j < g[i].size(); ++j) 
          cout << g[i][j] + 1 << " \n"[j == g[i].size() - 1];
      }
      exit(0);
    }
  }
  cout << "No\n";
}


Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var x = int.Parse(Console.ReadLine());
    var amari = x % 500;
    var gohyaku = (x-amari)/500;
    var goenn = (x-(gohyaku*500))%5;
    var goennsuu = (x-(gohyaku*500)-goenn)/5;
    var kotae = gohyaku*1000+goennsuu*5;
    Console.WriteLine(kotae);
    
  
      
  }
}

Measured memory_bytes: 13140
using System;

namespace Character
{
    class Counting_Characters
    {
        static void Main(string[] args)
        {
            var line = "";
            var count = new int[26];
            while ((line = Console.ReadLine()) != null )
            {
                var array =line.ToLower();
                for (int i = 0; i < array.Length; i++)
                    if (char.IsLetter(array[i]))
                        if (char.IsLower(array[i])) count[array[i] - 97]++;
            }
            for (int i = 0; i < 26; i++)
                Console.WriteLine((char)(i + 97) + " : " + count[i]);
        }
    }
}

Measured memory_bytes: 9232
#include<iostream>
#define REP(i,a) for(int i=0;i<(a);i++)
using namespace std;
int main(){
  int a,n,total=0;
  cin>>a;
  REP(i,a){
    cin>>n;
    total+=(n-1);
  }
  cout<<total<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7




def warshall_floyd(graph):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if graph[i][j] > graph[i][k] + graph[k][j]:
                    return 1




n = I()
graph = [[INF] * n for _ in range(n)]
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(n):
    edges = LI()
    for j in range(n):
        graph[i][j] = edges[j]
        graph[j][i] = edges[j]



if warshall_floyd(graph):
    print(-1)
else:
    ret = 0
    for i in range(n):
        for j in range(i + 1, n):
            if i == j:
                continue
            for k in range(n):
                if k != i and k != j and graph[i][k] + graph[k][j] == graph[i][j]:
                        break
            else:
                ret += graph[i][j]
    print(ret)

Measured memory_bytes: 50652
ABC = list(map(int, input().split()))
odds = [x for x in ABC if x % 2]
evens = [x for x in ABC if x % 2 == 0]

ans = 0
if len(odds) == 2:
    odds[0] += 1
    odds[1] += 1
    ans += 1
elif len(evens) == 2:
    evens[0] += 1
    evens[1] += 1
    ans += 1
ABC = sorted(odds + evens)
ans += (ABC[2] - ABC[0]) // 2 + (ABC[2] - ABC[1]) // 2
print(ans)


Measured memory_bytes: 9124
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int max =0;
		for(int i = 0; i < n; i++){
			x[i] = sc.nextInt();
			if(i !=0 && max < x[i]){
				max = x[i];
			}
		}
		int res = 0;
		int min = 0;

		for(int i = 1; i <= max; i++){
			int tmp = 0;
			for(int j = 0; j < x.length; j++){
				tmp += (i - x[j]) * (i - x[j]);
			}
			if(i == 1){
				min = tmp;
			}else if(min > tmp){
				min = tmp;
			}
		}
		System.out.println(min);

	}


}

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

using namespace std;

int knapsack[105][100005];
int weights[105];
int values[105];


int main(){
	int num_items ,total_weight;
	cin >> num_items >> total_weight;
	int sum_values = 0;
	for(int i=1;i<=num_items;i++){
		cin >> weights[i] >> values[i];
		sum_values+=values[i];
	}
	int ans = 0;
	// initialize dp table
	for(int item=0;item<=num_items;item++){
		for (int value=1;value<=sum_values;value++)
			knapsack[item][value] = 1e9+7;
	}
	for(int value=1; value<=sum_values; value++){
		for(int item=1; item<=num_items;item++){
			if(value < values[item])
				knapsack[item][value] = knapsack[item-1][value];
			else{
				knapsack[item][value] = min(knapsack[item-1][value],
										knapsack[item-1][value-values[item]]+weights[item]);
			}

		}
		if(knapsack[num_items][value]<=total_weight){
			ans=value;
		}
	}
	cout << ans;
}

Measured memory_bytes: 41216
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, m;
	cin >> n >> m;
	ll maxL = 0, minR = LINF;
	rep(i, m){
		ll l, r;
		cin >> l >> r;
		maxL = max(maxL, l);
		minR = min(minR, r);
	}
	co(max(0LL, minR-maxL+1));

	return 0;
}


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

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

    if (n % 2 == 0) {
        string former = s.substr(0, n / 2);
        string latter = s.substr(n / 2, n - 1);
        if (former == latter) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
F = [[] * 10 for i in range(N)]
for i in range(N):
    F[i] = list(map(int, input().split()))
P = [[] * 11 for i in range(N)]
for i in range(N):
    P[i] = list(map(int, input().split()))
L = [0] * 10
Sum_max = -float("inf")
for i in range(1, 1024):
    for j in range(10):
        L[j] = i % 2
        i = int(i / 2)
    Sum = 0
    for j in range(N):
        count = 0
        for k in range(10):
            if L[k] == 1 and F[j][k] == 1:
                count += 1
        Sum += P[j][count]
    Sum_max = max(Sum_max, Sum)
print(Sum_max)


Measured memory_bytes: 3064
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vector<pair<ll, ll>> v(N);
    REP(i, N) {
        ll a, b; cin >> a >> b;
        v[i] = {b, a};
    }

    sort(ALL(v));

    ll s = 0;
    REP(i, N) {
        s += v[i].se;
        if (s > v[i].fi) {
            print("No");
            return 0;
        }
    }

    print("Yes");
    
}


Measured memory_bytes: 6356
n = int(input())
As = list(map(int, input().split()))

as1 = [-(a+i) for i,a in enumerate(As)]
as2 = [a-i for i,a in enumerate(As)]

from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)
cnt = 0

for a1,a2 in zip(as1,as2):
    d1[a1] += 1
    d2[a2] += 1
# print(d1,d2)

for k in d1.keys():
    cnt += d1[k]*d2[k]
print(cnt)



Measured memory_bytes: 169488
package main

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

func find(parent []int, i int) int {
	if parent[i] == -1 {
		return i
	}
	parent[i] = find(parent, parent[i])
	return parent[i]
}

func unite(parent []int, i, j int) {
	i = find(parent, i)
	j = find(parent, j)
	if i == j {
		return
	}
	parent[i] = j
}

func readLinks(n, k int) [][]int {
	links := make([][]int, n)
	return links
}

func main() {
	n := readInt()
	k := readInt()
	l := readInt()

	roads := make([]int, n)
	rails := make([]int, n)
	for i := 0; i < n; i++ {
		roads[i] = -1
		rails[i] = -1
	}

	for i := 0; i < k; i++ {
		p := readInt()
		q := readInt()
		unite(roads, p-1, q-1)
	}

	for i := 0; i < l; i++ {
		p := readInt()
		q := readInt()
		unite(rails, p-1, q-1)
	}

	d := map[int]int{}
	result := make([]int, n)
	for i := 0; i < n; i++ {
		t := 2000001*find(roads, i) + find(rails, i)
		if _, ok := d[t]; ok {
			d[t] += 1
		} else {
			d[t] = 1
		}
	}

	for i := 0; i < n; i++ {
		result[i] = d[2000001*find(roads, i)+find(rails, i)]
	}

	printIntln(result...)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func printIntln(v ...int) {
	b := make([]byte, 0, 4096)
	for i := 0; i < len(v)-1; i++ {
		b = append(b, strconv.Itoa(v[i])...)
		b = append(b, " "...)
	}
	b = append(b, strconv.Itoa(v[len(v)-1])...)
	fmt.Println(string(b))
}


Measured memory_bytes: 20480
#include<iostream>
using namespace std;
int main()
{
   char a;
   cin>>a;
   if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
   {
       cout<<"vowel"<<endl;
   }
   else
   {
       cout<<"consonant"<<endl;
   }

    return 0;
}


Measured memory_bytes: 3036
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = zeros(Int,n+1)
	for i in 1:n
		b[i+1] = b[i]+a[i]
	end
	d = Dict{Int,Int}()
	ans = 0
	for i in n:-1:0
		if haskey(d,b[i+1])
			ans += d[b[i+1]]
			d[b[i+1]]+=1
		else
			d[b[i+1]] = 1
		end
	end
	println(ans)
end

main()

Measured memory_bytes: 140408
paths = []
for i in range(0, 3):
    a, b = [int(i) for i in input().split()]
    paths.append(a)
    paths.append(b)

if set(paths) != set([1, 2, 3, 4]):
    print("NO")
elif paths.count(1) >= 3 or paths.count(2) >= 3 or paths.count(3) >= 3 or paths.count(4) >= 3:
    print("NO")
else:
    print("YES")


    


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    ll la = 2, ra = 2;
    int k;
    cin >> k;
    vector<ll> v(k);
    for (auto &&i : v) scanf("%lld", &i);
    for (int i = k-1; i >= 0; --i) {
        ll q = ra/v[i]*v[i], p = (la+v[i]-1)/v[i]*v[i];
        if((p < la || ra < p)&&(q < la || ra < q)){
            puts("-1");
            return 0;
        }
        la = p, ra = q+v[i]-1;
    }
    cout << la << " " << ra << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
	int a, b, c;
	while(scanf("%d %d %d", &a, &b, &c))
	{
		if(a == -1 && b == -1 && c == -1)
		{
			break;
		}
		if((a == -1 || b == -1) && c == -1)
		{
			printf("F\n");
		}
		else
		{
			int sum = 0, k = 0;
			if(a >= 0)
			{
				sum += a; 
			}
			if(b >= 0)
			{
				sum += b;
			}	
			if(sum >= 80)
			{
				printf("A\n");
			}
			else if(sum >= 65 && sum < 80)
			{
				printf("B\n");
			}
			else if((sum >= 50 && sum < 65) || c >= 50)
			{
				printf("C\n");
			}
			else if(sum >= 30 && sum < 50)
			{
				printf("D\n");
			}
			else
			{
				printf("F\n");
			}
		}
	}
	return 0;
} 


Measured memory_bytes: 2592
#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	K, N;
	cin >> K >> N;
	vector<int>	temp(N);
	rep(i, N)
		cin >> temp.at(i);
	vector<int> vec(N);
	for (int i = 1; i < N; i++)
		vec.at(i) = temp.at(i) - temp.at(i - 1);
	vec.at(0) = K - temp.at(N - 1) + temp.at(0);
	cout << K - *max_element(vec.begin(), vec.end()) << endl;

}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**9)


N = int(input())
to = [[] for _ in range(N)]

for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = u - 1, v - 1
    to[u].append([v, w])
    to[v].append([u, w])


def dfs(v, color):
    for nv, w in to[v]:
        if color[nv] == -1:
            if w % 2:
                color[nv] = color[v] ^ 1
            else:
                color[nv] = color[v]
            dfs(nv, color)


def main():
    color = [-1] * N
    color[0] = 0
    dfs(0, color)
    print(*color, sep='\n')


if __name__ == "__main__":
    main()

Measured memory_bytes: 84400
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class DInsertion {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N;
    string S;
    cin >> N >> S;
    int before = 0;
    int after  = 0;
    rep(i, N) {
      if (S[i] == ')') {
        before++;
        if (after) {
          before--;
          after--;
        }
      } else {
        after++;
      }
    }
    cout << string(before, '(') + S + string(after, ')') << endl;
  }
};


signed main() {
  DInsertion solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;


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

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int a, b, c, d, n, ans;
int ar[234567];
string s;
bool b1, b2;
signed main() {
	cout << "square1001" << endl;
}


Measured memory_bytes: 3112
#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 rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int h,w;
vector<string>board;

ll solve(){
    vector<vector<ll>>dp(h, vector<ll>(w,inf));
    if(board[0][0]=='#')dp[0][0]=1;
    else dp[0][0]=0;
    rep(i, 0, h){
        rep(j, 0, w){
            rep(k, 0, 2){
                int nx = i + dx[k];
                int ny = j + dy[k];
                if(nx>=h||ny>=w)continue;
                int add = 0;
                if(board[nx][ny]=='#' && board[i][j]=='.')add++;
                chmin(dp[nx][ny], dp[i][j]+add);
            }
        }
    }
    return dp[h-1][w-1];
}
int main() {
    cin >> h >> w;
    board.resize(h);
    rep(i, 0, h)cin >> board[i];
    cout << solve() << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const int MOD = 1e9+7;
vi alphabet = {'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'};

int main() {
	int N,M;
  	cin >> N >>M;
  	int a = 1800*M+100*N;
  	ll ans = a*pow(2,M);
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char st[1000005];
int f[1000005], nxt[1000005], haa[1000005], ha[1000005];
int main() {
	scanf("%s", st + 1);
	int n = strlen(st + 1);
	for(int i = 0; i < 26; i ++) nxt[i] = 1000000;
	f[n + 1] = 1;
	for(int i = n; i >= 1; i --) {
		nxt[st[i] - 'a'] = i;
		for(int j = 0; j < 26; j ++) {
			if(f[i] == 0 || f[i] > f[nxt[j] + 1] + 1) f[i] = f[nxt[j] + 1] + 1, ha[i] = j, haa[i] = nxt[j] + 1;
		}
	}	
	int now = 1;
	while(now <= n) {
		printf("%c", char(ha[now] + 'a'));
		now = haa[now];
	}
	return 0;
}

Measured memory_bytes: 13312
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	vector<int> a(3); cin>>a[0]>>a[1]>>a[2];
	sort(a.begin(), a.end());
	cout<<a[0]*a[1]/2;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
	int N;
	cin >> N ;
	vector<int> x,y;
	for(int i =0;i<N;i++){
		int a,b;
		cin >> a >>b;
		x.push_back(a);
		y.push_back(b);
	}
 
 
 
	vector<int> dx,dy;
	for(int i = 0;i < N;i++){
		for(int j = 1;j < N-i; j++){
			dx.push_back(x[i]-x[i+j]);
			dy.push_back(y[i]-y[i+j]);
		}
	}
	int count=0;
	int ans=0;
	for(int i = 0; i < dx.size();i++){
		int a=0;
		for(int j = 1; j < dx.size()-i;j++){
			if(dx[i]==dx[i+j] && dy[i]==dy[i+j])a++;
			else if(dx[i]==-dx[i+j] && dy[i]==-dy[i+j])a++;
		}
		if(a > count) count = a;
	}
	
	if(N ==1)ans =1;
	else ans = N-count-1;
	cout << ans;
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
	int n,m,x,y;
	veci nx,ny;
	string ans = "No War";
	cin >> n >> m >> x >> y;
	REP(i,n){
		int tmp;
		cin >> tmp;
		nx.pb(tmp);
	}
	REP(i,m){
		int tmp;
		cin >> tmp;
		ny.pb(tmp);
	}
	sort(nx.begin(),nx.end());
	sort(ny.begin(),ny.end());
	if(nx.back() >= ny.front() || nx.back() >= y || ny.front() <= x){
		ans = "War";
	}
	cout << ans << endl;
	return 0;
}



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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back
#define PI         2*acos(0)
#define pb         push_back
#define mp         make_pair
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define bs         binary_search
#define For(i,j,k) for(i=j;i<k;i++)
#define FOR(i,j,k) for(i=j;i>=k;i--)
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define sp(x)      cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
int main()
{	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);
  
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0;
    bool flag = false;

	cin >> n;
	string s;
	cin >> s;
	x = n-1,d = 0,cnt = 0;
 
	while(x > d){
		while(d < n && s[d] == 'R') d++;
		while(x >= 0 && s[x] == 'W') x--;
		if(d > x) break;
		cnt++;
		s[d] = 'R',s[x] = 'W';
	}
	
	cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3712
import java.util.*;
public class Main {
	static Data[] data;
	static HashMap<String,Integer> groupName;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if(n == 0) break;
			data = new Data[n];
			groupName = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String[] in = sc.next().split(":|,|\\.");
				data[i] = new Data(in[0]);
				groupName.put(in[0], i);
				for (int j = 1; j < in.length; j++) {
					data[i].list.add(in[j]);
				}
			}
			int max = 0;
			for (int i = 0; i < n; i++) {
				HashMap<String, Boolean> alCount = new HashMap<String, Boolean>();
				int ret = DFS(0, alCount);
				max = Math.max(ret, max);
			}
			System.out.println(max);
		}
	}
	static int DFS(int a, HashMap<String,Boolean> alCount) {
		int ret = 0;
		for(int i = 0; i < data[a].list.size(); i++) {
			if(alCount.containsKey(data[a].list.get(i))) continue;
			alCount.put(data[a].list.get(i), true);
			if(groupName.containsKey(data[a].list.get(i))) ret += DFS(groupName.get(data[a].list.get(i)),alCount);
			else {
				ret++;
			}
		}
		return ret;
	}
	
	static class Data {
		String groupName;
		ArrayList<String> list = new ArrayList<String>();
		Data(String a) {
			groupName = a;
		}
	}
	
}

Measured memory_bytes: 53024
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long 
#define jaldi_chal  ios_base::sync_with_stdio(0); cin.tie(0);
#define tr(c,i) for(auto i=(c).begin(); i != (c).end(); i++)
#define REP(i,k) for( ll i=0;i<k;i++)
#define REW(i,a,b) for(ll i=a;i<=b;i++)
#define M 1000000007
#define F first
#define dbg(x)  cout<<#x<<" " <<x<<endl;
#define S second
#define inf 1e10
#define endl "\n"
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}

int main() {
jaldi_chal
ll k;
cin>>k;

ll sum=0;
for(ll i=1;i<=k;i++)
{
	REW(j,1,k)
	{
		REW(l,1,k)
		{
			sum+=gcd(i,gcd(j,l));
		}
	}
}

cout<<sum;


	return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    //ここだけ見てね！
    public void calc()
    {
        int K, S;
        K = cin.nextInt();
        S = cin.nextInt();
        int ans = 0;
        for (int X = 0; X <= K; X++)
        {
            for (int Y = 0; Y <= K; Y++)
            {
                int Z = S - X - Y;
                if (Z < 0 || Z > K) continue;
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 2648
fun main(args: Array<String>) {
    val (N, A, B) = readLine()!!.split(" ").map { it.toInt() }
    val list = readLine()!!.split("").filterNot { it.isEmpty() }
    val ans = solve(list, A, B)
    ans.forEach {
        println(it)
    }
}

fun solve(s: List<String>, A: Int, B: Int): List<String> {
    val availablePassing = A + B
    var nowPassingNumber = 0
    var foreignNumber = 0

    return s.map {
        if (it == "a") {
            if (nowPassingNumber < availablePassing) {
                nowPassingNumber = nowPassingNumber.plus(1)
                "Yes"
            } else {
                "No"
            }
        } else if (it == "b") {
            if (nowPassingNumber < availablePassing && foreignNumber < B) {
                nowPassingNumber = nowPassingNumber.plus(1)
                foreignNumber = foreignNumber.plus(1)
                "Yes"
            } else {
                foreignNumber = foreignNumber.plus(1)
                "No"
            }
        } else {
            "No"
        }
    }

}

Measured memory_bytes: 54504
p = input().split()
a = int(p[0])
b = int(p[1])

v = input()
s = list(v)

answer = False

for i in range(len(s)):
    q = s[i]
    if i == a:
        if q == '-':
            answer = True
        else:
            answer = False
            break
    else:
        if q == '-':
            answer = False
            break
        else:
            answer = True

if answer:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9140
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <stack> 
#include <set>
#include <map>
using namespace std;

typedef long long ll;
const int INF = 1000000002;
const int mod = 1000000007;

#define N 200010
#define X first
#define Y second

vector<int> lis[N];

int Max[N << 2], tag[N << 2];


void Build(int x, int l, int r)
{
	if (l == r)
	{
		Max[x] = l;
		tag[x] = 0;
		return;
	}
	int mid = (l + r) >> 1;
	Build(x << 1, l, mid);
	Build(x << 1 | 1, mid + 1, r);
	Max[x] = max(Max[x << 1], Max[x << 1 | 1]);
}

void PushDown(int x)
{
	if (tag[x] == 0) return;
	Max[x << 1] += tag[x];
	tag[x << 1] += tag[x];
	Max[x << 1 | 1] += tag[x];
	tag[x << 1 | 1] += tag[x];
	tag[x] = 0;
}


void Modify(int x, int L, int R, int l, int r)
{
	if (r < L || l > R) return;
	if (l <= L && r >= R)
	{
		++tag[x];
		++Max[x];
		return;
	}
	PushDown(x);
	int Mid = (L + R) >> 1;
	Modify(x << 1, L, Mid, l, r);
	Modify(x << 1 | 1, Mid + 1, R, l, r);
	Max[x] = max(Max[x << 1], Max[x << 1 | 1]);
}


int Query(int x, int L, int R, int l, int r)
{
	//cout << L << " " << R << " " << l << " " << r << " " << Max[x] << endl;
	if (r < L || l > R) return -INF;
	if (l <= L && r >= R) return Max[x];

	PushDown(x);
	int Mid = (L + R) >> 1;
	return max(Query(x << 1, L, Mid, l, r), Query(x << 1 | 1, Mid + 1, R, l, r));
}


int main()
{
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);

	int n, m, x, y, ans;
	scanf("%d %d", &n, &m);
	ans = max(0, n - m);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d %d", &x, &y);
		lis[x].push_back(y);
	}
	Build(1, 0, m + 1);
	for (int i = 0; i <= m; ++i)
	{
		for (int j = 0; j < lis[i].size(); ++j) Modify(1, 0, m + 1, 0, lis[i][j]);
		//cout << i << " " << Query(1, 0, m + 1, i + 1, m + 1) << endl;
		ans = max(ans, Query(1, 0, m + 1, i + 1, m + 1) - i - m - 1);
	}
	//cout << Query(1, 0, m + 1, 4, 4) << endl;
	printf("%d\n", ans);

	return 0;
}



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

using namespace std;

int main(void)
{
    string s;
    cin >> s;
    int kind = 0;
    vector<pair<char, int>> list;
    for (int i = 0; i < s.size(); ++i)
    {
        bool is_registered = false;
        for (int j = 0; j < list.size(); ++j)
        {
            if (list[j].first == s[i])
            {
                is_registered = true;
                list[j].second++;
                break;
            }
        }
        if (!is_registered)
        {
            list.push_back(make_pair(s[i], 1));
        }
    }
    if (list.size() == 2 && list[0].second == 2 && list[1].second == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int L,R,d;
  cin>>L>>R>>d;
  int cnt=0;
  for(int i=L ; i<=R ; i++){
    if(i%d==0) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

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

        if (n % 500 <= a) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int N=scanner.nextInt();
		int change= (1000-(N%1000));
		if (N%1000==0) {
			System.out.println("0");
		}else {
			System.out.println(change);
		}
	}
}


Measured memory_bytes: 35572
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin >> a >>b;
  int a1=a-1;
  int b1=b-1;
  if((b1%a1)!=0)
  cout << (b1/a1)+1 << endl;
  else
  cout << b1/a1 << endl;
    return 0;
}


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

int n,k,ans=0;


int main(){
    string s;
    cin>>s;
    if(s=="Sunny")cout<<"Cloudy"<<endl;
    if(s=="Cloudy")cout<<"Rainy"<<endl;
    if(s=="Rainy")cout<<"Sunny";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
const long long mod = 1000000007;
const long long INF = mod*mod;
int ansi = 1;
int solve()
{
	ll n,m;
	cin>>n>>m;
	ll arr[n];
	ll sum = 0;
	rep(i,n)
	{
		cin>>arr[i];
		sum+=arr[i];
		//
	}
	//cout<<sum<<endl;
	ll count = 0;
	sum = ceil((sum)/(4.0*m));
	//cout<<sum<<endl;
	rep(i,n)
	{
		//cout<<arr[i]<<endl;
		if(arr[i] >= sum)
		count++;
	}
	if(count>=m)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #else
	// #endif
	solve();
	// #ifndef ONLINE_JUDGE
	// cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
	// #endif
	return 0;
}

Measured memory_bytes: 256
N = int(input())
num_list = [int(input()) for _ in range(N)]
# print(num_list)

# i < j
max_val = -(10**9 + 1)
min_num = num_list[0]
for j, num in enumerate(num_list[1:N]):
    # print(f"num: {num}")
    max_val = max(max_val, num - min_num) 
    min_num = min(min_num, num)

print(max_val)


Measured memory_bytes: 15096
import Control.Applicative
import Data.Function
import Control.Monad

type Building = [[Int]]

initBuildings :: [Building]
initBuildings = replicate 4 $ replicate 3 $ replicate 10 0

update :: Int -> Int -> Int -> [Int] -> [Int]
update _ _ _ [] = []
update r v i (x:xs) = if i == r
                  then (v + x) : (update r v (i+1) xs)
                  else x : (update r v (i+1) xs)

nextBuilding :: Int -> Int -> Int -> Building -> Building
nextBuilding 1 r v [f1,f2,f3] = [(update r v 1 f1), f2, f3]
nextBuilding 2 r v [f1,f2,f3] = [f1, (update r v 1 f2), f3]
nextBuilding 3 r v [f1,f2,f3] = [f1, f2, (update r v 1 f3)]

next :: Int -> Int -> Int -> Int -> [Building] -> [Building]
next 1 f r v [b1,b2,b3,b4] = [nextBuilding f r v b1, b2, b3, b4]
next 2 f r v [b1,b2,b3,b4] = [b1, nextBuilding f r v b2, b3, b4]
next 3 f r v [b1,b2,b3,b4] = [b1, b2, nextBuilding f r v b3, b4]
next 4 f r v [b1,b2,b3,b4] = [b1, b2, b3, nextBuilding f r v b4]

app :: [[Int]] -> [Building] -> [Building]
app [] bs = bs
app ([b,f,r,v]:xs) bs = app xs $ next b f r v bs

main :: IO ()
main = do
    _ <- getLine
    op <- getContents
    let [b1,b2,b3,b4] = (app (map (map read . words) $ lines op) initBuildings)
    forM_ b1 $ \x -> putStrLn $ " " ++ (unwords $ map show x)
    putStrLn $ replicate 20 '#'
    forM_ b2 $ \x -> putStrLn $ " " ++ (unwords $ map show x)
    putStrLn $ replicate 20 '#'
    forM_ b3 $ \x -> putStrLn $ " " ++ (unwords $ map show x)
    putStrLn $ replicate 20 '#'
    forM_ b4 $ \x -> putStrLn $ " " ++ (unwords $ map show x)


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n;
	cin >> n;
	if (n % 2) {
		cout << "0\n";
		return 0;
	}
	long long ans = 0;
	long long x = 10;
	while (x <= n) {
		ans += n / x;
		x *= 5;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    int b = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            swap(p[i], p[j]);
            int c = 1;
            for (int h = 0; h < n; h++) {
                if (p[h] != h + 1) c = 0;
            }
            if (c) {
                cout << "YES" << endl;
                exit(0);
            }
            swap(p[i], p[j]);
        }
    }
    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};


int main(){
    IOS;
    make2(string,s,t);
    ll n=s.length(); ll m=t.length();
    ll an=-1;
    for(ll i=0;i+m-1<n;i++){
            bool flag=1;
        for(ll j=i;j<i+m;j++){
            if(s[j]==t[j-i] || s[j]=='?'){}
            else flag=0;
        }
        if(flag) an=i;
    }
    if(an==-1) cout<<"UNRESTORABLE \n";
    else{
        for(ll i=an;i<an+m;i++){
            s[i]=t[i-an];
        }
        for(ll i=0;i<n;i++) if(s[i]=='?') s[i]='a';
        cout<<s<<endl;
    }



    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>


int main(void)
{
	int i;
	char a[4],b[4];

	scanf("%s", a);
	scanf("%s", b);

	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0])
		puts("YES");
	else
		puts("NO");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m;

bool can (ll X) {
	ll A = m - (X > n ? 2*(X - n) : 0);
	return A >= 2*X;
}

int main()
{
	scanf("%lld%lld",&n,&m);
	ll S = 0, E = 1e12;
	while(S<E) {
		ll M = (S+E)/2 + 1;
		can(M) ? S = M : E = M-1;
	}
	printf("%lld\n",S);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string mp;
int n,T;
double mem[2001][2001];
bool used[2001][2001];

double dfs(int t,int pos){
  if(t==T)return mem[t][pos]=(mp[pos]=='R');
  if(used[t][pos])return mem[t][pos];
  used[t][pos]=1;

  double res=0;
  for(int i=1;i<=6;i++)res+=dfs(t+1,(pos+i)%n);
  return mem[t][pos]=res/6;
}

int main(){
  while(1){
    cin>>n>>T;
    if(!n&&!T)break;
    cin>>mp;

    memset(used,0,sizeof(used));  
    for(int i=0;i<2001;i++)
      for(int j=0;j<2001;j++) mem[i][j]=0;
    
    
    double ans=0;  
    for(int i=0;i<n;i++) ans=max(ans,dfs(0,i));
    printf("%.10f\n",ans);
  }
  return 0;
}

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

public class Main{



    public static void main(String[] args) {
        FastReader in = new FastReader();
        long a = in.nextLong(), b = in.nextLong(), ans = 0;
        while(a%2 == 1){
            ans^=(a-1);
            a--;
        }
        while((b-a)%4!=3){
            ans^=(b+1);
            b++;
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 22484
use std::io::Read;
use std::io::Write;
use std::io;

// fn sub() -> io::Result<()> {
//     let stdin = io::stdin();
//     let mut line = String::new();
//     stdin.read_line(&mut line)?;
//     let nq: Vec<&str> = line.split(" ").collect();
//     let n: i32 = nq[0].parse::<i32>().unwrap();
//     let q: i32 = nq[1].trim().parse::<i32>().unwrap();
//     let mut s = String::new();
//     stdin.read_line(&mut s)?;
//     for _j in 0..q {
//         let mut line = String::new();
//         stdin.read_line(&mut line)?;
//         if line.len() == 0
//         {
//             break;
//         }
//         let lr: Vec<&str> = line.split(" ").collect();
//         let l: usize = lr[0].parse::<usize>().unwrap() - 1;
//         let r: usize = lr[1].trim().parse::<usize>().unwrap();
//         let s = s.as_bytes();
//         let mut cnt = 0;
//         for i in l..r - 1 {
//             if s[i] == 'A' as u8 && s[i + 1] == 'C' as u8 {
//                 cnt += 1;
//             }
//         }
//         println!("{}", cnt);
//     }
//     Ok(())
// }

fn sub() -> io::Result<()> {
    let stdin = io::stdin();
    let mut line = String::new();
    stdin.read_line(&mut line)?;
    let nq: Vec<&str> = line.split(" ").collect();
    let n: usize = nq[0].parse::<usize>().unwrap();
    let q: usize = nq[1].trim().parse::<usize>().unwrap();
    let mut s = String::new();
    stdin.read_line(&mut s)?;
    let sbytes = s.as_bytes();
    let mut found_count: Vec<i32> = Vec::new();
    found_count.resize(n as usize, 0);
    let mut cnt = 0;
    for i in 0usize..(n - 1) as usize {
        if sbytes[i] == 'A' as u8 && sbytes[i + 1] == 'C' as u8 {
            cnt += 1;
        }
        found_count[i] = cnt;
    }
    found_count[(n - 1) as usize] = cnt;
    for _j in 0..q {
        let mut line = String::new();
        stdin.read_line(&mut line)?;
        if line.len() == 0
        {
            break;
        }
        let lr: Vec<&str> = line.split(" ").collect();
        let l: usize = lr[0].parse::<usize>().unwrap() - 1;
        let r: usize = lr[1].trim().parse::<usize>().unwrap() - 1;
        if r == l {
            println!("0");
        } else {
            if l == 0 {
                println!("{}", found_count[r - 1]);
            } else {
                println!("{}", found_count[r - 1] - found_count[l - 1]);
            }
        }
    }
    Ok(())
}

fn main() {
    sub().unwrap();
}


Measured memory_bytes: 4860
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
 const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


void solve(void){
  
  ll L, R;
  cin >> L >> R;
  
  int ans = 0;
  
  if(L/2019 == R/2019){
    int a = L%2019;
    int b = R%2019;
    if (a>b){swap(a, b);}
    int c=INF;
    for(int i=a; i<b; i++){
      for(int j=i+1; j<=b; j++){
     	 chmin(c, i*j%2019);
      }
    }
    ans=c;
  }

  cout << ans << endl;
  
  
  return;
   
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

if (0 in A):
    print(0)
    exit()

ans = 1
for i in range(N):
    if (ans > 10 ** 18):
        break
    ans *= A[i]

if (ans > 10**18):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 84604
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

int main(){
	int h,w,n;
	cin >> h >> w >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int k[100000]={};
	int x =0;
	for(int i=0;i<n;i++){
		for(int j=0;j<a[i];j++){
			k[x] = i+1;
			x+=1;
		}
	}
	int c[101][101]={};
	int y = 0;
	for(int i=0;i<h;i++){
		if(i%2==0){
			for(int j=0;j<w;j++){
				c[i][j]=k[y];
				y+=1;
			}
		}else{
			for(int j=w-1;j>=0;j--){
				c[i][j]=k[y];
				y+=1;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			cout << c[i][j] << " ";
		}
		cout << c[i][w-1] << endl;
	}

	return 0;
}

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

int main(void){
  int n, k, q; cin >> n >> k >> q;
  vector<int> score(n, 0);
  
  for(int i = 0; i < q; i++){
    int a; cin >> a;
    a = a - 1;
    
    score.at(a) += 1;
  }
  
  for(int i = 0; i < n; i++){
    if(score.at(i) - q + k > 0){
      cout << "Yes " << endl;
    }else{
      cout << "No " << endl;
    }
  }
}




Measured memory_bytes: 1152