akhauriyash/Code-Regression huggingface dataset:
/*
In every question first approach must be basic, atleast give 15 mins for try to solve in basic approach
*/
 #include<iostream>
 #include<cstring>
 #include<string>
 #include<vector>
 #include<utility>
 #include<stdlib.h>
 #include<limits.h>
 #include<cmath>
 #include<set>
 #include<initializer_list>
 #include<unordered_set>
 #include<unordered_map>
 #include<map>
 #include<iomanip>
 #include<algorithm>
 #include<queue>
 #include<stack>
  
 #define sze 1000005
 #define ld long double
 //#define ll unsigned long long
 #define ll long long
 #define endl "\n"
 #define pb push_back
 #define mkp make_pair
 #define mod 1000000007
 #define ff first
 #define ss second
 #define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
 #define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
 #define all(c) (c).begin(),(c).end()
//#define pi = 3.14159265358979323846
  
 using namespace std;
 //const ll inf=1ll<<60;
// cout << fixed << setprecision(6) << pi <<" "<<npi<<endl;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res%mod * a%mod)%mod;
        a = (a%mod * a%mod)%mod;
        b >>= 1;
    }
    return res;
}
//const int N=300005;

 int main()
 {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll n; cin>>n;
     string s1 = "hon" , s2 = "pon", s3 = "bon";
     int hash[15]={0};
     hash[9]=1;
     hash[2] = hash[4] = hash[5] = hash[7] = hash[9];
     hash[8] = 2;
     hash[0] = hash[1] = hash[6] = hash[8];
     hash[3] = 3;
     if(hash[n%10] ==1)
     {
         cout<<s1<<endl;
     }
     else if(hash[n%10]==2)
     {
         cout<<s2<<endl;
     }
     else if(hash[n%10]==3)
     {
         cout<<s3<<endl;
     }
 }


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

int main() {
    int n, x, count = 1;
    long total = 0;
    cin >> n;
    vector<long> a(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[i] = x;
    }
    sort(a.begin(), a.end());
    total += a[n - 1];
    for (int i = n - 2; count < n - 1; i--) {
        count++;
        total += a[i];
        if (count < n - 1) {
            count++;
            total += a[i];
        }
    }
    cout << total;
    return 0;
}

Measured memory_bytes: 4460
import queue

H,W = map(int,input().split())

temp = [[-1 for j in range(W+2)]]
B = temp+[[] for i in range(H)]+temp

dot = 0
for i in range(1,H+1):
    S = input()
    B[i].append(-1)
    for s in S:
        if s==".":
            B[i].append(H*W)
            dot += 1
        else:
            B[i].append(-1)
    B[i].append(-1)
    
Q = queue.Queue()
Q.put((1,1))
B[1][1]=1

min_root = dot
isok = False
while(not Q.empty()):
    y,x = Q.get()
    L = [[y-1,x],[y+1,x],[y,x-1],[y,x+1]]
    move = B[y][x]+1
    for dy,dx in L:
        if move < B[dy][dx]:
            Q.put((dy,dx))
            B[dy][dx] = move
            if dy==H and dx==W: isok=True
    #print(B)

if isok:
    print(dot-B[H][W])
else:
    print(-1)

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAX_N = 307;
int H, W, K;
int color[MAX_N][MAX_N];
int a[MAX_N][MAX_N];
string line;
int c = 1;

void color_abv(int row)
{
	for(int r=row-1;r>=0;--r){
		for(int j=0;j<W;++j){
			if(color[r][j]) return;
			color[r][j] = color[r+1][j];
		}
	}
}

void color_row(int row)
{
	for(int j=0;j<W;++j){
        if(a[row][j]){
            color[row][j]=c;
            for(int k=j-1;k>=0;--k){
                if(a[row][k]) break;
                color[row][k]=c;
            }
            for(int k=j+1;k<W;++k){
                if(a[row][k]) break;
                color[row][k]=c;
            }
            c++;
        }
	}
}

void color_below(int row)
{
	for(int r=row+1;r<H;++r){
		for(int j=0;j<W;++j){
			color[r][j] = color[r-1][j];
		}
	}
}

void solve()
{
	int last = -1;
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j)if(a[i][j]){
			color_row(i);
			color_abv(i);
			last = i;
			break;
		}
	}
	color_below(last);
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			if(!j) cout << color[i][j];
			else cout << " " << color[i][j];
		}
		cout << "\n";
	}
}

int main()
{
	cin >> H >> W >> K;
	getline(cin, line);
	for(int i=0;i<H;++i){
		getline(cin, line);
		for(int j=0;j<W;++j){
			a[i][j]=(line[j]=='#');
		}
	}
	solve();
	return 0;
}

Measured memory_bytes: 1536
n = int(input())
list_a = list(map(int, input().split()))
num_rank = [0 for _ in range(9)]
for one_a in list_a:
  temp_rank = one_a // 400
  if temp_rank > 8:
    temp_rank = 8
  num_rank[temp_rank] += 1
if len([i for i in num_rank[:-1] if i > 0]) > 0:
  min_color = len([i for i in num_rank[:-1] if i > 0])
else:
  min_color = 1
max_color = len([i for i in num_rank[:-1] if i > 0]) + num_rank[-1]
print("{} {}".format(min_color, max_color))

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
using namespace std;
typedef pair<int,int> Paint;

bool Pairfirst(const Paint& pf,Paint&ps){//sortCompare
  return pf.first < ps.first;
}

#define rep(i,q) for(int i = 0; (q) > i; i++)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007
int main(){
  int n;
  string s;
  cin>>n>>s;
  int b=0,w=0;
  for(int i = 0; n > i; i++){
    if(s[i]=='#')b++;
    else w++;
  }
  int d[n][2];
  d[0][0]=0;
  d[0][1]=1;
  if(s[0]=='#')d[0][0]=1;
  for(int i = 1; n > i; i++){
    if(s[i]=='#'){
      d[i][1]=min(d[i-1][1],d[i-1][0]);
      d[i][0] = d[i-1][0]+1;
    }else{
      d[i][0]=d[i-1][0];
      d[i][1]=d[i-1][1]+1;
    }
  }
  cout << min(min(d[n-1][0],d[n-1][1]),min(b,w)) << endl;
}

Measured memory_bytes: 2180
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

t, tt = map(int, input().split())
a, aa = map(int, input().split())
b, bb = map(int, input().split())

if a*t+aa*tt == b*t+bb*tt or a*t == b*t:
    print('infinity')
    exit()

diff1 = a*t-b*t

diff12 = a*t+aa*tt - (b*t+bb*tt)

if diff1*diff12>0:
    print(0)
    exit()

diff1 = abs(diff1)
diff12 = abs(diff12)

if diff1%diff12==0:
    print(-(-diff1//diff12)*2)
else:
    print(-(-diff1//diff12)*2-1)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<y;i++)

struct S {
	int c, d;
};

int main()
{
	int N, m;

	cin >> N >> m;

	vector<S> data(m);

	rep(i, 0, m) {
		cin >> data[i].c >> data[i].d;
	}

	while (true) {
		bool flag = false;

		rep(i, 0, m) {
			if (data[i].c == 0 && data[i].d == 0) {
				continue;
			}

			rep(j, i + 1, m) {
				if (data[j].c == 0 && data[j].d == 0) {
					continue;
				}

				if (data[i].d > data[j].c&&data[i].c < data[j].d) {
					data[i].c = min(data[i].c, data[j].c);
					data[i].d = max(data[i].d, data[j].d);
					data[j].c = 0;
					data[j].d = 0;
					flag = true;
				}
			}
		}

		if (flag == false) {
			break;
		}
	}

	int ans = N + 1;

	rep(i, 0, m) {
		ans += (data[i].d - data[i].c) * 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3088
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		Graph g = new Graph(N);
		for(int i=0; i<M; i++) {
			int A = sc.nextInt();
			int B = sc.nextInt();

			g.addEdge(g.getNode(A), g.getNode(B));
			g.addEdge(g.getNode(B), g.getNode(A));
		}

		boolean[] visited = new boolean[N];
		Arrays.fill(visited, false);
		//BFS
		Queue<Node> queue = new ArrayDeque<>();
		queue.add(g.getNode(1));
		visited[0] = true;
		while(!queue.isEmpty()) {
			Node n = queue.poll();

			for(Edge edge : n.edges) {
				Node node = edge.to;

				if(!visited[node.value-1]) {
					queue.add(node);
					visited[node.value-1] = true;
					if(node.root != null) {
						System.out.println("No");
						return;
					}else {
						node.root = n;
					}
				}
			}
		}

		System.out.println("Yes");
		for(int i=2; i<=N; i++) {
			System.out.println(g.getNode(i).root.value);
		}

	}

	//一般的なグラフ
	public static class Graph{
		int n;
		Map<Integer, Node> nodes;	//(ノード番号, ノード)

		//1~Nまでをもつグラフ
		public Graph(int n) {
			this.n = n;
			nodes = new HashMap<>(n);

			for(int i=0; i<n; i++) {
				nodes.put(i+1, new Node());
			}
		}

		public Graph(int n, int[] values) {
			this.n = n;
			nodes = new HashMap<>(n);

			for(int i=0; i<n; i++) {
				nodes.put(values[i], new Node(values[i]));
			}
		}

		public Node getNode(int node_n) {
			//ノード番号を指定してノードを取得
			return nodes.get(node_n);
		}

		public void addEdge(Node from, Node to) {
			//重みが1のグラフの場合(重みが均等な場合にも場合によっては使える)
			from.edges.add(new Edge(to, 1));
		}

		public void addEdge(Node from, Node to, long weight) {
			//エッジの重みが異なる場合
			from.edges.add(new Edge(to, weight));
		}

		public void removeEdge(Node from, Node to) {
			//指定したノード間のエッジを削除
			from.edges.remove(new Edge(to, 1));
		}
	}

	public static int count = 0;
	//ノードを表すクラス
	public static class Node{

		int value;
		List<Edge> edges;
		boolean visited = false;
		Node root;

		public Node(){
			value = count+1;
			edges = new ArrayList<Edge>();
			count++;
		}

		public Node(int value) {
			this.value = value;
			edges = new ArrayList<Edge>();
		}

		@Override
		public boolean equals(Object obj) {
			if(obj instanceof Node) {
				Node n = (Node)obj;
				if(this.value == n.value)
					return true;
				else
					return false;
			}

			return false;
		}

		@Override
		public int hashCode() {
			return Objects.hash(this.value);
		}
	}

	//エッジを表すクラス
	public static class Edge{
		Node to;		//行き先
		long weight;		//重み

		public Edge(Node to, long weight) {
			this.to = to;
			this.weight = weight;
		}

		@Override
		public boolean equals(Object obj) {
			if(obj instanceof Edge) {
				Edge e = (Edge)obj;
				if(this.to.equals(e.to))
					return true;
				else
					return false;
			}

			return false;
		}

		@Override
		public int hashCode() {
			return Objects.hash(this.to);
		}
	}

}


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

#define INFTY 1000000001
int cnt = 0;

void merge(int A[], int left, int mid, int right) {
    int i, j, k;
    int n1, n2;
    n1 = mid - left;
    n2 = right - mid;
    vector<long long int> L; vector<long long int> R;
    L.resize(n1 + 1); R.resize(n2 + 1);
    for (i = 0; i < n1; i++) L[i] = A[left + i];
    for (i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = INFTY;
    R[n2] = INFTY;
    j = 0;
    k = 0;
    for (i = left; i < right; i++) {
        ++cnt;
        if (L[j] <= R[k]) {
            A[i] = L[j];
            j++;
        }
        else {
            A[i] = R[k];
            k++;
        }
    }
}
void merge_sort(int A[], int left, int right) {
    if (left + 1 < right) {
        int mid;
        mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
}
int main() {
    int i, n, S[500000];

    cin >> n;
    for (i = 0; i < n; i++) cin >> S[i];

    merge_sort(S, 0, n);

    for (i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << S[i];
    }
    cout << endl;
    cout << cnt << endl;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    bool isUpL, isUpR, up;
    int N, ans;

    while( cin >> N, N ){
        ans = 0;
        isUpL = isUpR = up = false;
        REP( i, N ){
            string s; cin >> s;
            if( s[0] == 'l' ) isUpL ^= 1;
            if( s[0] == 'r' ) isUpR ^= 1;

            if( up && isUpL == false && isUpR == false ){
                ans++;
                up ^= 1;
            }else if( !up && isUpL == true && isUpR == true ){
                ans++;
                up ^= 1;
            }
        }
        cout << ans << endl;
    }
}



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

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int w, h;
int board[21][21];
int ans = INF;
bool valid(int y, int x) { return 0 <= y && y < h && 0 <= x && x < w; }
void print() {
    rep(y, h) {
        rep(x, w) printf("%d ", board[y][x]);
        printf("\n");
    }
}
void dfs(int y, int x, int cnt) {
    // printf("debug: %d %d %d\n", y, x, cnt);
    // print();
    if (cnt == 10) return;
    rep(k, 4) {
        int ny = y;
        int nx = x;
        if (!valid(ny + dy[k], nx + dx[k])) continue;
        if (board[ny + dy[k]][nx + dx[k]] == 1) continue;
        while (1) {
            if (!valid(ny + dy[k], nx + dx[k])) break;
            ny += dy[k];
            nx += dx[k];
            if (board[ny][nx] == 3) {
                ans = min(cnt + 1, ans);
                return;
            }
            if (board[ny][nx] == 1) {
                board[ny][nx] = 0;
                dfs(ny - dy[k], nx - dx[k], cnt + 1);
                board[ny][nx] = 1;
                break;
            }
        }
    }
}
int main() {
    while (cin >> w >> h, w) {
        ans = INF;
        rep(i, h) rep(j, w) cin >> board[i][j];
        rep(y, h) rep(x, w) if (board[y][x] == 2) dfs(y, x, 0);
        if (ans == INF) ans = -1;
        cout << ans << endl;
    }
    return 0;
}

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

int n;
vector<lint> a, b;
lint mod = 1000000007;

// a^n mod pを計算　O(log n)
long long pow_mod(long long a, long long n, long long p) {
    if (n == 0) return 1;
    if (n & 1) return pow_mod(a, n - 1, p) * a % p;
    long long temp = pow_mod(a, n / 2, p);
    return temp * temp % p;
}

pair<lint, lint> reg(lint x, lint y) {
    lint div = gcd(x, y);
    x /= div, y /= div;
    if (y < 0) {
        x *= -1, y *= -1;
    }
    if (y == 0 && x < 0) {
        x *= -1;
    }
    return {x, y};
}

pair<lint, lint> auth(pair<lint, lint> p) {
    lint x = -p.second, y = p.first;
    if (y < 0) {
        x *= -1, y *= -1;
    }
    if (y == 0 && x < 0) {
        x *= -1;
    }
    return {x, y};
}

int main() {
    cin >> n;
    map<pair<lint, lint>, lint> count;
    a.resize(n), b.resize(n);
    vector<pair<lint, lint>> vec;
    lint zeros = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        if (a[i] == 0 && b[i] == 0) {
            zeros++;
            continue;
        }
        auto v = reg(a[i], b[i]);
        vec.push_back(v);
        count[v]++;
    }
    set<pair<lint, lint>> trash;
    lint ans = 1;
    for (int i = 0; i < (int)vec.size(); i++) {
        if (trash.count(vec[i])) {
            continue;
        }
        auto o = auth(vec[i]);
        lint mul = (pow_mod(2, count[vec[i]], mod) + pow_mod(2, count[o], mod) - 1) % mod;
        ans = ans * mul % mod;
        trash.insert(vec[i]);
        trash.insert(o);
    }
    lint res = (zeros % mod + ans % mod - 1) % mod;
    if (res < 0) {
        res = (res + mod) % mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 59424
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,input,sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>input;
        sum+=input;
    }
    if(sum<=n){cout<<n-sum;}
    else cout<<-1;
    return 0;
}   

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
main() {
	int N;
	cin >> N;

	int b = 2, p = 2, n, ans = 1;
	while (1) {
		if (b*b > N)
			break;
		p = 2;
		while (1) {
			n = 1;
			for (int i = 0; i < p; i++)
				n *= b;
			if (n*b > N) 
				break;
			p++;
		}
		if (n > ans)
			ans = n;
		b++;
	}
		
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
void main()
{
    double r = rdElem!double;

    writefln("%.15f", 2.0 * PI * r);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 2956
n = gets.chomp.to_i
a = gets.chomp.split(' ')

result = Array.new(1000000, nil)
sentou = 0
matsubi = -1

a.reverse.each.with_index do |num, i|
  if (i.even?)
	result[sentou] = num
    sentou += 1
  else
    result[matsubi] = num
    matsubi -= 1
  end
end
puts result.compact.join(' ')

Measured memory_bytes: 33412
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main() {
    for(string line; getline(cin, line), line != "0"; ) {
        int sa = 0, sb = 0;
        for(int i = 1; i < (int)line.length(); i++) {
            (line[i] == 'A' ? sa : sb)++;
        }
        if(sa >= 10 && sb >= 10) {
            (sa > sb ? sa : sb)++;
            cout << sa << ' ' << sb << endl;
        }
        else {
            (sa == 10 ? sa : sb)++;
            cout << sa << ' ' << sb << endl;
        }
    }
}

Measured memory_bytes: 1180
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> in(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    in[i].resize(a);
    for (int j = 0; j < a; j++) {
      cin >> in[i][j].first >> in[i][j].second;
      in[i][j].first--;
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    bool ok = true;
    for (int j = 0; j < n; j++) if (1 & (i >> j)) {
      for (int k = 0; k < (int) in[j].size(); k++) {
        if (in[j][k].second) {
          ok &= ((i >> in[j][k].first) & 1);
        } else {
          ok &= ((i >> in[j][k].first) & 1) == 0;
        }
      }
    }
    if (ok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b,res=0;
  cin >> a;
  cin >> b;

  if(a>b){
    res += a;
    --a;
  }else{
    res += b;
    --b;
  }
  res+= max(a,b);

  cout << res << "\n";
  return 0;
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int Pow( int i ){
return i * i ;
}

bool is_int( int ans ){
int c = sqrt( ans ) ;
return c * c == ans ;
}

int n , d ;
int a[ 30 ][ 30 ] ;

int main() {

  cin >> n >> d ;

  forn( int , i , 0 , n ){
    forn( int , j , 0 , d ){
      cin >> a[ i ][ j ] ;
    }
  }

  int cnt = 0 ;

  forn( int , i , 0 , n ){
    forn( int , j , i + 1 , n ){
        int  ans = 0 ;
        forn( int , idx , 0 , d ){
             ans += Pow( a[ i ][ idx ] - a[ j ][ idx ] ) ;
        }
        cnt += is_int( ans ) ;
    }
  }

  cout << cnt << "\n" ;

  return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

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

ll comb(ll n){
    return n*(n-1)/2;
}

int main(){
    ll n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    UnionFind U(n);
    ll cur=comb(n);
    vector<ll>res;
    rep(i,m){
        res.push_back(cur);
        int c=a[m-1-i];
        int d=b[m-1-i];
        if(U.issame(c,d))continue;  
        ll sa=U.size(c);
        ll sb=U.size(d);          
        cur-=sa*sb;
        U.merge(c,d);    
    }
    reverse(res.begin(),res.end());
    rep(i,res.size()){
        cout<<res[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        if(n == 1 || m ==1) {
            if(n == m) {
                System.out.println(1);
                return;
            }
            long ans = Math.max(n, m);
            System.out.println(ans - 2);
            return;
        }
        else {
            long ans = n * m - (n + n + m + m - 4);
            System.out.println(ans);
            return;
        }
    }
}

Measured memory_bytes: 35684
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;




int main(int argc, const char * argv[])
{
    int n, r;
    while(cin >> n >> r){
        if(n == 0 || r == 0) return 0;
        
        int cards[n];
        int next[n];
        
        for(int i = 0; i < n; i++){
            cards[i] = n - i;
        }
        
        // 　DEBUG
        /*
        for(int i = 0; i < n; i++){
            cout << cards[i] << " ";
        }
        cout << "\n";
        */
        
        int p, c;
        for(int i = 0; i < r; i++){
            cin >> p >> c;
            int j = 0;
            for(j = 0; j < c; j++){
                next[j] = cards[p+j-1];
            }
            for(int k = 0; k < p-1; k++){
                next[j] = cards[k];
                j++;
            }
            for(;j < n; j++){
                next[j] = cards[j];
            }
            
            for(int j = 0; j < n; j++){
                cards[j] = next[j];
            }
            /*
            for(int i = 0; i < n; i++){
                cout << cards[i] << " ";
            }
            cout << "\n";
             */
        }
        
        cout << cards[0] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1160
int main(void){
  int N,L,S=0,max=0;
  int i=0;
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&L);
    
    if(L>max){
      S+=max;
      max=L;
    }
    else
      S+=L;
  }
  if(max<S){
   
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }  
  return 0;
 
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	static void Main() => Console.WriteLine(string.Join("\n", GetNumbers().Take(int.Parse(Console.ReadLine()))));

	static IEnumerable<long> GetNumbers()
	{
		long d10 = 1, t = 0;
		for (int d = 0; ; d++)
		{
			for (int i = 0; ; i += 10)
			{
				var v0 = (i + 1) * d10 - 1;
				if (($"{i}".Sum(c => c - '0') + 9 * d) * d10 < v0) break;
				for (int j = 0; j < 10; j++)
				{
					var v = v0 + j * d10;
					if (v <= t) continue;
					yield return t = v;
				}
			}
			d10 *= 10;
		}
	}
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << c <<" " << a << " "<< b << endl;
}


Measured memory_bytes: 256
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    char s[64][64];
    int h,w,i,j,k,l,r;
    scanf("%d%d",&h,&w);
    for(i=0;i<h;i++){scanf("%s",s[i]);}
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(s[i][j]!='.'){continue;}
            r='0';
            for(k=-1;k<=1;k++){
                for(l=-1;l<=1;l++){
                    if(i+k<0 || j+l<0){continue;}
                    if(s[i+k][j+l] == '#'){r++;}
                }
            }
            s[i][j]=r;
        }
    }
    for(i=0;i<h;i++){printf("%s\n",s[i]);}
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>

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

Measured memory_bytes: 1012
#include<iostream>
#include<cstdio>
using namespace std;
int f[15],p[15];
bool s[15][15];
bool c[15];
int main(void)
{
    int n,m,cnt=0,ans=0;
    cin >> n >> m;
    for(int i=0;i<m;i++)
    {
        cin >> f[i];
        for(int j=0;j<f[i];j++)
        {
            int t;
            cin >> t;
            s[i][t-1] = 1;
        }
    }
    for(int i=0;i<m;i++)
        cin >> p[i];
    for(int k=0;k< 1<<n;k++)
    {
        cnt=0;
        for(int i=0; i<m; i++)
        {
            int x = 0;
            for(int j=0; j<n; j++)
            {
                if ( s[i][j] && k>>j & 1)
                {
                    x++;
                }
            }
            if(x%2==p[i])
                cnt++;
        }
        if(cnt==m)
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll x;cin >> x;
    if(x == 0){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpl;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll a; cin >> a;
        ll ans = a+a*a+a*a*a;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
char arr[4];
for(int i=0;i<4;i++)cin>>arr[i];
if((arr[0]==arr[1]&&arr[0]==arr[2])||(arr[1]==arr[2]&&arr[1]==arr[3]))cout<<"Yes";
else cout<<"No";
  return 0;
}


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

int main()
{
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++)
  {
    cin >> L[i];
  }
  int cnt = 1;
  int now = 0;
  for (int i = 0; i < N; i++)
  {
    now += L[i];
    if (now <= X)
      cnt++;
    else
    {
      break;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S; cin >> S; 
	int N = (int) S.size() + 1; 
	long long int left[500010] = {}; 
	long long int right[500010] = {}; 
	for(int i = 1; i < N; i++){
		if(S.at(i-1) == '<') left[i] = left[i-1] + 1; 
		else left[i] = 0LL; 
	}
	for(int i = N-2; i >= 0; i--){
		if(S.at(i) == '>') right[i] = right[i+1] + 1; 
		else right[i] = 0LL; 
	}
	long long int ans = 0LL; 
	for(int i = 0; i < N; i++){
		ans += max(left[i], right[i]); 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 8708
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[100005];
    int n,i,c1=0,c0=0;
    scanf("%s",s);
    n = strlen(s);
    for(i=0;i<n;i++)
    {
        if(s[i] == '1')
            c1++;
        if(s[i] == '0')
            c0++;
    }
    printf("%d",2*(c1>c0?c0:c1));

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
	int rooms[4][3][10];
	int num;
	int n1,n2,n3,n4;
	int i,j,k;

	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				rooms[i][j][k] = 0;
			}
		}
	}

	scanf("%d",&num);

	for(i=1;i<=num;i++){
		scanf("%d %d %d %d",&n1,&n2,&n3,&n4);
		rooms[n1-1][n2-1][n3-1] += n4;
	}

	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",rooms[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3){
			printf("####################\n");
		}
	}

	return 0;
}

Measured memory_bytes: 1040
import java.io.*;
    public class Main{
      public static void main(String [] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] list = reader.readLine().split(" ");
        int sum = 0;
        for(String s:list){
          sum+= Integer.parseInt(s);}
        if(sum>=22){
          System.out.println("bust");
        }
        else{
          System.out.println("win");}
      }}

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int& x: X) cin >> x;
  vector<int> S = X;
  sort(S.begin(), S.end());
  for (int x: X) {
    if (S[N/2] <= x) cout << S[N/2-1] << endl;
    else cout << S[N/2] << endl;
  }
}

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

typedef long long ll;

using namespace std;

int m,n,ans=0;
int a[5001],b[5001];

int main(){
    
    scanf("%d%d",&m,&n);
    
    for(int i=0;i<m;i++)
        scanf("%d",&a[i]);
    
    for(int i=0;i<n;i++)
        scanf("%d",&b[i]);
    
    for(int i=0;i<n;i++){
        int c=0;
        for(int j=0;j<m;j++){
            if(b[i+c]==a[j])
                c++;
        }
        ans=max(ans,c);
    }
    
    printf("%d\n",ans);
    
    return 0;
}

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

int main( void )
{
    int N,K;
    cin >> N >> K;
    int x = 1;
    
    rep(i,N)
    {
        x = min(x*2,x+K);
    }
    
    cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
  ll n,k;
  cin >>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++) cin >>a[i];
  if((n-1)%(k-1)==0) cout <<(n-1)/(k-1)<<endl;//(n-k+(k-1))/(k-1)
  else cout <<((n-1)/(k-1))+1<<endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.math.*;

public class Main {
    private static Scanner sc;

    public static void main(final String[] args) {
        final Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null)
                br.close();
        }

        public String next() throws IOException {
            if (i < s.length)
                return s[i++];
            String st = br.readLine();
            while (st == "")
                st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long[] nextLongArray(int n) throws NumberFormatException, IOException {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }
    }

    private void solve() {
        try {
            long a = sc.nextLong();
            long v = sc.nextLong();
            long b = sc.nextLong();
            long w = sc.nextLong();
            long t = sc.nextLong();
            if (v <= w) {
                System.out.println("NO");
                return;
            } else {
                long diff = Math.abs(a - b);
                long aa = (v - w) * t;
                if (aa >= diff) {
                    System.out.println("YES");
                } else {
                    System.out.println("NO");
                }

            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}


Measured memory_bytes: 32748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ar array
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  for(auto& c: s)
    if(c=='?')
      c = 'D';
  cout << s;
  return 0;
}


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M;cin>>N>>M;
  vector<vll> end(3*(M+1));
  for(ll i=0;i<N;i++){
    ll L,R;cin>>L>>R;
    L+=M;
    end[R].push_back(L);
    end[R+M].push_back(L+M);
  }
  priority_queue<ll> Q;
  vll done(3*(M+1),0);
  ll ma=0;
  for(ll i=0;i<3*(M+1);i++){
    //debug(i);
    for(ll e:end[i])Q.push(-e);
    while(!Q.empty()&&-Q.top()<i)Q.pop();
    if(i>0)done[i]=done[i-1];
    if(!Q.empty()){
      done[i]++;
      Q.pop();
    }
    if(i>=M){
      ma=max(ma,done[i]-done[i-M]);
    }
    //debug(done[i]);
  }
  cout<<N-ma<<endl;
  return 0;
}


Measured memory_bytes: 27644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc076_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S, T;
  cin >> S >> T;

  if (S.size() < T.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  bool ok = false;
  for (int i = S.size() - T.size(); i >= 0; i--) {
    bool replace = true;
    rep(j, T.size()) {
      if (S[i + j] != T[j] && S[i + j] != '?') {
        replace = false;
        break;
      }
    }
    if (replace) {
      S.replace(i, T.size(), T);
      ok = true;
      break;
    }
  }
  if (!ok) {
    cout << "UNRESTORABLE" << endl;
  } else {
    rep(i, S.size()) { cout << (S[i] == '?' ? 'a' : S[i]); }
  }
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var L = cin.ReadInt;
            var R = cin.ReadInt;

            int MinMod = 2019;
            if (R - L > 2019) {
                MinMod = 0;
            }

            L = L % 2019;
            R = R % 2019;

            for (int i = L; i < R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int TmpMod = (i * j) % 2019;
                    if (TmpMod < MinMod){
                        MinMod = TmpMod;
                    }
                }
            }

            Console.WriteLine(MinMod);
            return;

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.IntMap as IMap
import qualified Data.Vector as V
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt

sqleft :: Seq a -> a
sqleft q = sqleft_(Sq.viewl q)
sqleft_ :: ViewL a -> a
sqleft_ (x :< xs) = x
sqright :: Seq a -> a
sqright q = sqright_(Sq.viewr q)
sqright_ :: ViewR a -> a
sqright_ (xs :> x) = x
-------------------------------------------------------------

main = do
    s <- getLine
    print $ (length $ group s) - 1
    

Measured memory_bytes: 4988
alpha = 'abcdefghijklmnopqrstuvwxyz'
N= int(input())
len_alpha = 26
tmp = N
calc = tmp
cnt = 1

while tmp > 0:
    calc = tmp
    tmp -= (len_alpha **cnt)
    cnt += 1

res =''
for i in range(1, cnt - 1):
    tmp = int((calc-1)/(len_alpha**(cnt - i - 1)))
    calc -= tmp * len_alpha**(cnt - i - 1)
    res += alpha[tmp]

res += alpha[calc-1]
print(res)

Measured memory_bytes: 9160
#include<iostream>
#include<algorithm>
using namespace std;
int a[100010];
int main(){
    int n;
    cin>>n;
    if(n%2){
        cout<<"0\n";
        return 0;
    }
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    n=n/2-1;
    if(a[n+1]==a[n]){
        cout<<"0\n";
        return 0;
    }
    cout<<a[n+1]-a[n];
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int cost=0;
        int ans = 0;
        int N = sc.nextInt();
        //String[] str = new String[N];
        int[] A = new int[N+2];
        A[0]=0;
        for (int i=1;i<=N;i++){
        //    str[i]=sc.next();
            A[i]=sc.nextInt();
        }
        A[N+1]=0;
        sc.close();


        //for(int i=0;i<N;i++){

            /*List<String> list = new ArrayList<>(Arrays.asList(str));
            list.remove(i);
            str  = list.toArray(new String[list.size()]);
            for(int j=0;j<N-1;j++){
                A[j] = Integer.parseInt(str[j]);
            }*/
            
            for(int k=1;k<=N;k++){
                //if(k!=0){
                    int tmp = Math.abs(A[k-1]-A[k]);
                    cost+=tmp;
                //}
                /*else{
                    cost = (A[k]>0)?A[k]:-A[k];
                }*/
            }
            cost+=Math.abs(A[N]);
            //System.out.println(cost);

            for(int i=1;i<=N;i++){
                ans = cost+Math.abs(A[i-1]-A[i+1])-Math.abs(A[i]-A[i-1])-Math.abs(A[i]-A[i+1]);
                System.out.println(ans);
            }
        //}
    }
}

Measured memory_bytes: 62164
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,e,i,j,k,l=0;
vector<int>v;
cin>>a;
for(i=1;i<=a;i++)
{
cin>>b;
v.push_back(b);}
sort(v.begin(),v.end());
for(i=0;i+1<a;i++)
{
 l+=v[i+1]-v[i];
}
cout<<l<<endl;
}

Measured memory_bytes: 256