akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stdio.h>
#include <tuple>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////
#define tpl tuple<int,int,int>
#define mktp make_tuple

int L;
int N,M;
//int bit[20],ex=0;
vector<tpl> a;

int main(){
    scanf("%d",&L);
    L--;
    int min=-1,s=0,Max=0;
    for(m=1;m*2-1<=L;m*=2){
        //printf("\n%d %d %d",i,i+1,a[i-1]);
        //printf("\n%d %d %d",i,i+1,0);
        /*
        if(L&m){
            a.push_back(m);
        }else{
            if(min==-1)min=m;
            s+=m;
            b.push_back(m);
        }
        */
        N++;
        a.push_back(mktp(N,N+1,m));
        a.push_back(mktp(N,N+1,0));
    }
    int M=m;
    int l=L-m+1;
    for(i=N,j=m/2;j>0;j/=2,i--){
        if(l&j){
            a.push_back(mktp(i,N+1,M));
            M+=j;
        }
    }
    
    N++;
    M=a.size();
    
    printf("%d %d",N,M);

    for(i=0;i<a.size();i++){
        printf("\n%d %d %d",get<0>(a[i]),get<1>(a[i]),get<2>(a[i]));
    }
    /*
    for(i=1;i<=a.size();i++)
    {
        printf("\n%d %d %d",i,i+1,a[i-1]);
        printf("\n%d %d %d",i,i+1,0);
    }
    for(j=0;j<b.size();j++)
    {
        printf("\n%d %d %d",i+j,i+j+1,b[j]);
        printf("\n%d %d %d",i+j,i+j+1,0);
    }
    */
    
/*
    for(k=0;k<b.size();k++){
        printf("\n%d %d %d",i+j+k,i+j+k+1,m);
    }
*/

    return 0;
}

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

using namespace std;

#define MAX 250
#define MAX_R 1050
#define INF 1e8

int G1[MAX][MAX], G2[MAX][MAX];
int dp[MAX_R][MAX];

int main(){
  int N, M;

  while(cin >> N >> M ,(N | M)){
    fill(G1[0], G1[MAX], INF);
    fill(G2[0], G2[MAX], INF);

    int x, y, t;
    char ch;
    for(int i = 0 ; i < M ; i++){
      cin >> x >> y >> t >> ch;
      x--, y--;
      if(ch == 'L'){
        G1[x][y] = G1[y][x] = min(G1[y][x], t);
      }else{
        G2[x][y] = G2[y][x] = min(G2[y][x], t);
      }
    }
    
    for(int i = 0 ; i < N ; i++){
      G1[i][i] = G2[i][i] = 0;
    }
    
    for(int k = 0 ; k < N ; k++){
      for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
          G1[i][j] = min(G1[i][j], G1[i][k]+G1[k][j]);
          G2[i][j] = min(G2[i][j], G2[i][k]+G2[k][j]);
        }
      }
    }

    int R, z[MAX_R];
    for(int i = 0 ; i < MAX_R ; i++){
      for(int j = 0 ; j < MAX ; j++){
        dp[i][j] = INF;
      }
    }

    cin >> R;
    for(int i = 0 ; i < R ; i++){
      cin >> z[i]; z[i]--;
    }

    int now = z[0];
    dp[0][now] = 0;
    for(int r = 1 ; r < R ; r++){
      int next = z[r];
      for(int j = 0 ; j < N ; j++){
        for(int i = 0 ; i < N ; i++){
          dp[r][j] = min(dp[r][j], dp[r-1][i] + G1[now][i] + G2[i][j] + G1[j][next]);
        }
	dp[r][j]=min(dp[r][j], dp[r-1][j] + G1[now][next] );
      }
      now = next; 
    }

    int ans = INF;
    for(int i = 0 ; i < N ; i++){
      ans = min(ans, dp[R-1][i]);
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2672
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	long long int N, A, T, a = 1, t = 1, tmpt = 1, tmpa = 1;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> T >> A;
		t = (t + T - 1) / T * T;
		while (a> t / T*A)
		{
			t += t;
		}
		a = t / T*A;

		tmpa = (tmpa + A - 1) / A*A;
		while (tmpt>tmpa/A*T)
		{
			tmpa += tmpa;
		}
		a = min(tmpa, a);
		t = a / A*T;
		tmpt = t;
		tmpa = a;
	}
	cout << a + t;
}


Measured memory_bytes: 256
def insertion_sort(l):
    for i in range(1, len(l)):
        tmp = l[i]
        j = i - 1
        while j >= 0 and l[j] > tmp:
            l[j+1] = l[j]
            j -= 1
        l[j+1] = tmp
        print(' '.join(map(str, l)))
    return l



if __name__ == '__main__':
    N = int(input())
    l = list(map(int, input().split()))

    print(' '.join(map(str, l)))
    insertion_sort(l)



Measured memory_bytes: 5604
// 1_abc035_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

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++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    if(a[0] == 0 && a[n - 1] == 0){
        cout << "Yes" << endl;
        return 0;
    }
    if(n % 3 != 0){
        cout << "No" << endl;
        return 0;
    }

    unsigned int x, y, z;
    x = a[0];
    y = a[n / 3];
    z = a[2 * n / 3];
    int flag = 0;
    rep(i, n / 3){
        if(a[i] != x) flag = 1;
    }
    for(int i = n / 3; i < 2 * n / 3; i++){
        if(a[i] != y) flag = 1;
    }
    for(int i = 2 * n / 3; i < n; i++){
        if(a[i] != z) flag = 1;
    }

    if((x ^ y) != z) flag = 1;

    if(flag){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
string s,st;
int main()
{
	cin >>s;
	st="";
	for (int i=s.size()-1; i>=0; i--)
	    st+=s[i];
	for (int i=0; i<st.size(); i++)
	    if (st[i]=='b') st[i]='d';
	       else if (st[i]=='d') st[i]='b';
	       else if (st[i]=='p') st[i]='q';
	       else if (st[i]=='q') st[i]='p';
	if (st==s) cout<<"Yes";
	   else cout<<"No";
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int A = sc.nextInt();
    
    if(H%A==0){
    System.out.println(H/A);
    }else{
      System.out.println(H/A+1);
    }
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <map>

using namespace std;
long long arr[200001];
map <long long,long long> mp; // cati de i
map <long long, long long> mp2; // cate perechi cu i
long long sum = 0;


long long solve(long long k)
{
    long long del = arr[k];
    mp[del]--;
    long long rs = sum - mp2[del] + (mp[del] * (mp[del] - 1)) / 2;
    mp[del]++;
    return rs;

}


int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        long long temp;
        cin >> temp;
        arr[i] = temp;
        mp[temp]++;
    }
    for (int i = 1; i <=n; i++){
        if (mp[i] != 0){
            long long temp = (mp[i] *(mp[i] - 1)) / 2;
            mp2[i] = temp;
            sum += temp;
        }
        else
            mp2[i] = 0;
        //cout << i << " " << mp2[i] << "\n";
    }
    //cout << sum;
    for (int i = 0; i <n; i++){
        cout << solve(i) << "\n";
    }
    return 0;
}


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

ans = ["a"]
for n in range(N - 1):
    nex = []
    for v in ans:
        for i in range(ord("a"), max(ord(s) for s in v) + 2):
            nex.append(v + chr(i))
    ans = nex[:]
        
print(*sorted(ans), sep="\n")


Measured memory_bytes: 65500
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

int a[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	int k, n, mmax = 0;
	cin >> k >> n;
	for (int i = 0; i < n; i++) 
		cin >> a[i];

	for (int i = 0; i < n; i++) {
		if (i == n - 1) {
			mmax = max(mmax, k - a[i] + a[0]);
		}
		else mmax = max(mmax, a[i + 1] - a[i]);
	}

	cout << k - mmax;
}

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

std::string s;
int main() {
	std::cin >> s;

	long long ans = 0;
	long long num = 0;
	for (int i = 0, end = s.size(); i < end; ++i)
		if (s[i] == 'W') {
			ans += i - num;
			++num;
		}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 640
n,k = input().split(" ")
n = int(n)
k = int(k)
min = 1000000000000000001
abs0 = 0
if n == 0:
    print(0)
elif k == 1:
    print(0)
elif n == 1:
    print(1)
else:
    if n > k:
        n = n % k
        print(abs(k-n))
    else:        
        for i in range(1000000000):
            abs0 = abs(k - n)
            n = abs0
            if abs0 < min:
                min = abs0
            elif min == abs0:
                print(abs0)
                break

Measured memory_bytes: 3064
from collections import defaultdict

n = int(input())
A = [int(i) for i in input().split()]
p = 10 ** 9 + 7

m = n % 2 == 0
cnt = defaultdict(int)

for a in A:
    if (a % 2 == 0) == m:
        print(0)
        exit()
    cnt[a] += 1

if cnt[0] > 1:
    print(0)
    exit(0)

del cnt[0]

for c in cnt.values():
    if c != 2:
        print(0)
        exit(0)

print(pow(2, (n//2), p))

Measured memory_bytes: 14820
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var L = items[0];
            var R = items[1];
            var d = items[2];
            var answer = 0;
            foreach(var i in Enumerable.Range(L, R - L + 1))
            {
                if (i % d == 0)
                {
                    answer++;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28312
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    s = input()

    if s[1] == "o":
        first = ((True, True, True),
                 (False, True, False),
                 (True, False, False),
                 (False, False, True))
    else:
        first = ((True, True, False),
                 (False, True, True),
                 (True, False, True),
                 (False, False, False))

    for a, b, c in first:
        kinds = [None] * (n + 1)
        kinds[1] = b
        kinds[0] = a
        kinds[2] = c

        for i in range(2, n):
            if kinds[i]:
                if s[i] == "o":
                    kinds[i + 1] = kinds[i - 1]
                else:
                    kinds[i + 1] = not kinds[i - 1]
            else:
                if s[i] == "o":
                    kinds[i + 1] = not kinds[i - 1]
                else:
                    kinds[i + 1] = kinds[i - 1]

        res = ""
        flag = True
        for i in range(n):
            left = kinds[(i - 1) % n]
            right = kinds[(i + 1) % n]
            res += "S" if kinds[i] else "W"
            if (s[i] == "o" and kinds[i]) or (s[i] == "x" and not kinds[i]):
                if left != right:
                    flag = False
                    break
            else:
                if left == right:
                    flag = False
                    break
        if flag:
            print(res)
            sys.exit()

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 109844
#include <bits/stdc++.h>
using namespace std;
const int nmax=1e6+3;
int n,k,v[nmax],sol;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i=1;i<=n;++i) cin>>v[i];
    while(true)
    {
        n-=k-1;
        ++sol;
        if(n<=1) break;
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[19][19] = {};
int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    //ll a[13];
    rep(i, N)
    {
        string s;
        cin >> s;
        ll t;
        #if 1
        int pos = s.find('.');
        if(pos == string::npos)
        {
            t = stoll(s) * 1000000000;
        }
        else
        {
            string a = s.substr(0, pos);
            string b = s.substr(pos+1);
            while (b.size() < 9) b += '0';
            t = stoll(a + b);
        }
        #else
        int f = 0, k = 9;
        for (char c : s) {
            if (c == '.') {
                f = 1;
                continue;
            }
            if (f) {
                k--;
            }
            t *= 10;
            t += c - '0';//t += atoll(&c);
        }
        for (int j = 0; j < k; j++) {
            t *= 10;
        }
        #endif
        //a[i] = t;
        int x = 0, y = 0;
        while(t%2 == 0) { t /= 2; ++x; }
        while(t%5 == 0) { t /= 5; ++y; }
        x = min(x, 18);
        y = min(y, 18);
        rep2(i, 18-x, 19)rep2(j, 18-y, 19)
        {
            ans += dp[i][j];
        }
        ++dp[x][y];
    }
    //rep(i, N) cout << a[i] << endl;
    cout << ans << endl;

    return 0;
}

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

int main() {
	for (int a=0;a<9;a=a+1){
		for(int b=0;b<9;b=b+1){
			cout<<a+1<<"x"<<b+1<<"="<<(a+1)*(b+1)<<endl;
		}
	}
}

Measured memory_bytes: 2908
#include<stdio.h>

int main(){
	int a,b,c,d,left,right;
	
	scanf("%d%d%d%d",&a,&b,&c,&d);
	
	left=a+b;
	right=c+d;
	
	if(left>right){
		printf("Left");
	}else if(left<right){
		printf("Right");
	}else{
		printf("Balanced");
	}
	
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int ans = 0;
    ans = (n - 1) * (m - 1);  
    printf("%d\n", ans);
    return 0;
}

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

# Mの約数列挙
divs = set()
for i in range(1, int(M ** 0.5) + 1):
    if M % i == 0:
        divs.add(i)
        divs.add(M // i)

ans = 0
for d in divs:
    if N * d <= M:
        ans = max(ans, d)

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>M>>N>>K;
    cout<<N / K - (M - 1) / K<<endl;
}


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

using namespace std;

void work(int a, int b, int c, int d) {
		int tmp = max(a, max(b, c));
		printf("%d\n", d + (tmp - a) / 2 + (tmp - b) / 2 + (tmp - c) / 2);
}

int main( ) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a % 2 == b % 2 && b % 2 == c % 2) {
		work(a, b, c, 0);
	}
	else if (a % 2 == b % 2) {
		a ++; b ++;
		work(a, b, c, 1);
	}
	else if (a % 2 == c % 2) {
		a ++; c ++;
		work(a, b, c, 1);
	}
	else {
		b ++; c ++;
		work(a, b, c, 1);
	}
	return 0;
}


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

int dp[100010];

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < 100010; i++)
    {
        dp[i] = i;
        
    }
    
    int m;
    for(int i = 1; i <= n; i++)
    {
        m = 1;
        while ((i - pow(6, m)) >= 0) {
            dp[i] = min(dp[i], (dp[i - (int)pow(6, m)] + 1));
            m++;
        }
        m = 1;
        while ((i - pow(9, m)) >= 0) {
            dp[i] = min(dp[i], (dp[i - (int)pow(9, m)] + 1));
            m++;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
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++)
typedef int64_t Int;
typedef pair<int,int> p;

int main(){
    int N; cin >> N;
    vector<int> A(N);

    int max_p = -1, max_p_id = -1, cnt_p = 0;
    int max_n = -1, max_n_id = -1, cnt_n = 0;;
    rep(i,N){
        cin >> A[i];
        if(A[i] > 0){
            cnt_p++;
            if( A[i] > max_p){
                max_p = A[i];
                max_p_id = i+1;
            }
        }
        if(A[i] < 0){
            cnt_n++;
            if(-A[i] > max_n){
                max_n = -A[i];
                max_n_id = i+1;
            }
        }
    }

    if(max_n == -1){
        cout << N-1 << endl;
        rep1(i,N-1) cout << i << " " << i+1 << endl;
    } else if (max_p == -1){
        cout << N-1 << endl;
        rep(i,N-1) cout << N-i << " " << N-(i+1) << endl;
    } else if(max_p >= max_n){
        cout << N-1 + cnt_n << endl;
        rep(i,N){
            if(A[i] < 0) cout << max_p_id << " " << i+1 << endl;
        }
        rep1(i,N-1) cout << i << " " << i+1 << endl;
    } else {
        cout << N-1 + cnt_p << endl;
        rep(i,N){
            if(A[i] > 0) cout << max_n_id << " " << i+1 << endl;
        }
        rep(i,N-1) cout << N-i << " " << N-(i+1) << endl;
    }


}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll X, Y;
	cin >> X >> Y;
	for(ll i = 1;; i++) {
		X *= 2;
		if(Y < X) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

// void __print(int x) {cerr << x;}
// void __print(long x) {cerr << x;}
// void __print(long long x) {cerr << x;}
// void __print(unsigned x) {cerr << x;}
// void __print(unsigned long x) {cerr << x;}
// void __print(unsigned long long x) {cerr << x;}
// void __print(float x) {cerr << x;}
// void __print(double x) {cerr << x;}
// void __print(long double x) {cerr << x;}
// void __print(char x) {cerr << '' << x << '';}
// void __print(const char *x) {cerr << '"' << x << '"';}
// void __print(const string &x) {cerr << '"' << x << '"';}
// void __print(bool x) {cerr << (x ? "true" : "false");}

// template<typename T, typename V>
// void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
// template<typename T>
// void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
// void _print() {cerr << "]\n";}
// template <typename T, typename... V>
// void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
// #ifndef ONLINE_JUDGE
// #define debug(x...) cerr << "[" << #x << /"] = ["; _print(x)
// #else
// #define debug(x...)
// #endif

int main()
{
    //fastio
    ll a,b,c,d;
    sfffl(a,b,c);
    sfl(d);
    //ll m = INT_MIN;
    ll m = -1000000000000000000;
    m = max(m,a*c);
    m = max(m,a*d);
    m = max(m,b*c);
    m = max(m,b*d);
    //cout<<m<<endl;
    printf("%lld",m);
    return 0;
}

Measured memory_bytes: 3832
#include<iostream>

using	namespace std;

int main() {
	int A, B;

	cin >> A >> B;

	if (A > B) {
		cout << A * 2 - 1 << endl;
	}
	else if(A<B){
		cout << B * 2 - 1 << endl;
	}
	else {
		cout << A + B << endl;
	}
}

Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

typedef long long LL;

struct Edge {
  int node;
  LL dist;
};

struct Node {
  LL value;
  vector <Edge> edges;
  bool vis;
};

vector<Node> nodes;

bool check(int n, LL value) {
  if (nodes[n].vis) {
    return nodes[n].value == value;
  }
  nodes[n].value = value;
  nodes[n].vis = true;
  for (Edge &edge : nodes[n].edges) {
    if (!check(edge.node, value + edge.dist)) {
      return false;
    }
  }
  return true;
}

int main(int argc, char *argv[])
{
  int n, m;
  cin >> n >> m;
  nodes.resize(n);
  for (int i = 0; i < m; ++i) {
    int l, r;
    LL d;
    cin >> l >> r >> d;
    --l, --r;
    nodes[l].edges.push_back({r, d});
    nodes[r].edges.push_back({l, -d});
  }
  bool ans = true;
  for (int i = 0; i < n; ++i) {
    if (!nodes[i].vis && !check(i, 0)) {
      ans = false;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 16384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    double b = sc.nextDouble();
    long bb = (long)((double)100 * b + 0.1);
    long ans = (a * bb) / (long)100;
    System.out.println(ans);
  }
}

Measured memory_bytes: 37384
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define MAX 1000000000 
using namespace std;

int main()
{
    int x,y;
    cin>>x>>y;
    int a=y/2;
    int b=0;
    if(a+b<x ||y%2==1) 
    {
        cout<<"No\n";
        return 0;
    }
    if(a+b==x)
    {
        cout<<"Yes\n";
        return 0;
    }
    else
    {
        int rem=a+b-x;
        if((a/2)>=rem)
        {
            cout<<"Yes\n";
        }
        else cout<<"No\n";
    }
}

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

int main(){
  int n; cin >> n;
  vector<int> a(n,0);

  rep(i,n-1) {
    int ind; cin >> ind;
    a.at(ind-1)++;
  }
  rep(i,n) {
    cout << a.at(i) << endl;
  }
}


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

using namespace std;

int main() {
  char ch[233];
  scanf("%s", ch);
  int ans = 0;
  for(int i = 0; i < strlen(ch); i++) ans += ch[i] == 'x';
  puts(ans <= 7 ? "YES" : "NO");
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
P p[100000];

void solve()
{
    sort(p, p+N);
    REP(i, N-1) cout << p[i].se << " ";
    cout << p[N-1].se << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N){
        p[i].se = i+1;
        cin >> p[i].fi;
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 1664
#include<stdio.h>
char s[2000005],t[2000005];
int main(){
	scanf("%s",s);
	scanf("%s",t);
	int ans=0;
	for(int i=0;s[i]!='\0';i++) if(s[i]!=t[i]) ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2124
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        int[] A = new int[N];
                        for (int i = 0; i < N; i++) {
                                A[i] = sc.nextInt();
                        }
                        int ans = 0;
                        for (int i = 0; i < N; i++) {
                                int minj = i;
                                for (int j = i; j < N; j++) {
                                        if (A[j] < A[minj]) {
                                                minj = j;
                                        }
                                }
                                if (i != minj) {
                                        ans++;
                                }
                                int tmp = A[i];
                                A[i] = A[minj];
                                A[minj] = tmp;
                        }
                        for (int i = 0; i < N; i++) {
                                System.out.print(A[i]);
                                if (i < N - 1) {
                                        System.out.print(" ");
                                } else {
                                        System.out.print("\n");
                                }
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 26144
n,m = map(int,input().split())
ps = []
for i in range(m):
  p,s = input().split()
  p = int(p)
  ps.append((p,s))
  
ans = [[0]*2 for _ in range(n)]
for i in range(m):
    if ans[ps[i][0]-1][1] == 1:
        continue
    if ps[i][1] == "AC":
        ans[ps[i][0]-1][1] = 1
        continue
    if ps[i][1] == "WA":
        ans[ps[i][0]-1][0]  += 1
        
p = 0
q = 0
for i in ans:
    if i[1] == 1:
        q += 1
        p += i[0]

print(q,p)


Measured memory_bytes: 29052
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[])=>{for(let i=0;i<a.length;i+=2)if(s==a[i])return a[i+1]};
const main = ()=>{
  out(sw(nin(),[
    25,'Christmas',
    24,'Christmas Eve',
    23,'Christmas Eve Eve',
    22,'Christmas Eve Eve Eve',
  ]));
}
main();

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int left = 0;
  int right = 0;
  int cnt = 0;
  string x = "(";
  string y = ")";
  for(int i=0; i<N; i++){
    if(S.at(i) == ')'){
      right++;
      if(right > left){
        cnt++;
        right--;
      }
    }
    else{
      left++;
    }
  }
  
  for(int i=0; i<cnt; i++){
    S = x + S;
  }
  
  left = 0;
  right = 0;
  cnt = 0;
  for(int i=S.size()-1; i>=0; i--){
    if(S.at(i) == '('){
      left++;
      if(right < left){
        cnt++;
        left--;
      }
    }
    else{
      right++;
    }
  }
  
  for(int i=0; i<cnt; i++){
    S = S + y;
  }

  cout << S << endl;

}

Measured memory_bytes: 256
i,v,s[5000],m,*p;main(n){for(;scanf("%d",&n),n;printf("%d\n",m))for(memset(s,i=0,n*4),m=-1e5;i++<n;)for(scanf("%d",&v),p=s+i;p---s;m=*p>m?*p:m)*p+=v;exit(0);}

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

int n,m;
vector<int>vec[100005];

void topo(int nod,vector<bool>&vis,stack<int>&sta)
{
	vis[nod]=true;
	for(int i=0;i<vec[nod].size();i++)
	{
		if(!vis[vec[nod][i]])
		topo(vec[nod][i],vis,sta);
	}
	sta.push(nod);
}


ll longestpath()
{
	stack<int>sta;
	vector<bool>vis(n+1,false);
	int i;
	for(i=1;i<=n;i++)
	{
		if(!vis[i])
		topo(i,vis,sta);
	}
	
	vector<int>len(n+1,0);
	while(!sta.empty())
	{
		int a=sta.top();
		sta.pop();
	    for(int i=0;i<vec[a].size();i++)
	    len[vec[a][i]]=max(len[vec[a][i]],len[a]+1);	
	}
	int a=0;
	for(i=1;i<=n;i++)
	a=max(a,len[i]);
	
	return a;
	
}

int main()
{
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
    int a,b;
    cin>>n>>m;
    while(m--)
    {
    	cin>>a>>b;
    	vec[a].push_back(b);
	}
	
	cout<<longestpath();
}

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

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

int main(int argc, char **argv)
{
    int n;
    string s;
    int l;
    vector<string> songs;
    vector<int> mins;

    cin >> n;

    rep(i, n)
    {
        cin >> s >> l;
        songs.push_back(s);
        mins.push_back(l);
    }
    cin >> s;

    vector<string>::iterator it = find(songs.begin(), songs.end(), s);
    int idx = (it - songs.begin());

    ll sum = 0;
    for (int i = idx + 1; i < mins.size(); i++)
    {
        sum += mins[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import math
from operator import itemgetter
n = int(input())
m =[]
l1 =[]
l2 =[]
for i in range(n):
    m.append(input().split())
    l1.append([int(m[i][0])+int(m[i][1]),int(m[i][0]),int(m[i][1])])
l1.sort(key=itemgetter(0),reverse=True)
ans = 0
if n%2 == 0:
    m = math.floor(n/2)
    for i in range(m):
        ans += l1[2*i][1]
        ans -= l1[(2*i)+1][2]
else:
    ans += l1[0][1]
    m = math.floor((n-1)/2)#n=3 m=1
    for i in range(1,m+1):
        ans -= l1[(2*i)-1][2]
        ans += l1[(2*i)][1]

print(ans)

Measured memory_bytes: 55264
N = int(input())
D1 = [0]*N
D2 = [0]*N
ans = 'No'
for i in range(N):
    D1[i], D2[i] = map(int, input().split())
list = []
for i in range(N):
  if D1[i] == D2[i]:
    list.append(0)
  else:
    list.append(1)
for i in range(N-2):
  if list[i] == 0 and list[i+1] == 0 and list[i+2] == 0:
    ans ='Yes'
print(ans)

Measured memory_bytes: 9200
X,Y = map(int, input().split())

trd = 100000
srd = 200000
onrd = 300000

if X == 3 and 3 < Y:
    print(trd)
elif X == 2 and 3 < Y:
    print(srd)
elif X == 1 and 3 < Y:
    print(onrd)
elif Y == 3 and 3 < X:
    print(trd)
elif Y == 2 and 3 < X:
    print(srd)  
elif Y == 1 and 3 < X:
    print(onrd)
elif X == 3 and Y == 3:
    print((trd)+(trd))
elif X == 3 and Y == 2:
    print((trd) +(srd))
elif X == 3 and Y == 1:
    print((trd)+(onrd))
elif X == 2 and Y == 3:
    print((srd)+(trd))
elif X == 2 and Y == 2:
    print((srd)+(srd))
elif X == 2 and Y == 1:
    print((srd)+(onrd))
elif X == 1 and Y == 3:
    print((onrd)+(trd))
elif X == 1 and Y == 2:
    print((onrd) + (srd))
elif X == 1 and Y == 1:
    print((onrd)+(onrd) + 400000)
else:
    print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <map>
#include <queue>
#include <cstring>
#include <set>
#include <stack>
using namespace std;
typedef long long int ll;

int min_k(ll a,ll b){
	int left=0,right=1e9;
	while(right-left>1){
		ll mid=(left+right)/2;
		if((a+1)*mid>=b&&(b+1)*mid>=a){
			right=mid;
		}else{
			left=mid;
		}
	}
	return right;
}

int cul(int a,int b,int k){
	int left=0,right=1e9;
	while(right-left>1){
		int mid=(left+right)/2;
		int aa=a-mid;
		int bb=b-max(0,(mid-1)/k);
		if(bb<=(ll)(aa+1)*k){
			left=mid;
		}else{
			right=mid;
		}
	}
	return left+max(0,(left-1)/k);
}

void query(int a,int b,int l,int r){
	int k=min_k(a,b);
	int right=cul(a,b,k);
	for(int i=l;i<=r;i++){
		if(i<=right){
			if(i%(k+1)==0){
				printf("B");
			}else{
				printf("A");
			}
		}else{
			int j=(a+b)-i+1;
			if(j%(k+1)==0){
				printf("A");
			}else{
				printf("B");
			}
		}
	}
	printf("\n");
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int q; cin >> q;
	while(q--){
		int a,b,c,d; cin >> a >> b >> c >> d;
		query(a,b,c,d);
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long

using namespace std;
const int N = 3000;
const int P = 1e9 + 7;

int n, k;
int fac[N * N], inv[N * N], f[N][N];

int power(int a,int b) {
	int res = 1;
	while (b > 0) {
		if (b & 1) res = res * a % P;
		a = a * a % P, b >>= 1;
	}
	return res;
}

int C(int n,int m) {
	int A = fac[n];
	int B = inv[n-m] * inv[m] % P;
	return A * B % P;
}

signed main(void)
{
	cin >> n >> k;
	fac[0] = 1;
	for (int i=1;i<=2100 * 2100;++i)
		fac[i] = fac[i-1] * i % P;
	f[0][0] = 1;
	int MAXN = 2000 * 2000;
	inv[MAXN] = power(fac[MAXN], P - 2);
	for (int i=MAXN - 1;i>=0;--i) 
	    inv[i] = inv[i+1] * (i + 1) % P;
	for (int i=1;i<=n;++i)
		for (int j=0;j<=i;++j) {
			f[i][j] = f[i-1][j];
			if (j == 0) continue;
			f[i][j] += f[i][j-1] * (n-j+1) % P * C(n*k-i-(j-1)*(k-1)-1,k-2) % P;
			f[i][j] %= P;
		}
	cout << f[n][n] + (k == 1) << endl;
	return 0;
} 

Measured memory_bytes: 115328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,m,i;
	string s,t;
	scanf("%i %i",&n,&m);
	ll k=(ll)n*m/__gcd(n,m);
	cin >> s >> t;
	map<ll,char> mp;
	for(i=0;i<n;i++)
	{
		ll p=k/n*i+1;
		mp[p]=s[i];
	}
	for(i=0;i<m;i++)
	{
		ll p=k/m*i+1;
		if(mp.count(p) && mp[p]!=t[i]) return 0*printf("-1\n");
	}
	printf("%lld\n",k);
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

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

  int N;
  cin >> N;

  // n == 2^x - 1 なら自明
  // n == 2^x なら不可能
  // 半開区間でXORが0になるようにする

  int nn = N;
  int oneCount = 0;
  while (nn > 0) {
    if (nn & 1) oneCount++;
    nn >>= 1;
  }
  if (oneCount <= 1) {
    cout << "No" << endl;
    return 0;
  }

  int nplus1 = N+1;
  int bitCount = 0;
  while (nplus1 > 0) {
    nplus1 >>= 1;
    bitCount++;
  }
  int nx = 0;
  for (int i = 0; i < bitCount-1; i++) {
    nx <<= 1;
    nx = nx | 1;
  }
  vector<Pii> edge;
  for (int i = 1; i < nx; i++) {
    edge.push_back(Pii(i, i+1));
  }
  edge.push_back(Pii(nx, N+1));
  for (int i = 1; i < nx; i++) {
    edge.push_back(Pii(N+i, N+i+1));
  }
  for (int i = nx; i < N-1; i+=2) {
    edge.push_back(Pii(i+2, i+1));
    edge.push_back(Pii(i+1, 2));
    edge.push_back(Pii(3, N+i+2));
    edge.push_back(Pii(N+i+2, N+i+1));
  }
  if (N % 2 == 0) {
    int a = N ^ (N-2), p = 2;
    while ((a ^ p) != 0) {
      a ^= p;
      p++;
    }
    edge.push_back(Pii(N, N-2));
    edge.push_back(Pii(p, N+N));
  }

  cout << "Yes" << endl;
  for (auto x: edge) cout << x.first << " " << x.second << endl;
  return 0;
}
/*
001
010
011
100
101
110

110 110
100 010
010 000
*/


Measured memory_bytes: 4336
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int n;
  scanf("%d", &n);
  while(true) {
    int k = (int)sqrt(n);
    if(k*k==n) break;
    n--;
  }
  printf("%d\n", n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll=long long;
using namespace std;
ll a[220000];
vector<ll>s;
int main(){
  ll n;
  cin>>n;
  rep(i,1,n+1)cin>>a[i];
  for(int i=n-(n+1)%2;i>0;i-=2)s.push_back(a[i]);
  for(int i=2;i<=n;i+=2)s.push_back(a[i]);
  if(n%2==1)rep(i,0,s.size())cout<<s[i]<<" ";
  else irep(i,s.size()-1,0)cout<<s[i]<<" ";
}

Measured memory_bytes: 5360
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n; cin >> n;

  vector<P> t(n);
  if (n==1) {
    cout << 0 << endl;
    return 0;
  }
  int minx = INT_MAX;
  int maxx = INT_MIN;
  int miny = INT_MAX;
  int maxy = INT_MIN;
  rep(i, n) {
    int x, y; cin >> x >> y;
    if (x > y) swap(x, y);
    if (x < minx) {
      minx = x;
    }
    if (x > maxx) {
      maxx = x;
    }
    if (y < miny) {
      miny = y;
    }
    if (y > maxy) {
      maxy = y;
    }
    t.at(i) = P(x, y);
  }
  long ans = (ll)(maxx - minx) * (maxy - miny);
  //debug(maxx); debug(minx); debug(maxy); debug(miny); debugln(ans);

  sort(t.begin(), t.end());
  int ma = max(t.at(0).second, t.at(n-1).first);
  int mif = min(t.at(0).second, t.at(n-1).first);
  int tmp = INT_MAX;
  for(int i=0; i<n-1; i++) {
    mif = min(mif, t.at(i).second);
    int mi = min(mif, t.at(i+1).first);
    ma = max(ma, t.at(i).second);
    tmp = min(tmp, ma-mi);    
  }
  ans = min((ll)ans, (ll)tmp * (maxy - minx));
  cout << ans << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define INF (1<<29)
using namespace std;
typedef pair<int,int>pii;
int n,m;
int fx;
vector<int>G[100010];
inline int read_int(){
	int t=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')t=-1,ch=getchar();
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*t;
}
vector<int>ord;
int tp;
void dfs(int from,int to,int h[],bool d){        //d==0?#--- :---#
	int t=-1;
	for(int i:G[to]){
		if(h[i]==0){
			t=i;
			break;
		}
	}
	if(t==-1){
		tp++;
		if(tp==2){
			printf("%d\n",ord.size());
			for(int i=0;i<ord.size()-1;i++)printf("%d ",ord[i]);
			printf("%d\n",ord.back());
			exit(0);
		}
//		reverse(ord.begin(),ord.end());
		dfs(to,from,h,1^d);
	}else{
		tp=0;
		h[t]=1;
//		reverse(ord.begin(),ord.end());
		if(d)ord.pb(t);
		else ord.insert(ord.begin(),t);
		dfs(t,from,h,1^d);
	}
}
int h[100010];
int main(){
//	freopen("produce/Hamiltonish.txt","r",stdin);
//	freopen("result.log","w",stdout);
	n=read_int(),m=read_int();
	for(int i=1;i<=m;i++){
		int x=read_int(),y=read_int();
		G[x].pb(y),G[y].pb(x);
	}
//	memset(h,0,sizeof(h));
	dfs(1,G[1][0],h,1);
	puts("-1");
	return 0;
}


Measured memory_bytes: 18552
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    long double ans;
    long double n;
    cin >> n;
    ans = (n-(int(n/2)))/n;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }

vec<P<ll, int>> factorize(ll n) {
    vec<P<ll, int>> ans;
    for(ll i = 2; i*i <= n; i++) {
        if (n%i) continue;
        ans.emplace_back(i, 0);
        while (n%i==0) {
            n /= i;
            ans.back().second++;
        }
    }
    if (n != 1) ans.emplace_back(n, 1);
    return ans;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll c = gcd(a, b);
    vec<P<ll, int>> fc = factorize(c);
    cout << fc.size() + 1 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

vector<vector<ll>> g;
//mapの使い方

//aのn乗 mod c
ll expmod(ll a,ll n){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1) ans=ans*aa%MOD;
    aa=aa*aa%MOD;
    beki/=2;
    if (beki==0)break;
  }
  return ans;
}


ll moddiv(ll a,ll b){
	ll x0=MOD,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%MOD;
      if (x2==1){
        ans=(n2+MOD)%MOD;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%MOD)*b-t)/b;
}
//剰余の割ざん



int main(){
  ll ans=0;
  cin >> n >> k;
  vi a(k+1),b(k);
  g.resize(k*50+100);

  for(ll i=2;i<=k;i++){
    for(ll j=i*2;j<=k;j+=i){
      g[j].emplace_back(i);
    }
  }


  for(ll i=1;i<=k;i++){
    ll nm=k/i;
    a[i]=expmod(nm,n);
  }


  for(ll i=k;i>=2;i--){
    ll atmp=a[i];
    for(auto aa:g[i]){
      a[aa]=(a[aa]-atmp+MOD)%MOD;
    }
    a[1]=(a[1]-atmp+MOD)%MOD;
  }

  ans=0;
  for(ll i=1;i<=k;i++){
    ans=(ans+a[i]*i)%MOD;
  }

  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 134468
import java.util.*;
import java.io.*; 
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void solve(int TC) throws Exception{
        int h = ni(), w = ni();
        boolean[] row = new boolean[h], col = new boolean[w];
        char[][] grid = new char[h][w];
        for(int i = 0; i< h; i++){
            String s = n();
            for(int j = 0; j< w; j++){
                grid[i][j] = s.charAt(j);
                if(grid[i][j]=='#'){
                    row[i] = true;
                    col[j] = true;
                }
            }
        }
        for(int i = 0; i< h; i++){
            for(int j = 0; j< w; j++){
                if(row[i] && col[j]){
                    p(grid[i][j]);
                }
            }
            if(row[i])pn("");
        }
    }
    //SOLUTION ENDS
    long mod = (int)1e9+9, IINF = (long)1e12;
    final int MAX = (int)1e5+1, INF = (int)1e9, root = 3;
    DecimalFormat df = new DecimalFormat("0.00000000");
    double PI = 3.141592653589793238462643383279502884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = true;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{    
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
}

Measured memory_bytes: 25940