akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 10000
#include<cstring>
using namespace std;
char a[N],b[N];
int n,ans,u,v;
struct node{
	int x,y;
}q[N];
void getans(int x){
	if (ans>x||ans<0)ans=x;
}
int dis(int x,int y){
	if (x>y)return n-x+y;
	return y-x;
}
int dis1(int x,int y){
	if (x>=y)return x-y;
	return x+n-y;
}
bool cmp(const node&a,const node&b){
	return a.x>b.x||(a.x==b.x&&a.y>b.y);
}
void work(int x){
	u=v=0;
	int l=n,r=1,tot=0;
	while (!b[l])l--;
	while (!b[r])r++;
	for (int i=1;i<=n;i++){
		if (b[i])l=i;
		if (a[i]!=b[i]){
			u++;
			if (x<dis1(r,i))q[++tot].x=dis(l,i),q[tot].y=dis1(r,i)-x;
		}
		if (i==r)r=r%n+1;
		while (!b[r])r=r%n+1;
	}
	if (!tot)return;
	sort(q+1,q+tot+1,cmp);
	int y=0,s=q[1].x*2;
	for (int i=1;i<=tot;i++){
		s=min(s,(q[i].x+y)*2);
		y=max(y,q[i].y);
	}
	s=min(s,y*2);
	u+=s;
}
int main(){
	scanf(" %s",a+1);
	scanf(" %s",b+1);
	n=strlen(a+1);
	int x=0,y=0;
	for (int i=1;i<=n;i++){
		a[i]-='0',b[i]-='0';
		x+=a[i];
		y+=b[i];
	}
	if (!y&&x){
		printf("-1");
		return 0;
	}else{
		if (!y&&!x){
			printf("0");
			return 0;
		}
	}
	ans=-1;
	for (int i=0;i<n;i++){
		work(i);
		getans(u+i);
		for (int j=0;j<n;j++)a[j]=a[j+1];
		a[n]=a[0];
	}
	for (int i=1;i<=n/2;i++)
		swap(a[i],a[n-i+1]),swap(b[i],b[n-i+1]);
	for (int i=0;i<n;i++){
		work(i);
		getans(u+i);
		for (int j=0;j<n;j++)a[j]=a[j+1];
		a[n]=a[0];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<vector<bool>> F(N, vector<bool>(10));
	vector<vector<int>> P(N, vector<int>(11));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			bool b;
			cin >> b;
			F.at(i).at(j) = b;
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 10; j++) {
			int n;
			cin >> n;
			P.at(i).at(j) = n;
		}
	}

	int ans = INT_MIN;
	vector<int> c(N);

	for (int bit = 1; bit < (1 << 10); bit++) {
		//cout << bitset<10>(bit) << endl;
		for (int i = 0; i < N; i++) c.at(i) = 0;

		for (int i = 0; i < 10; i++) {
			if (bit & (1 << i)) {
				for (int j = 0; j < N; j++) {
					if (F.at(j).at(i)) c.at(j)++;
				}
			}
		}
		//for (int i = 0; i < N; i++) cout << c.at(i) << endl;

		int n = 0;
		for (int i = 0; i < N; i++) {
			//cout << P.at(i).at(c.at(i)) << endl;
			n += P.at(i).at(c.at(i));
		}
		//cout << "n:" << n << endl;

		ans = max(ans, n);
		//cout << ans << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3664
import Control.Applicative
import Control.Monad

helper :: (Int, Int) -> Int -> IO (Int, Int)
helper (x, y) _ = do
    z <- readLn
    return (min x z, max y (z - x))

solve :: Int -> Int -> Int -> IO Int
solve x y n = snd <$> foldM helper (min x y, y - x) [1 .. n - 2]

main :: IO ()
main = do
    n <- readLn
    x <- readLn
    y <- readLn
    solve x y n >>= print

Measured memory_bytes: 130052
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    int n, d;
    cin >> n >> d;
    vll x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    two_sat ts(n);
    rep(i, n) rep(j, n) {
        if(i != j) {
            if(abs(x[i]-y[j]) < d) ts.add_clause(i, false, j, true);
        }
        if(i < j) {
            if(abs(x[i]-x[j]) < d) ts.add_clause(i, false, j, false);
            if(abs(y[i]-y[j]) < d) ts.add_clause(i, true, j, true);
        }
    }
    bool ans = ts.satisfiable();
    cout << (ans ? "Yes" : "No") << endl;
    if(!ans) return;
    auto vb = ts.answer();
    for(int i = 0; i < n; ++i) {
        if(vb[i]) cout << x[i] << endl;
        else cout << y[i] << endl;
    }
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int N;
  bool flag = false;

  cin >> N;

  for(int i = 0; i <= N/4; i++){
    for(int j = 0; j <= N/7; j++){
      if(N == i*4 + j*7) flag = true;
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

	return 0;
}


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

using namespace std;

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    int b[30];
    for (int i = 1; i <= m; i++){
        cin >> b[i];
    }
    int res = 0;
    for (int i = 1; i <= n; i++){
        int sum = c;
        for (int j = 1; j <= m; j++){
            int x;
            cin >> x;
            sum += x * b[j];
        }
        if (sum > 0){
            res++;
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    print('Good' if all([S[i] != S[i+1] for i in range(len(S)-1)]) else 'Bad')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3892
def f():
    return raw_input()
def f2():
    return raw_input().split()

dic = {}
n = int(f())
for i in range(n):
    c1, c2 = f2()
    if c1 == 'insert':
        dic[c2] = 0
    elif c1 == 'find':
        if dic.has_key(c2):
            print 'yes'
        else:
            print 'no'

Measured memory_bytes: 62736
n = int(input())
AC = 0
WA = 0
TLE = 0
RE  = 0
for i in range(n):
    s = input()
    if s == "AC":
        AC += 1
    elif s == "WA":
        WA += 1
    elif s == "TLE":
        TLE += 1
    else:
        RE += 1
    
print("AC x",AC)
print("WA x",WA)
print("TLE x",TLE)
print("RE x",RE)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int n;
ll am=1000,x=0,b;
cin>>n;
ll a[n];
FOR(i,n)
{
	cin>>a[i];
}
FOR(i,n-1)
{
  if(a[i+1]>a[i])
  {
  	am+=((am/a[i])*(a[i+1]-a[i]));
  }
}
cout<<am<<endl;
return  0;
}






Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#define rep(i,n) for(int i = 0; i <n; ++i)
using namespace std;
typedef long long ll;


int main() {

	ll N,MIN=0,MAX=0;
	cin>>N;
	int A[N+10];
	for (int i = 1; i <=N; ++i)
	{
		cin>>A[i];
	}

	ll money=1000;
	MIN=A[1];
	MAX=A[1];
	ll MIN_day,MAX_day,num=0;
	for (int i = 1; i < N; ++i)
	{
		MIN=min(A[i],A[i+1]);
		MAX=max(A[i],A[i+1]);
		if (A[i]<A[i+1])
		{
			MIN_day=i;
			MAX_day=i+1;
		}
		else{
			MAX_day=i;
			MIN_day=i+1;
		}
		if (MAX_day>MIN_day && money/MIN!=0){
			money=money+(money/MIN)*(MAX-MIN);//買えるだけ買う 所持金÷底値の商が買える数
			num+=money/MIN;
		}


	}
	cout<<money<<endl;
return 0;
}



Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

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

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	string res = "Yes";
	if (abs(a - b) > d || abs(b - c) > d)
	{
		res = "No";
	}

	if (abs(a - c) <= d)
	{
		res = "Yes";
	}

	println(res);
}

Measured memory_bytes: 256
//package AtCoder_163;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader  br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        long d=Long.parseLong(st.nextToken());
        int n=Integer.parseInt(st.nextToken());
        long sum=0;
        st=new StringTokenizer(br.readLine());
        for(int i=1;i<=n;i++){
            sum+=Integer.parseInt(st.nextToken());
        }
        if(sum<=d){
            System.out.println(d-sum);
        }
        else{
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 33788
N = int(input())
mod = int(1e9) + 7
C = list(map(int, input().split()))
C.sort(reverse=True)
def doubling(n, m):
  y = 1
  base = n
  while m != 0:
    if m % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    m //= 2
  return y
b = 1
if N == 1:
  L, R = 0, 1
else:
  b = doubling(2, N-2)
  L, R = b, (2 * b) % mod
S1 = 0
S2 = 0
for i in range(N):
  S1 += (i * C[i]) % mod
  S1 %= mod
  S2 += C[i]
  S2 %= mod
print((doubling(2, N) * (S1 * L + S2 * R)) % mod)

Measured memory_bytes: 25768
N = int(input())
h_list = list(map(int,input().split()))

costs = [None for _ in range(N)]

for i in range(N):
    if i == 0:
        cost = 0
    elif i == 1:
        cost = costs[i-1] + abs(h_list[i-1] - h_list[i])
    else:
        cost = min(
            costs[i-1] + abs(h_list[i-1] - h_list[i]),
            costs[i-2] + abs(h_list[i-2] - h_list[i])
        )
    costs[i] = cost

print(costs[-1])

Measured memory_bytes: 52984
// +-x


#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>

using namespace std;

int main()
{
    int A,B;

    cin >> A >> B;
    int x = max(A+B,max(A-B,A*B));
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    if s[i:i+2]=='AC':
        t[i+1]=t[i]+1
    else:
        t[i+1]=t[i]

for i in range(q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])







Measured memory_bytes: 6188
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
#include <iomanip>
#include <sstream>
#include <unordered_map>

using namespace std;
typedef long long ll;


ll ans, mx, mn, flag, sum, cnt;

int main(){
	string s;
	cin>>s;
	string t=s;
	reverse(s.begin(),s.end());
	for(ll i=0; i<s.size(); i++){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans/2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c[30];
int main()
{
    string s;
    cin>>s;
    int i,f=0;
    for(i=0;i<s.size();i++)
        c[s[i]-97]++;
    for(int j=0;j<26;j++)
    {
        if(c[j]%2!=0)
        {
            f=1;
            break;
        }
    }
    if(f==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n, k;
    while(cin>>n>>k, n){
        vector<ll> a(n+10, 0);
        for(int i=1; i<=n; i++){
            cin>>a[i];
            a[i]+=a[i-1];
        }

        ll ans=-INF;
        for(int i=1; i+k-1<=n; i++){
            chmax(ans, a[i+k-1]-a[i-1]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3576
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int N = in.nextInt();
        int X = in.nextInt();
        int ans = 1;
        int preD = 0;
        for (int i = 0; i < N; i++) {
            int l = in.nextInt();
            int d = preD + l;

            if (d <= X) {
                ans++;
            }

            preD = d;
        }
        out.println(ans);
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

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

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

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

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 22356
#include<stdio.h>

int main(void)
{
  char S[11];//'\0'が入る
  scanf("%s",S );// Sが文字列の先頭のアドレスを渡す
  int i = 0;
  int count = 0;
  int max = 0;
  for(i = 0; S[i] != '\0'; i++)
  {
    if(S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C')
    {
      count++;
      if(count > max) max = count;
    }
    else
    {
      count = 0;
    }
    
    
  }
  printf("%d",max);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define MAX 200000
#define INF 2000000000

int compare_int(const void *a,const void *b){
	return *(int*)a-*(int*)b;
}

int main(){
	int n,m;
	int a[MAX+1];
	int b[MAX+1];
	int j=0,k=0;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	a[n]=INF;
	
	qsort(a,n,sizeof(int),compare_int);
	
	scanf("%d",&m);
	for(int i=0;i<m;i++)
		scanf("%d",&b[i]);
	b[m]=INF;
	
	qsort(b,m,sizeof(int),compare_int);
	
	for(int i=0;i<n+m;i++){
		if(a[j]==INF && b[k]==INF)break;
	
		if(a[j] < b[k])
			printf("%d\n",a[j++]);

		else if(a[j] > b[k])
			printf("%d\n",b[k++]);

		else if(a[j]==b[k]){
			printf("%d\n",a[j]);
			int temp=a[j];
			while(a[j]==temp)j++;
			while(b[k]==temp)k++;
		}
	}
	
	return 0;
	
}


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

int main(){
	int i[10];
	for(int j=0;j<=9;j++){
		cin >> i[j];
	}
	int h[3] ={0,0,0};
	for(int j =0;j<=9;j++){
		if(h[0]<=i[j]){
			h[2]=h[1];
			h[1]=h[0];
			h[0]=i[j];
		}
		else if(h[1]<=i[j]){
			h[2]=h[1];
			h[1]=i[j];
		}
		else if(h[2]<=i[j]){
			h[2]=i[j];
		}
	}
	cout<<h[0]<<"\n";
	cout<<h[1]<<"\n";
	cout<<h[2]<<"\n";
	return 0;

}

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

int main()
{
  int a, b;
  cin >> a >> b;
  
  string numStr = to_string(a) + to_string(b);
  int num = stoi(numStr);
  
  double sqrtNum = sqrt((double)num);
  
  if (sqrtNum == ceil(sqrtNum)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
C = [] 

def calc(L):
    p, q, r = 0, 0, 0
    for k in range(M):
        p += L[k][0]
        q += L[k][1]
        r += L[k][2]
    return abs(p) + abs(q) + abs(r)

for k in range(N):
    s, t, u = map(int,input().split())
    C.append([s,t,u])

D = sorted(C, key = lambda x: -(x[0]+x[1]+x[2]))
E = sorted(C, key = lambda x: -(x[0]-x[1]+x[2]))
F = sorted(C, key = lambda x: -(x[0]+x[1]-x[2]))
G = sorted(C, key = lambda x: -(-x[0]+x[1]+x[2]))
H = sorted(C, key = lambda x: -(-x[0]-x[1]+x[2]))
I = sorted(C, key = lambda x: -(-x[0]+x[1]-x[2]))
J = sorted(C, key = lambda x: -(x[0]-x[1]-x[2]))
K = sorted(C, key = lambda x: -(-x[0]-x[1]-x[2]))

ans = max(calc(D),calc(E),calc(F),calc(G),calc(H),calc(I),calc(J),calc(K))

print(ans)


Measured memory_bytes: 40688
#include <stdio.h>
#include <stdlib.h>
#define int long long

int ABS(int a){
	return a >= 0 ? a : -a;
}

signed main(){
	int N, i;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * (N + 2));
	int *S = (int *)malloc(sizeof(int) * (N + 2));
	int *T = (int *)malloc(sizeof(int) * (N + 2));
	A[0] = 0;
	A[N + 1] = 0;
	for(i = 1; i <= N; i++){
		scanf("%lld", &A[i]);
	}
	S[0] = 0;
	for(i = 1; i <= N; i++){
		S[i] = S[i - 1] + ABS(A[i] - A[i - 1]);
	}
	T[N + 1] = 0;
	for(i = N; i > 0; i--){
		T[i] = T[i + 1] + ABS(A[i] - A[i + 1]);
	}
/*	for(i = 1; i <= N; i++){
		printf("S[%lld] = %lld\n", i, S[i]);
	}
	for(i = 1; i <= N; i++){
		printf("T[%lld] = %lld\n", i, T[i]);
	}
*/	for(i = 1; i <= N; i++){
		printf("%lld\n", S[i - 1] + ABS(A[i - 1] - A[i + 1]) + T[i + 1]);
	}
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;

int main(){
	int l, r;
	cin >> l >> r;

	if (r - l>1e4){
		cout << 0 << endl;
		return 0;
	}

	while (true){
		if (l > 2019){
			l -= 2019;
		}
		else{
			break;
		}
	}

	while (true){
		if (r > 2019){
			r -= 2019;
		}
		else{
			break;
		}
	}

	int saisyo = 0;
	bool first = true;

	for (int i = l; i < r; i++){
		for (int j = i+1; j <= r; j++){
			int mod = (i*j) % 2019;

			if (first){
				saisyo = mod;
				first = false;
			}
			else{
				if (saisyo > mod){
					saisyo = mod;
				}
			}

			//cout << mod << endl;
		}
	}

	//int nd[10][10];

	//for (int i =0; i<n; i++){
	//	for (int j =0; j<d; j++){
	//		cin >> nd[i][j];
	//	}
	//}

	//int count = 0;


	//for (int i = 0; i < n; i++){
	//	for (int p = i + 1; p < n; p++){
	//		double kyori = 0;
	//		double kei = 0;
	//		for (int j = 0; j < d; j++){
	//			kei += pow((nd[i][j] - nd[p][j]), 2);

	//			//if (i == n - 1){
	//			//	kei += pow((nd[i][j] - nd[0][j]), 2);
	//			//}
	//			//else{
	//			//	kei += pow((nd[i][j] - nd[i + 1][j]), 2);
	//			//}
	//		}
	//		kyori = sqrt(kei);
	//		//cout << kyori << endl;
	//		if (ceil(kyori) != floor(kyori)) {
	//			
	//		}
	//		else {
	//			++count;
	//		}
	//	}
	//}

	cout << saisyo << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
extern crate core;

use std::fmt;
use std::collections::VecDeque;
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}

fn main() {
    let_all!(n: usize);
    let mut cell = Vec::<i32>::with_capacity(n);
    for _ in 0 .. n {
        let_all!(p: i32);
        cell.push(p);
    }
    let mut rev_edge = vec![Vec::<usize>::new(); n];
    for i in 0 .. n {
        match cell[i] {
            0 => for j in 1 .. 7 {
                if i + j < n {
                    rev_edge[(i + j) as usize].push(i);
                }
            },
            diff => rev_edge[(i as i32 + diff) as usize].push(i),
        }
    }
    let mut min_count = vec![-1; n];
    min_count[n - 1] = 0;
    let mut queue = VecDeque::<usize>::new();
    queue.push_back(n - 1);
    while let Some(c) = queue.pop_front() {
        for &prev in &rev_edge[c] {
            if min_count[prev] == -1 {
                if cell[prev] == 0 {
                    min_count[prev] = min_count[c] + 1;
                    queue.push_back(prev);
                }else {
                    min_count[prev] = min_count[c];
                    queue.push_front(prev);
                }
            }
        }
    }
    println!("{}", min_count[0]);
}


Measured memory_bytes: 13124
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    // 整数の入力
    string s;
    cin >> s ;
    // 出力
    int count = 0;
    for(int i = 0; i<3; i++){
	if(s[i] == 'o'){
	    count += 1;
	}
    }
    int rmn = 700;
    int tpg = 100*count;
    int val = rmn + tpg; 
    cout << val << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

int sum[100010];

int main(){
    int n,m,i,j,k;

    while( scanf("%d %d",&n,&m) != EOF ){
        rep(i,n-1){
            int t; scanf("%d",&t);
            sum[i+1] = sum[i] + t;
        }
        int now = 0;
        int res = 0;
        rep(i,m){
            scanf("%d",&k);
            res += abs(sum[now] - sum[now+k]);
            res %= 100000;
            now += k;
        }
        printf("%d\n",res);
    }
    return 0;
}

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

int N, M;
const int MAX_N = 100000;
int H[MAX_N + 1];
bool is_good[MAX_N + 1];
int ans = 0;

int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  fill(is_good, is_good + N, true);

  for (int j = 0; j < M; j++)
  {
    int a, b;
    cin >> a >> b;
    if (H[a - 1] <= H[b - 1]) {
      is_good[a - 1] = false;
    } 
    if (H[a - 1] >= H[b - 1]) {
      is_good[b - 1] = false;
    }
  }
  for (int k = 0; k < N; k++) {
    if (is_good[k]) {
      ans++;
    }
  }

  printf("%d", ans);

  return 0;
}

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll l, r;
	cin >> l >> r;
	int ans = 2019;
	if (r - l > 2019) {
		cout << 0;
	}
	else {
		l %= 2019;
		r %= 2019;
		if (l > r)
			swap(l, r);
		for (int i = l; i <= r; i++) {
			for (int j = l; j <= r; j++) {
				if (i != j)
					ans = min(ans, i * j % 2019);
			}
		}
		cout << ans;
	}
}

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

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

	int ans = 1;
	for(int i = 2; i < x; i++){
		int tmp = i * i;
		while(true){
			if(tmp > x)
				break;
			if(ans < tmp)
				ans = tmp;
			tmp *= i;
		}
	}


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define ln() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007; // 998244353 , 1000000007
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
	bool operator>(const edge& right) const {
		return cost > right.cost;
	}
};

struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
	bool operator>(const point& right) const {
		return x == right.x ? y > right.y : x > right.x;
	}
};

ll bisect_left(ll arr[], ll arr_size, ll key) {
	return distance(arr, lower_bound(arr, arr + arr_size, key));
}

ll bisect_left(vector<ll> vc, ll key) {
	return lower_bound(vc.begin(), vc.end(), key) - vc.begin();
}

ll pow_mod(ll a, ll x) {
	if (x == 0) return 1;
	if (x == 1) return a % MOD;
	ll ret = pow_mod(a, x / 2);
	if (x % 2 == 0) ret = (ret*ret) % MOD;
	else ret = ((a % MOD) * ((ret*ret) % MOD)) % MOD;
	return ret;
}

void build_mod_fact(ll arr[], ll n) {
	arr[0] = 1;
	repi(i, 1, n + 1) {
		arr[i] = (arr[i - 1] * i) % MOD;
	}
	return;
}

void build_mod_fact_inv(ll arr_fact[], ll arr_fact_inv[], ll n) {
	arr_fact_inv[n] = pow_mod(arr_fact[n], MOD - 2);
	repd(i, n - 1, -1) {
		arr_fact_inv[i] = (arr_fact_inv[i + 1] * (i + 1)) % MOD;
	}
	return;
}

ll comb_mod(ll n, ll r, ll arr_fact[], ll arr_fact_inv[]) {
	return (((arr_fact[n] * arr_fact_inv[n - r]) % MOD) * arr_fact_inv[r]) % MOD;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}


///////////////////////////////////////////////////////////////////////////////////////

ll n, x, ans;
ll sBP[100], sP[100];

void calc_s(ll N) {
	sBP[0] = 1, sP[0] = 1;
	repi(i, 1, N + 1) {
		sBP[i] = sBP[i - 1] * 2 + 3;
		sP[i] = sP[i - 1] * 2 + 1;
	}
	return;
}

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

	calc_s(n);
	repd(i, n, -1) {
		if (sBP[i] == x) {
			ans += sP[i];
			x -= sBP[i];
		}
		else if (sBP[i] / 2 < x) {
			ans += sP[i - 1] + 1;
			x -= sBP[i - 1] + 2;
		}
		else {
			x -= 1;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s = input()
l = len(s)
ans = [1] * l
for i in range(l):
    if s[i] == 'R' and s[i+1] == 'R':
        ans[i+2] += ans[i]
        ans[i] = 0
for i in range(l-1,0,-1):
    if s[i-1] == 'L' and s[i] == 'L':
        ans[i-2] += ans[i]
        ans[i] = 0
print(*ans)


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

int main()
{
	int N;cin >> N;
	vector<int> order(N);
	for (int i=0;i<N;i++) order[i]=i+1;
	vector<int> pre(N),now(N);
	for (int i=0;i<N;i++) cin >> pre[i];
	for (int i=0;i<N;i++) cin >> now[i];
	int first=0,second=0,cnt=0;;
	do
	{
		cnt++;
		bool can1=true;
		bool can2=true;
		for (int i=0;i<N;i++)
		{
			if (order[i]!=pre[i]) can1=false;
			if (order[i]!=now[i]) can2=false;
		}
		if (can1) first=cnt;
		if (can2) second=cnt;
	} while (next_permutation(order.begin(),order.end()));
	cout << abs(second-first) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    int num; int rem;
    cin >> num >> rem;
    vector<int> arr(num);
    cins(arr);

    int odd = 0;
    for(int i = 0; i < num; i++) {
        if(arr[i]%2) {odd=1; break;}
    }
    if(!odd) {
        cout << (rem ? 0 : (1LL<<num));
        return 0;
    }
    // If contains odd
    cout << (1LL<<(num-1)) << endl;
    return 0;
}

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

int main(){
	long long int q,h,s,d,n;
	cin>>q>>h>>s>>d;
	cin>>n;

	long long int ans = (n/2)*min(8*q,min(4*h,min(2*s,d)));
	ans += (n%2)*min(4*q,min(2*h,s));

	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>
using namespace std;

int main(void){
    int a, b, c;

    cin >> a >> b >> c;
    int n = a - b;
    int ans = c - n;
    if(ans <= 0){
        ans = 0;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define rmin(r, x) r = min(r, x)
#define rmax(r, x) r = max(r, x)
#define ends ' '
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int maxm = 1e5 + 10;

ll n, m, x, s[maxm];
int in[maxm];

int main(void) {
    fastio;
    cin >> n >> x >> m;
    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        if(in[x]) {
            int j = i - in[x];
            ans += (n - i + 1) / j * (s[i - 1] - s[in[x] - 1]);
            ans += s[in[x] + (n - i + 1) % j - 1] - s[in[x] - 1];
            cout << ans;
            return 0;
        }
        in[x] = i;
        ans += x;
        s[i] = s[i - 1] + x;
        x = x * x % m;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4412
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
   string  s;
   int ans = 0;
   cin >> s;
   for(int i =0; i< s.size()-1 ; i++){
       if(s[i] == s[i+1]){
           if(s[i]=='1') {s[i+1] = '0';}
           else {s[i+1] = '1';}
           ans++; 
        }
           
}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int64_t b004()
{
    size_t n;
    int64_t x;
    cin >> n >> x;
    vector<int64_t> a(n);
    cin >> a;

    for(size_t i = 0; i < n; ++ i)
        a.push_back(a[i]);

    int64_t out = numeric_limits<int64_t>::max();

    for(size_t k = 0; k < n; ++ k)
    {
        deque<size_t> idx;
        for(size_t i = n - k; i < n; ++i)
        {
            while(!idx.empty() && a[i] < a[idx.back()])
                idx.pop_back();

            idx.push_back(i);
        }

        int64_t acc = x * (int64_t) k;

        for(size_t i = n; i < a.size(); ++i)
        {
            while(!idx.empty() && a[i] < a[idx.back()])
                idx.pop_back();

            idx.push_back(i);

            while(idx.front() + k < i)
                idx.pop_front();

            acc += a[idx.front()];
        }

        out = min(acc, out);
    }

    return out;
}

int main(const int argc, char * argv [])
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << b004();

    return EXIT_SUCCESS;
}


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

int main() {
    int N; cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++){
        cin >> v[i];
        v[i]--;
    }

    int ans = 0;
    for (int i = 0; i < N-1; i++)
    {
        if(i==v[i] && i+1==v[i+1]){
            swap(v[i], v[i+1]);
            ans++;
        } 
    }
    
    for (int i = 0; i < N; i++)
    {
        if(i==v[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double ans=w*h/2.0;

    if(x==w/2&&y==h/2){
        printf("%.9f 1",ans);
    }else{
        printf("%.9f 0",ans);

    }



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(int argc, const char** argv) {
    int N,i,j,k;
    cin>>N;
    vector<int> dp(3);
    for(i=0;i<N;i++){
        vector<int> new_dp(3,0);
        vector<int> c(3);

        for(j=0;j<3;j++)
            cin>>c[j];
        
        for(j=0;j<3;j++){
            for(k=0;k<3;k++){
                if(j!=k){
                    new_dp[k] = max(new_dp[k],dp[j]+c[k]);
                }
            }
        }
        dp = new_dp;  
    }
    cout<<max({dp[0],dp[1],dp[2]});
    return 0;
}

Measured memory_bytes: 256
N,Q=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(N-1)]
px=[list(map(int,input().split())) for i in range(Q)]

data=[[] for i in range(N+1)]
for a,b in ab:
    data[a].append(b)
    data[b].append(a)

count=[0]*(N+1)
for p,x in px:
    count[p]+=x

#dfsをする。
que=[1]

#一度通った頂点は、1にする。
flag=[0]*(N+1)
flag[1]=1
while que:
    u=que.pop()
    for v in data[u]:
        if flag[v]==0:
            flag[v]=1
            count[v]+=count[u]
            que.append(v)

print(*count[1:])

Measured memory_bytes: 125088
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 100005

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


int dp[ARRAY_MAX];//ボタンiまで見た時に地点jにいるときの最小コスト


namespace mp = boost::multiprecision;

int main() {


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

	int n;
	cin >> n;
	
	mp::cpp_int x = 1;
	
	//連続するn個の整数で合成数なものはn!+2～n!+n


	for (int i = 1; i <= n+1; i++) {

		x *= i;

	}
	x += 2;

	cout << x << endl;
	for (int i = 0; i < n; i++)
	{
		cout << i + 2 << endl;
	}

	   	
	return 0;
}


Measured memory_bytes: 3268
#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(){
    string w;
    bool hantei=true;
    cin >> w;
    map<char,int>a;
    rep(i,w.size()){
        a[w[i]] ++ ;
    }
    
    for(auto b: a){
        auto c = b.second;
        
        if(c%2 != 0)hantei =false;
    }
    if(hantei) cout << "Yes" <<endl;
    else        cout << "No" <<endl;
}

Measured memory_bytes: 256
n=int(input())
s=str(input())
d=True

if len(s)%2==0:
  for i in range(len(s)//2):
    if s[i]!=s[len(s)//2+i]:
      d=False
else:
  d=False
  
if d:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9148
N=int(input())

print(0,flush=True)
init=input()
if init=="Vacant":
    exit()
print(N-1,flush=True)
ende=input()
if ende=="Vacant":
    exit()

cnt=2
s=0
e=N-1

while cnt<=19:

    c= (s+e)//2
    leng_sc = c-s
    leng_ce = e-c
    print(c,flush=True)
    tmp=input()
    if tmp=="Vacant":
        exit()
    else:        
        if (leng_sc%2==0 and tmp!=init) or (leng_sc%2==1 and tmp==init):
            e = c
            ende = tmp
        else:
            s = c
            init = tmp

    cnt+=1


Measured memory_bytes: 3660
#include <cstdio>
#include <cassert>
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

typedef long long ll;
const int INF = 100100100;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

int d[100][100];

int n, m;

void wf(const vector<tuple<int, int, int>> &edges) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) d[i][j] = 0;
      else { d[i][j] = INF; }
    }
  }
  for (auto edge : edges) {
    int a, b, c;
    tie(a, b, c) = edge;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
}

bool removable(tuple<int, int, int> &edge) {
  int a, b, c;
  tie(a, b, c) = edge;
  for (int i = 0; i < n; ++i) {
    if (d[i][a] + c == d[b][i]) return false;
  }
  return true;
}

int main() {
  cin >> n >> m;
  vector<tuple<int, int, int>> edges;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    edges.emplace_back(a, b, c);
  }
  wf(edges);
  int ans = 0;
  for (int i = 0; i < m; ++i) { 
    if (removable(edges[i])) ++ans;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
def partition(A, l, r):
    x = A[r - 1]
    i = l - 1
    for j in range(l, r - 1):
        if A[j][1] <= x[1]:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r - 1] = A[r - 1], A[i + 1]
    return i + 1


def quick_sort(A, l, r):
    if r - l > 1:
        q = partition(A, l, r)
        quick_sort(A, l, q)
        quick_sort(A, q, r)


n = int(input())
A = []
for i in range(n):
    a, b = input().split()
    A.append((a, int(b)))
dct0 = {}
for a in A:
    dct0[a[1]] = []
for a in A:
    dct0[a[1]].append(a[0])
quick_sort(A, 0, n)
dct1 = {}
for a in A:
    dct1[a[1]] = []
for a in A:
    dct1[a[1]].append(a[0])
if dct0 == dct1:
    print('Stable')
else:
    print('Not stable')
for a in A:
    print(*a)



Measured memory_bytes: 23656
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cctype>
using namespace std;

char a;int n,b,r;

inline bool Count(){
	for(int i=1;i<=n;++i){
		cin>>a; if(a=='R') ++r; else ++b;
	}return r>b;
}
signed main(){
	return cin>>n,cout<<(Count()?"Yes":"No"),0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;



#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;
struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};
const constexpr ll MOD = 1e9 + 7;


ll extGCD(ll a, ll b, ll& x, ll& y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}
ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}

int main() {
    int N; cin >> N;
    if(N==1){
        cout << "Hello World" << endl;
    }else{
        int a, b; cin >> a >> b;
        cout << a+b << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int BUFFSIZE = 1 << 17;

char buffer[BUFFSIZE];
int pointer = BUFFSIZE;

char Advance() {
    if (pointer == BUFFSIZE) {
        fread(buffer, 1, BUFFSIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0;
    char ch = Advance();
    while (!isdigit(ch))
        ch = Advance();
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer;
}

char color[2][2] = {{'B', 'G'},
                    {'R', 'Y'}};

char Color(int i, int j, int d) {
    return color[(i / d) % 2][(j / d) % 2];
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int n, m, d;
    scanf("%d%d%d", &n, &m, &d);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            int i0 = j + i, j0 = j - i + n;
            char ch = Color(i0, j0, d);
            printf("%c", ch);
            if (j == m - 1)
                printf("\n");
        }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

int main(){
	int n, m, t, a1, a2, a[101], used=0;
	cin >> n >> m >> t;
	used += m;
	
	REP(i,n) cin >> a[i];
	
	for (int i=0; i<n-1; i++){
		used += min(a[i+1]-a[i], 2*m);
	}
	used += min(m, t-a[n-1]);
	cout << t-used << endl;
	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int N; 
cin >> N; 
char C[610][610]; 
for(int i = 0; i < N; i++){
  for(int j = 0; j < N; j++){
cin >> C[i][j]; 
C[i+N][j] = C[i][j];
  }
}
int count = 0; 
for(int K = 0; K < N; K++){
int ans = 1; 
 for(int i = 0; i < N; i++){
  for(int j = i+1; j < N; j++){
 if(C[i+K][j] != C[j+K][i]){
 ans = 0; 
}
}
}
count += ans; 
}
cout << N * count << endl; 
}

Measured memory_bytes: 640
N, L = map(int, input().split())
apples = [L + i for i in range(N)]
if(apples[0]>0 and apples[-1]>0):
    print(sum(apples)-min(apples))
elif(apples[0]<0 and apples[-1]<0):
    print(sum(apples)-max(apples))
else:
    print(sum(apples))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define mp make_pair
const ll inf = 1e18;
const int nax = 2e6 + 7;

using namespace std;
string s;
//int fl1 , fl2;
int main(int argc,char ** argv){
	dhoom;
	ll n , a , b;
	cin >> n >> a >> b;
	cout << (n / (a + b))*a + min(n%(a+b) , a) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

# UnionFind
class UnionFind:
    def __init__(self,n):
        self.n=n
        self.a=[-1]*n
        self.siz=n
    def root_find(self,x):
        if self.a[x]<0:
            return x
        else:
            self.a[x]=self.root_find(self.a[x])
            return self.a[x]
    def unite(self,x,y):
        x=self.root_find(x)
        y=self.root_find(y)
        if x==y:
          return
        elif self.a[x]<self.a[y]:
            self.a[x]+=self.a[y]
            self.a[y]=x
        else:
            self.a[y]+=self.a[x]
            self.a[x]=y
        self.siz-=1
    def root_same(self,x,y):
        return self.root_find(x)==self.root_find(y)

n,q=map(int,input().split())
u=UnionFind(n)
for _ in range(q):
    t,a,b=map(int,input().split())
    if t==0:
        u.unite(a,b)
    else:
        print(u.root_same(a,b)+0)

Measured memory_bytes: 11864