akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = l[0], R = l[1];

        Console.WriteLine(N >= 10 ? R : R + (100 * (10 - N)));
    }
}


Measured memory_bytes: 13268
fun main(){
    val (h,w) = readLine()!!.split(" ").map{it.toInt()}
    val s = MutableList(h){
        readLine()!!.toString().toCharArray()
    }

    val dx = listOf(0, 0, 1, 1, 1, -1, -1, -1)
    val dy = listOf(1, -1, 0, 1, -1, 0, 1, -1)

    for(i in 0 until h){
        for(j in 0 until w) {
            var count = 0
            if (s[i][j] == '.') {
                for(k in 0 .. 7)
                if (
                        (i + dx[k]) in 0 until h &&
                        (j + dy[k]) in 0 until w &&
                        s[i + dx[k]][j + dy[k]] == '#'
                ) {
                    count++
                }
                //println(count)
                s[i][j] = "$count"[0]
            }
        }
    }
    s.forEach{
        it.forEach { char ->
            print(char)
        }
        println("")
    }

}


Measured memory_bytes: 40508
import collections
n=int(input())
s=[]
for i in range(n):
  X=''
  Y=sorted(input())
  for i in range(10):
    X+=Y[i]
  s.append(X)
cnt=collections.Counter(s)
ans=0
for i in cnt.values():
  ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 24008
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int p[100000];
int main(){
  int N, K;
  cin >> N >> K;

  rep(i, N){
    cin >> p[i];
  }
  sort(p, p + N);

  int ans = p[N - 1] - p[0];
  rep(i, N - K + 1){
    ans = min(ans, p[i + K - 1] - p[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    s =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    s = ''.join([_s for i,_s in enumerate(s) if i%2==0])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(s)


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

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);
    int A, B;
    while(cin>>A>>B){
        if(A>=13)
            cout<<B<<endl;
        else if (A<13 && A>=6)
            cout<<B/2<<endl;
        else
            cout<<0<<endl;
    }
	return 0;
}



Measured memory_bytes: 256
import           Control.Monad
import           Data.List
main = do
    n <- readLn :: IO Int
    a <- replicateM n readLn :: IO [Int]
    let m1 = maximum a
        m2 = maximum $ delete m1 a
    mapM_ (\i -> print $ if i == m1 then m2 else m1) a


Measured memory_bytes: 62204
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

x, y = map(int, input().split())
a = y-2*x
b = 4*x - y
if a >= 0 and a%2 == 0 and b >= 0 and b%2 == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 68360
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
long long A[210000];

int main() {
    while (cin >> N) {
        long long res = 0;
        long long num = 0;
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
            if (A[i] == 0) {
                res += num/2;
                num = 0;
            }
            else {
                num += A[i];
            }
        }
        res += num/2;
        
        cout << res << endl;
    }
}











Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{
    char s[15];
    scanf("%s", s);

    int Dcnt = 0, cnt = 0;
    for (int i = 0; s[i] != '\0'; i++)
    {
        Dcnt++;
        if(s[i] == 'o'){
            cnt++;
        }
    }

    printf("%s\n", cnt + (15 - Dcnt) >= 8 ? "YES" : "NO");
    return 0;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll MOD = 1e9+7;
ll POW(ll b, ll e) {
	ll r = 1;
	while(e) {
		if(e & 1) {
			r *= b;
			r %= MOD;
		}
		b *= b;
		b %= MOD;
		e /= 2;
	}
	return r;
}
int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ll s;
	cin >> s;
	ll ans = 0;
	vll fact(2001), invfact(2001);
	M00(i, 2001) {
		if(i == 0) fact[i] = 1;
		else fact[i] = (fact[i-1] * (i)) % MOD;
		invfact[i] = POW(fact[i], MOD-2);
	}
	for(int i = 1; 3*i <= s; i++) {
		//i bins, s-3*i balls C(s-3i + i-1. i-1);
		ll delta = fact[s-2*i-1] * invfact[i-1];
		delta %= MOD;
		delta *= invfact[s-3*i];
		delta %= MOD;
		delta += MOD;
		delta %= MOD;
		ans += delta;
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3672
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[M];
		int[] B = new int[M];
		for (int i=0;i<M;i++) {
			A[i] = sc.nextInt()-1;
			B[i] = sc.nextInt()-1;
		}

		long[] ans = new long[M];
		ans[M-1] = (long)N*(N-1)/2;
		UnionFind uni = new UnionFind(N);
		for (int i=M-1;i>0;i--) {
			ans[i-1]=ans[i];
			if (uni.root(A[i])!=uni.root(B[i])) {
				ans[i-1]=ans[i-1]-uni.size(A[i])*uni.size(B[i]);
				uni.connect(A[i],B[i]);
			}
		}

		for (int i=0;i<M;i++) {
			System.out.println(ans[i]);
		}
	}

	static class UnionFind {
		List<Integer> Parent;
		UnionFind(int N) {
			Parent = new ArrayList<Integer>();
			Integer[] values = new Integer[N];
			Arrays.fill(values, -1);
			Parent.addAll(Arrays.asList(values));
		}
		int root(int A) {
			if (Parent.get(A) < 0)
				return A;
			int root = root(Parent.get(A));
			Parent.set(A, root);
			return root;
		}
		int size(int A) {
			return -Parent.get(root(A));
		}

		boolean connect(int A, int B) {
			A = root(A);
			B = root(B);
			if (A == B) {
				return false;
			}

			if (size(A) < size(B)) {
				int temp = A;
				A = B;
				B = temp;
			}

			Parent.set(A, Parent.get(A) + Parent.get(B));
			Parent.set(B, A);

			return true;
		}
	}
}

Measured memory_bytes: 91364
import java.util.*;
import java.io.*;
public class Main{
  
    public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        boolean found=false;
        for(int i=1;i<=10000;i++){

            if(((i*8)/100)==a && ((i*10)/100)==b){
                found=true;
                System.out.println(i+" ");
                break;
            }
        }
        if(!found){
            System.out.println(-1);
        }

    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
using namespace std;
int main() {
    int k;
    string s;
    while (cin >> k) {
        cin >> s;
        if (s.size() <= k)
            cout << s << endl;
        else {
            for (int i = 0; i < k; i++) {
                cout << s[i];
            }
            cout << "..." << endl;
        }
    }
}



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

int main(){
	int hand[5];
	int d[3]={2,3,1};
	while(1){
		cin >> hand[0];
		if(hand[0] == 0) break;
		int cou[4] = {0};
		cou[hand[0]]++;
		for(int i=1;i<=4;i++){
			cin >> hand[i];
			cou[hand[i]]++;
		}
		int tmp=0,temp=0;
		for(int i=1;i<=3;i++){
			if(cou[i] == 5){
				tmp = 1;
				break;
			}
			else if(cou[i] == 0){
				temp = i;
			}
		}
		for(int i=0;i<5;i++){
			if(tmp == 1 || temp == 0) cout << "3" << endl;
			else {
				if(hand[i] == d[temp-1]) cout << "1" << endl;
				else cout << "2" << endl;
			}
		}
	}
}

Measured memory_bytes: 1152
# Matrix Vector Multiplication

matrixSize = [int(i) for i in input().rstrip().split()]
n = matrixSize[0]
m = matrixSize[1]

matrix = []
for i in range(n):
    array = [int(j) for j in input().rstrip().split()]
    matrix.append(array)
# print(matrix)

vector = [int(input()) for k in range(m)]
# print(vector)

for i in range(n):
    multiple = 0
    for j in range(m):
        multiple += matrix[i][j] * vector[j]
    print(multiple)



Measured memory_bytes: 6012
import sys


def LI():
    return list(map(int, input().split()))


def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y % x, x)


input()
A = LI()

g = 0
for a in A:
    g = gcd(g, a)
if g != 1:
    print("not coprime")
    sys.exit()

sosudayo = [True] * 1100000
sosudayo[0] = False
sosudayo[1] = False
for i in range(2, 1100000):
    if not sosudayo[i]:
        continue
    for j in range(i*i, 1100000, i):
        sosudayo[j] = False

used = [False] * 1100000
sosu = [a for a in A if sosudayo[a]]
for i in sosu:
    used[i] = True
ruto_sosu = [a for a in range(1100) if sosudayo[a]]
not_sosu = [a for a in A if not sosudayo[a]]

for i in not_sosu:
    for j in ruto_sosu:
        if i == 1:
            break
        if i % j != 0:
            continue
        if used[j]:
            print("setwise coprime")
            sys.exit()
        used[j] = True
        while i % j == 0:
            i //= j
    if i > 1:
        if used[i]:
            print("setwise coprime")
            sys.exit()
        used[i] = True

print("pairwise coprime")


Measured memory_bytes: 126396
import sys
d = list(map(int,input().split()))
A = d[0]
B = d[1]
cnt = 0
while True:
    #A口がcnt個ある。cntが1のときA*1口
    #cntが2以上のとき、
    if A*cnt - cnt +1 >= B:
        print(cnt)
        sys.exit(0)
    cnt +=1


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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((v).begin(), (v).end())
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

int main(int argc, char *argv[])
{
    int N, K;
    cin >> N >> K;
    vi p(N);
    rep(i, N) {
        cin >> p[i];
    }

    vsort(p);

    int ans = 0;
    rep(i, K) {
        ans += p[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

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

    LL a, b, x;
    cin >> a >> b >> x;
    LL ans = b/x - max(0LL, a-1)/x;
    if (a==0) ++ans;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
#define lmax LLONG_MAX
#define lmin LLONG_MIN
#define f(i,a,b) for(long long i=a;i<b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define tc long long test;cin>>test;while(test--)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define input(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define output(a,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define endl "\n"
#define mem(a) memset(a,-1,sizeof(a))
#define ll long long

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin>>n;

    int a[n+1]={0};

    f(i,1,n+1){
        for(int j=1;j*i<=n;j++){
            a[i*j]++;
        }
    }

    int ans=0;
    f(i,0,n){
        ans+=a[i];
    }

    cout<<ans<<endl;

    return 0; 
}










Measured memory_bytes: 7540
# -*- coding: utf-8 -*-

n, x = [int(w) for w in raw_input().split()]
a = [int(w) for w in raw_input().split()]

b = [a[i] + a[i+1] for i in xrange(n - 1)]

ans = 0
for i in xrange(n - 1):
    if b[i] > x:
        d = b[i] - x
        ans += d
        b[i] = x
        if i < n - 2:
            b[i + 1] = b[i + 1] - min(d, a[i + 1])

print ans


Measured memory_bytes: 11828
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
	int a = scanner.nextInt();
    int b = scanner.nextInt();
    scanner.close();
    
    if(a % 2 == 0){
      System.out.print("Even");
        return;
    }
 
    if(b % 2 == 0){
      System.out.print("Even");
        return;
    }
    
    System.out.print("Odd");
  }

}

Measured memory_bytes: 23124
m, k = map(int, input().split())
ret = []
if k >= 2 ** m or (m == 1 and k == 1):
    ret.append(-1)
elif m == 1:
    ret = [0, 0, 1, 1]
else:
    ret.append(k)
    for i in range(2 ** m):
        if i != k:
            ret.append(i)
    ret.append(k)
    for i in range(2 ** m - 1, -1, -1):
        if i != k:
            ret.append(i)
print(' '.join(map(str, ret)))

Measured memory_bytes: 31640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    for (int N, M;;) {
        cin >> N >> M;
        if (N == 0 and M == 0) { break; }
        if (N <= 20) {
            vector<vector<int>> b(N, vector<int>(M));
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < M; j++) {
                    char c;
                    cin >> c, b[i][j] = c - '0';
                }
            }
            const int MASK = 1 << N;
            int ans = 0;
            for (int mask = 0; mask < MASK; mask++) {
                int cnt = 0;
                vector<int> sum(M, 0);
                for (int i = 0; i < N; i++) {
                    if (mask & (1 << i)) {
                        cnt++;
                        for (int j = 0; j < M; j++) { sum[j] ^= b[i][j]; }
                    }
                }
                bool ok = true;
                for (int i = 0; i < M; i++) {
                    if (sum[i] == 1) { ok = false; }
                }
                if (ok) { ans = max(ans, cnt); }
            }
            cout << ans << endl;
        } else {
            vector<int> b(N, 0);
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < M; j++) {
                    char c;
                    cin >> c, b[i] |= (c - '0') << j;
                }
            }
            const int MASK = 1 << M;
            vector<int> dp(MASK, -1);
            dp[0] = 0;
            for (int i = 0; i < N; i++) {
                auto tmp = dp;
                for (int j = 0; j < MASK; j++) {
                    if (dp[j] == -1) { continue; }
                    tmp[j ^ b[i]] = max(tmp[j ^ b[i]], dp[j] + 1);
                }
                dp = tmp;
            }
            cout << dp[0] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 84888
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

int main(void) {

	int sx=0, sy=0 , tx=0 ,ty=0;
	cin >> sx >> sy >> tx >> ty;

	string res;
	
	for (int h = sy; h < ty; h++) {
		res += 'U';
	}

	for (int w = sx; w < tx; w++) {
		res += 'R';
	}
	
	for (int h = sy; h < ty; h++) {
		res += 'D';
	}

	for (int w = sx; w < tx; w++) {
		res += 'L';
	}

	res += 'L';
	for (int h = sy; h <= ty; h++) {
		res += 'U';
	}

	for (int w = sx; w <= tx; w++) {
		res += 'R';
	}

	res += 'D';
	res += 'R';

	for (int h = sy; h <= ty; h++) {
		res += 'D';
	}

	for (int w = sx; w <= tx; w++) {
		res += 'L';
	}

	res += 'U';

	cout << res << endl;
	return 0;
	



}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }

bool can(int x) {
    if (x % 2 == 0) return false;
    int cnt = 0;
    for (int i = 1; i <= x; i++) if (x%i == 0) cnt++;
    return cnt == 8;
}

int main() {
    int n; scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += can(i);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define mod1        987654319 
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll fact(ll n){ if(n==0){return 1;}return (n*fact(n-1))%mod1;}
ll power(ll x, ll y,ll mod){ll out = 1;while (y > 0){if (y & 1) out=(out*x)%mod;y = y>>1;x = (x*x)%mod;}return out%mod;}
ll inverse(ll a){return power(a,mod1-2,mod1);}
ll gcd(ll a,ll b){if(b==0){return a;}gcd(b,a%b);}
ll a[2000000];
void sieve(){ll i,j;fli(i,2,1000001){if(a[i]==0){for(j=i*i;j<1000001;j+=i){a[j]=1;}}}}
map<ll,vector<ll> >m1;
vector<ll>v1;
bool compar(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second);
} 
ll level[1000000];
vector<ll>root;
void comp()
{
	ll i,j,l,r;
	cin>>l>>r;
	ll lim=min(2019+l,r);
	ll ans=2020,temp;
	for(int i=l;i<lim;i++)
	{
		for(int j=i+1;j<=lim;j++)
		{
			temp=(i%2019);
			temp*=(j%2019);
			temp%=2019;
			if(ans>temp)
			{
				ans=temp;
			}
		}
	}
	cout<<ans<<"\n";
} 
int main()
{
	speedup;
	ll i=0,t;
	ll n;
	//cin>>t;
	t=1;
	while(t--)
	{
	 comp();
	}
}

Measured memory_bytes: 2304
#include <stdio.h>

int main() {
	int n = 0;
	unsigned long long total = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			total += i;
		}
	}
	printf("%llu",total);

	return 0;
}

Measured memory_bytes: 1732
n,m = map(int,input().split())
dp = [10**9]*(2**n)
dp[0] = 0
for _ in range(m):
  a,_ = map(int,input().split())
  c = list(map(int,input().split()))
  t = 0
  for x in c:
    t |= 1<<(x-1)
  for b in range(2**n):
    dp[b|t] = min(dp[b|t],dp[b]+a)
if dp[-1] > 10**8:
  print(-1)
else:
  print(dp[-1])


Measured memory_bytes: 3188
N = int(input())
row1 = [int(n) for n in input().split()]
row2 = [int(n) for n in input().split()]

sum1 = row1[0]
sum2 = sum(row2)
max_candy = sum1 + sum2
for i in range(1,N):
    sum1 += row1[i]
    sum2 -= row2[i-1]
    current = sum1+sum2
    if(max_candy < current):
        max_candy = current
print(max_candy)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <string>
#include <cstring>
#define REP(i,n) for(int i=0;i<n;i++)
using Int = long long;
using namespace std;
bool eql(const string &s, int idx, const char *t)
{
    int len = strlen(t);
    for (int i = 1; i <= len; i++) {
        if (s[idx-i] != t[len-i]) return false;
    }
    return true;
}
int main()
{
    string s; cin >> s;
    int idx = s.size();
    while (idx > 0) {
        if (eql(s, idx, "dream")) idx -= 5;
        else if (eql(s, idx, "dreamer")) idx -= 7;
        else if (eql(s, idx, "erase")) idx -= 5;
        else if (eql(s, idx, "eraser")) idx -= 6;
        else break;
    }
    cout << (idx == 0 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;

    if(a<=8 and b<=8){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

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

string change(int n){
  string s = "";
  while(n > 0){
    s += (n % 10 + '0');
    n/=10;
  }
  reverse(s.begin(),s.end());
  return s;
}

int main(){
  int n;

  while(cin >> n ,n){
    string str;
    cin >> str;

    while(n--){
      string tmp = "";
      int cnt = 1;
      char key = str[0];
      int size = str.size();
      str[size] = '#';
      for(int i = 1 ; i <= size ; i++){
	if(key == str[i]){
	  cnt++;
	}
	else{
	  tmp += change(cnt);
	  tmp += key;
	  key = str[i];
	  cnt = 1;
	}
      }
      
      str = tmp;
    }
    cout << str << endl;
  }

  return 0;
}

Measured memory_bytes: 1344
from collections import Counter

N = int(input())
S = [input() for i in range(N)]

Sc = Counter(S).most_common()
m = Sc[0][1]
ans = []
for s in Sc:
    if s[1] == m:
        ans.append(s[0])
    else:
        break
ans.sort()
for a in ans:
    print(a)


Measured memory_bytes: 45036
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  int x[200000];
  int srt_x[200000];
  REP(i,n){
    int xx;cin>>xx;
    x[i]=xx;
    srt_x[i]=xx;
  }
  sort(srt_x, srt_x+n);
  int dwn=srt_x[n/2-1];
  int up=srt_x[n/2];
  REP(i,n){
    if(x[i]<=dwn){
      P(up);
    }else{
      P(dwn);
    }
  }
  return 0;
}


Measured memory_bytes: 3712
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException{
		// TODO ?????????????????????????????????????????????

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] input = br.readLine().split(" ");
            int a = Integer.parseInt(input[0]);
            int b = Integer.parseInt(input[2]);
            String op = input[1];
            if (op.equals("+")){
                System.out.println(a + b);
            } else if (op.equals("-")){
                System.out.println(a - b);
            } else if (op.equals("*")){
                System.out.println(a * b);
            } else if (op.equals("/")){
                System.out.println(a / b);
            } else if (op.equals("?")){
                break;
            }         
            
        }

	}

}

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

using namespace std;

int n;
int a[100001];
int b[100001];
int b1[100001];
int ans = 0;

int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
    }
    memset(b,0,sizeof(b));
    memset(b1,0,sizeof(b1));
    b[1] = a[1];
    b1[n] = a[n];
    for(int i = 2;i <=n;i++)
        b[i] = __gcd(b[i - 1],a[i]);
    for(int i = n - 1;i >= 1;i--)
        b1[i] = __gcd(b1[i + 1],a[i]);
    for(int i = 1;i <= n;i++)
    {
        if(i == 1)
            ans = max(ans,b1[2]);
        else if(i == n)
            ans = max(ans,b[n - 1]);
        else
            ans = max(ans,__gcd(b[i - 1],b1[i + 1]));
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1408
import itertools
import math

def dist(x0, y0, x1, y1):
  ans = math.sqrt((x0-x1)**2 + (y0-y1)**2)
  return ans

N = int(input())
x = [0] * N 
y = [0] * N

for i in range(N):
  x[i],y[i] = map(int, input().split())

goukei = 0

jr = list(itertools.permutations(range(N), N)) #jr=順列
#print(jr[1])
#print(type(jr[1]))
#print(jr[1][1])
#print(type(jr[1][1]))

for i in range(len(jr)):
  for j in range(N-1):
    goukei += dist(x[jr[i][j]], y[jr[i][j]], x[jr[i][j+1]], y[jr[i][j+1]])
print(goukei/len(jr))

Measured memory_bytes: 13868
#include<stdio.h>


int funcA(int kane,double ritu, int tesuu, int year){
   int i;
   int B=0;
    for(i=0;i<year;i++){
        B=kane*ritu;
        kane+=B-tesuu;
    }
    return kane;

}

int funcB(int kane,double ritu, int tesuu, int year){
   int i;
   int B=0,S=0;
    for(i=0;i<year;i++){
        B=kane*ritu;
        kane-=tesuu;
        S+=B;
    }
    return kane+S;

}
int funcC(int num[],int n){
    int max=0;
    int i;
        
    for(i=0;i<n;i++){
        if(max<num[i]){
            max=num[i];
        }
    }
    return max;
}




main(){
    int m;
    int kane;
    int year;
    int n;
    int flag;
    double ritu;
    int tesuu;
    int i,j;
    int num[100];
    
    scanf("%d",&m);
    
    for(i=0;i<m;i++){
        scanf("%d",&kane);
       
        scanf("%d",&year);
       
        scanf("%d",&n);
        
        for(j=0;j<n;j++){
            num[j] = 0;
            scanf("%d %lf %d",&flag,&ritu,&tesuu);
        
            if(flag==0){
            num[j]=funcB(kane,ritu,tesuu,year);
            }else{
            num[j]=funcA(kane,ritu,tesuu,year);        
            }
        }
        printf("%d\n",funcC(num,n));
    }
    
    return 0;
    
    

}

Measured memory_bytes: 632
n , m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1] * n
for i in range(m):
    a, b = map(int,input().split())
    if h[a-1] > h[b-1]:
        c = b
        ans[c-1] = 0 
    elif h[a-1] < h[b-1]:
        c = a
        ans[c-1] = 0
    else:
        ans[a-1] = 0
        ans[b-1] = 0
print(sum(ans))

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(n);
    int left = 0, right = 0;
    rep(i, m)
    {
        cin >> a[i];
        if (a[i] < x)
            left++;
        else
            right++;
    }
    int ans = min(left, right);
    c(ans);

    return 0;
}

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

int main(){
    ll n;
    ll m1=0,m2=0,num;
    cin >> n;
    for(ll i=0;i<n;i++){
        ll a;
        cin >> a;
        if(a>=m1){
            m2 = m1;
            m1 = a;
            num = i;
        }
        else if(a>=m2){
            m2 = a;
        }
    }
    for(ll i=0;i<n;i++){
        if(i==num)  cout << m2 << endl;
        else    cout << m1 << endl;
    }
    return 0;
} 

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

int main(int argc, char *argv[])
{
    using ll = long long;
    ll N;
    cin >> N;
    ll res = 0;
    ll x = 10;
    if (N & 1) return cout << 0 << endl, 0;
    while (N / x) {
        res += N / x;
        x *= 5;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

def main():
    n,k = mi()
    a =li()

    fp = [0] * n

    nxt = 0
    for i in range(1,n+10):
        
        idx = a[nxt]-1
        # print('idx',idx)
        if i == k:
            print(idx+1)
            return
        elif fp[idx] > 0:
            rs = fp[idx]
            re = i
            break
        
        else:
            fp[idx] = i
            nxt = idx

    roop_count = re - rs

    modd = (k - rs)%roop_count
    for i in range(modd):
        idx = a[idx]-1
    print(idx+1)
    return

if __name__ == "__main__":
    main()

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

int main()
{
    char c;
    //cout<<"enter alphabet:";
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
    cout << "vowel" << endl;
    else
        cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 256
s = input() #sys.stdin.readlineは最後が改行

n = len(s)
hn = (n-1)//2
hs = s[:hn]

for i in range(hn):
    if s[i] != s[-1-i]:
        print('No')
        exit()
    if hs[i] != hs[-1-i]:
        print('No')
        exit()

print('Yes')




Measured memory_bytes: 2940
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

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

long numDivisors(long n, long k) {
    return n / k;
}

long calc(long a, long b, long c, long d) {

    long x = numDivisors(b, c) + numDivisors(b, d) - numDivisors(b, lcm(c, d));
    long y = numDivisors(a-1, c) + numDivisors(a-1, d) - numDivisors(a-1, lcm(c, d));


    return (b - a + 1) - (x - y);
}

void main() {
    long a, b, c, d; scan(a, b, c, d);
    writeln(calc(a, b, c, d));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               string s,t;
               cin>>s>>t;
               int count=0;
               for(int i=0;i<s.size();++i)
               {
                    if(s[i]!=t[i])
                         count++;
               }
               cout<<count;
       }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  if ((N - 1) % (K - 1) == 0)
    cout << (N - 1) / (K - 1) << endl;
  else
    cout << (N - 1) / (K - 1) + 1 << endl;
}


Measured memory_bytes: 256
#include<math.h>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){
    int r;
    cin >> r;
    cout << 2 * r * M_PI << endl;

    return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include<queue>
#include<map>
using namespace std;
queue<pair<string,int> >Q;
map<string,int> M;
int main()
{
	for(;;)
	{
		string s;
		cin>>s;
		if(s=="0")break;
		Q.push(make_pair(s,0));
		M[s]=1;
		int res=999;
		for(;!Q.empty();)
		{
			pair<string,int>p=Q.front();Q.pop();
			s=p.first;
			int flg=0;
			for(int i=0;i<s.length()-1;i++)
			{
				if(s[i]!=s[i+1])
				{
					flg=1;
					s[i]=s[i+1]=315-s[i]-s[i+1];
					if(M[s]==0)
					{
						M[s]=1;
						pair<string,int> ins(s,p.second+1);
						Q.push(ins);
					}
					s=p.first;
				}
			}
			if(flg==0)
				res=min(res,p.second);
		}
		if(res==999)cout<<"NA"<<endl;
		else cout<<res<<endl;
		M.clear();
	}
}

Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	sort(all(a));
	int ans = 0;
	if((a[1]-a[0])%2==0)ans=(a[1]-a[0])/2+(a[2]-a[1]);
	else ans=(a[1]-a[0])/2+(a[2]-a[1])+2;
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

using namespace std;

int main(){
	int N, A, B, C, X;
	while (true) {
		cin >> N >> A >> B >> C >> X;
		if (!N & !A && !B && !C && !X) { break; }
		int res = 0;

		vector<int> Y(N);
		for (int i = 0; i < N; i++) { cin >> Y[i]; }
		
		int rail = 0;
		for (int i = 0; i <= 10000 && rail < N; i++) {
			if (X == Y[rail]) {
				res = i;
				rail++;
			}
			X = (A * X + B) % C;
		}

		if (rail == N) {
			cout << res << endl;
		} else {
			cout << "-1" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 100000
#define vmax 10000
#define sentinel 2000000000
#define INF (1<<29)
constexpr long long int inf = 100000000000000000;
constexpr long long int rinf = -(INT64_MAX);
static const int NIL=-1;

//cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);

vector<int> g[MAX];
list<int> out;
bool V[MAX];
int n;

void dfs(int u){
    V[u]=true;
    for(auto v:g[u]){
        if(!V[v]) dfs(v);
    }
    out.push_front(u);
}

int main(){
    int s,t,m;
    cin>>n>>m;
    rep(i,n) V[i]=false;
    for(int i=0;i<m;i++){
        cin>>s>>t;
        g[s].push_back(t);
    }

    rep(i,n){
        if(!V[i]) dfs(i);
    }

    for(auto it:out){
        cout<<it<<endl;
    }

    return 0;
}






Measured memory_bytes: 6072
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if(a < c){
            a = c;
        }
        if(b > d){
            b = d;
        }
        if(b < a){
            System.out.println(0);
        }else{
            System.out.println(b - a);
        }
    }
}

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

int main(){
  int a, b, c=1, d=1, x=0, y=0;
  cin >> a >> b;
  rep(i,a){
    x+=b*c;
    c*=10;
  }
  rep(i,b){
    y+=a*d;
    d*=10;
  }

  if(b>=a){
    cout << y << endl;
  }
  else{
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <functional>

typedef long long ll;
using namespace std;


int main(){
    int x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3496
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

ll gcd(ll x, ll y) {
    if(x<y) gcd(y,x);
    while(y>0) {
        ll tmp = x%y;
        x = y;
        y = tmp;
    }
    return x;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    string s,t; cin >> s >> t;
    ll l = n / gcd(n,m) * m;
    map<int,char> sm,tm;
    bool flag = true;
    REP(i,n) {
        int x = i * l/n + 1;
        sm[x] = s[i];
    }
    REP(i,m) {
        int y = i * l/m + 1;
        tm[y] = t[i];
        if(tm[y]==sm[y]) continue;
        else {
            if(sm[y]==0) continue;
            else flag = false;
        }
    }
    cout << (flag ? l : -1) << endl;
    return 0;
}

Measured memory_bytes: 12544
#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned int U;
#define L 1<<21
bool HA[L];
char T[256];

int main() {
    U n, s, t;
    char c;
    T['A'] = (char)1, T['C'] = (char)2, T['G'] = (char)3, T['T'] = (char)4;
    scanf("%d", &n);
    while ( getchar() != '\n' );
    while (n--) {
        s = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            s += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[s] = true;
        } else {
            puts( HA[s] ? "yes" : "no" );
        }
    }
    return 0;
}

Measured memory_bytes: 2100
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N, K; cin >> N >> K;
    int lim = (N - 1) * (N - 2) / 2;
    if(K > lim) cout << -1 << endl;
    else {
        vector< pair<int, int> > edges;
        for(int i=1; i<N; i++) {
            edges.emplace_back(1, i+1);
        }

        int rem = lim - K;
        for(int i=1; i<N; i++) {
            for(int j=i+1; j<N; j++) {
                if(rem > 0) {
                    rem--;
                    edges.emplace_back(i+1, j+1);
                }
            }
        }

        cout << edges.size() << endl;
        for(auto e : edges) cout << e.first << " " << e.second << endl;
    }
    return 0;
}


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

public class Main {

    static long mod = (long) (1e9 + 7);

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        String s = in.next();
        char[] c = s.toCharArray();
        char prev = Character.MIN_VALUE;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (prev != c[i]) {
                ans++;
                prev = c[i];
            }
        }
        out.println(ans);
        out.close();
    }

    static long[][] powMat(long[][] a, long pow) {
        if (pow == 1) {
            return a;
        } else {
            if (pow % 2 == 0) {
                return powMat(mul(a, a), pow / 2);
            } else {
                return mul(a, powMat(mul(a, a), pow / 2));
            }
        }
    }

    static long[][] mul(long[][] a, long[][] b) {
        int n = a.length;
        long[][] c = new long[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    c[i][k] = (c[i][k] + (a[i][j] * b[j][k]) % mod) % mod;
                }
            }
        }
        return c;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }
}

Measured memory_bytes: 23124
from collections import defaultdict, deque
def sub():

    N, M = [int(e) for e in input().split()]
    es = [[int(x) for x in input().split()] for _ in range(M)]

    outs = defaultdict(list)
    ins = defaultdict(int)
    for v1, v2 in es:
        outs[v1].append(v2)
        ins[v2] += 1

    q = deque(v1 for v1 in range(1, N+1) if ins[v1] == 0)
    dp_table = [0 for i in range(N+1)]
    res = []
    while q:
        v1 = q.popleft()
        res.append(v1)
        for v2 in outs[v1]:
            ins[v2] -= 1
            if ins[v2] == 0:
                q.append(v2)
                dp_table[v2] = max(dp_table[v2], dp_table[v1] + 1)
    print(max(dp_table))

if __name__ == "__main__":
    sub()


Measured memory_bytes: 104280
def main():
    import heapq
    n,m = map(int,input().split())
    job = {}
    for i in range(n):
        a,b = map(int,input().split())
        if a not in job.keys():
            job[a] = [b]
        else:
            job[a].append(b)
    ans = 0
    hp = []
    for i in range(1,m+1):
        if i in job.keys():
            for j in range(len(job[i])):
                heapq.heappush(hp,-1*job[i][j])
        if len(hp)>0:
            ans += -1*heapq.heappop(hp)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 29232
#include <iostream>
int main() {
	int n[10000], x, i;
	int min = 0, max = 0;
	long sum = 0;

	std::cin >> x;
	if (x > 10000) return 0;

	for (i = 0; i < x; i++) {
		std::cin >> n[i];
	}

	for (i = 0; i < x; i++) {
		if (i == 0) {
			min = n[i];
			max = n[i];
		}
		if (min > n[i])
			min = n[i];
		if (max < n[i])
			max = n[i];
		sum += n[i];
	}

	std::cout << min << " " << max << " " << sum << std::endl;

	return 0;
}

Measured memory_bytes: 3124
n = int(input())
if n < 105:
    print(0)
elif 105 <= n and n < 135:
    print(1)
elif 135<= n and n < 165:
    print(2)
elif 165 <= n and n < 189:
    print(3)
elif 189 <= n and n < 195:
    print(4)
else:
    print(5)


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<ll> b(n);
  rep(i, n-1) { 
    cin >> b[i];
  }

  ll ans = b[0];
  rep2(i, 1, n-1) {
    ans += min(b[i-1], b[i]);
  }
  cout << ans + b[n-2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t N,K,S; cin>>N>>K>>S;
    vector<int64_t> V(N,10e8);

    if(S==10e8){
        rep(i,0,N-K) V.at(i)=1;
    }else{
        rep(i,0,K) V.at(i)=S;
    }

    for(auto v:V) cout<<v<<" ";
    cout<<endl;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> ar(n);

  for(ll i = 0; i < n; i++){
    cin >> ar[i];
  }

  ll ans1, ans2;
  ans1 = ans2 = 0; 
  ll cum = 0;
 
    //偶数が正の場合
  for(ll i = 0; i < n; i++){
    cum += ar[i];
    if(i % 2 == 0){
        if(cum <= 0){
            ans1 += abs(cum - 1);
            cum = 1;
        }
    }else{
        if(cum >= 0){
            ans1 += abs(cum + 1);
            cum = -1;
        }
    }
  }

   //偶数が負の場合
  cum = 0;

  for(ll i = 0; i < n; i++){
    cum += ar[i];
    if(i % 2 == 0){
        if(cum >= 0){
            ans2 += abs(cum + 1);
            cum = -1;
        }
    }else{
        if(cum <= 0){
            ans2 += abs(cum - 1);
            cum = 1;
        }
    }
  }
  
    ll prans = min(ans1, ans2);

  cout << prans << endl;

  return 0;

}


Measured memory_bytes: 1024