akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		HashMap<String,Integer> x=new HashMap<>();
		int n=sc.nextInt();
		String[] z=new String[n];
		int max=1;
		for(int i=0;i<n;i++) {
			z[i]=sc.next();
		}
		Arrays.sort(z);
		for(int i=0;i<n;i++) {
			if(x.containsKey(z[i])) {
				x.put(z[i], x.get(z[i])+1);
				max=Math.max(max, x.get(z[i]));
			}
			else
				x.put(z[i], 1);
		}
		for(int i=0;i<n;i++) {
			if(x.get(z[i])==max) {
				pw.println(z[i]);
				x.put(z[i], -1);
			}
		}
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int k; cin >> k;
    string s; cin >> s;
    if(s.size() <= k) {
        cout << s;
    } else {
        irep(i, k) {
            cout << s[i];
        }
        cout << "...";
    }
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 3620
#include <string>
#include <iostream>

using namespace std;

int main()
{
    string S, P; int N;
    
    getline(cin, P);
    
    N = stoi(P);
    
    for(int i = 0; i < N; i++)
    {
        getline(cin, S);
        
        while(S.find("Hoshino") != string::npos)
        {
            S.replace(S.find("Hoshino"), 7, "Hoshina");
        }
        
        cout << S << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  string ans="No";
  for(int i=0;i<S.size()-1;i++){
    if(S[i]=='A' && S[i+1]=='C'){ans="Yes";}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static List<Integer> P;
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        boolean takahashiTurn = true;
        while(A>0 && C>0){
            if(takahashiTurn){
                C -= B;
            }else{
                A -= D;
            }
            takahashiTurn = !takahashiTurn;
        }
        if(A <= 0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

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

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll a,v,b,w,t;
    
    cin >> a >> v >> b >> w >> t;

    ll tm;
    if(w-v!=0){
        tm = abs(b-a)/(v-w);
    }else if(a-b==0){
        cout << "YES" << endl;
        return 0;
    }else{
        cout << "NO" << endl;
        return 0;
    }

    if(tm < t && tm > 0){
        cout << "YES" << endl;
    }else if(tm == t && abs(b-a)%(v-w) == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3648
N = int(input())
s = [int(input()) for i in range(N)]

if sum(s) % 10 == 0:
    Min = 1000
    for i in s:
        if i % 10:
            Min = min(Min, i)
    ans = sum(s) - Min if Min != 1000 else 0

else:
    ans = sum(s)

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, M;
string S[101], T[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> S[i];
    cin >> M;
    rep(i, 0, M) cin >> T[i];

    int ans = 0;
    rep(si, 0, N) {
        int point = 0;
        rep(i, 0, N) if (S[i] == S[si]) point++;
        rep(i, 0, M) if (T[i] == S[si]) point--;
        ans = max(ans, point);
    }
    cout << ans << endl;
}

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

int main() {
  int i;
  cin >> i;
  
  int s1, s2, s3;
  s1 = i / 100 > 0 ? 1 : 0;
  i -= 100 * s1;
  s2 = i / 10 > 0 ? 1 : 0;
  i -= 10 * s2;
  s3 = i;
  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}

int main()
{
    ios;
    ll n;
    cin>>n;
    ll ans1,ans2;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans1=i;
            ans2=n/i;
        }
    }
 
    cout<<ans1+ans2-2<<endl;




}















Measured memory_bytes: 3588
#include <iostream>

int main()
{
	int N, M, A, B,ans=0;
	long *H;
	bool *t;
	std::cin >> N >> M;
	H = new long[N];
	t = new bool[N];
	for (int i = 0; i < N; i++)
	{
		std::cin >> H[i];
	}
	for (int i = 0; i < M; i++)
	{
		std::cin >> A >> B;
		if (H[A-1] <= H[B-1])t[A-1] = true;
		if (H[A-1] >= H[B-1])t[B-1] = true;
	}
	for (int i = 0; i < N; i++)
	{
		if (t[i] != true)ans += 1;
	}
    std::cout << ans;
}

Measured memory_bytes: 4516
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	gets := getStdinIntArr()
	fmt.Println(gets[0] * gets[1])
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	sc.Scan()
	rtn, _ := strconv.Atoi(sc.Text())
	return rtn
}
func getStdinInt64() int64 {
	sc.Scan()
	rtn, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}


Measured memory_bytes: 1756
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<vector>
#define R register
#define next kkksc03
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
inline ll read();
inline void write(ll x);
inline void writesp(ll x);
inline void writeln(ll x);
char s1[1000000],s2[1000000];
ll ans,n;
int main(){	
	n=read();
	for(R ll i=1,x;i<=n;i++){
		x=read();
		if(x==ans+1) ans++;
	}
	if(!ans) writeln(-1);
	else writeln(n-ans);
}
inline ll read(){
	ll x=0,t=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') t=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*t;
}
inline void write(ll x){
	if(x<0){putchar('-');x=-x;}
	if(x<=9){putchar(x+'0');return;}
	write(x/10);putchar(x%10+'0');
}
inline void writesp(ll x){
	write(x);putchar(' ');
}
inline void writeln(ll x){
	write(x);putchar('\n');
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    double a,b;
    cin >> a >> b;
    printf("%9f\n",a/b);
    return 0;
}

Measured memory_bytes: 256
import math
import sys

class SegmentTree(object):
    __slots__ = ["elem_size", "tree", "default"]

    def __init__(self, a: list, default: int):
        real_size = len(a)
        self.elem_size = elem_size = 1 << math.ceil(math.log2(real_size))
        self.tree = tree = [default] * (elem_size * 2)
        tree[elem_size:elem_size+real_size] = a
        self.default = default

        for i in range(elem_size - 1, 0, -1):
            l, r = tree[i<<1], tree[(i<<1)+1]
            tree[i] = l if l < r else r

    def get_value(self, x: int, y: int) -> int:
        l, r = x + self.elem_size, y + self.elem_size
        tree, result = self.tree, self.default
        while l < r:
            if l & 1:
                if tree[l] < result:
                    result = tree[l]
                l += 1
            if r & 1:
                r -= 1
                if tree[r] < result:
                    result = tree[r]
            l, r = l >> 1, r >> 1

        return result

    def set_value(self, i: int, value: int) -> None:
        k = self.elem_size + i
        self.tree[k] = value
        self.update(k)

    def update(self, i: int) -> None:
        tree = self.tree
        while i > 1:
            i >>= 1
            l, r = tree[i<<1], tree[(i<<1)+1]
            tree[i] = l if l < r else r
 
n, q = map(int, input().split())
tree = SegmentTree([2**31-1]*n, 2**31-1)
ans = []
append = ans.append
for com, x, y in (map(int, l.split()) for l in sys.stdin.readlines()):
    if com == 0:
        tree.set_value(x, y)
    else:
        append(tree.get_value(x, y+1))
print(*ans, sep="\n")


Measured memory_bytes: 16352
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

N,M=mint()
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for x in range(N-M+1):
    for y in range(N-M+1):
        tmp=True
        for i,j in product(range(M),repeat=2):
            if A[x+i][y+j]!=B[i][j]:
                tmp=False
                break
        if tmp:
            print('Yes')
            exit()
print('No')

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vec h(n);
    init(h);
    h.insert(h.begin(), 0);
    h.push_back(0);

    int cnt = 0;
    bool on = false;
    while (sum_(h) > 0) {
        repall (i, h) {
            if (not on and i > 0) on = true;
            if (on and i == 0) on = false, cnt++;
            if (i > 0) i--;
        }
    }
    print(cnt);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
    int n;
    cin>>n;

    int ans=1;
    int now;
    int tmp;
    int hoge=0;
    for(int i=1;i<=n;i++){
        now = 0;
        tmp = i;
        while(1){
            if(tmp%2==0){
                now++;
            }
            else{
                break;
            }
            tmp =  tmp/2;
        }
        if(hoge<now){
             hoge = now;
             ans = i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int M, D, ans = 0;
    cin >> M >> D;
    FOR(m, 1, M + 1){
        FOR(d, 1, D + 1){
            int d1 = d % 10;
            int d10 = d / 10;
            if(d1 >= 2 && d10 >= 2 && d1 * d10 == m) ans++;
        }
    }
    PRINT(ans);
    return 0;
}

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

int main(){

    int N,M;
    cin>>N>>M;
    int ans=1;
    for(int i=0;i<M;i++){
        ans*=2;
    }
    ans=ans*(100*(N-M)+1900*M);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
r = [True] * N
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    if H[A] > H[B]:
        r[B] = False
    elif H[A] < H[B]:
        r[A] = False
    else:
        r[A] = False
        r[B] = False
print(len(list(_r for _r in r if _r == True)))

Measured memory_bytes: 20024
S, T, D = map(int, input().split())
S -= T
*W, = map(int, input().split())
F = sum(W)
if F >= 0:
    su = S
    for i, w in enumerate(W):
        su += w
        if su <= 0:
            print(i+1)
            break
    else:
        print(-1)
    exit(0)
su = 0
mi = 0
for d in W:
    su += d
    mi = min(mi, su)

k = max((S+mi-F-1) // -F, 0)
S += k*F
for i, w in enumerate(W):
    S += w
    if S <= 0:
        print(i+1+k*D)
        break
else:
    assert 0


Measured memory_bytes: 16128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	cout << (N-2)*180 << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll all;

long sub(const int ai, const vector<int>& count) {
    ll r = 0;
    if (count[ai] <= 1) {
        r = all;
    } else {
        r = all - count[ai] + 1;
    }

    return r;
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> count(n + 1, 0);
    map<long, long> m;

    rep(i, n) {
        cin >> a[i];
        count[a[i]]++;
    }

    for (int i = 0; i < n; i++) {
        if (count[a[i]] >= 2) {
            m[a[i]] = count[a[i]];
        }
    }

    all = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        all += it->second * (it->second - 1) / 2;
    }

    // for (auto it = m.begin(); it != m.end(); it++) {
    //     printf("m %d->%d\n", it->first, it->second);
    // }
    for (int i = 0; i < n; i++) {
        cout << sub(a[i], count) << endl;
    }

    return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout<< #i<< "= "<< i << endl
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>>x;
    vector<int> ans(n);


    REP(i,n){
        int t;
        cin >> t;
        x.pb(make_pair(t,i));
    }

    sort(x.begin(),x.end());
    REP(i,n){
        int k = x[i].second;
    if(i >= (n/2)){
        ans.at(k) = x[n/2-1].first;
    }else{
        ans.at(k) = x[n/2].first;
        }
    }

    REP(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main()
{
    ll ans=0;

    string s;

    int n;
    cin>>n;
    ll m=0,a=0,r=0,c=0,h=0;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s[0]=='M')m++;
        if(s[0]=='A')a++;
        if(s[0]=='R')r++;
        if(s[0]=='C')c++;
        if(s[0]=='H')h++;
    }

    if((m!=0) + (a!=0) + (r!=0)+(c!=0)+(h!=0) <3)cout<<0;
    else
    {
        ans += m*a*r;
        ans += m*a*c;
        ans += m*a*h;
        ans += m*r*c;
        ans += m*r*h;
        ans += m*c*h;
        ans += a*r*c;
        ans += a*r*h;
        ans += a*c*h;
        ans += r*c*h;
        cout<<ans;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/divisors.hpp
#ifndef DIVISORS_HPP
#define DIVISORS_HPP


namespace tools {
  template <typename T>
  ::std::vector<T> divisors(const T& n) {
    ::std::vector<T> head;
    ::std::vector<T> tail;

    T i;
    for (i = static_cast<T>(1); i * i < n; ++i) {
      if (n % i == static_cast<T>(0)) {
        head.push_back(i);
        tail.push_back(n / i);
      }
    }

    // if n is a square number
    if (i * i == n) {
      head.push_back(i);
    }

    ::std::copy(tail.rbegin(), tail.rend(), ::std::back_inserter(head));
    return head;
  }
}

#endif

// main.cpp

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

  i64 answer = std::numeric_limits<i64>::max();
  if (n == s) {
    answer = std::min(answer, n + 1);
  }
  if (n > s) {
    for (const i64& b_minus_one : tools::divisors(n - s)) {
      const i64 b = b_minus_one + 1;
      i64 f = 0;
      i64 tmp_n = n;
      while (tmp_n > 0) {
        f += tmp_n % b;
        tmp_n /= b;
      }
      if (f == s) {
        answer = std::min(answer, b);
      }
    }
  }

  std::cout << (answer == std::numeric_limits<i64>::max() ? -1 : answer) << std::endl;
  return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int main() {
	int n, m;
	long long a[N], ans = 10000000000;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i + m <= n; i++) {
		if (a[i] <= 0 && 0 <= a[i + m - 1]) {
			ans = min(ans, 2 * (a[i + m - 1] - a[i]) - max(-a[i], a[i + m - 1]));
		} else {
			ans = min(ans, max(abs(a[i + m - 1]), abs(a[i])));
		}
		// cout << i << ' ' << ans << '\n';
	}
	cout << ans << '\n';
}


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

#ifdef LOCAL
 #include <bits/debugger.hpp>
 #define __int64 __int64_t
#else 
 #define debug(a...) //
#endif

int main()
{
 ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
 int n , k;
 cin >> n >> k;
 vector<int> a(n);
 for(int& i : a) cin >> i;
 sort(a.begin() , a.end());
 int ans = 0;
 for(int i = 0; i < k; i++) ans += a[i];
 cout << ans << '\n';
 return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 100005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,ar[N],dp[N],k;
ll maxval(ll i){
	if(i>=n) return 0;
	
	if(dp[i]!=-1){
		return dp[i];
	}
	ll an=1e18,j;
	for(j=i+1;j<=i+k&&j<=n;j++){
		an=min(an,maxval(j)+abs(ar[j]-ar[i]));
	}
	return dp[i]=an;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,l;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	memset(dp,-1,sizeof(dp));
	ll an=maxval(1);
	cout<<an;
	return 0;
}

Measured memory_bytes: 9800
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	bool operator<(const struct Info &arg) const{
		return used_num > arg.used_num;
	};
	int array[16];
	int state,sum_cost,used_num;
};

int N,M;
int POW[17];
int dp[65536];
int futon[16],demand[101];

void func(){

	futon[0] = 0;
	for(int i = 1; i <= N; i++)scanf("%d",&futon[i]);
	demand[0] = 0;
	for(int i = 1; i <= M; i++)scanf("%d",&demand[i]);

	sort(demand,demand+(M+1));

	N++;

	for(int i = 0; i < POW[N]; i++)dp[i] = BIG_NUM;

	Info first;
	first.state = 0;
	first.used_num = 0;
	first.sum_cost = 0;

	priority_queue<Info> Q;

	Q.push(first);

	int tmp_sum,next_state;

	while(!Q.empty()){

		if(Q.top().used_num == N){
			Q.pop();
		}else if(Q.top().sum_cost > dp[Q.top().state]){
			Q.pop();
		}else{

			for(int loop = 0; loop < N; loop++){
				if(Q.top().state & (1 << loop)){
					//Do noghint
				}else{
					Info next_info;
					for(int i = 0; i < Q.top().used_num; i++)next_info.array[i] = Q.top().array[i];
					next_info.array[Q.top().used_num] = futon[loop];

					if(Q.top().used_num > 0){
						next_info.array[Q.top().used_num] += next_info.array[Q.top().used_num-1];
					}
					int index = 0;
					tmp_sum = 0;
					for(int i = 1; i <= M; i++){
						while(index < Q.top().used_num && abs(demand[i]-next_info.array[index]) > abs(demand[i]-next_info.array[index+1]))index++;
						tmp_sum += abs(demand[i]-next_info.array[index]);
					}

					next_state = Q.top().state + POW[loop];

					if(dp[next_state] > tmp_sum){
						dp[next_state] = tmp_sum;
						next_info.state = next_state;
						next_info.sum_cost = tmp_sum;
						next_info.used_num = Q.top().used_num+1;
						Q.push(next_info);
					}
				}
			}
			Q.pop();
		}
	}

	printf("%d\n",dp[POW[N]-1]);
}


int main(){

	for(int i = 0; i < 17; i++)POW[i] = pow(2,i);

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}
	return 0;

}

Measured memory_bytes: 11192
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

typedef struct{
    int parent;
    int depth;
    int mlch;
    int r;
}node;

vector<node> l;

void decide(int d,int id){
    l[id].depth = d;
    if(l[id].r != -1)decide(d,l[id].r);
    if(l[id].mlch != -1)decide(d+1,l[id].mlch);
}

int main(void){
    int n,k,box,num;
    cin >> n;
    l.resize(n);
    for(int i=0;i<n;i++){
        l[i].parent = -1;
        l[i].mlch = -1;
        l[i].r = -1;
    }
    for(int i=0;i<n;i++){
        cin >> num;
        cin >> k;
        box = num;
        for(int j=0;j<k;j++){        
            if(j==0){
                cin >> l[num].mlch;
                num = l[num].mlch;
                l[num].parent = box;
            }else{
                cin >> l[num].r;
                num = l[num].r;
                l[num].parent = box;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(l[i].parent == -1){
            decide(0,i);
            break;
        }
    }
    for(int i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d, ",i,l[i].parent,l[i].depth);
        if(l[i].parent == -1){
            printf("root, [");
            if(l[i].mlch != -1){
                printf("%d",l[i].mlch);
                num = l[i].mlch;
                while(l[num].r != -1){
                    printf(", %d",l[num].r);
                    num = l[num].r;
                }
            }
            printf("]\n");
        }else if(l[i].mlch == -1){
            printf("leaf, []\n");
        }else{
            printf("internal node, [%d",l[i].mlch);
            num = l[i].mlch;
            while(l[num].r != -1){
                printf(", %d",l[num].r);
                num = l[num].r;
            }
            printf("]\n");
        }
    }
    return 0;
}


Measured memory_bytes: 7512
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make(map[int]int, n)
	for i := 1; i <= n; i++ {
		temp := 0
		fmt.Scan(&temp)
		a[i] = temp
	}

	temp := map[int]int{}
	val := []int{}
	for i, v := range a {
		temp[v] = i
		val = append(val, v)
	}
	sort.Ints(val)
	for _, v := range val {
		fmt.Printf("%d ", temp[v])
	}
}

Measured memory_bytes: 13056
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
const int N = 2e5;
const long long INF = 2e12;
using namespace std;
int n,a[N + 5],p[N + 5];
long long ans,k;
int cmp(int x,int y)
{
    return x > y;
}
int check(long long x)
{
    long long m = k,now;
    for (int i = 1;i <= n;i++)
        if (1ll * a[i] * p[i] > x)
        {
            now = x / p[i];
            now = a[i] - now;               
            if (m < now)
                return 0;
            if (now > 0)
                m -= now;
        }
    return 1;
}
int main()
{
    scanf("%d%lld",&n,&k);
    for (int i = 1;i <= n;i++)
        scanf("%d",&a[i]);
    for (int i = 1;i <= n;i++)
        scanf("%d",&p[i]);
    sort(a + 1,a + n + 1);
    sort(p + 1,p + n + 1,cmp);
    long long l = 0,r = INF,mid;
    while (l <= r)
    {
        mid = l + r >> 1;
        if (check(mid))
            r = mid - 1,ans = mid;
        else
            l = mid + 1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		scan.close();
		int []k = new int[3];
		k[0] = A + B;
		k[1] = A - B;
		k[2] = A * B;
		Arrays.sort(k);
		System.out.println(k[2]);

	}
}

Measured memory_bytes: 25172
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, L[MAXN], R[MAXN], mx, ans, ind;
pll P[MAXN];
set<pll> stL, stR;

int main() {
    fast_io;

    cin >> n;
    for (ll i = 1; i <= n; i++) {
        cin >> L[i] >> R[i];
        if (L[i] > mx || L[i] == mx && R[i] < R[ind]) ind = i;
        mx = max(mx, L[i]);
        P[i] = {R[i], L[i]};
        ans = max(ans, R[i] - L[i] + 1);
        stL.insert({L[i], i});
        stR.insert({R[i], i});
    }


    sort(P + 1, P + n + 1);
    P[n + 1].X = INF;
    ll l = 0;
    for (ll i = 1; i <= n; i++) {
        if (P[i].X >= R[ind]) continue;
        l = max(l, P[i].Y);
        ans = max(ans, min(R[ind] - L[ind] + 1, max(0LL, P[i + 1].X - L[ind] + 1)) + max(0LL, P[1].X - l + 1));
        //cout << i << sep << min(R[ind] - L[ind] + 1 , max(0LL , P[i + 1].X - L[ind] + 1)) + max(0LL , P[1].X - l + 1) << endl;
    }


    for (ll i = 1; i <= n; i++) {
        stL.erase({L[i], i});
        stR.erase({R[i], i});
        ll A = (*prev(stL.end())).X, B = (*stR.begin()).X;
        ans = max(ans, max(0LL, B - A + 1) + max(0LL, R[i] - L[i] + 1));
        stL.insert({L[i], i});
        stR.insert({R[i], i});
    }

    cout << ans << endl;

    return 0;
}
/*

*/


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

int main() {
 char x,l;
 int cards[4][13], y, z, n, j, k;
 cin >> n;
 for(j = 0; j < 4; j++) {
   for(k = 0; k < 13; k++) {
     cards[j][k] = 0;
   }
 }

 for(int i = 0; i < n; i++) {
   cin >> x >> y;
   if (x == 'S') z = 0;
   else if (x == 'H') z = 1;
   else if (x == 'C') z = 2;
   else z = 3;
   cards[z][y-1] = 1;
 }       
 for(j = 0; j < 4; j++) {
   for(k = 0; k < 13; k++) {
     if(cards[j][k] == 0) {
if (j == 0) l = 'S';
else if (j == 1) l = 'H';
else if (j == 2) l = 'C';
else l = 'D'; 
cout << l << " " << k + 1 << endl;
     }       
   }       
 }       
} 

Measured memory_bytes: 3040
N,K = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
A.insert(0,0)
rireki = [1]
counter = 1
now = 1
flag = [0 for _ in range(N + 1)]
flag[1] = 1
while(flag[A[now]] == 0):
    counter += 1
    rireki.append(A[now])
    flag[A[now]] = counter
    now = A[now]
if K < flag[A[now]]:
    print(rireki[K])
else:
    K += counter - (flag[A[now]] - 1)
    K -= flag[A[now]] - 1
    K %= counter - (flag[A[now]] - 1)
    print(rireki[flag[A[now]]- 1 + K])



Measured memory_bytes: 32244
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#define pb push_back
#define mk make_pair
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, pair<int, int> >piii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
const int inf = 1e9;
const LL INF = 1e18;
const int M = 1e9 + 7;
//__int128
int f[200];

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

	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i){
		int x;
		cin >> x;
		f[i] = f[i - 1] + x;
	}
	int res = inf;
	for(int i = 1; i <= n; ++i){
		res = min(res, abs(f[n] - 2 * f[i - 1]));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  map<long long,int> last;
  last[0] = 1;
  int mod = 1000000007;
  long long tag = 1e6;
  for(int i=0;i<n;++i){
    map<long long,int> curr;
    int tmp;cin>>tmp;
    // 以1e6为界限;
    for(auto i:last){
      long long key = i.first;
      long long v = i.second;
      if(key%tag == tmp){
        curr[key+1] += v;
        curr[key+1] %= mod;
      }
      if((key/tag)%tag == tmp){
        curr[key+tag] += v;
        curr[key+tag] %= mod;
      }
      if(key/(tag*tag) == tmp){
        curr[key+tag*tag] += v;
        curr[key+tag*tag] %= mod;
      }  
    }
    last = curr;
  }
  long long res = 0;
  for(auto i:last){
    res+=i.second;
  	res%=mod;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

sys.setrecursionlimit(5*10**5)

N,M = map(int,input().split())
edge = [[] for i in range(N)]
rev_edge = [[] for i in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    edge[a].append(b)
    rev_edge[b].append(a)

seen = [False]*N
stop = []

def dfs(v):
    for nv in edge[v]:
        if not seen[nv]:
            seen[nv]=True
            dfs(nv)
    stop.append(v)

for i in range(N):
    if not seen[i]:
        seen[i] = True
        dfs(i)

seen = [False]*N

def scc():
    res = []
    connect = []
    def rev_dfs(v):
        for nv in rev_edge[v]:
            if not seen[nv]:
                connect.append(nv)
                seen[nv]=True
                rev_dfs(nv)

    while stop:
        while stop and seen[stop[-1]]:
            stop.pop()
        if not stop:
            break
        connect = [stop[-1]]
        seen[stop[-1]] = True
        rev_dfs(stop[-1])
        res.append(connect)
    return res

res = scc()
print(len(res))
for L in res:
    print(len(L),*L)


Measured memory_bytes: 252968
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> v(true, n);

    int l = 1, r = n;
    for(int i = 0; i < m; i++) {
        int l_in, r_in;
        cin >> l_in >> r_in;
        if (l_in > l) {
            l = l_in;
        }
        if (r_in < r) {
            r = r_in;
        }
    }
    cout << (r >= l ? r-l+1 : 0) << endl;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let (n, w): (usize, usize) = (io.read(), io.read());

    //dp ： 価値を＿＿にするのに最小の重さ？
    let inf = 5 << 28;
    let mut dp = vec![vec![inf; 1000902]; n + 2];
    dp[0][0] = 0;
    for i in 1..n + 1 {
        let (ww, vv): (usize, usize) = (io.read(), io.read());
        //io.debug2(ww, vv);

        for j in 0..1000099 {
            if j >= vv {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - vv] + ww);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
        //io.debug2(i, &dp[i]);
    }
    let mut ans = 0;
    // for i in 0..1001 {
    //     ans = max(if dp[n][i] == inf { 0 } else { dp[n][i] }, ans);
    // }

    for i in 0..1000001 {
        if dp[n][i] <= w {
            ans = max(ans, i);
        }
    }
    io.writeln(ans);
}

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


Measured memory_bytes: 839932
#include <iostream>

int main()
{
    int64_t h, w;
    std::cin >> h >> w;

    if (h % 3 == 0 || w % 3 == 0)
    {
        std::cout << 0 << std::endl;
        return 0;
    }

    // 縦に3分割、横に3分割した時の差
    int64_t result = std::min(h,w);

    // 縦に先に分割する場合
    {
        const int64_t y = h * w / 3 / w;
        const int64_t x = w / 2;
        for (int i = 0; i < 3; ++i)
        {
            const int64_t a = (y + i) * w;
            const int64_t b = (h - (y + i)) * (w / 2);
            const int64_t c = (h - (y + i)) * (w - w / 2);

            const int64_t max = std::max(a, c);
            const int64_t min = std::min(a, b);
            result = std::min(result, max - min);
        }
    }

    // 横に先に分割する場合
    {
        const int64_t x = h * w / 3 / h;
        const int64_t y = h / 2;
        for (int i = 0; i < 3; ++i)
        {
            const int64_t a = (x + i) * h;
            const int64_t b = (w - (x + i)) * (h / 2);
            const int64_t c = (w - (x + i)) * (h - h / 2);

            const int64_t max = std::max(a, c);
            const int64_t min = std::min(a, b);
            result = std::min(result, max - min);
        }
    }

    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 3608
class UnionFind:

    def __init__(self, size: int):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.size = size
        self.parent = [-1] * size

    def find(self, x: int) -> int:
        """
        xを含む集合の代表を求める
        """
        if self.parent[x] < 0:
            return x
        # 集合の代表にリンクを繋ぎ変える
        same_group_items = []
        while self.parent[x] >= 0:
            same_group_items.append(x)
            x = self.parent[x]
        for child in same_group_items:
            self.parent[child] = x
        return x

    def unite(self, x: int, y: int):
        """
        xを含む集合とyを含む集合を併合する
        """
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x != root_y:
            if self.parent[root_x] >= self.parent[root_y]:
                self.parent[root_x] += self.parent[root_y]
                self.parent[root_y] = root_x
            else:
                self.parent[root_y] += self.parent[root_x]
                self.parent[root_x] = root_y

    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)

    def count_group(self) -> int:
        """
        集合の数を数える。
        """
        count = 0
        for i in range(self.size):
            if self.parent[i] < 0:
                count += 1
        return count


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

max_n = 0
for i in range(n):
    p = uf.find(i)
    max_n = max(max_n, -uf.parent[p])
print(max_n)


Measured memory_bytes: 18564