akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

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

int H, W;
vector<vector<char>> cc;
vector<vector<int>> check;

bool dfs (int x, int y) {
  check[y][x] = 1;
  if (x == W && y == H) {
    bool f = true;
    REP (i, 1, H + 1) {
      REP (j, 1, W + 1) {
	if (!((cc[i][j] == '#' && check[i][j] == 1) || (cc[i][j] == '.' && check[i][j] == 0))) f = false;
      }
    }
    if (f) return true;
    check[y][x] = 0;
    return false;
  }
  REP (i, 0, 2) {
    int xx = x + dx[i];
    int yy = y + dy[i];
    if (cc[yy][xx] == '.') continue;
    bool f = dfs(xx, yy);
    if (f) return true;
  }
  check[y][x] = 0;
  return false;
}


int main () {
  cin >> H >> W;
  cc = vector<vector<char>>(10, vector<char>(10, '.'));
  check = vector<vector<int>>(10, vector<int>(10, 0));
  REP (i, 1, H + 1) {
    REP (j, 1, W + 1) {
      cin >> cc[i][j];
    }
  }
  cout << (dfs(1, 1) == 1 ? "Possible" : "Impossible") << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import itertools

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main():
    N = int(input())    # maximum of N is 10^5

    for i in range(2, 500):
        tmp = combination_count(i, 2)
        if N < tmp:
            print('No')
            return
        elif N == tmp:
            print('Yes')
            array = [x+1 for x in range(i)]
            accum = [[] for x in range(i)]
            for idx, (i, j) in enumerate(itertools.combinations(array, 2)):
                accum[i-1].append(idx + 1)
                accum[j-1].append(idx + 1)
            print(len(accum))
            for item in accum:
                txt = str(len(item)) + " " + " ".join([str(x) for x in item])
                print(txt)
            return
        else:
            continue

    return


main()

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

#define ll long long
#define MOD 100000007

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << (ll)max(a*c, max(a*d, max(b*c, b*d)));
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <cmath>
using namespace std;
int main(){
  double x1, y2, x2, y1, x, y, c;
  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
  x=x2-x1;
  y=y2-y1;
  c = x*x + y*y;
  printf("%lf\n", sqrt(c));
}


Measured memory_bytes: 2744
#include <iostream>
#include <cmath>

using namespace std;

const int kMaxN = 100;

int main() {
    int n;
    int A[2][kMaxN];

    cin >> n;
    
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            cin >> A[i][j];
        }
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
        int sum = 0;
        int row = 0;
        for (int j = 0; j < n; j++) {
            sum += A[row][j];
            if (j == i) {
                row++;
                sum += A[row][j];
            }
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        if(s.contains("B") && s.contains("A")){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23892
import Control.Applicative
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

readInts :: IO (S.Set Int)
readInts =
    S.fromList . map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

main = do
    _ <- getLine
    ss <- readInts
    _ <- getLine
    ts <- readInts
    print . S.size $ ss `S.intersection` ts

Measured memory_bytes: 4284
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <iomanip>

using namespace std;

#define INF 0x3f3f3f3f
#define MAX 111
#define ll long long

int main()
{
    char s[123456];
    scanf("%s", s);
    int i, flag = 0, n = strlen(s);
    for(i = 1; i < n-1; i++)
    {
        if(s[i-1] != s[i+1])
        {
            flag = 1;
            break;
        }
    }
    if(flag)
    {
        if(n % 2 == 0) //偶数个
        {
            if(s[0] != s[n-1])
                printf("Second\n");
            else
                printf("First\n");
        }
        else
        {
            if(s[0] != s[n-1])
                printf("First\n");
            else
                printf("Second\n");
        }
    }
    else
        printf("Second\n");
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    ll n, m;
    cin >> n >> m;
    if(n==1 && m==1) cout << '1' << endl;
    else if(n==1) cout << m-2 << endl;
    else if(m==1) cout << n-2 << endl;
    else if(n==2 || m==2) cout << '0' << endl;
    else cout << (n-2) * (m-2) << endl;

    return 0;
}


Measured memory_bytes: 256
K = int(input())

base_runrun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
test_num = max(base_runrun) + 1

def check_runrun(num):
    runrun_flg = True
    str_num = str(num)
    for i in range(len(str_num)-1):
        if abs(int(str_num[i]) - int(str_num[i+1]))>1:
            runrun_flg = False
            break
    return runrun_flg

def check_ceil(num):
    str_num = str(num)
    ceil_digit = None
    for i in range(len(str_num)-1):
        tmp = int(str_num[i]) - int(str_num[i+1])
        if tmp >1:
            ceil_digit = i + 1 # 桁数とリストのインデックス調整
            nine = False
        elif tmp < -1:
            ceil_digit = i + 1 # 桁数とリストのインデックス調整
            nine = True
            break
    if ceil_digit is not None:
        if nine:
            num_seq = ''
            for _ in range(len(str_num)-ceil_digit):
                num_seq = num_seq + '9'
            str_num = str_num[:ceil_digit] + num_seq
            str_num = str(int(str_num)+1)
        else:
            num_seq = str(int(str_num[ceil_digit-1])-1)
            for _ in range(len(str_num)-ceil_digit-1):
                num_seq = num_seq + '0'
            str_num = str_num[:ceil_digit] + num_seq
    return int(str_num)


while K > len(base_runrun):
    runrun_flg = check_runrun(test_num)
    if runrun_flg:
        base_runrun.append(test_num)
        test_num += 1
    else:
        test_num = check_ceil(test_num)
print(base_runrun[K-1])

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void dfs(int v, P cant, vb &seen, const vii &g) {
  seen[v] = true;
  for(int nv : g[v]) {
    if(seen[nv]) continue;
    if(make_pair(min(v,nv), max(v,nv)) == cant) continue;
    dfs(nv, cant, seen, g);
  }
}

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

  int n, m;
  cin >> n >> m;
  vii g(n);
  vector<P> e(m);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
    e[i] = make_pair(a,b);
  }
  int ans = 0;
  for(P cant : e) {
    vb seen(n);
    int cnt = 0;
    rep(i,n) {
      if(seen[i]) continue;
      cnt++;
      dfs(i, cant, seen, g);
    }
    if(cnt != 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int N; cin >> N;
    vector<char> S(N);
    int cnt = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> S.at(i);
        if(S.at(i) == 'Y')
        {
            cnt = 1;
            break;
        }
    }
    if(cnt == 0)
    {
        cout << "Three" << endl;
    }
    else
    {
        cout << "Four" << endl;
    }
}

Measured memory_bytes: 256
S = input()
N = len(S) + 1
a = [0] * N
b = [0] * N

for i in range(0, N - 1):
    if S[i] == '<':
        a[i + 1] = a[i] + 1

for i in range(N - 2, -1, -1):
    if S[i] == '>':
        b[i] = b[i + 1] + 1

# print(a)
# print(b)

# ans = [0]
# for c in S:
#     if c == '<':
#         ans.append(ans[-1] + 1)
#     else:
#         ans.append(ans[-1] - 1)
# print(ans)

# countG = [0]
# countL = [0]
# for c in S:
#     if c == '<':
#         countG.append(countG[-1] + 1)
#         countL.append(countL[-1])
#     else:
#         countG.append(countG[-1])
#         countL.append(countL[-1] + 1)

# print(countG)
# print(countL)

res = [max(x, y) for x, y in zip(a, b)]
# print(sum(res))

# S = input()
# N = len(S) + 1
# a = [0] * N
# b = [0] * N
# for i in range(0, N-1):
#     if S[i] == '<':
#         a[i+1] = a[i] + 1

# for i in range(N-2, -1, -1):
#     if S[i] == '>':
#         b[i] = b[i+1] + 1
# print(a)
# print(b)

# res = [max(x, y) for x, y in zip(a, b)]

print(sum(res))


Measured memory_bytes: 86092
#include<bits/stdc++.h>
#define f first
#define s second
#define endl "\n"
#define M 1000000007
#define pb push_back
#define pf push_front
#define eb emplace_back
#define MM_PI 3.14159265358979323846
#define TEST_CASE int t;cin>>t;while(t--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T pow(T a, T b, long long m) {T ans = 1; while (b > 0) { if (b % 2 == 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans % m; }

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;

const int maxn = 1e5 + 10;
vi tree[maxn];
int cache[maxn];
int dp(int s) {
	if (cache[s] != -1)return cache[s];
	int ans = 1;
	for (int i = 0; i < tree[s].size(); i++) {
		ans = max(ans, dp(tree[s][i]) + 1);
	}
	cache[s] = ans;
	return ans;
}
void solve() {
	memset(cache, -1, sizeof(cache));
	int n, m, a, b;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		tree[a].pb(b);
	}
	int ans = -1 * maxn;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, dp(i));
	}
	cout << ans - 1 << endl;

}
int main() {


	//IOS
	//make();
	//TEST_CASE
	solve();
	return 0;
}

Measured memory_bytes: 8192
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {

		Map<Integer, Integer> wk = IntStream.range(0, 3).collect(() -> new HashMap<Integer, Integer>(),
				(t, i) -> {
					t.merge(nextInt(), 1, (oldV, newV) -> oldV + newV);
				},
				(t, u) -> {
					t.putAll(u);
				});

		out.println(wk.size());
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 26580
N, X = map(int, input().split())


# 漸化式を立てて解く
def f(n, x):
    return (
        0 if x <= 0 else
        2**(n + 1) - 1 if x >= 2**(n + 2) - 3 else
        f(n - 1, x - 1) +
        f(0, x - (2**(n + 1) - 2)) +
        f(n - 1, x - (2**(n + 1) - 1))
    )


ans = f(N, X)

print(ans)


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

int main() {
    // 例 1: 2 つの整数 a, b を入力し、a と b の最大公約数と最小公倍数を出力する
    int N, R;
    cin >> N >> R;
    if (N >= 10) cout << R << endl;
    else cout << R + (10 - N) * 100 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

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

    int n, k; cin>>n>>k;
    vi p(n);
    for (int &i : p) cin>>i;
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i=0; i<k; ++i)ans += p[i];
    cout<<ans;



}


Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
int main(){
	char w[15];
	char t[1000] = {};
	char end[] = "END_OF_TEXT";
	int len;
	int c=0;
	scanf("%s",w);
	len=strlen(w);
	scanf("%s",t);
	for(int i=0;strcmp(t,end) != 0;i++){
		
		if(len == strlen(t)){
			for(int j=0;j<strlen(t);j++)if((t[j]>=65&&t[j]<=90))t[j] += 32;
			if(strcmp(w,t) == 0)c++;
		}
		scanf("%s",t);
	}
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 2096
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define N_MAX 12
#define M_MAX 1000
#define STATE_MAX 4096
#define INF 1000000000

int a[M_MAX], b[M_MAX], key[M_MAX];

void solv()
{
	int N, M; scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++){
		scanf("%d%d", a + i, b + i);

		int c[N_MAX];
		for (int j = 0; j < b[i]; j++){
			scanf("%d", c + j);
		}

		key[i] = 0;
		for (int j = 0; j < b[i]; j++){
			key[i] = key[i] | (1 << (c[j] - 1));
		}
	}

	int dp[M_MAX][STATE_MAX];
	for (int i = 0; i < M; i++){
		fill(dp[i], dp[i] + STATE_MAX, INF);
	}

	dp[0][0] = 0; dp[0][key[0]] = a[0];
	for (int i = 1; i < M; i++){
		for (int s = 0; s < STATE_MAX; s++){
			dp[i][s] = min(dp[i][s], dp[i - 1][s]);
			dp[i][s | key[i]] = min(dp[i][s | key[i]], dp[i - 1][s] + a[i]);
		}
	}

	int all = 0;
	for (int i = 0; i < N; i++){
		all = all | (1 << i);
	}
	if (INF == dp[M - 1][all]){
		dp[M - 1][all] = -1;
	}
	printf("%d", dp[M - 1][all]);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

using namespace std;

int main()
{
	int N, i;
	string s;
	vector<string> W;

	cin >> N;
	for (i = 0; i < N; i++)
	{
		cin >> s;
		W.push_back(s);
	}

	i = 0;
	while (i + 1 < N)
	{
		if (W[i].back() != W[i + 1].front())
		{
			cout << "No" << endl;
			return 0;
		}

		i++;

		for (int j = 0; j < i; j++)
		{
			if (W[i] == W[j])
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int s, w; cin >> s >> w;
    if (s > w) puts("safe");
    else puts("unsafe");
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 500'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  cin >> n;
  vector<int> a(n);
  for (int& x : a) {
    cin >> x;
  }
  sort(begin(a), end(a));
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      for (int q = 0; q < j; ++q) {
        ans += a[i] < a[j] + a[q] && a[i] != a[j]  && a[j] != a[q];
      }
    }
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



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

int main() {
  ll A;
  long double B;
  cin >> A >> B;
  long double ans = A * B;
  cout << (ll) ans << endl;
  return 0;
}


Measured memory_bytes: 3716
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
using ll = long long;
const int INF = 1e8;

int main() {
  int N;
  cin >> N;
  vector<vector<ll>> L(N, vector<ll>(2));
  for (int i = 0; i < N; i++) {
    ll L_tmp;
    ll X_tmp;
    cin >> X_tmp >> L_tmp;
    L[i][0] = X_tmp - L_tmp;
    L[i][1] = X_tmp + L_tmp;
  }
  sort(L.begin(), L.end(), [](const vector<ll> &alpha, const vector<ll> &beta) {
    return alpha[1] < beta[1];
  });

  int ans = 1;
  ll x_last = L[0][1];
  for (int i = 1; i < N; i++) {
    if (L[i][0] < x_last) {
      continue;
    }
    x_last = L[i][1];
    ans++;
  }

  cout << ans << endl;

  return 0;
}


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

int main(void){

  double x;
  scanf("%lf", &x);
  double takahashi = 100;
  for (long i = 1; ; i++) {
    takahashi *= 1.01;
    takahashi = floor(takahashi);
    if (takahashi >= x) {
      printf("%ld\n", i);
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1752
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	vector<vector<long long int>>dp(N, vector<long long int>(N));
	if (N % 2) {
		for (int i = 0; i < N; i++) {
			dp[i][i] = v[i];
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			dp[i][i] = -v[i];
		}
	}
	for (int i = 1; i < N; i++) {
		for (int j = 0; j + i < N; j++) {
			if (i % 2 == N % 2) {
				dp[j][i + j] = min(dp[j + 1][i + j] - v[j], dp[j][i + j - 1] - v[i + j]);
			}
			else {
				dp[j][i + j] = max(dp[j + 1][i + j] + v[j], dp[j][i + j - 1] + v[i + j]);
			}
		}
	}

	cout << dp[0][N - 1] << endl;
	return 0;
} 

Measured memory_bytes: 72192
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# 配列から累積和を返す
def make_cumulative(A):
    C = [0] * (len(A) + 1)
    for i, a in enumerate(A):
        i += 1
        C[i] = C[i - 1] + a
    return C


def main():
    N = NI()
    A = NLI()
    C = make_cumulative(A)[1:]
    PM = []
    MP = []
    for i in range(len(A)):
        PM.append((-1) ** i)
        MP.append((-1) ** (i+1))
    diff = 0
    ans = 0
    for c, sign in zip(C, PM):
        if (c + diff) * sign > 0:
            pass
        else:
            if c + diff > 0:
                ans += c + diff + 1
                diff = - c - 1
            elif c + diff < 0:
                ans += 1 - c - diff
                diff = 1 - c
            else:
                ans += 1
                diff += sign

    diff = 0
    ans2 = 0
    for c, sign in zip(C, MP):
        if (c + diff) * sign > 0:
            pass
        else:
            if c + diff > 0:
                ans2 += c + diff + 1
                diff = - c - 1
            elif c + diff < 0:
                ans2 += 1 - c - diff
                diff = 1 - c
            else:
                ans2 += 1
                diff += sign

    print(min(ans, ans2))

if __name__ == "__main__":
    main()

Measured memory_bytes: 21580
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

const long long MOD=1e9+7;
const long long BASE=0x234567;

struct RollingHash {
    string s;
    long long mod, base;
    vector<long long> hash, pow;
    RollingHash() {}
    RollingHash(string s, long long m, long long b): s(s), mod(m), base(b) {
        pow.resize(s.length()+1); pow[0]=1;
        for (size_t i=0; i<s.length(); ++i)
            (pow[i+1] = pow[i]*base) %= mod;

        hash.assign(s.length()+1, 0);
        for (size_t i=0; i<s.length(); ++i)
            (hash[i+1] = hash[i]+pow[i]*s[i]) %= mod;
    }
    long long get_hash(size_t first, size_t last) {
        return (hash[last]-hash[first]+mod) % mod;
    }
    long long make_hash(string t) {
        long long h=0;
        for (size_t i=0; i<t.length(); ++i)
            (h += pow[i]*t[i]) %= mod;

        return h;
    }
    long long diff(long long h, size_t pos, size_t len) {
        return (h*pow[pos]-get_hash(pos, pos+len))%mod;
    }
    bool is_equiv(long long h, size_t pos, size_t len) {
        return !diff(h, pos, len);
    }
    template <class Functor>
    void findall(const string &t, Functor F) {
        long long h=make_hash(t);
        for (size_t pos=0; pos+t.length()<=s.length(); ++pos)
            if (is_equiv(h, pos, t.length()))
                F(pos);
    }
};

int main() {
    char buf[1<<20];
    scanf("%s", buf);
    string T(buf);

    RollingHash rhash(T, MOD, BASE);

    scanf("%s", buf);
    string P(buf);

    auto output=[](size_t pos)->void {
        printf("%zu\n", pos);
    };

    rhash.findall(P, output);
    return 0;
}

Measured memory_bytes: 20992
local mfl = math.floor
local n, k = io.read("*n", "*n")
k = mfl((n - 1) * (n - 2) / 2) - k
if k < 0 then
  print(-1)
else
  local cur = 0
  print(n - 1 + k)
  for i = 2, n do
    print(1 .. " " .. i)
  end
  if k ~= 0 then
    for i = 2, n - 1 do
      for j = i + 1, n do
        print(i .." " .. j)
        cur = cur + 1
        if cur == k then break end
      end
      if cur == k then break end
    end
  end
end


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

ll N, M;
bool out[301];

ll solve(int remain, vector<vector<long long>> &A) {
  ll ret = 0;
  if (!remain)
    return 10000;

  ll L[M] = {};
  int index = 0;
  REP(n, N) REP(m, M) if (!out[A[n][m]]) {
    L[A[n][m]]++;

    if (ret < L[A[n][m]]) {
      ret = max(ret, L[A[n][m]]);
      index = A[n][m];
    }
    break;
  }

  out[index] = true;
  return min(ret, solve(remain - 1, A));
}

int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  cin >> M;
  vector<vector<long long>> A(N - 1 + 1, vector<long long>(M - 1 + 1));
  for (int i = 0; i <= N - 1; i++) {
    for (int j = 0; j <= M - 1; j++) {
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  cout << solve(M, A) << endl;
  return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   string x;
   cin >> x;
   int cnt = 0;
   int ans = 0;
   rep (i, x.size()) {
      if (x[i] == 'S') {
         cnt++;
      } else {
         cnt--;
         if (cnt < 0) {
            cnt = 0;
         } else {
            ans++;
         }
      }
   }

   cout << x.size() - ans*2 << endl;

   return 0;
}

Measured memory_bytes: 640
def saizo(A:list):

	uplen = 0
	downlen = 0
	num = len(A)

	for j in range(num-1):
		tmp = A[j+1] - A[j]
		if A[j+1] >= A[j]:
			uplen = max(uplen,tmp)
		else:
			downlen = max(downlen,abs(tmp))
			
	print(uplen,downlen)


if __name__ == '__main__':

	n = int(input())
	for i in range(n):
		input()
		saizo(list(map(int,input().split())))





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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	long long step = 0;
	int max_height = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] < max_height) step += max_height - a[i];
		else max_height = a[i];
	}
	cout << step << endl;
	return (0);
}


Measured memory_bytes: 3996
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly int INFTY = int.MaxValue;

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = int.Parse(input[1]);

            int[,] dp = new int[V, V];
            for (int i = 0; i < V; i++)
            {
                for (int j = 0; j < V; j++)
                {
                    dp[i, j] = i == j ? 0 : INFTY;
                }
            }

            int s, t, d;
            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                s = int.Parse(input[0]);
                t = int.Parse(input[1]);
                d = int.Parse(input[2]);

                dp[s, t] = d;
            }

            WarshallFloyd(dp, V);

            StringBuilder sb = new StringBuilder();
            if (IsNegative(dp, V))
            {
                sb.AppendLine("NEGATIVE CYCLE");
            }
            else
            {
                for (int i = 0; i < V; i++)
                {
                    for (int j = 0; j < V; j++)
                    {
                        if (j != 0) sb.Append(" ");
                        sb.Append(dp[i, j] == INFTY ? "INF" : dp[i, j].ToString());
                    }
                    sb.AppendLine();
                }
            }
            Console.Write(sb);
        }

        static void WarshallFloyd(int[,] dp, int V)
        {
            for (int k = 0; k < V; k++)
            {
                for (int i = 0; i < V; i++)
                {
                    if (dp[i, k] == INFTY) continue;
                    for (int j = 0; j < V; j++)
                    {
                        if (dp[k, j] == INFTY) continue;
                        dp[i, j] = Math.Min(dp[i, j], dp[i, k] + dp[k, j]);
                    }
                }
            }
        }

        static bool IsNegative(int[,] dp, int V)
        {
            for (int i = 0; i < V; i++)
            {
                if (dp[i, i] < 0) return true;
            }
            return false;
        }
    }
}

Measured memory_bytes: 9824
#include<bits/stdc++.h>
using namespace std;
int n,m,x;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&x);
		n-=x;
	}
	if(n<0)n=-1;
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 3828
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int gcd(int a, int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

int main() {
	speed;
	int n, v, g = 0;
	vector<int>a(1000001);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> v;
		a[v]++;
		g = gcd(v, g);
	}
	if (g != 1)
		cout << "not coprime";
	else {
		vector<char> prime(1000000 + 1, true);
		prime[0] = prime[1] = false;
		for (int i = 2; i <= 1000000; ++i) {
			if (prime[i]) {
				int cnt = 0;
				for (int j = i; j <= 1000000; j += i) {
					prime[j] = false;
					cnt += a[j];
				}
				if (cnt > 1)
					return cout << "setwise coprime", 0;
			}
		}
		cout << "pairwise coprime";
	}
}

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

int main(){
  int n;
  string s="No";
  cin>>n;
  if(n%10==7){
    s="Yes";
  }
  n=n/10;
  if(n%10==7){
    s="Yes";
  }
  n=n/10;
  if(n%10==7){
    s="Yes";
  }
  cout<<s;
}
  

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
int main(){
    int a ,b;
    cin>>a>>b;
    if(a>12)
        cout << b << endl;
    else if(a<6)
        cout << 0 << endl;
    else
        cout << b / 2 << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define sss(i,a,b) for( register int i=(a); i<=(b); ++i)
#define zzz(i,a,b) for( register int i=(a); i>=(b); --i)
#define ll long long 
#define ri register int
#define M(x)    (((x)+mod)%mod)
#define pii pair<int,int>
#define mii map <int,int> 
inline int rrr()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
inline ll rll()
{
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
ll x1,x2,y11,y2,x3,y3;

int main()
{
    ll s=rll();if(s!=1e18) y3=x2=(ll)sqrt(s)+1;
    else y3=x2=(ll)sqrt(s);
    ll tmp=x2*y3-s;
    y2=tmp;x3=1;x1=0;y11=0;
    cout<<x1<<" "<<y11<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0
 
#define putb push_back
#define f first
#define s second
 
#define putf push_front
#define gainb pop_back
 
#define gainf pop_front
#define len(x) (ll)x.size()
 
typedef double db;
typedef long long ll;
 
const ll ary=40+5;
const ll mod=1e9+7;
const ll inf=1e18;
 
using namespace std;
ll n;
int main(){
	cin>>n;
	cout<<n*n;
}

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

using namespace std;

int main(void) {
  int d, n;
  cin >> d >> n;
  if (n == 100) {
    cout << (int)(pow(100, d)) * 101 << endl;
    return 0;
  }
  cout << (int)(pow(100, d)) * n << endl;
	return 0;
}


Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// kotatsugame氏.
// https://atcoder.jp/contests/abc142/submissions/7825341
#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> G[1000];
int cnt[1000];
int main(){
    scanf("%d %d", &N, &M);
    for(int i = 0; i < M; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        u--, v--;
        G[u].push_back(v);
        cnt[v]++;
    }
    queue<int> q;
    for(int i = 0; i < N; i++) if(cnt[i] == 0) q.push(i);
    int sz = 0;
    while(!q.empty()){
        sz++;
        int u = q.front(); q.pop();
        for(int v : G[u]) if(--cnt[v] == 0) q.push(v);
    }
    printf("%d\n", -(sz == N));
    return 0;
}

Measured memory_bytes: 256
m,p,q,r,b,*c;C[8][101][101];main(n){for(;~scanf("%d%d",&n,&m);){for(memset(C,9,9e4);n--;C[0][p][q]=C[0][q][p]=r,C[1][p][q]=C[1][q][p]=b)scanf("%d%d%d%d",&p,&q,&r,&b);for(n=m;n;n--)for(p=m;p;p--)for(q=m;q;q--)for(r=8;r--;*c=*c<b?*c:b)b=C[r][p][n]+C[r][n][q],c=C[r][p]+q;for(scanf("%d",&m);m--;printf("%d\n",C[r][p][q]))scanf("%d%d%d",&p,&q,&r);}}

Measured memory_bytes: 732
#include <stdio.h>
 
int main(void){
    int n,q;
    int s[10000],t[500];
    int i,j,c=0;
 
    scanf("%d",&n);
    for(i=0;i<n;++i){
        scanf("%d",&s[i]);
    }
 
    scanf("%d",&q);
    for(i=0;i<q;++i){
        scanf("%d",&t[i]);
    }
     
    for(i=0;i<q;++i){
        for(j=0;j<n;++j){
            if(s[j]==t[i]){
                c++;
                break;
            }
        }
    }
    printf("%d\n",c);
     
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
const int maxn=2e5+10;
int a[maxn];
int b[maxn];
int u[maxn];
int v[maxn];
bool cmp (int x,int y) {
	return x>y;
}
int main() {
	int n;
	cin>>n;
	int upp=-1;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	for(int i=0;i<n;i++) {
		cin>>u[i];
		a[u[i]]++;
		upp=max(upp,u[i]);
	}
	for(int i=0;i<n;i++) {
		cin>>v[i];
		b[v[i]]++;
	}
	bool f=true;
	for(int i=0;i<=maxn-10;i++) {
		if(a[i]+b[i]>n&&a[i]) {
			f=false;
			break;
		}
	}
	if(!f) {
		cout<<"No"<<endl;
	} else {
		bool f1=true;
		int pos=0;
		sort(v,v+n,cmp);
		for(int i=n-1;i>=0;i--) {
			if(v[i]==u[i]) {
				int tmp=v[i];
				while(v[pos]==u[i]||v[i]==u[pos]) pos++;
				v[i]=v[pos];
				v[pos]=tmp;
			}
		}
		for(int i=0;i<n;i++)  {
			if(v[i]==u[i]) {
				f1=false;
				break;
			}
		}
		if(f1) {
			cout<<"Yes"<<endl;
			for(int i=0;i<n;i++) cout<<v[i]<<" ";
		}
		else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 6756
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut solver = Solver::new(100001, n);
    for _ in 0..n {
        solver.add_point(scan(tokens), scan(tokens));
    }
    solver.solve();
}

struct Solver {
    n: usize,
    k: usize,
    ys_of_x: Vec<Vec<usize>>,
    xs_of_y: Vec<Vec<usize>>,
    c_of_x: Vec<usize>,
    c_of_y: Vec<usize>,
}

impl Solver {
    fn new(n: usize, k: usize) -> Solver {
        Solver {
            n: n,
            k: k,
            ys_of_x: vec![Vec::new(); n],
            xs_of_y: vec![Vec::new(); n],
            c_of_x: vec![0; n],
            c_of_y: vec![0; n],
        }
    }
    fn add_point(&mut self, x: usize, y: usize) {
        self.ys_of_x[x].push(y);
        self.xs_of_y[y].push(x);
    }
    fn solve(&mut self) {
        let mut m = 0;
        for x in 0..self.n {
            if self.c_of_x[x] == 0 && !self.ys_of_x[x].is_empty() {
                m += 1;
                self.dfs_x(x, m);
            }
        }
        let mut nx_of_c: Vec<usize> = vec![0; m + 1];
        let mut ny_of_c: Vec<usize> = vec![0; m + 1];
        for x in 0..self.n {
            nx_of_c[self.c_of_x[x]] += 1;
        }
        for y in 0..self.n {
            ny_of_c[self.c_of_y[y]] += 1;
        }
        let mut ans = 0;
        for c in 1..m + 1 {
            ans += nx_of_c[c] * ny_of_c[c];
        }
        ans -= self.k;
        println!("{}", ans);
    }
    fn dfs_x(&mut self, x: usize, c: usize) {
        if self.c_of_x[x] != 0 {
            return;
        }
        self.c_of_x[x] = c;
        for i in 0..self.ys_of_x[x].len() {
            let y = self.ys_of_x[x][i];
            self.dfs_y(y, c);
        }
    }
    fn dfs_y(&mut self, y: usize, c: usize) {
        if self.c_of_y[y] != 0 {
            return;
        }
        self.c_of_y[y] = c;
        for i in 0..self.xs_of_y[y].len() {
            let x = self.xs_of_y[y][i];
            self.dfs_x(x, c);
        }
    }
}


Measured memory_bytes: 21628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for(int i = 0;i < M;i++){
    cin >> L.at(i) >> R.at(i);
  }
  int LM = 0 ,Rm = 100000;
  for(int l= 0;l < M;l++){
    if(L.at(l) > LM){
      LM = L.at(l);
    }
  }
  for(int r = 0;r < M;r++){
    if(R.at(r) < Rm){
      Rm = R.at(r);
    }
  }
  if(Rm >= LM){
  cout << Rm - LM + 1<< endl;
  }
  else if (Rm < LM){
    cout << 0 << endl;
  }
}
    
    
    
      
    
  

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

/* define const */

/* finish defineing const */
int n;
int t[1010];
int a[1010];

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++) cin >> t[i] >> a[i];
  // input

  long at = t[0], aa = a[0];

  for (int i = 1; i < n; i++) {
    long tmp;
    long tt = t[i], ta = a[i];
    bool f = false;
    if (!(at <= tt && aa <= ta)) {
      tmp = max((at + (tt-1)) / tt, (aa + (ta - 1)) / ta);
      at = tt * tmp;
      aa = ta * tmp;
    }
    else {
      at = tt;
      aa = ta;
    }
    //    cout << ":" << at << " " << aa << endl;
  }
  
  cout << (at + aa) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int a, b;

int main(void)
{

	scanf( "%d %d", &a, &b );
	
	if ( a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 )
		printf( "Possible\n" );
	else
		printf( "Impossible\n" );
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){

    char pas[4];
    char pres[4];
    scanf("%s",pas);

    scanf("%s",pres);
    int c=0;
    for(int i=0; i<3; i++)
        if(pas[i]==pres[i])
            c++;
    printf("%d",c);
    return 0;
    
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, ans;
  	vector<int> vec;
  	cin >> N;
  	for (int i = 0; i < N; i++){
    	int a; cin >> a;
      	vec.push_back(a);
    }
  	sort(vec.begin(), vec.end());
  	ans = vec[vec.size() - 1] - vec[0];
  	cout << ans;
}

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

const int SIZE=2010;
int L[SIZE][SIZE],R[SIZE][SIZE];
int U[SIZE][SIZE],D[SIZE][SIZE];

signed main()
{
    int H,W; cin>>H>>W;
    vector<string> s(H);
    for(int i=0;i<H;i++){
	cin>>s[i];
    }

    for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	    if(s[i][j]=='#'){
		L[i][j]=R[i][j]=-1;
		U[i][j]=D[i][j]=-1;
	    }
	}
    }

    for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	    if(s[i][j]=='#') continue;
	    if(j==0) L[i][j]=0;
	    else L[i][j]=L[i][j-1]+1;
	}
    }
    for(int i=0;i<H;i++){
	for(int j=W-1;j>=0;j--){
	    if(s[i][j]=='#') continue;
	    if(j==W-1) R[i][j]=0;
	    else R[i][j]=R[i][j+1]+1;
	}
    }
    for(int j=0;j<W;j++){
	for(int i=0;i<H;i++){
	    if(s[i][j]=='#') continue;
	    if(i==0) U[i][j]=0;
	    else U[i][j]=U[i-1][j]+1;
	}
    }
    for(int j=0;j<W;j++){
	for(int i=H-1;i>=0;i--){
	    if(s[i][j]=='#') continue;
	    if(i==H-1) D[i][j]=0;
	    else D[i][j]=D[i+1][j]+1;
	}
    }

    int ans=0;
    for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	    if(s[i][j]=='#') continue;
	    ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]+1);
	}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 130560
# ABC112b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, t = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]

ans = 9999

for i in c:
    if (i[1] <= t):
        ans = min(ans, i[0])
print(ans if ans != 9999 else 'TLE')

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

int main() {
  int N;
  cin >> N;
  int d[N];
  for (int i=0; i<N; i++) cin >> d[i];
  sort(d, d+N);
  cout << d[N/2] - d[N/2-1] << endl;
}


Measured memory_bytes: 640
n=int(input())
F=[input().split() for _ in range(n)]
P=[list(map(int,input().split())) for _ in range(n)]

ans=-float("inf")
for i in range(1,2**10):
    cnt=0
    num=format(i,"b").zfill(10)
    for j,k in enumerate(F):
        cnt +=P[j][len([v for v in range(10) if k[v]==num[v]=="1"])]
    ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 43868
#include<iostream>

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

int main (void){

    int a,b;
    int flag = 0;
    int temp = 0; //check
    cin  >> a>>b;

    if((a+ b)>16){
        cout<<":(";
        return 0;
    }

    int array[16];

    rep(i,16){
        array[i] = 0;
    }

    if(a < b){
        int c = a;
        a = b;
        b = c;
    }
    int m = (a-b) * 2-1;

    if((16 -(a - b)) < m){
        
        cout<<":(";
        return 0;
    }

    int n = a+b;
   
    rep(i,n){
        if((i % 2) == 0 && a > 0){          //A
            array[i] = 1;
            if(array[i] == temp){
                flag = 1;
               // cout<<i <<"abreak"<<endl;
                break;
            }
            temp = array[i];
            a--;
            //cout<<"a:"<<a<<endl;

        }else if((i % 2 ) == 1 && b > 0){   //B
            array[i] = -1;
            if(array[i] == temp){
                flag = 1;    
               // cout<<i<< "bbreak"<<endl;
                break;
            }
            temp = array[i];
            b--;
          //  cout<<"b:"<<b<<endl;
        }else if((i % 2) == 1 && b <= 0){
            array[i] = 0;
            // cout<< "kittaa";
        }
        
    }

    if(flag == 1){
        cout << ":(";
    }else cout<<"Yay!";

    return 0;
}

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

bool linearSearch(int a[], int n, int key) {
    int i = 0;
    a[n] = key;
    while(a[i] != key)  i++;
    return i != n;
}

int main() {
    int a[100000]{}, key, n, q, sum{};
    
    cin >> n;
    
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    cin >> q;
    
    for(int i = 0 ; i < q; i++) {
        cin >> key;
        if(linearSearch(a, n, key))
            sum++;
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3496
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int k,s,ans=0; cin>>k>>s;
    rep(x,k+1)rep(y,k+1){
        int z=s-x-y;
        if(z>=0 && z<=k) ans++;
    }
    cout<<ans<<endl;
}

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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	string S;
	cin >> S;
	int w;
	cin >> w;
	REP(i, S.length())
	{
		if (i%w == 0)
		{
			cout << S[i];
		}
	}
	cout << endl;
	return 0;
}

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


signed main(){
    int N,M;
    cin >> N >> M;
    if(N==1&&M==1){
        cout << 1 << endl;
    }else if(N==1){
        cout << M-2 << endl;
    }else if(M==1){
        cout << N-2 << endl;
    }else{
        cout << (N-2)*(M-2) << endl;
    }
    return 0;
}


Measured memory_bytes: 256