akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
//?¶????????????????????????????????????§??????????????????????¢????????????????
constexpr int INF = 2000000000;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double a = -x1 + x2, b = -y1 + y2, c = (-pow(x1, 2) - pow(y1, 2) + pow(x2, 2) + pow(y2, 2)) / 2;
		double d = -x1 + x3, e = -y1 + y3, f = (-pow(x1, 2) - pow(y1, 2) + pow(x3, 2) + pow(y3, 2)) / 2;
		double y = (c*d - a*f) / (b*d - a*e);
		double x = (f - e*y) / d;
		cout <<fixed<<setprecision(3)<< x << " " << y <<" "<< hypot(x1 - x, y1 - y) << endl;
	}
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define ll long long
using namespace std;
using u64 = uint64_t;
using u128 = __uint128_t;

int main(){ 
    int N;
    cin>>N;
    string S;
    cin>>S;
    if(N%2==1){
        cout<<"No"<<endl;
        return 0;
    }else{
        for(int i=0;i<N/2;i++){
            if(S[i]!=S[N/2+i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
main = do
  [n, k] <- (map read . words) <$> getLine
  ab <- map (map read . words) <$> replicateM n getLine
  putStrLn $ show $ solve k ab

solve:: Int -> [[Int]] -> Int
solve k ab = chu k 0 ma b
  where
    ma = maximum [ x | [x, _] <- ab ]
    b = sortOn negate $ [ b | [_, b] <- ab, b > ma ]

chu:: Int -> Int -> Int -> [Int] -> Int
chu h n ma []
  | h <= 0 = n
  | otherwise = chu (h - ma) (n + 1) ma []
chu h n ma (b:bs)
  | h <= 0 = n
  | otherwise = chu (h - b) (n + 1) ma bs


Measured memory_bytes: 153980
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  string O, E;
  cin >> O >> E;
  for (int i = 0; i < (int)O.size(); ++i) {
    cout << O[i];
    if (O.size() > E.size() && i == (int)O.size() - 1) break;    
    cout << E[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cstring>
#define N 100010
using namespace std;
char a[N],b[N];
int len;
signed main(int argc,char **argv)
{
	scanf("%s",&a);len=strlen(a);
	for(int i=0;i<len;++i)b[len-i-1]=a[i];
	for(int i=0;i<len;++i)
		if(b[i]=='b')b[i]='d';
		else if(b[i]=='d')b[i]='b';
		else if(b[i]=='p')b[i]='q';
		else b[i]='p';
	for(int i=0;i<len;++i)
	if(a[i]!=b[i]){printf("No");return 0;}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    int k = n / 15;
    std::cout<<(800 * n - 200 * k)<<std::endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp
arr1 = Array.new(N+1,0)
arr2 = Array.new(N+1,0)

for i in 0..N do
  if i == 0
    arr1[i] = 0
  elsif S[i-1] == "W"
    arr1[i] = arr1[i-1] + 1
  else
    arr1[i] = arr1[i-1]
  end
  j = N - i
  if j == N
    arr2[j] = 0
  elsif S[j] == "E"
    arr2[j] = arr2[j+1] + 1
  else
    arr2[j] = arr2[j+1]
  end
end

arr = Array.new(N+1){|i| arr1[i] + arr2[i]}

puts arr.min


Measured memory_bytes: 9484
# https://atcoder.jp/contests/abc126/tasks/abc126_e

class UnionFind():
    # https://www.slideshare.net/chokudai/union-find-49066733
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        # root[x]>=0の場合は、特に直接的な意味を持たない気がする。計算に寄与するので意味はあるのだろうが。
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        # 無結合の時はRank=0,結合して1つ木が深くなると根がRank+=1
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    #
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        # (1)xのランクの方が大きい(位置が深い)場合
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        # (2)yのランクの方が大きい(位置が深い)場合 or 等しい場合
        # また等しい場合、引数の2つめのyの方のランクを1つ増やす
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    # Return: True or False
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
    
#######################################################
N,M=map(int,input().split())
UN=UnionFind(N)
for _ in range(M):
    s,t,u = map(int,input().split())
    UN.Unite(s,t)
    
#print(UN.root)
ans=0
for i in UN.root:
    if i<0:
        ans +=1
print(ans-1)

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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    string s;
    int K;

    cin >> s >> K;

    int N = s.size();

    rep(i, N) {
        if (s[i] != 'a' && s[i] + K > 'z') {
            K -= 'z' - s[i] + 1;
            s[i] = 'a';
        }
    }

    s[N - 1] += K % 26;

    cout << s << endl;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using eg = vector<vector<Edge>>;

int main()
{
    ios::sync_with_stdio(false);
    // 2部グラフか否かを判定する
    int N, M;
    cin >> N >> M;
    vvi graph(N);
    REP(i, M) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        graph[u].push_back(v);
        graph[v].push_back(u);  
    }
    bool isBi = true;   // bipartite
    vi color(N, -1);
    color[0] = 0;
    queue<int> q;
    q.push(0);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        for(auto u: graph[v]) {
            if(color[u] != -1) {
                if(color[u] == color[v]) {
                    isBi = false;
                    break;
                }
                continue;
            }
            color[u] = (color[v]+1) & 1;
            q.push(u);
        }
        if(!isBi) break;
    }
    ll ans;
    if(!isBi) ans = (ll)N * (N - 1) / 2 - M;
    else {
        sort(color.begin(), color.end());
        ll count = upper_bound(color.begin(), color.end(), 0) - lower_bound(color.begin(), color.end(), 0);
        ans = count * (N - count) - M ;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
  int n,m,l;
  cin >> n >> m >> l;
  long long A[n][m],B[m][l],C[n][l];
  fill(C[0], C[n], 0);
  for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++)
      cin >> A[i][j];
  for(int i = 0; i < m; i++)
    for(int j = 0; j < l; j++)
      cin >> B[i][j];
  for(int i = 0; i < n; i++)
    for(int j = 0; j < l; j++)
      for(int k = 0; k < m; k++)
        C[i][j] += A[i][k] * B[k][j];
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < l; j++) {
      cout << C[i][j];
      if(j != l - 1)
        cout << ' ';
    }
    cout << endl;
  }
}

Measured memory_bytes: 3228
import java.util.*;

/*
問題文
3 個の整数 A1,A2,A3 が与えられます。
A1+A2+A3 が 22 以上なら bust、21 以下なら win を出力してください。

制約
1≤Ai≤13
(i=1,2,3)入力中のすべての値は整数である。

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();

        // 問題文そのまんま
        if (a1 + a2 + a3 >= 22) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    }
}

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

int K;
int A[3];

int main()
{
    scanf("%d%d%d",A,A + 1,A + 2);
    scanf("%d",&K);
    sort(A,A + 3);
    for(int i = 0; i < K; i++)A[2] *= 2;
    printf("%d\n",A[0] + A[1] + A[2]);
    return 0;
}


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

#define N_MAX 8
#define INF 1145141919
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

#define IMP "Impossible"
#define POS "Possible"

typedef unsigned long long ull;

int i, j;

int n, m;
int k;

int h, w;

ull t[N_MAX];
char d[N_MAX + 1][N_MAX + 2];

void solve(){
	int result = 0;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (d[i][j] == '#') result++;
		}
	}
	puts((result == h + w - 1) ? POS : IMP);
	return;
}

int main (void) {
	scanf("%d%d", &h, &w);
	for (i = 0; i < h; i++) scanf("%s", d[i]);

	solve();
	return 0;
}




Measured memory_bytes: 128
'''input
3 5
1 2 1
2 3 0
'''
# connected components
from sys import stdin, setrecursionlimit
from bisect import bisect_left
import sys, threading


# main start
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
k = 0
for i in range(n):
    if arr[i] == k + 1:
        k += 1

if k == 0:
    print(-1)
else:
    print(n - k)

Measured memory_bytes: 25752
N=int(input())
S=input()

count=0
for i in range(1000):
    W=str(i).rjust(3,'0')
    a,b,c=W[0],W[1],W[2]
    t=0
    while S[t]!=a and t<N-1:
        t+=1
    t+=1
    if t>N-1:
        continue
    while S[t]!=b and t<N-1:
        t+=1
    t+=1
    if t>N-1:
        continue
    while S[t]!=c and t<N-1:
        t+=1
    if t<N:
        if S[t]==c:
#            print(W)
            count+=1

print(count)

Measured memory_bytes: 42460
N,W = map(int,input().split())
dp = [0]+[W+1]*(N*10**3)
for i in range(N):
    w,v = map(int,input().split())
    for j in range(N*10**3+1-v)[::-1]:
        dp[j+v] = min(dp[j+v],dp[j]+w)
for i in range(N*10**3+1)[::-1]:
    if dp[i]<=W:
        print(i)
        exit()


Measured memory_bytes: 43432
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanInt() int {
	scanner.Scan()
	a, err := strconv.Atoi(scanner.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func main() {
	scanner.Split(bufio.ScanWords)

	scanInt()
	m := scanInt()

	l := scanInt() - 1
	r := scanInt() - 1
	for i := 1; i < m; i++ {
		ll := scanInt() - 1
		rr := scanInt() - 1
		if ll > l {
			l = ll
		}
		if rr < r {
			r = rr
		}
	}
	if l > r {
		fmt.Println(0)
	} else {
		fmt.Println(r - l + 1)
	}
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

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

  cout << a-b-c+d << endl;
  
  return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define maxn 10000
#define INF 2e9
using namespace std;
multiset<int> son[2][maxn];
int need[maxn], n, head[maxn], nxt[maxn], a[maxn], edge, deg[maxn], dl[maxn];
void create(int u, int v)
{
	edge++; a[edge] = v; nxt[edge] = head[u]; head[u] = edge; deg[v]++;
}
void dfs(int u, int fa)
{
	need[u] = 0;
	for (set<int>::iterator it = son[0][u].begin(); it != son[0][u].end(); it++)
	{
		int x = *it;
		if (x != fa && son[1][u].find(x) != son[1][u].end())
			dfs(x, u);
	}
}
void get_fa(int c, int u, int fa)
{
	if (need[u] && need[fa])
	{
		if (c == 0) create(u, fa);
		else create(fa, u);
	}
	for (set<int>::iterator it = son[c][u].begin(); it != son[c][u].end(); it++)
	{
		int x = *it;
		if (x != fa) get_fa(c, x, u);
	}
}
int check(int rt)
{
	for (int i = 1; i <= n; i++)
		need[i] = 1;
	dfs(rt, 0);
	get_fa(0, rt, 0);
	get_fa(1, rt, 0);
	int lef = 1, righ = 0, sum = 0;
	for (int i = 1; i <= n; i++)
		if (need[i])
		{
			sum++;
			if (deg[i] == 0) dl[++righ] = i;
		}
	while (lef <= righ)
	{
		int u = dl[lef];
		for (int i = head[u]; i; i = nxt[i])
		{
			int v = a[i];
			deg[v]--;
			if (deg[v] == 0) dl[++righ] = v;
		}
		lef++;
	}
	edge = 0;
	for (int i = 1; i <= n; i++)
		head[i] = deg[i] = 0;
	if (righ == sum) return sum;
	else return INF;
}
int main()
{
	int T;
	scanf("%d", &T);
	while (T--)
	{
		scanf("%d", &n);
		for (int i = 1; i <= n - 1; i++)
		{
			int u, v;
			scanf("%d%d", &u, &v);
			son[0][u].insert(v);
			son[0][v].insert(u);
		}
		for (int i = 1; i <= n - 1; i++)
		{
			int u, v;
			scanf("%d%d", &u, &v);
			son[1][u].insert(v);
			son[1][v].insert(u);
		}
		int res = INF;
		for (int i = 1; i <= n; i++)
			res = min(res, check(i));
		for (int i = 1; i <= n; i++)
			if (son[0][i].size() == 1)
			{
				int x = *son[0][i].begin();
				son[0][i].erase(x);
				son[0][x].erase(i);
				for (int j = 1; j <= n; j++)
					if (j != x && j != i)
					{
						son[0][j].insert(i);
						son[0][i].insert(j);
						res = min(res, check(i) + 1);
						son[0][i].erase(j);
						son[0][j].erase(i);
					}
				son[0][x].insert(i);
				son[0][i].insert(x);
			}
		if (res == INF) res = -1;
		printf("%d\n", res);
		for (int i = 1; i <= n; i++)
		{
			son[0][i].clear();
			son[1][i].clear();
		}
	}
}

Measured memory_bytes: 1280
package main

import "fmt"

func check(s string, c byte) bool {
	for i := range s {
		if s[i] != c {
			return false
		}
	}
	return true
}
func main() {
	var s string
	fmt.Scan(&s)
	m := make(map[byte]int, 0)
	for i := 0; i < len(s); i++ {
		m[s[i]]++
	}
	ans := 10000000
	if len(m) != 1 {
		for keychar := range m {
			cnt := 0
			t := make([]byte, len(s))
			copy(t, []byte(s))
			for !check(string(t), keychar) {
				var tt []byte
				for i := 0; i < len(t)-1; i++ {
					if t[i] == keychar || t[i+1] == keychar {
						tt = append(tt, keychar)
					} else {
						tt = append(tt, t[i])
					}
				}
				t = tt
				cnt++
			}
			ans = min(ans, cnt)
		}
	} else {
		ans = 0
	}
	fmt.Println(ans)
}

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


Measured memory_bytes: 896
#include <iostream>
using namespace std;
 
void gcd(int a, int b, int step);
 
int main()
{
    int a, b;
 
    while (cin >> a >> b, a){
        gcd(a, b, 0);
    }
 
    return (0);
}
 
void gcd(int a, int b, int step)
{
    if (b == 0){
        cout << a << " " << step << endl;
    }
    else if (a < b){
        return (gcd(a, b % a, step + 1));
    }
    else {
        return (gcd(b, a % b, step + 1));
    }
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int calc(int a, int b, int c){
	return a * 10 + b + c;
}

int main(int argc, char const *argv[]) {
	int a,b,c;
	std::cin >> a >> b >> c;
	std::cout << max(calc(a,b,c),max(calc(b,a,c), calc(c,a,b))) << '\n';
	return 0;
}


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

int main(){
    int a,b;
    string sa,sb;
    cin>>a>>b;
    for(int i=0;i<b;i++){
        sa+=to_string(a);
    }
    for(int i=0;i<a;i++){
        sb+=to_string(b);
    }
    cout<<min(sa,sb)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
#define NIL -1

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

    vector<LL> num_judge(4, 0);

    vector<string> s(n);
    for(LL i=0; i<n; i++){
        cin >> s[i];
    }

    for(LL i=0; i<n; i++){
        if(s[i]=="AC"){
            num_judge[0]++;
        }else if(s[i]=="WA"){
            num_judge[1]++;
        }else if(s[i]=="TLE"){
            num_judge[2]++;
        }else if(s[i]=="RE"){
            num_judge[3]++;
        }
    }

    cout << "AC x " << num_judge[0] << endl;
    cout << "WA x " << num_judge[1] << endl;
    cout << "TLE x " << num_judge[2] << endl;
    cout << "RE x " << num_judge[3] << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;


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

    string S;
    cin >> S;
    int ca = 0, cb = 0, cc = 0;
    for (char c : S) {
        if (c == 'a')
            ca++;
        if (c == 'b')
            cb++;
        if (c == 'c')
            cc++;
    }

    int n[3];
    n[0] = ca;
    n[1] = cb;
    n[2] = cc;
    sort(n, n + 3);
    if ((n[0] == n[1] && n[2] - n[1] <= 1) || (n[1] - n[0] <= 1 && n[1] == n[2]))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;


    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.charAt(5)=='0'&&(s.charAt(6)=='1'||s.charAt(6)=='2'||s.charAt(6)=='3'||s.charAt(6)=='4')){
			System.out.println("Heisei");
		}else{
			System.out.println("TBD");
		}
	}
}

Measured memory_bytes: 21844
from copy import deepcopy

def main():
    while True:
        n = int(input())
        if n == 0:
            break

        tate = [0 for i in range(n)]

        for i in range(n):
            num = 0
            m = map(int, input().split())
            hoge = deepcopy(m)

            tate = [x + y for (x, y) in zip(tate, hoge)]

            for j in m:
                print("{:5}".format(j), end='')
                num += j
            print("{:5}".format(num))

        num = 0
        for j in tate:
            print("{:5}".format(j), end='')
            num += j
        print("{:5}".format(num))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7920
#import <Foundation/Foundation.h>
#import <stdarg.h>

@interface StdIO : NSObject
+(NSMutableString*)stringFromStdIn; // 標準入力から NSString を得る
+(void)printf:(NSString*)format, ...; // 標準出力へ出力
@end

@implementation StdIO
+(NSMutableString*)stringFromStdIn
{
    NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
    NSMutableString *result = [NSMutableString string];
    NSData *data = [handle availableData];
    while ([data length] > 0) {
        [result appendString:[[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]];
        data = [handle availableData];
    }
    NSUInteger length = [result length];
    if (length >= 1 && [result characterAtIndex:length-1] == '\n') { // 入力末尾に改行文字があれば削除
        [result deleteCharactersInRange:NSMakeRange(length-1,1)];
    }
    return result;
}
+(void)printf:(NSString*)format, ...
{
    va_list arguments;
    va_start(arguments, format);
    NSString *string = [[[NSString alloc] initWithFormat:format arguments:arguments] autorelease];
    NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
    [fileHandle writeData:[string dataUsingEncoding:NSUTF8StringEncoding]];
    va_end(arguments);
}
@end

@interface NSMutableArray (Extension)
-(id)shift;
@end

@implementation NSMutableArray (Extension)
-(id)shift
{
    if ([self count] > 0) {
        id first = [self objectAtIndex: 0];
        [self removeObjectAtIndex: 0];
        return first;
    } else {
        return nil;
    }
}
@end
int main() {
    @autoreleasepool {
        NSString *S = [StdIO stringFromStdIn];
        NSUInteger length = [S length];
        NSArray *words = @[@"dream", @"erase", @"eraser", @"dreamer"];
        NSMutableArray *candidates = [NSMutableArray arrayWithObject:@0]; // 切断に成功している位置の候補を格納するキュー
        NSNumber *candidate;
        while ((candidate = [candidates shift])) { // 先頭候補を取り出し
            NSUInteger currentIndex = [candidate unsignedIntegerValue]; 
            for (NSString *word in words) {
                NSUInteger size = [word length];
                NSUInteger nextIndex = currentIndex + size;
                if (nextIndex <= length) {
                    NSString *prefix = [S substringWithRange:NSMakeRange(currentIndex, size)];
                    if ([prefix isEqualToString: word]) {
                        if (nextIndex == length) { // ちょうど末尾にたどり着いたら終了
                            [StdIO printf:@"YES"];
                            return 0;
                        } else {
                            [candidates addObject:@(nextIndex)];
                        }
                    }
                }
            }
        }
        [StdIO printf:@"NO"];
    }
    return 0;
}


Measured memory_bytes: 9956
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();
  if (m > n) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  string ret;
  ret += (char)('z' + 1);
  for (int i = 0; i + m <= n; ++i) {
    bool found = false;
    for (int j = 0; j < m; ++j) {
      if (s[i + j] != '?' && s[i + j] != t[j]) {
        found = true;
        break;
      }
    }
    if (found) continue;
    string cur = s;
    for (int j = 0; j < n; ++j) {
      if (j >= i && j < i + m) {
        cur[j] = t[j - i];
      } else {
        cur[j] = s[j] == '?' ? 'a' : s[j];
      }
    }
    ret = min(ret, cur);
  }
  if (ret == "{") ret = "UNRESTORABLE";
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
import string, collections

if __name__ == '__main__':
    n = int(input())

    tables = []
    for _ in range(n):
        line = input()

        table = collections.defaultdict(int)
        for ch in line: table[ch] += 1

        tables.append(table)

    answers = []
    for ch in string.ascii_lowercase:
        x = min(table[ch] for table in tables)
        answers.extend(ch for _ in range(x))

    print(''.join(answers))


Measured memory_bytes: 3772
ary = []
ARGF.each do |line|
  m, f, r = line.split.map(&:to_i)
  break if (m + f + r) == -3
  sum = m+f
  if m < 0 || f < 0
    ary << "F"
  elsif sum >= 80
    ary << "A"
  elsif sum >= 65 && sum < 80
    ary << "B"
  elsif sum >= 50 && sum < 65
    ary << "C"
  elsif r >= 50
    ary << "C"
  elsif sum >= 30 && sum < 50
    ary << "D"
  else
    ary << "F"
  end
end

puts ary

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, l, r;
  while (cin >> n >> l >> r, n) {
    vector<int> a(n);
    for (auto&& e : a) {
      cin >> e;
    }
    int res = 0;
    for (int x = l; x <= r; ++x) {
      int mi = n;
      for (int i = 0; i < n; ++i) {
        if (x % a[i] == 0) {
          mi = i;
          break;
        }
      }
      if (mi == n) {
        res += n % 2 == 0;
      } else {
        res += mi % 2 == 0;
      }
    }
    cout << res << '\n';
  }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  ll n, k;
  cin >> n >> k;
  vector<vi> g(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  combination c(1e6);
  vector<mint> fact(1e6, 1);
  rep2(i, 1, 1e6) fact[i] = fact[i - 1] * i;
  ll m = k;
  mint ans = m;
  stack<int> st;
  vb seen(n, false);
  st.push(0);
  seen[0] = true;
  while(!st.empty()) {
    if(m > k - 2) m--;
    int i = st.top();
    st.pop();
    ll s = g[i].size() - k + m + 1;
    ans *= c(m, s) * fact[s];
    for(auto v : g[i]) {
      if(seen[v]) continue;
      seen[v] = true;
      st.push(v);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 30072
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n; cin >> n;
  int a[2];
  cin >> a[0] >> a[1];
  int t = 0;
  while(true){
    if(t % 2 == 0){
      if(a[0]+1 != a[1]) a[0]++;
      else a[0]--;
    }else{
      if(a[0] != a[1]-1) a[1]--;
      else a[1]++;
    }
    t++;
    if(a[0] <= 0){
      cout << "Borys" << endl;
      break;
    }
    if(a[1] > n){
      cout << "Alice" << endl;
      break;
    }
  }

  return 0;
}



//


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
ll MOD = 1000000007;
ll INF =1<<30;



int main(){
    ll a,b,c,k;
    cin >> a>>b>>c>>k;
    if(k%2==0) cout <<a-b<<endl;
    else cout << b-a <<endl;
}

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

int a,b,c,d,e;
    cin >> a >>b >>c >>d >>e;
    if(a<40) a=40;
    if(b<40) b=40;
    if(c<40) c=40;
    if(d<40) d=40;
    if(e<40) e=40;
    cout <<(a+b+c+d+e)/5 <<endl;



return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,a,n) for(int i=a;i<n;i++)
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}

  bool operator < (const Point &p) const{
    return x!=p.x?x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
  }
};
typedef Point vect;
struct seg{Point p1,p2;};
double norm(Point p){return p.x*p.x+p.y*p.y;}
double abs(Point p){return sqrt(norm(p));}
double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}
double cross(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}
int CCW(Point p0,Point p1,Point p2){
  Point a=p1-p0;
  Point b=p2-p0;
  if(cross(a,b)>EPS)return 1;
  if(cross(a,b)<-EPS)return -1;
  if(dot(a,b)<-EPS)return 2;
  if(norm(a)<norm(b))return -2;
  return 0;
}
double getDistancePP(Point a,Point b){
  return abs(a-b);
}
double getDistanceLP(seg l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}
double getDistanceSP(seg s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}
bool intersect(Point p1,Point p2,Point p3,Point p4){
  return(CCW(p1,p2,p3)*CCW(p1,p2,p4)<=0&&CCW(p3,p4,p1)*CCW(p3,p4,p2)<=0);
}
bool intersect(seg s1,seg s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}
double getDistance(seg s1,seg s2){
  if(intersect(s1,s2))return 0.0;
  return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),
    min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}
int main(){
  double a,b,c,d;
  int n,ve,al;
  while(cin>>n>>ve>>al,n){
    Point p[n][5];
    seg D[n][5];
    r(i,n){
      scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
      r(j,5){
        p[i][j].x=a-d*sin(M_PI/180*(72*j+c));
        p[i][j].y=b+d*cos(M_PI/180*(72*j+c));
      }
      D[i][0].p1=p[i][0];D[i][0].p2=p[i][2];
      D[i][1].p1=p[i][1];D[i][1].p2=p[i][3];
      D[i][2].p1=p[i][2];D[i][2].p2=p[i][4];
      D[i][3].p1=p[i][3];D[i][3].p2=p[i][0];
      D[i][4].p1=p[i][4];D[i][4].p2=p[i][1];
    }
    double w[n][n];
    r(i,n)r(j,n)w[i][j]=i==j?0:1000000000;
    r(i,n)R(j,i+1,n){
      double t=1000000000;
      r(k,5)r(l,5)t=min(t,getDistance(D[i][k],D[j][l]));
      w[i][j]=w[j][i]=t;
    }
    r(k,n)r(i,n)r(j,n)w[i][j]=min(w[i][j],w[i][k]+w[k][j]);
    printf("%.11f\n",w[ve-1][al-1]);
  }
}

Measured memory_bytes: 3684
#include <stdio.h>
 
int main() {
    
    int n, a, azedou = 0;
    
    scanf("%d", &n);
    
    int cont = 0;
    
    while(cont < n) {
        scanf("%d", &a); 
        
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                azedou = 1;
                break;
            }
        }
        
        ++cont;
        
    } if (azedou) {
        printf("DENIED\n");
    } else {
        printf("APPROVED\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
struct fastio{fastio(){std::ios::sync_with_stdio(false);std::cin.tie(nullptr);}}_fast_io_;
template<class T> bool chmin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

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

	int ans = 0;
	int l = 0, r = n - 1;
	while (l < r) {
		while (l < n and s[l] == 'R') l++;
		while (r >= 0 and s[r] == 'W') r--;
		if (r <= l) break;
		if (s[l] == 'W' and s[r] == 'R') ans++;
		std::swap(s[l], s[r]);
	}
	
	std::cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<class T>using vv = vector<vector<T>>;

#define in(v) v; cin >> v;
// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif

int main() {
  int in(K);

  queue<ll> q;
  rep(i, 9)
    q.push(i+1);

  rep(i, K-1) {
    ll p = q.front(); q.pop();
    rep(j, 3) {
      int n = p % 10;
      int next = n + j - 1;
      if (next < 10 && next >= 0 && abs(n - next) <= 1) {
        q.push(p * 10LL + next);
      }
    }
  }
  cout << q.front() << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
//repetition
//------------------------------------------
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;

int main() {
    int a, b;
    cin >> a >> b;
    int r = 0;
    for (int i = a; i <= b; i++) {
        int s = i % 10;          //１桁目
        int t = i / 10000 % 10;  //５桁目(ここは%10がなくてもよい)
        //５桁なので真ん中の桁は無視してよい
        int u = i / 10 % 10;    //２桁目
        int v = i / 1000 % 10;  //４桁目
        if (s == t && u == v) r++;
    }
    cout << r << endl;

}

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

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

int main() {
  int a;
  string S;
  cin>>S;
  //vector<int> a(N+1);
  if(S == "SUN") cout<<7<<endl;
  else if(S == "MON") cout<<6<<endl;
  else if(S == "TUE") cout<<5<<endl;
  else if(S == "WED") cout<<4<<endl;
  else if(S == "THU") cout<<3<<endl;
  else if(S == "FRI") cout<<2<<endl;
  else cout<<1<<endl;
  
  //cout<<count<<endl;
  
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

class UnionFindVerSize():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self._parent = [n for n in range(0, N)]
        # グループのサイズ（個数）
        self._size = [1] * N

    def find_root(self, x):
        """ xの木の根(xがどのグループか)を求める """
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x]) # 縮約
        return self._parent[x]

    def unite(self, x, y):
        """ xとyの属するグループを併合する """
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        """ xが属するグループのサイズ（個数）を返す """
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        """ グループ数を計算して返す """
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans
      
uf = UnionFindVerSize(n)

for _ in range(m):
  a,b = map(int,input().split())
  uf.unite(a-1,b-1)

a = uf.calc_group_num()
print(a-1)

Measured memory_bytes: 75600
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

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

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

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	l, r := readInt(), readInt()

	ans := 2018
	r = min(r, l+2019)
	for i := l; i < r; i++ {
		for j := l + 1; j <= r; j++ {
			mod := (i * j) % 2019
			ans = min(ans, mod)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
   int x,a,b;cin>>x>>a>>b;
   x -= a;
   while(1){
       x-=b;
       if(x<b)break;
   }
   cout<<x;
}



Measured memory_bytes: 256
def resolve():
    N = int(input())
    W = [input() for _ in range(N)]
    used = []
    for i in range(1, N):
        if W[i-1][-1] != W[i][0] or W[i] in used:
            print("No")
            return 
        used.append(W[i-1])
    print("Yes")




if '__main__' == __name__:
    resolve()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
void dfs(int depth,ll x,vector<ll> &num){
  num.push_back(x);
  if(depth == 11) return;
  ll tmp = x % 10;
  for(int i = -1; i < 2; i++){
    if(tmp + i >= 0 && tmp + i < 10) dfs(depth + 1, x * 10 + tmp + i, num); 
  }
}
int main()
{
  int K; cin >> K;
  vector<ll> num;
  FOR(i,1,10)
    dfs(1,i,num);
  sort(ALL(num));
  cout << num.at(K - 1) << endl;
}

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

using namespace std;

typedef pair<int, int> PII;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

#define N 100010

int n, a[N]; 

int main() {
	cin >> n;
	int cur = 1;
	ll S = 0;
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
		int num = (a[i]-1)/cur;
		S += num;
		if (a[i]%cur == 0 && (cur == 1 || a[i] == cur)) cur++;
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define reps(i,o,n) for(int i=o;i<n;++i)
#define eb emplace_back
#define pb push_back

using namespace std;

int fun(int x,int n,int m){
  if(n<m) swap(n,m);
  if(x<n) return x+1;
  if(x<m) return n;
  return n+m-x;
}
typedef pair<int,int> pii;

  int n,m,t;
set<pii> rch,ex,rch2;
void dfs1(int x,int y){
  if(x<0 || x>=n || y<0 || y>=m || rch.count(pii(x,y))) return;
  rch.emplace(x,y);
  if(ex.count(pii(x,y))==0) return;
  reps(i,x-1,x+2)reps(j,y-1,y+2) dfs1(i,j);
}
bool dfs2(int x,int y){
  if(x<0 || x>=n || y<0 || y>=m || rch2.count(pii(x,y))) return 0;
  rch2.emplace(x,y);
  if(rch.count(pii(x,y))){
    return 1;
  }
  if(ex.count(pii(x,y))==0) return 0;
  reps(i,x-1,x+2)reps(j,y-1,y+2) if(dfs2(i,j)) return 1;
  return 0;
}

int main(){
  cin>>n>>m>>t;
  rep(i,t){
    int x,y;
    cin>>x>>y;
    ex.emplace(x,y);
  }
  reps(i,1,m) dfs1(0,i);
  reps(i,1,n-1) dfs1(i,m-1);
  int re=2;
  rep(i,m-1){
    if(rch.count(pii(n-1,i)) && ex.count(pii(n-1,i))){
      cout<<0<<endl;
      return 0;
    }
    if(dfs2(n-1,i)) re=1;
  }
  reps(i,1,n-1){
    if(rch.count(pii(i,0)) && ex.count(pii(i,0))){
      cout<<0<<endl;
      return 0;
    }
    if(dfs2(i,0)) re=1;
  }
  cout<<re<<endl;
  
  return 0;
}

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

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

int main() 
{
  int N; cin >>N;
  int min = 100000;
  int Sum;
  
  for (int i=1; i<N; i++) {
    Sum = kakuinowa(i) + kakuinowa(N-i);
    if (Sum<min) min = Sum;
    
  }
  cout << min << endl;
}

Measured memory_bytes: 256
k=gets.to_i
l=[0]
z=1
r=[]
while k>0
  if l==[9]*z
    l=[1]+[0]*z
    r=[-1]+[0]*(z-1)
    z+=1
  else
    f=false
    -1.downto(-z+1) do |i|
      if l[i-1]==9&&r[i]<0||l[i-1]<9&&r[i]<1
        r[i]+=1
        l[i]+=1
        (i+1).upto(-1) do |j|
          if l[j-1]==0
            r[j]=0
            l[j]=l[j-1]
          else
            r[j]=-1
            l[j]=l[j-1]-1
          end
        end
        f=true
        break
      end
    end
    if !f
      l[0]+=1
      (-z+1).upto(-1) do |j|
        if l[j-1]==0
          r[j]=0
          l[j]=l[j-1]
        else
          r[j]=-1
          l[j]=l[j-1]-1
        end
      end
    end
  end
  k-=1
end
puts l.join


Measured memory_bytes: 3836
function Main(s){
	s=s.split(/\n|\s/);
	s[0]|=0;
	s[1]|=0;
	
	var ans=Math.ceil(s[0]/(s[1]-1));
	if(s[1]==2){ans=s[0]-1;}
	else if((s[0]%(s[1]-1))==1){ans--;}
	
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28488
#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, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
  int n;
  cin >> n;
  vector<string>a(n);
  vector<ll>b;
  set<string>ans;
  ll cnt=0;
  rep(i, 0, n)cin >> a[i],sort(a[i].begin(),a[i].end());
  sort(a.begin(),a.end());
  b.push_back(1);
  rep(i, 1, n){
      if(a[i]==a[i-1])b.back()++;
      else b.push_back(1);
  }
  sort(b.begin(),b.end(),greater<ll>());
  rep(i, 0, b.size()){
      if(b[i]>1)cnt += (b[i]*(b[i]-1)/2);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 8444
#![allow(unused)]

use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let (coin_a, coin_b, omocha) = {
        let v = parse_vec::<i32>();
        (v[0], v[1], v[2])
    };

    if coin_a + coin_b >= omocha {
        println!("Yes");
    } else {
        println!("No");
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352