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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++) cin >> S.at(i);
    int AC=0, WA=0, TLE=0, RE=0;
    for(int i=0; i<N; i++){
        if(S.at(i) == "AC") AC++;
        else if(S.at(i) == "WA") WA++;
        else if(S.at(i) == "TLE") TLE++;
        else if(S.at(i) == "RE") RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;

}

Measured memory_bytes: 6432
package main

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

var MaxN int

func main() {
	sc := NewScanner()

	MaxN = Pow(10, 12)

	n := sc.ReadInt()

	ans := 0
	primeCounts := PrimeFactorize(n)
	for _, count := range primeCounts {
		ans += f(count)
	}

	fmt.Println(ans)
}

func f(n int) int {
	switch {
	case n < 1:
		return 0
	case n < 3:
		return 1
	case n < 6:
		return 2
	case n < 10:
		return 3
	case n < 15:
		return 4
	case n < 21:
		return 5
	case n < 28:
		return 6
	case n < 36:
		return 7
	case n < 45:
		return 8
	}
	return -1
}

func PrimeFactorize(n int) map[int]int {
	primeCounts := make(map[int]int)

	sqrtMax := int(math.Sqrt(float64(MaxN)))

	for n%2 == 0 {
		primeCounts[2]++
		n /= 2
	}
	for n%3 == 0 {
		primeCounts[3]++
		n /= 3
	}

	flag := true
	for i := 5; n > 1 && i <= sqrtMax; {
		for n%i == 0 {
			primeCounts[i]++
			n /= i
		}

		if flag {
			i += 2
		} else {
			i += 4
		}
		flag = !flag
	}

	if n > 1 {
		primeCounts[n]++
	}

	return primeCounts
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


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

int main() {
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  int r = 0;
  int a = 1;
  int b = -1;
  ll ans = 1;
  while(1){
    if(r>= n) break;
    if(s1[r] == s2[r]){
      a = 1;
      r++;
    }else {
      a = 0;
      r += 2;
    }
    if(b == -1 && a == 1) ans *= 3;
    else if(b == -1 && a == 0) ans *= 6;
    else if(b == 1 && a == 1) ans *= 2;
    else if(b == 1 && a == 0) ans *= 2;
    else if(b == 0 && a == 1) ans *= 1;
    else if(b == 0 && a == 0) ans *= 3;
    ans %= mod;
    b = a;
  }
  cout << ans << endl;
}

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

pair<string, int> solve(string s, int n){
	if((int)s.length() == 1){
		if(n==0) return make_pair(string(1, s[0]), 1);
		return make_pair("0", 1);
	}
	
	int ptr=0;
	int len=0;
	while(ptr < (int)s.length()){
		int num=0;
		while('0'<=s[ptr] && s[ptr]<='9'){
			num = num*10 + s[ptr]-'0';
			ptr++;
		}
		if(num==0) num=1;
		
		string search;
		if(s[ptr] == '('){
			int depth=1;
			int rem = ptr+1;
			ptr++;
			while(depth>0){
				if(s[ptr]=='(') depth++;
				if(s[ptr]==')') depth--;
				ptr++;
			}
			search = s.substr(rem, ptr-rem-1);
		}else{
			search = string(1, s[ptr]);
			ptr++;
		}
		
		pair<string, int> ret = solve(search, n-len);
		int sublen = ret.second;
		if(ret.first != "0")
			return ret;
		if(sublen*num > n-len)
			return solve(search, (n-len)%sublen);
		len += num*sublen;
	}
	return make_pair("0", len);
}

int main(){
	while(1){
		string s;
		int n;
		cin >> s >> n;
		if(s=="0") break;
		cout << solve(s, n).first << endl;
	}
	return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000001
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 300001;
const ll M = 1;
struct point {
    ll x, y;
    ll i;
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    else if(n & 1)
        return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll tmp = fast_exp(x, n >> 1);
        return tmp * tmp % mod;
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    //int test = 0;
    while(_--)
    {
        ll n, m, x = 0, y = 0, ans = 0;
        m = 2019;
        string s;
        cin >> s;
        n = s.size();
        ll cnt[m] = {};
        cnt[0]++;
        y = 1;
        for(int i = n - 1; i > -1; i--)
        {
            x = x + (s[i] - '0') * y;
            x = x % m;
            cnt[x]++;
            y = y * 10 % m;
        }
        for(int i = 0; i < m; i++) ans += cnt[i] * (cnt[i] - 1) >> 1;
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cfloat>
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))

#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, j, n, m) rep(i, n) rep (j, m)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)

#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")
#define sca(A, n, m) {                      \
  rep(i, n){                                    \
        rep(j, m - 1) cout << A[i][j] << " ";     \
        cout << A[i][m-1] << endl;              \
    }                                           \
}
#define sca1(A, n, m) {                    \
    FOR(i, 1, n){                                \
        FOR(j, 1, m-1) cout << A[i][j] << " ";   \
        cout << A[i][m] << endl;                \
    }                                           \
}

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define in4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

inline void scan(int &t) {
    int n = 0, s = 1;
    char ch = getchar();
    while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
    if (ch == '-') s = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') n = n * 10 + ch - '0', ch = getchar();
    t = n * s;
}

string s0, s1;

int main() {
    s0 = "CODEFESTIVAL2016";
    while (cin >> s1) {
        int ans = 0;
        rep (i, 17) ans += s0[i] != s1[i];
        cout << ans << '\n';
    }
    return 0;
}


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

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int LG = 20;
const double EPS = 3e-16;

pair<long double, long double> a[N];

long double dist(long double x1, long double y1, long double x2, long double y2){
	return sqrt(abs(x1 - x2) * abs(x1 - x2) + abs(y1 - y2) * abs(y1 - y2));
}
int b[N];
int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	long long n; cin >> n;
	
	for(long long i = 0; i < n; i++){
		cin >> a[i].first >> a[i].second;
		b[i] = i;
	}
	long double sum = 0;
	long long cnt = 0;
	do{
		cnt++;
		for(long long i = 1; i < n; i++){
			long double x1 = a[b[i - 1]].first, y1 = a[b[i - 1]].second, x2 = a[b[i]].first, y2 = a[b[i]].second;
			sum += dist(x1, y1, x2, y2);
		}
	}while(next_permutation(b, b + n));
//	cout << cnt << "\n";
	cout << fixed << setprecision(10) << sum / cnt;
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner sn, PrintWriter out) {
            int a = sn.nextInt();
            int b = sn.nextInt();
            int c = sn.nextInt();
            int min1 = Math.min(Math.min(a, b), c);
            int min2 = 0;
            if (min1 == a) {
                min2 = Math.min(c, b);
            } else if (min1 == b) {
                min2 = Math.min(a, c);
            } else if (min1 == c) {
                min2 = Math.min(a, b);
            }
            out.println(min1 + min2);

        }

    }
}



Measured memory_bytes: 21844
const lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    n,k=intLine()
    v=intLine()
    m=0
    for i in 0:min(n,k)
        for j in n:-1:max(i,n-k+i)
            l=ifelse(i>0,ifelse(i>1,v[1:i],[v[1]]),[])
            r=ifelse(j<n,ifelse(j<n-1,v[j+1:n],[v[n]]),[])
            append!(l,r)
            if length(l)<1
                continue
            end
            sort!(l)
            for x in 1:min(length(l),k-i-n+j)
                if l[x]<0
                    l[x]=0
                end
            end
            m=max(m,sum(l))
        end
    end
    println(m)
end
main()

Measured memory_bytes: 121752
#include<iostream>
using namespace std;
int main()
{
	int n,li,ri,x=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>li>>ri;
		for(int a=li;a<=ri;++a)
		{
			x++;
		}
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const unsigned long Max = 10000000;
bool data[Max + 1];

void eratos(){
	for( int i = 0;i <= Max;i++ ) data[i] = true;

	data[0] = data[1] = false;

	for( int i = 2;i * i <= Max;i++ ) if( data[i] ) for( int j = 2;i * j <= Max;j++ ) data[ i * j ] = false;
}

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

	int n;
	while( cin >> n && n != 0 ){
		for( int i = n;i >= 13;i-- ){
			if( data[i] == true && data[i - 2] == true && data[i - 6] == true && data[i - 8] == true ){
				cout << i << endl;
				break;
			}
		}
	}

	return 0;

}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  rep(i, N - 1)
  {
    if (S[i + 1] == '?' && S[i] == 'P')
      S[i + 1] = 'D';
  }

  rep(i, N)
  {
    if (S[i] == '?')
      S[i] = 'D';
  }
  cout << S << endl;
  return 0;
}

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

int main()
{
  char c;
  cin >> c;
  
  vector<char> vowel = {'a', 'e', 'i', 'o', 'u'};

  bool is_ok = false;
  for (auto it = vowel.begin(); it != vowel.end(); it++) {
    if (c == *it) {
      is_ok = true;
      break;
    }
  }

  if (is_ok == true) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
rl() = [parse(Int64, x) for x in split(readline())]

function solve()
    N, M, K = rl()
    A = rl()
    B = rl()

    na = 0
    for (i, a) in enumerate(A)
        if K < a
            break
        end
        K -= a
        na += 1
    end

    r = na

    for (nb, b) in enumerate(B)
        K -= b
        while K < 0 && na > 0
            K += A[na]
            na -= 1
        end
        if K < 0
            break
        end
        r = max(r, na + nb)
    end
    r
end

println(solve())


Measured memory_bytes: 201040
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void)
{
    int H, W;
    int n;
    vector<string> canvas;
    const int dx[4] = {-1, 0, 1, 0};
    const int dy[4] = {0, -1, 0, 1};
    bool flag = true;

    cin >> H >> W;
    canvas.resize(H);
    for (int i = 0; i < H; i++) cin >> canvas[i];

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (canvas[i][j] == '.') continue;
            flag = false;
            for (int k = 0; k < 4; k++)
            {
                int x = j + dx[k];
                int y = i + dy[k];
                if (x < 0 || W <= x) continue;
                if (y < 0 || H <= y) continue;
                flag = (flag || (canvas[y][x] == '#'));
            }
            if (!flag) break;
        }
        if (!flag) break;
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
from queue import Queue

k = int(input().strip())
if 1<= k <= 9:
    print(k)
    exit()

q = Queue()
for i in range(1, 10):
    q.put(i)

ans = 0
count = 9
while True:
    ne = Queue()
    while not q.empty():
        now = str(q.get())
        if now[-1] == '0':
            for i in range(0, 2):
                count += 1
                rep = int(now + str(i))
                if count == k:
                    ans = rep
                    break
                ne.put(rep)
        elif now[-1] == '9':
            for i in range(8, 10):
                count += 1
                rep = int(now + str(i))
                if count == k:
                    ans = rep
                    break
                ne.put(rep)
        else:
            cen = int(now[-1])
            for i in range(cen - 1, cen + 2):
                count += 1
                rep = int(now + str(i))
                if count == k:
                    ans = rep
                    break
                ne.put(rep)
        if ans != 0:
            break
    if ans != 0:
        break
    q = ne
print(ans)


Measured memory_bytes: 54612
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
	unsigned short *A,*B;
	
	int C[VMAX+1];
	int n,j,i;
	scanf("%d",&n);
	
	A=malloc(sizeof(short)*n+1);
	B=malloc(sizeof(short)*n+1);
	
	for(i=0;i<=VMAX;i++) {
		C[i]=0;
	}
	
	for(i=0;i<n; i++) {
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}
	
	for(i=1;i<=VMAX; i++) {
		C[i]=C[i]+C[i-1];
	}
	
	for(j=1;j<=n; j++) {
		B[C[A[j]]]=A[j];
		C[A[j]]--;
	}
	
	for(i=1;i<=n; i++) {
		if(i>1)printf(" ");
		printf("%d",B[i]);
	}
	
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 9712
#include <algorithm>
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int res = 0;
  if (X == Y) {
    res = min(A + B, 2 * C) * X;
  } else if (X < Y) {
    res = min(A + B, 2 * C) * X + min(B, 2 * C) * (Y - X);
  } else {
    res = min(A + B, 2 * C) * Y + min(A, 2 * C) * (X - Y);
  }
  printf("%d\n", res);
}

Measured memory_bytes: 3232
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    if N < M:
        N, M = M, N
    if N == 1:
        return 1
    if M == 1:
        return N - 2
    return (N - 2) * (M - 2)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    print(solve(N, M))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main(){
  int a, b, k;
  double c, rad, h;

  scanf("%d %d %d",&a,&b,&k);
  rad=k*3.14159265/180.0;
  
  h=(double)b*sin(rad);
  c=sqrt(pow(a,2)+pow(b,2)-2.0*a*b*cos(rad));
  
  printf("%f\n%f\n%f\n",(double)a*h/2.0,a+b+c,h);
  return 0;
}



Measured memory_bytes: 2048
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    P = [0] * (N + 1)
    P[0] = (0, 0, 0)
    for i in range(1, N + 1):
        P[i] = tuple(map(int, readline().split()))

    ok = True
    for i in range(N):
        dt = P[i + 1][0] - P[i][0]
        dx = P[i + 1][1] - P[i][1]
        dy = P[i + 1][2] - P[i][2]
        if dt < abs(dx) + abs(dy) or (dt - abs(dx) - abs(dy)) % 2 == 1:
            ok = False
            break

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

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 22188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d, A, B, C, D;
  cin >> N;
  
  d = N%10; D = N/10;
  c = D%10; C = D/10;
  b = C%10; a = C/10;
  
  if ((a == b && b == c )||( b == c && c == d)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#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--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int k; cin >> k;
    int ans = -1;
    if(k % 2 == 0 || k % 5 == 0){
        cout << "-1" << endl;
        return 0;
    }
    k *= 9;
    if(k % 7 == 0) k /= 7;

    int mod = 1;
    rep(i,9000001){
        mod *= 10;
        mod %= k;
        if(mod == 1){
            ans = i+1;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
namespace remoon {
    #define re register
    #define de double
    #define le long double
    #define ri register int
    #define ll long long
    #define sh short
    #define pii pair<int, int>
    #define mp make_pair
    #define pb push_back
    #define tpr template <typename ra>
    #define rep(iu, st, ed) for(ri iu = st; iu <= ed; iu ++)
    #define drep(iu, ed, st) for(ri iu = ed; iu >= st; iu --)	
    #define gc getchar
    inline int read() {
        int p = 0, w = 1; char c = gc();
        while(c > '9' || c < '0') { if(c == '-') w = -1; c = gc(); }
        while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
        
        return p * w;
    }
    int wr[50], rw;
    #define pc(iw) putchar(iw)
    tpr inline void write(ra o, char c = '\n') {
        if(!o) pc('0');
        if(o < 0) o = -o, pc('-');
        while(o) wr[++ rw] = o % 10, o /= 10;
        while(rw) pc(wr[rw --] + '0');
        pc(c);
    }
    tpr inline void cmin(ra &a, ra b) { if(a > b) a = b; }
    tpr inline void cmax(ra &a, ra b) { if(a < b) a = b; } 
    tpr inline bool ckmin(ra &a, ra b) { return (a > b) ? a = b, 1 : 0; }
    tpr inline bool ckmax(ra &a, ra b) { return (a < b) ? a = b, 1 : 0; }
}
using namespace std;
using namespace remoon;

#define sid 200505

int t[sid], ans[sid];
int A, n, m, up, down;
struct node {
	int t, a, id;
	friend bool operator < (node a, node b)
	{ return a.t < b.t; }
} q[sid];

inline int upd(int v, int num) {
	return max(0, min(A, v + num));
}

int main() {
	A = up = read(); n = read();
	rep(i, 1, n) t[i] = read();
	m = read();
	rep(i, 1, m) {
		q[i].t = read(); q[i].a = read();
		q[i].id = i;
	}
	sort(q + 1, q + m + 1);
	int fr = 0, to = 1;
	int opt = -1, sum = 0, add = 0;
	while(to <= m) {
		if(t[fr + 1] < q[to].t && fr < n) {
			fr ++;
			add = opt * (t[fr] - t[fr - 1]);
			down = upd(down, add); up = upd(up, add);
			sum += add; opt *= -1;
		}
		else {
			int tim = q[to].t - t[fr];
			int val = max(down, min(up, q[to].a + sum));
			ans[q[to].id] = upd(val, tim * opt);
			to ++;
		}
	}
	rep(i, 1, m) write(ans[i]);
	return 0;
}

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

int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  int ans = A[0];
  for (int i = 0; i < N; i++)
  {
    ans = gcd(ans, A[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


immutable long MOD = 10^^9 + 7;

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}

void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    auto M = S.length.to!int;

    auto mem = new long[][](N + 1, N + 1);
    foreach (i; 0..N+1) fill(mem[i], -1);
   
    // dp(i, j) : i回キーを叩いてj文字入力されている場合の数
    long dp(int i, int j) {
        if (i == 0 && j == 0) return 1;
        if (i <= 0 || j < 0) return 0;
        if (j > i) return 0;
        if (mem[i][j] >= 0) return mem[i][j];

        long ret = 0;
        if (j == 0) {
            ret += dp(i - 1, j);
            ret %= MOD;
        }
        ret += dp(i - 1, j + 1); // Back Space
        ret %= MOD;
        ret += dp(i - 1, j - 1) * 2; // 0 or 1
        ret %= MOD;
        return mem[i][j] = ret;
    }


    auto ans = dp(N, M);
    ans = ans * powmod(powmod(2, MOD-2, MOD), M, MOD) % MOD;
    ans.writeln;
}


Measured memory_bytes: 202876
def main():

    n = int(input())
    nums = list(map(int, input().split()))
    ans = 0
    flg = True
    while flg:
        for i in range(len(nums)):
            if nums[i] % 2 == 0:
                num = nums[i] / 2
                nums[i] = num
            else:
                flg = False
                break
        if flg:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9088
#include<stdio.h>
int main()
{
    int n,i,max=0,ans=0,k,a,chk=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a);
        if(i==0) k=a;
        if(k==a)  chk++;
        if(a>max) max=a;
        ans=ans+a;
    }
    if(chk==n) printf("%d\n",ans);
    else printf("%d\n",ans-max/2);
        return 0;

}


Measured memory_bytes: 128
//Compiler optimization
#pragma GCC optimize("Ofast")

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

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ': ' << x << endl

//const
const  ll INF = 1e18;

//どうせ使う
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;

int main(){
    ll d;cin >> n >> d;
    ans = 0;
    fr(i,n){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y <= d*d)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3544
import java.util.*;

public class Main {
    private static int solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.nextLine());
        int[] nums = lineToIntNums(scanner.nextLine());

        for (int i = 0; i < N; i ++) {
            nums[i] --;
        }

        int ret = 0;
        for (int i = 0; i < N; i ++) {
            if (nums[i] == i) {
                if (i == N - 1) {
                    swap(i - 1, i, nums);
                } else {
                    swap(i, i + 1, nums);
                }
                ret ++;
            }
        }

        return ret;
    }

    private static void swap(int i, int j, int[] nums) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }

    private static final String ex1 = "5\n" +
            "1 4 3 5 2";
    private static final String ex2 = "2\n" +
            "1 2";
    private static final String ex3 = "2\n" +
            "2 1";
    private static final String ex4 = "9\n" +
            "1 2 4 9 5 8 7 3 6";

    public static void main(String[] args) {
//        System.out.println(solve(new Scanner(ex1)));
//        System.out.println(solve(new Scanner(ex2)));
//        System.out.println(solve(new Scanner(ex3)));
//        System.out.println(solve(new Scanner(ex4)));

        System.out.println(solve(new Scanner(System.in)));
    }

    private static int[] lineToIntNums(String line) {
        String[] strNums = line.split(" ");
        int[] ret = new int[strNums.length];
        for (int i = 0; i < strNums.length; i ++) {
            ret[i] = Integer.parseInt(strNums[i]);
        }
        return ret;
    }

    private static long[] lineToLongNums(String line) {
        String[] strNums = line.split(" ");
        long[] ret = new long[strNums.length];
        for (int i = 0; i < strNums.length; i ++) {
            ret[i] = Long.parseLong(strNums[i]);
        }
        return ret;
    }
}


Measured memory_bytes: 51064
card = sum([list(map(int, input().split())) for _ in range(3)], [])

check = sum([[False, False, False] for _ in range(3)], [])

ls = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 4, 8],
    [2, 4, 6],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8]
]

N = int(input())

result = "No"

for i in range(N):
    b = int(input())
    if b in card:
        check[card.index(b)] = True
    for e in ls:
        if all([check[el] for el in e]):
            result = "Yes"
            break

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,l[110];
    cin>>n;
    rep(i,n)cin>>l[i];
    sort(l,l+n);
    int ans=0;
    rep(i,n){
        rep(j,n){
            rep(k,n){
                if(i<j&&j<k){
                    if(l[i]<l[j]&&l[j]<l[k]){
                        if(l[i]+l[j]>l[k])ans++;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
const std::string yes = "Yes";
const std::string no  = "No";

//modint
template<long long mod> struct modint {
    long long x;
    modint(long long x=0) : x((x%mod+mod)%mod) {}
    static int get_mod() { return mod; }
    modint &operator+=(const modint &a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator-=(const modint &a) {
        if((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator*=(const modint &a) {
        x = (int) (1LL * x * a.x % mod);
        return *this;
    }
    modint &operator/=(const modint &a) {
        *this *= a.inv();
        return *this;
    }
    modint operator-() const { return modint(-x); }
    modint operator+(const modint &a) const { return modint(*this) += a; }
    modint operator-(const modint &a) const { return modint(*this) -= a; }
    modint operator*(const modint &a) const { return modint(*this) *= a; }
    modint operator/(const modint &a) const { return modint(*this) /= a; }
    bool operator==(const modint &a) const { return x == a.x; }
    bool operator!=(const modint &a) const { return x != a.x; }
    modint pow(long long t) const {
        if (!t) return 1;
        modint<mod> a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    modint inv() const {
        return pow(mod-2);
    }
    friend std::ostream &operator<<(std::ostream &os, const modint &a) { return os << a.x; }
    friend std::istream &operator>>(std::istream &is, modint &a) {
        long long t;
        is >> t;
        a = modint<mod>(t);
        return (is);
    }
};
//const long long mod = 998244353;
const long long mod = 1000000007;
using mint = modint<mod>;

int main(){
    int n; std::cin >> n;
    mint ans = 1;
    rep(i,n) ans *= i+1;
    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3580
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		MaximumDifference solver = new MaximumDifference();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class MaximumDifference {

		private int n;
		private ArrayList<Integer> a;
		private int output;

		private Scanner scanner;

		public MaximumDifference() {
			scanner = new Scanner(System.in);
		}

		public void readInput() {
			a = new ArrayList<Integer>();
			n = scanner.nextInt();
			for(int i=0; i<n; i++) {
				a.add(scanner.nextInt());
			}
		}

		public void solve() {
			Collections.sort(a);
			output = a.get(a.size()-1) - a.get(0);
		}

		public void writeOutput() {
			System.out.println(output);
		}
	}
}


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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            cout<<s[i];
        }
    }
    cout<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int N;
int A[100];

void show() {
  for (int i = 0; i < N; i++) {
    printf("%d%c", A[i], i == N-1 ? '\n' : ' ');
  }
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }

  bool flag = true;
  int cnt = 0;
  while(flag) {
    flag = false;
    for(int j = N-1; j >= 1; j--) {
      if(A[j] < A[j-1]) {
        swap(A[j], A[j-1]);
        flag = true;
        cnt++;
      }
    }
  }
  show();
  printf("%d\n", cnt);
}

Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 3564
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, K) = list(map(int,input().split()))
H  = list(map(int,input().split()))
H.sort(reverse=True)
# print(H)

if K >= len(H):
    print(0)
    exit(0)

Hrest = H[K:]
# print(Hrest)
ans = sum(Hrest)
print(ans)


Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


int main()
{
    ll n;
    cin >> n;
    vector<ll> x;
    rep(i, n){ ll tmp; cin >> tmp; x.push_back(tmp);}

    vector<ll> sum;
    ll sum_cnt = 0;
    rep(i, n + 1) {
        sum.push_back(sum_cnt);
        sum_cnt += x[i];
    }

    mint ans_m(0); //答え
    mint mut(1); //(n-1)!除算
    for (ll i = 1; i < n; i++)
    {
        mint m(i);
        mut *= m;
    }
    mint sumprob(0);
    rep(i, n - 1){
        ll ip = i + 1;
        mint ans_part(0);
        mint line = x[ip] - x[i];
        sumprob += (mint)1/(mint)ip;
        ans_part = sumprob * line;
        ans_part *= mut;
        //cout << ans_part.x << endl;
        ans_m += ans_part;
    }

    cout << ans_m.x << endl;

}



Measured memory_bytes: 2548
def maxheapify(A,i):
    l = 2*i
    r = 2*i + 1

    if l < len(A) and A[l] > A[i]:
        largest = l
    else:
        largest = i
    
    if r < len(A) and A[r] > A[largest]:
        largest = r

    if largest != i:
        A[i],A[largest] = A[largest],A[i]
        maxheapify(A,largest)

if __name__ == "__main__":
    n = int(input())
    heap = list(map(int,input().split()))
    heap.insert(0,0)

    for i in range(int(len(heap)/2),0,-1):
        maxheapify(heap,i)

    for n in range(1,len(heap)):
        print(' {}'.format(heap[n]),end='')
    print()



Measured memory_bytes: 63704
// Program to count the numbers divisible by 
// M in a given range 
#include <bits/stdc++.h> 
using namespace std; 
using ll=long long int;
int main()
{
    ll n,c=0;
    cin>>n;
    
    for(int i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        
        if( i%2!=0 && x%2!=0 )
        c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3560
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    ll n,v;
    cin>>n>>v;
    V<ll> a(n,0),b(n,0),c(n,0),d(n,0);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>c[i];
    for(int i=0;i<n;i++)cin>>d[i];
    V<ll> ab,cd;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)ab.emplace_back(a[i]+b[j]);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)cd.emplace_back(c[i]+d[j]);
    }
    sort(all(cd));
    ll ans=0;
    for(int i=0;i<ab.size();i++){
        ans+=upper_bound(all(cd),v-ab[i])-lower_bound(all(cd),v-ab[i]);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 23120
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <numeric>

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &aa:a) cin >> aa;
    int k = 1;
    for (auto aa : a) {
        if (aa == k) {
            ++k;
        }
    }
    if (k == 1) {
        cout << "-1\n";
        return 0;
    }
    cout << n - k + 1 << "\n";
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
import math


def solve(R: int):
    print(math.pi * 2 * R)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    solve(R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    int N,M;
    scanf("%d%d",&N,&M);
    data gate[M];
    rep(i,M){
        scanf("%d%d",&gate[i].a,&gate[i].b);
    }
    int min=100000,max=0;
    rep(i,M){
        if(max<gate[i].a){
            max=gate[i].a;
        }else{
            ;
        }
        if(min>gate[i].b){
            min=gate[i].b;
        }else{
            ;
        }
    }
    if(min-max<0){
        printf("0");
        return 0;
    }else{
        printf("%d",min-max+1);
    }
}



Measured memory_bytes: 2472
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main()
{
	int n, x, t, ans;
	cin >> n >> x >> ans;
	ans = abs(x - ans);
	while (--n){
		cin >> t;
		ans = gcd(ans, abs(x - t));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>v(N);
  for(int i=0;i<N;i++) cin>>v[i];
  vector<int>c(N);
  for(int i=0;i<N;i++) cin>>c[i];
  long x=0;
  for(int i=0;i<N;i++) if(v[i]-c[i]>0)x+=(v[i]-c[i]);
  cout<<x<<endl;
}
    
  
  

Measured memory_bytes: 256
from collections import deque
n, c = [int(x) for x in input().split()]
Q = []
for _ in range(n):
    Q.append(deque())
for _ in range(c):
    p, t, x = [int(_) for _ in (input()+" 0").split()][:3]
    if p == 0:
        Q[t].append(x)
    elif p == 1:
        try:
            print(Q[t][0])
        except IndexError:
            pass
    elif p == 2:
        try:
            Q[t].popleft()
        except IndexError:
            pass



Measured memory_bytes: 14584
def main(n,k,h):
    #初期化
    inf = 2**31 -1
    dp = [inf] * n
    dp[0] = 0
    #現在の足場
    for i in range(n):
        #ジャンプする距離
        for j in range(1, k+1):
            #ジャンプ先が範囲外ならスキップ
            if n-1 < i+j:
                break
            #dpマップに値を配る
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))
    return dp[-1]

n,k = map(int,input().split())
h = list(map(int,input().split()))
print(main(n,k,h))

Measured memory_bytes: 52448
#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3516
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().split()

S = sorted(S)
ls = [[] for i in range(N + 1)]
max_num = 0
left = 0
right = 0
while right < N:
    while right < N and S[left] == S[right]:
        right += 1
    if (right  - left) >= max_num:
        ls[right - left].append(S[left].decode())
        max_num = right - left
    left = right
    
print('\n'.join(ls[max_num]))


Measured memory_bytes: 47872
from itertools import accumulate
import bisect
n, m, k = map(int,input().split())
a_lst = [0] + list(accumulate(list(map(int,input().split()))))
b_lst = list(accumulate(list(map(int,input().split()))))

ans = 0
for i in range(n+1):
    cnt = i
    num = k - a_lst[i]
    if num < 0:
        continue
    b_yomeru = bisect.bisect_right(b_lst,num)
    cnt += b_yomeru
    if ans < cnt:
        ans = cnt

print(ans)


Measured memory_bytes: 45204
#include<bits/stdc++.h>
#define U [1<<17]={}
typedef long long L;using namespace std;map<L,L> T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
    d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}
L M(L i){return i?B[i]+M(i-(i&-i)):0;}
L S(L x,L i){for(x=G(x)-M(i+1)+M(i++);i<1e5;B[i]+=x,i+=i&-i);}
L W(){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}
main(){for(cin>>n>>k;++p<n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(c=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;S(a=H[a],O[a]=c++))X[a]=p;
       for(cin>>a;cin>>s>>a>>b;*s&2?W():A[a]+=b,S(H[a],O[a]),a?S(a,O[a]-1):0);}

Measured memory_bytes: 33492
# coding: utf-8
# Your code here!
a=int(input())
b=int(input())
c=int(input())
d=int(input())
ans=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==d:
                ans+=1
print(ans)

Measured memory_bytes: 3060