akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 210
int n, m, k;
ll g[N][N];
int main(){
	cin>>n>>m>>k;
	vector<int> r(k);
	rep(i, k) cin>>r[i];
	rep(i, k) r[i]--;
	rep(i, n) rep(j, n) if(i!=j) g[i][j] = 1e15;
	rep(i, m){
		int a, b, c;
		cin>>a>>b>>c;
		a--; b--;
		g[a][b] = g[b][a] = c;
	}
	rep(l, n) rep(i, n) rep(j, n) g[i][j] = min(g[i][j], g[i][l]+g[l][j]);
	sort(all(r));
	ll res = 1e18;
	do{
		ll s = 0;
		rep(i, k-1) s += g[r[i]][r[i+1]];
		res = min(res, s);
	}while(next_permutation(all(r)));
	cout<<res<<endl;
	return 0;
}


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

#define REP(i,n) for(int i =0; i <n; ++i)

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll mod = 1000000007

using namespace std;

int n;
vector<double> x(10);
vector<double> y(10);

double dist(int i,int j){
    return  sqrt((x[i] - x[j])*(x[i] - x[j])+ (y[i] - y[j])*(y[i] - y[j]));
}

int main(){
    cin >> n;
    REP(i,n){
        cin >> x[i] >> y[i] ;
    }

    int a = 1;
    REP_(i,1,n+1){
        a *= i;
    }
    double r = 0;

    REP(i,n){
        REP(j,n){
            if(i == j)continue;
            r += dist(i,j);
        }
    }

    cout <<std::setprecision(15) <<  r/n << endl;



    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int A, B, C, D;
    cin >> A >> B >> C >> D;


    int res1=INF32;
    if(B >= C){
        cout << "Yes" << endl;
        return 0;
    } 
    else{
        res1 = C / B;
        if(C%B!=0) res1++;
    } 

    int res2 =INF32;
    res2 = A / D;
    if(A%D!=0) res2++;

    if(res1 <= res2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main(void){
    
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    
    if(x-r < 0 ||  x + r > W || y - r < 0 || y+r > H){
        cout<<"No"<<endl;
    }else{
        cout << "Yes" << endl;
    }
    
}


Measured memory_bytes: 3108
N = int(input())
arr = list(map(int, input().split()))

if sum(arr) == 0:
    print(0)
    exit()
#if N == 1:
#    print(arr[0])
#    exit()

count =0
while True:
    count +=1
    start = False

    for i in range(N):
        if arr[i] != 0:
            arr[i] -= 1
            start = True
            continue
        if arr[i] == 0 and start == True:
            break
    if sum(arr) == 0:
        break
print(count)

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

import sys

def top_k_sort(data, k=3, reverse=True):
    data.sort(reverse=True)
    return data[:k]

def main():
    data = []
    for line in sys.stdin:
        data.append(int(line))

    for h in top_k_sort(data):
        print(h)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7740
N = gets.to_i
ac = 0
wa = 0
tle = 0
re = 0
a = []

N.times {
  a << gets.chomp
}
a.each do |result|
  if result == 'AC'
    ac += 1
  elsif result == 'WA'
    wa += 1
  elsif result == 'TLE'
    tle += 1
  else
    re += 1
  end  
end
puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

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

using namespace std;

//#define FILE_IO

typedef long long LL;
typedef pair<LL, int> pli;

int N, E, T;
int p[100005];
LL dp[100005];
priority_queue <pli, vector<pli>, greater<pli> > dpmin, dpmns;
int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d%d", &N, &E, &T);
    for(int i = 1; i <= N; i++) scanf("%d", &p[i]);

    int pos = 1;
    dpmin.push({0, 0});
    for(int i = 1; i <= N; i++)
    {
        while(2 * (p[i] - p[pos]) >= T)
        {
            dpmns.push({dp[pos - 1] - 2LL * p[pos], pos});
            pos++;
        }

        while(!dpmin.empty() && dpmin.top().second < pos - 1)
            dpmin.pop();

        dp[i] = dpmin.top().first + T;
        pli x = {0, 0};
        if(!dpmns.empty())  dp[i] = min(dp[i], 2LL * p[i] + dpmns.top().first), x = dpmns.top();

        dpmin.push({dp[i], i});
    }

    LL ans = 1LL * dp[N] + 1LL * E;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 4344
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int dp[1010][1010];
bool doll[1010][1010];
int n, m, h, r;

signed main(){
	while (cin >> n && n) {
		rep(i, 0, 1010) {
			rep(j, 0, 1010) {
				doll[i][j] = false;
				dp[i][j] = 0;
			}
		}
		rep(i, 0, n) {
			cin >> h >> r;
			doll[h][r] = true;
		}
		cin >> m;
		rep(i, 0, m) {
			cin >> h >> r;
			doll[h][r] = true;
		}
		rep(i, 1, 1010) {
			rep(j, 1, 1010) {
				if (doll[i][j]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
				}
				else {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}
			}
		}
		cout << dp[1001][1001] << endl;
	}
}

Measured memory_bytes: 10120
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n, m, k;
    cin>>n>>m>>k;
    lli i,a[n],b[m], ans=0, point=0, totb=0, tota=0;
    stack<lli> s;
    
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<m;i++)
    {
        totb+=b[i];
        if(totb>k) 
        {
            totb-=b[i];
            break;
        }
        s.push(b[i]);
    }
    ans=max(ans, (lli)s.size());
    
    for(i=0;i<n;i++)
    {
        tota+=a[i];
        if(tota>k) break;
        
        while(tota+totb>k && s.size())
        {
            totb-=s.top();
            s.pop();
        }
        ans=max(ans, i+1+(lli)s.size());
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8364
//J

#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;

// 入力
int N;

// DP テーブル
double dp[310][310][310];
double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if (i > 0) res += rec(i-1, j, k) * i;
    if (j > 0) res += rec(i+1, j-1, k) * j;
    if (k > 0) res += rec(i, j+1, k-1) * k;
    res += N;
    res *= 1.0 / (i + j + k);

    return dp[i][j][k] = res;
}

int main() {
    cin >> N;
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a == 1) ++one;
        else if (a == 2) ++two;
        else ++three;
    }

    // 初期化
    memset(dp, -1, sizeof(dp));

    // 答え
    cout << fixed << setprecision(10) << rec(one, two, three) << endl;
}





Measured memory_bytes: 236592
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m=sc.nextInt(),f=sc.nextInt();
        int b=sc.nextInt()-m;
        System.out.println(b<=f?b<0?0:b:"NA");
    }
}


Measured memory_bytes: 26304
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef struct{
  double x,y;
}P;

void koch(int n, P a, P b){
  P s,t,u;
  double th = M_PI * 60.0 /180.0;  
  if(n == 0)return;
  
  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n",s.x,s.y);
  
  koch(n-1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  
  koch(n-1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);

  koch(n-1, t, b);
}

int main(){
  P a,b;
  int n;

  scanf("%d",&n);
  if(n<0 || n>6){
    printf("nは０から６までにして\n");
    exit(2);
  }
  
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y); 
  return 0;
}



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


def solve(A: int, P: int):
    fragment = A * 3 + P
    print(int(fragment / 2))
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
	int n;
	cin >> n;
	if (n == 1)
		cout << "Hello World";
	else
	{
		int a, b;
		cin >> a >> b;
		cout << a + b;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();
        int c = 1;
        for(int i=1; i<n; i++) {
            if(s.charAt(i) != s.charAt(i-1)) {
                c++;
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 25772
import java.util.*;

public class Main {
	public static void main(String[] args) {
		class Process {
			private String name;
			private long time;
		}
		Queue<Process> queue = new LinkedList<Process>();		
		Scanner scanner = new Scanner(System.in);
		
		long n = scanner.nextLong();
		long q = scanner.nextLong();
				
		for (int i = 0; i < n; i ++) {
			Process process = new Process();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			queue.add(process);
		}
		scanner.close();

		long currentTime = 0;
		
		while (queue.size() > 0) {
			Process currentProcess = queue.remove();
			
			if (currentProcess.time <= q) {
				currentTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + currentTime);
			} else {
				currentProcess.time -= q;
				currentTime += q;
				queue.add(currentProcess);
			}
		}
	}
} 



Measured memory_bytes: 73452
S = int(input())

top = S // 100
under = S % 100

if 0 < top and top <= 12:
    if 0 < under and under <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < under and under <= 12:
        print('YYMM')
    else:
        print('NA')


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

LL K, n, r;

int main(){
	scanf("%lld", &K); puts("50");
	n = K / 50; r = K % 50;
	for (int i=1; i<=r; i++) printf("%lld ", 99-r+n);
	for (int i=r+1; i<=50; i++) printf("%lld ", 49-r+n);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdint>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;

bool binarySearch(int A[], int n, int key){
    int left = 0;
    int right = n;
    int mid;
    while (left < right){
        mid = (left+right) / 2;
        if (key == A[mid]) return true;
        if (key > A[mid]) left = mid+1;
        else if (key < A[mid]) right = mid;
    }
    return false;
}

int main(){
    int n, A[100000], q, key;
    int sum = 0;

    scanf("%d", &n);
    for (int i=0; i<n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (int i=0; i<q; i++){
        scanf("%d", &key);
        if(binarySearch(A, n, key)) sum++;
    }

    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 1560
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for (;;) {
			int n = Integer.parseInt(scan.next());
			int m = Integer.parseInt(scan.next());
			if (n == 0 && m == 0) break;
			int a[] = new int[n];
			int w[] = new int[m];
			for (int i = 0; i < n; i++) {
				a[i] = Integer.parseInt(scan.next());
			}
			for (int j = 0; j < m; j++) {
				w[j] = Integer.parseInt(scan.next());				
			}
			SortedSet<Integer> commonAdditions = null;
			for (int i = 0; i < n; i++) {
				SortedSet<Integer> additions = new TreeSet<Integer>();
				boolean bJust = calcNearestWeight(a[i], w, 0, 0, additions);
				if (!bJust) {
					if (commonAdditions == null) {
						commonAdditions = additions;
					} else {
						commonAdditions.retainAll(additions);
					}
				}
			}
			if (commonAdditions == null) {
				System.out.println(0);				
			} else {
				if (commonAdditions.size() > 0) {
					System.out.println(commonAdditions.first());
				} else {
					System.out.println(-1);
				}
			}
		}
		scan.close();
	}

	private static boolean calcNearestWeight(int x, int w[], int i, int sum, SortedSet<Integer> additions) {
		if (x == sum) return true;
		if (i == w.length) {
			additions.add(Math.abs(x - sum));
			return false;
		}
		if (calcNearestWeight(x, w, i + 1, sum, additions)) return true;
		if (calcNearestWeight(x, w, i + 1, sum + w[i], additions)) return true;
		return calcNearestWeight(x, w, i + 1, sum - w[i], additions);
	}
}



Measured memory_bytes: 170232
k, x = gets.chomp.split(" ").map(&:to_i);
as = gets.chomp.split(" ").map(&:to_i);

before = as[-1] - k
max = 0
as.each do |a|
  tmp =  a - before
  max = [max, tmp].max
  before = a
end

puts k-max

Measured memory_bytes: 20612
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// 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>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void print(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printl(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}


signed main (){
    int v[3];
    rep(i,0,3)cin>>v[i];
    int k;cin>>k;
    sort(v,v+3);
    rep(i,0,k)v[2]*=2;
    cout<<accumulate(v,v+3,0)<<endl;

}
/*
*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_PANA2020
{
    class MainClass
    {

        static long[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);

            if(s[0]==1||s[1]==1){
                WriteLine(1);
                return;
            }
            WriteLine((s[0]*s[1]/2) + (s[0]*s[1])%2);
        }
    }
}


Measured memory_bytes: 11220
//|  ADARSH SINGH KUSHWAHA |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Bahut_tej_gand_faad ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define mp map<ll,ll>
#define ve vector<ll>
#define st set<int>
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define srt(v) sort(v.begin(),v.end(),greater<int>())
#define mod 1000000007
#define max 1000001
vector<int> a(200005);
void solve(){
	ll n;
	cin>>n;
	int k=0;
	int h=0;
	while(n--){
		int a,b;
		cin>>a>>b;
		if(a==b){
			h++;
		}else{
			if(h>k){
				k=h;
			}
			h=0;
		}
		if(h>k){
			k=h;
		}
	}
	if(k>=3){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}
int main(){
	Bahut_tej_gand_faad;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3932
aa, bb, cc, dd = ARGF.gets.chomp.split.collect {|el| el.to_i}

ta = true
while (0 < aa) && (0 < cc)
  if ta
    cc -= bb
  else
    aa -= dd
  end
  ta = !ta
end

ans = if 0 < aa
        "Yes"
      else
        "No"
      end

puts ans


Measured memory_bytes: 14320
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>

using namespace std;

static const long double EPS = 1e-10;
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2; // p2→p0→p1
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

class Point{
    public: 
    long double x,y;
    Point(long double x = 0.0, long double y = 0.0): x(x), y(y) {}
    Point operator + (Point p) const { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) const { return Point(x-p.x, y-p.y); }
    Point operator * (long double a) const { return Point(x*a, y*a); }
    Point operator / (long double a) const { return Point(x/a, y/a); }
    bool operator < (const Point &p) const { return (x != p.x ? x < p.x : y < p.y); }
    bool operator == (const Point &p) const { return fabsl(x - p.x) < EPS && fabsl(y - p.y) < EPS; }
    long double abs() const { return sqrt(norm()); }
    long double norm() const { return x*x + y*y; }
    long double dot(Point p) const { return x*p.x + y*p.y; }
    long double cross(Point p) const { return x*p.y - y*p.x; }   
};

class Segment{
    public: 
    Point p,q;
    Segment(Point p, Point q): p(p), q(q) {}
};

typedef Point Vector;
typedef Segment Line;

int ccw(Point p0, Point p1, Point p2){
    Point a = p1 - p0;
    Point b = p2 - p0;
    if(a.cross(b) > EPS) return COUNTER_CLOCKWISE;
    if(a.cross(b) < -EPS) return CLOCKWISE;
    if(a.dot(b) < -EPS) return ONLINE_BACK;
    if(a.norm() < b.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;
}

// 線分交差判定
bool intersect(Point p0, Point p1, Point p2, Point p3){
    return ccw(p0, p1, p2) * ccw(p0, p1, p3) <= 0 && ccw(p2, p3, p0) * ccw(p2, p3, p1) <= 0;
}

bool intersect(Segment s1, Segment s2){
    return intersect(s1.p, s1.q, s2.p, s2.q);
}

long double getDistanceLP(Line l, Point p){
    return abs((l.q-l.p).cross(p-l.p)) / (l.q-l.p).abs();
}

long double getDistanceSP(Segment s, Point p){
    if((s.q - s.p).dot(p - s.p) < -EPS) return (p-s.p).abs();
    if((s.p - s.q).dot(p - s.q) < -EPS) return (p-s.q).abs();
    return getDistanceLP(s, p);
}

long double getDistance(Segment s1, Segment s2){
    if(intersect(s1, s2)) return 0.0;
    return min(min(getDistanceSP(s1, s2.p), getDistanceSP(s1, s2.q)), min(getDistanceSP(s2, s1.p), getDistanceSP(s2, s1.q)));
}

int main(){
    int n;
    cin >> n;
    vector<Point> ps(4, Point());
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            cin >> ps[j].x >> ps[j].y;
        }
        Segment s1 = Segment(ps[0], ps[1]);
        Segment s2 = Segment(ps[2], ps[3]);
        printf("%.10Lf\n", getDistance(s1, s2));
    }
}


Measured memory_bytes: 3284
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
string tonum(string &str, int i,map<char,string> &data){
  if(i==str.size()) return "";
  return data[str[i]] + tonum(str,i+1,data);
}
int main(void){
  map<char,string> data;
  data[' '] = "101";
  data['\''] = "000000";
  data[','] = "000011";
  data['-'] = "10010001";
  data['.'] = "010001";
  data['?'] = "000001";
  data['A'] = "100101";
  data['B'] = "10011010";
  data['C'] = "0101";
  data['D'] = "0001";
  data['E'] = "110";
  data['F'] = "01001";
  data['G'] = "10011011";
  data['H'] = "010000";
  data['I'] = "0111";
  data['J'] = "10011000";
  data['K'] = "0110";
  data['L'] = "00100";
  data['M'] = "10011001";
  data['N'] = "10011110";
  data['O'] = "00101";
  data['P'] = "111";
  data['Q'] = "10011111";
  data['R'] = "1000";
  data['S'] = "00110";
  data['T'] = "00111";
  data['U'] = "10011100";
  data['V'] = "10011101";
  data['W'] = "000010";
  data['X'] = "10010010";
  data['Y'] = "10010011";
  data['Z'] = "10010000";
  string input;
  while(getline(cin,input)){
    string code = tonum(input,0,data);
    for(int i=0; i<code.size(); i+=5){
      string five = code.substr(i,5);
      if(five.size()<5){
        while(five.size()!=5) five.push_back('0');
      }
      int num5 = 0;
      REP(i,5) num5+=(five[i]-'0')*pow(2,4-i);
      if(num5<26){
        cout<<(char)('A'+num5);
      }else{
        if(num5==26) cout<<' ';
        if(num5==27) cout<<'.';
        if(num5==28) cout<<',';
        if(num5==29) cout<<'-';
        if(num5==30) cout<<'\'';
        if(num5==31) cout<<'?';
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import itertools
n=104730;a=list(range(n));a[:2]=0,0
for i in range(2,323):a[i*2::i]=[0]*len(a[i*2::i])
p=list(itertools.compress(range(n),a))
for e in iter(input,'0'):print(sum(p[:int(e)]))


Measured memory_bytes: 10464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin>>n;
	if(n%3!=0){
		rep(i,n){
			int a; cin>>a;
			if(a!=0){
				cout<<"No"<<endl;
				return 0;
			}
		}
		cout<<"Yes"<<endl;
		return 0;
	}
	map<int,int> mp;
	rep(i,n){
		int a; cin>>a;
		mp[a]++;
	}
	int num[4]={};
	int idx=0;
	for(auto i:mp){
		if(i.second!=n/3 and i.second!=2*n/3 and i.second!=n){
			cout<<"No"<<endl;
			return 0;
		}
		num[idx]=i.first;
		if(i.second==2*n/3){
			num[2]=i.first;
		}
		idx++;
		if(idx==4){
			cout<<"No"<<endl;
			return 0;
		}
	}
	if((num[0]^num[1])!=num[2]){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main(){
    int N;
    cin>>N;
    vector<int> p(N);
    for(int i=0; i<N; i++){
      cin>>p[i];
    }
    int ans =0;
    for(int i=0; i<N; i++){
      if(p[i]!=i+1){
        ans++;
      }
    }
    if(ans>2){
      cout<<"NO"<<endl;
    }
    else{
      cout<<"YES"<<endl;
    }
}

Measured memory_bytes: 256
import numpy as np

h, w, k = map(int, input().split())
painted = []
for i in range(h):
    painted.append(list(input()))
ans = 0
for i in range(2**(h+w)):
    painted_dum = np.array(painted)
    for j in range(h):
        if ((i >> j) & 1):
            painted_dum[j, :] = '*'
    for l in range(w):
        if ((i >> (h + l)) & 1):
            painted_dum[:, l] = '*'
    cnt_dum = np.count_nonzero(painted_dum == '#')
    if cnt_dum == k:
        ans += 1
print(ans)


Measured memory_bytes: 27168
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdint>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;








queue<pair<string,int>> Q;
int n;
int q;
int timer;

int main()
{
    scanf("%d", &n);
    scanf("%d", &q);

    for (int i=0; i<n; i++){
        string inName;
        char inNameChar[10];
        int inTime;
        scanf("%s", inNameChar);
        inName = inNameChar;
        scanf("%d", &inTime);
        Q.push(make_pair(inName, inTime));
    }

    while(!Q.empty()){
        pair<string, int> tmpPair;
        tmpPair = Q.front();
        Q.pop();

        int tmpElapseTime;
        tmpElapseTime = min(tmpPair.second, q);
        tmpPair.second -= tmpElapseTime;
        timer += tmpElapseTime;
        if (tmpPair.second > 0){
            Q.push(tmpPair);
        } else {
            printf("%s ", tmpPair.first.c_str());
            printf("%d\n", timer);
        }
    }


    return 0;
}

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

int main(void)
{
  int n,a[1000];

  cin >> n;
  for(int i=1; i<=n; i++)
    cin >> a[i];

  for(int i=n; i>=1; i--){
    cout << a[i];
    if(i != 1)
      cout << " ";
    }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

class UnionFind{
public:
	vector<int> par;
	vector<int> rank;
	vector<int> size;
 
	UnionFind(int n){
		rep(i,n){
			par.push_back(i);
			rank.push_back(0);
			size.push_back(1);
		}
	}
 
	int find(int x) {
		if(par[x]==x){
			return x;
		}else{
			return par[x]=find(par[x]);
		}
	}
 
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			par[x]=y;
			size[y]+=size[x];
		}else{
			par[y]=x;
			size[x]+=size[y];
			if(rank[x]==rank[y]) rank[x]++;
		}
	}

	bool same(int x,int y){
		return find(x)==find(y);
	}
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vector<P> a(m);
  UnionFind uf(n);
  rep(i,m){
    cin>>a[i].fi>>a[i].se;
    a[i].fi--;
    a[i].se--;
  }
  reverse(begin(a),end(a));
  vector<ll> ans;
  ll now=n*(n-1)/2;
  ans.push_back(now);
  rep(i,m){
    bool flag=uf.same(a[i].fi,a[i].se);
    ll cnt1=uf.size[uf.find(a[i].fi)];
    ll cnt2=uf.size[uf.find(a[i].se)];
    uf.unite(a[i].fi,a[i].se);
    if(!flag){
      now-=cnt1*cnt2;
    }
    ans.push_back(now);
  }
  reverse(begin(ans),end(ans));
  FOR(i,1,ans.size()) cout<<ans[i]<<endl;
}


Measured memory_bytes: 4968
n=int(input())
t,a=map(int,input().split())
x=list(map(int,input().split()))
b=[]
for i in range(n):
  x[i]=t-x[i]*0.006
  b.append(a-x[i])
  if(b[i]<0):
    b[i]=b[i]*-1
    
print(b.index(min(b))+1)
  

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <math.h>

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

typedef long long ll;
using namespace std;
bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

set<ll> enum_div(ll n)//nの約数を列挙
{
    set<ll> ret;
    for(ll i=1 ; i*i<=n ; ++i)
    {
        if(n%i == 0)
        {
            ret.insert(i);
            if(i!=1 && i*i!=n)
            {
                ret.insert(n/i);
            }
        }
    }
    return ret;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}




int main() {
    ll A, B;
    cin >> A;
    cin >> B;
    if (A==B) {
        if (IsPrime(A) && IsPrime(B)) {
            cout << 2 << endl;
            return 0;
        }
    }
    set<ll> dA = enum_div(A);
    set<ll> dB = enum_div(B);
    set<ll> gcs;
    set_intersection(ALL(dA),ALL(dB),inserter(gcs,gcs.end()));

    set<ll> pgcs;
    for (auto x: gcs) {
        if (IsPrime(x)) {
            pgcs.insert(x);
        }
        else if (x==1) {
            pgcs.insert(1);
        }
    }
    cout << pgcs.size() << endl;


    return 0;
}


Measured memory_bytes: 1152
use proconio::*;

fn main() {
    input! {
        n: usize,
        k: i64,
        a: [i64; n],
    }
    let mut res = 0i64;
    for i in 0..n {
        if a[i] >= k {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2964
n = int(input())
A, B, C = [], [], []
for i in range(n):
    a,b,c = map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)

dpA = [0]*n
dpB = [0]*n
dpC = [0]*n

dpA[0] = A[0]
dpB[0] = B[0]
dpC[0] = C[0]

for i in range(1, n):
    dpA[i] = A[i] + max(dpB[i-1], dpC[i-1])
    dpB[i] = B[i] + max(dpC[i-1], dpA[i-1])
    dpC[i] = C[i] + max(dpA[i-1], dpB[i-1])

print(max(dpA[-1], dpB[-1], dpC[-1]))

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

int main() {
	int a, b;
	long long mod = 1000000007;
	cin >> a >> b;
	vector<long long> fact(100001,1);

	for (int i = 1; i <= 100000; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
	}

	if (abs(a - b) > 1)cout << 0 << endl;
	else if (abs(a - b)) {
		cout << (fact[a] * fact[b]) % mod << endl;
	}
	else {
		cout << ((fact[a] * fact[b]) % mod) * 2 % mod << endl;
	}
}


Measured memory_bytes: 1024
void main() {
	auto ip = readAs!(int[]), K = ip[0], S = ip[1];
	int res;
	foreach(x; 0..K+1) foreach(y; 0..K+1) {
		auto z = S - x - y;
		if(z >= 0 && z <= K) res++;
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < n; ++i)

using namespace std;

int n, k;
int a[200000];
int b[200000];
int c;

int main(){
    scanf("%d%d", &n, &k);
    int an = 1, bn = 1;
    rep(i, n){
        int x;
        scanf("%d", &x);
        if(x < 0){
            a[an++] = -x;
        }
        else if(x == 0){
            c = 1;
        }
        else{
            b[bn++] = x;
        }
    }
    reverse(a + 1, a + an);
    int ans = 1e9;
    rep(i, min(an, k + 1 - c)){
        if(k - i - c >= bn){
            continue;
        }
        int p = a[i];
        int q = b[k - i - c];
        ans = min(2 * min(p, q) + max(p, q), ans);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
b=[]

if n%2==0:

    for i in range(n):

        if n-i*2-1 > 0:
            b.append(a[n-i*2-1])
        else:
            k=abs(n-i*2)
            b.append(a[k])

else:
    
    for i in range(n):

        if n-i*2-1 >= 0:
            b.append(a[n-i*2-1])
        else:
            k=abs(n-i*2-1)
            b.append(a[k-1])

print(*b)





Measured memory_bytes: 26180
#include <stdio.h>

int main(void) {
	int N, i;
	long p;
	p = 1;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		p *= (i + 1);
		p = p % 1000000007;
	}
	printf("%ld\n", p);
	return 0;
}

Measured memory_bytes: 128
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
p=Counter(a)
c=0
d=0
for a,b in p.items():
    if b>3:
        if c<a:
            c=a
        if d<a:
            d=a
    elif b>1:
        if c==0:
            c=a
        else:
            if d>c and c<a:
                c=a
            elif d<=c and d<a:
                d=a
print(c*d)

Measured memory_bytes: 18600
def main():
    import sys
    input = sys.stdin.readline

    N, a0, d, mod = map(int, input().split())

    def matmul(A, B):
        C = [[0] * len(B[0]) for _ in range(len(A))]
        for i in range(len(A)):
            for j in range(len(B[0])):
                for k in range(len(B)):
                    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod
        return C

    def matpow(A, p):
        n = len(A)
        B = [[0] * n for _ in range(n)]
        for i in range(n):
            B[i][i] = 1
        while p > 0:
            if p & 1:
                B = matmul(B, A)
            A = matmul(A, A)
            p >>= 1
        return B

    ans = [[a0%mod], [a0%mod], [d%mod]]
    ok_prev = 0
    for i in range(len(str(a0)), 20):
        ok = N
        ng = -1
        mid = (ok+ng)//2
        while ok - ng > 1:
            if len(str(a0 + d * mid)) >= i+1:
                ok = mid
            else:
                ng = mid
            mid = (ok+ng)//2

        mat = [[(10**i)%mod, 1, 1],
               [0, 1, 1],
               [0, 0, 1]]
        ans = matmul(matpow(mat, ok - ok_prev-1), ans)
        ok_prev = ok-1
        if ok == N:
            break
    print(ans[0][0])


if __name__ == '__main__':
    main()


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

// main
int main(){
    int N, M;
    cin >> N >> M;

    vector<bool> ac_flag_vec(N+100, false);
    vector<int> wa_vec(N+100, 0);
    int penalty_count = 0;

    int problem_num;
    string result;
    for (int i = 0; i < M; ++i){
        cin >> problem_num >> result;
        if (!ac_flag_vec[problem_num] && result == "WA"){
            wa_vec[problem_num]++;
        }else if (!ac_flag_vec[problem_num] && result == "AC"){
            ac_flag_vec[problem_num] = true;
            penalty_count += wa_vec[problem_num];
        }
    }

    cout << accumulate(ac_flag_vec.begin(), ac_flag_vec.end(), 0) << " " << penalty_count << "\n";
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n) {
        for (int j = i; j < n; ++j) {
            string t = s.substr(0, i);
            for (int k = j; k < n; ++k) {
                t += s[k];
            }
            //cout << t << endl;
            if (t == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        if (num <1 || num > 100){
          System.out.println("Out of range");
        } else{
          System.out.println( (num+1) / 2 );
        }
    }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],pos[100005],pre[100005],nxt[100005];
int main(){
    long long s=0,ans=0;
	cin>>n;
	for (long long i=1;i<=n;i++)
		cin>>a[i],pos[a[i]]=i;
	for (long long i=0;i<=n+1;i++)
		pre[i]=max(i-i,i-1),nxt[i]=min(n+1,i+1);
	s=n*(n-1)/2;
   	for (long long i=1;i<=n;i++){
   		ans+=s;
   		long long x=pos[i];
   		s-=(pre[x]-pre[pre[x]])*(nxt[x]-x);
   		s-=(nxt[nxt[x]]-nxt[x])*(x-pre[x]);
   		pre[nxt[x]]=pre[x];
   		nxt[pre[x]]=nxt[x];
	}
	cout<<ans;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    long long N, K;
    cin >> N >> K;

    vector<long long> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    vector<int> cnt0(40, 0);
    vector<int> cnt1(40, 0);

    for(long long temp: A){
        for(int i = 0; i < 40; i++){
            if(temp & (1LL << i)){
                cnt1[i]++;
            }
            else{
                cnt0[i]++;
            }
        }
    }

    vector<long long> bestSum(40);
    bestSum[0] = 0;
    for(int i = 1; i < 40; i++){
        long long plus;
        if(cnt1[i - 1] > cnt0[i - 1]){
            plus = cnt1[i - 1] * (1LL << (i - 1));
        }
        else{
            plus = cnt0[i - 1] * (1LL << (i - 1));
        }

        bestSum[i] = bestSum[i - 1] + plus;
    }

    long long tempSum = 0;
    long long ans = 0;
    for(int i = 39; i >= 0; i--){
        if(K & (1LL << i)){
            // 0, K未満確定
            long long temp = tempSum + cnt1[i] * (1LL << i) + bestSum[i];
            ans = max(ans, temp);

            // 1
            tempSum += cnt0[i] * (1LL << i);
        }
        else{
            // 0
            tempSum += cnt1[i] * (1LL << i);
        }
    }
    ans = max(ans, tempSum);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
   int l,r,d;
   cin>>l>>r>>d;

   int ans=0;

   for(int i=l;i<=r;i++){
      if(i%d==0) ans++;
   }
   cout<<ans;
   

return 0;
}


Measured memory_bytes: 3632
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

l,r = MAP()
if(l%2019>=r%2019) or (r-l>=2018):
  print(0)
  exit()
else:
  l %= 2019
  r %= 2019

ans = inf
for i in range(l,r):
  for j in range(i+1,r+1):
    ans = min(ans, i*j%2019)

print(ans)

Measured memory_bytes: 10144
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;


int main(){
    ll k;
    cin >> k;
    if(k == 0 || k == 1){
        cout << 2 << endl;
        cout << 0 << " " << 0 + 2*(k==1) << endl;
        return 0;
    }

    ll n = min(k, 50LL);
    vector<ll> ans(n);
    ll x = k/(50LL);
    ll y = k%(50LL);
    rep(i, n){
        ans[i] = (n - i - 1) + x;
        if(i < y) ans[i]++;
    }

    cout << ans.size() << endl;
    rep(i, n) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[205][100005]={0};
const ll mod=1e9+7;
ll pw[100005]={0};
ll pow(ll x,ll y){
  if(pw[x]>0) return pw[x];
  if(y==0) return 1;
  ll ret=pow(x,y/2);
  ret*=ret;
  ret%=mod;
  if(y%2==1) ret*=x;
  return pw[x]=ret%mod;
}
int main(){
  ll n,x;
  cin>>n>>x;
  dp[0][x]=1;
  vector<ll> vec;
  for(ll i=0;i<n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
  }
  sort(vec.begin(),vec.end());
  for(ll i=1;i<=n;i++){
    ll okper=pow(n+1-i,mod-2),ngper=((n-i)*okper)%mod;
    for(ll j=0;j<=x;j++){
      ll nxt=j%vec[n-i];
      dp[i][nxt]+=dp[i-1][j]*okper%mod;
      dp[i][j]+=dp[i-1][j]*ngper%mod;
      dp[i][nxt]%=mod;
      dp[i][j]%=mod;
    }
  }
  ll ans=0;
  for(ll i=0;i<100005;i++) {
    ans+=(dp[n][i]*i)%mod;
    ans%=mod;
  }
  for(ll i=1;i<=n;i++){
    ans*=i;
    ans%=mod;
  }
  cout<<ans<<endl;
}


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

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if (B - A <= 0) cout << "delicious" << endl;
    else if (B - A <= X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int a,b;
    cin >>a >>b;
    double f=a,g=b;
    //cout << (a/b) << " " << (a%b) << " " << (f/g) << endl;
    printf("%d %d %.5f\n",(a/b),(a%b),(f/g));
    
    return 0;
}


Measured memory_bytes: 3188
import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();

		System.out.printf("%.6f %.6f",r*r*Math.PI,2 * Math.PI*r);
	}
}

Measured memory_bytes: 19076
#include <cstdio>

const int MAXN = (int)1e5;

int a[MAXN];
int f[MAXN];

int solve(int n) {
  int res = 0;
  f[n - 1] = 0;
  for (int i = n - 2; i >= 0; --i) {
    if (a[i] >= a[i + 1]) {
      f[i] = f[i + 1] + 1;
    } else {
      f[i] = 0;
    }
    if (f[i] > res) res = f[i];
  }
  return res;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  printf("%d\n", solve(n));
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
int n, r[128]; bool used[22370000]; char com[7], s[13];
int main() {
	scanf("%d", &n); r[65] = 1, r[67] = 2, r[71] = 3;
	for(int i = 0; i < n; i++) {
		scanf("%s %s", com, s);
		int h = 0, l = strlen(s);
		for(int j = 0; j < l; j++) h = h * 4 + r[s[j]];
		for(int j = 0; j < l; j++) h += 1 << (2 * l);
		if(com[0] == 105) used[h] = true;
		else puts(used[h] ? "yes" : "no");
	}
}

Measured memory_bytes: 3980
#include<iostream>
using namespace std;
int main()
{
    int n,l;
    cin>>n;
    l=n%10;
    if(l==2||l==4||l==5||l==7||l==9)
    {
        cout<<"hon"<<endl;
    }
    else if(l==0||l==1||l==6||l==8)
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"bon"<<endl;
    }
    return 0;
}

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


signed main() {
    int n, m;
    cin >> n >> m;
    vi p(m), wa_sum(n);
    vector<string> s(m);
    rep(i, m) cin >> p[i] >> s[i];
    vector<bool> is_AC(n, false);
    vi tmp_wa(n);
    
    ll ans = 0;
    ll ac = 0;

    rep(i, m){
        if(s[i] == "AC"){
            if(is_AC[p[i]-1] == false){
                ac++;
                is_AC[p[i]-1] = true;
            }
        }
        if(s[i] == "WA"){
            if(is_AC[p[i]-1] == false){
                tmp_wa[p[i]-1]++;
            }
        }
    }

    rep(i, n){
        if(is_AC[i]) ans += tmp_wa[i];  
    }
    cout << ac << " " << ans << endl;
}

Measured memory_bytes: 8712
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	if (K > (N - 2) * (N - 1) / 2) cout << -1;
	else {
		vector<int> V;
		cout << (N - 1) * N / 2 - K << endl;
		int X = (N - 2) * (N - 1) / 2;
		for (int i = 2; i <= N; i++) {
			cout << 1 << " " << i << endl;
			if (i <= N - 2) V.push_back(0);
			else V.push_back(1);
		}
		for (int i = 0; i < (N - 2) * (N - 1) / 2 - K; i++) {
			int COUNT = 0, P[2] = {};
			for (int i = 0; i < N - 1; i++) {
				if (V[i] == 1) P[COUNT] = i + 2, COUNT++;
			}
			cout << P[0] << " " << P[1] << endl;
			next_permutation(V.begin(), V.end());
		}
	}
}

Measured memory_bytes: 256
n = int(input())
red, blue = [], []
for _ in range(n):
    a, b = map(int, input().split())
    red.append([a, b, min(a, b)])
for _ in range(n):
    a, b = map(int, input().split())
    blue.append([a, b, min(a, b)])
    
red.sort(key=lambda x: x[1])
blue.sort(key=lambda x: x[0])
status = [False for _ in range(n)]
ans = 0
for i in range(n):
    for j in range(n-1, -1, -1):
        if not status[j]:
            if red[j][0] < blue[i][0] and red[j][1] < blue[i][1]:
                ans += 1
                status[j] = True
                break
print(ans)


Measured memory_bytes: 9260
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String ss = sc.next();
		String tt = sc.next();
		
		int count = 0;
		
		for (int i=0;i<3;i++){
			if (ss.charAt(i) == tt.charAt(i))
				count++;
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 22740
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long solve(long long x)
{
    if(x == 1) return 1;
    return 2*solve(x/2)+1;
}
int main()
{
    long long h;
    cin>>h;
    cout<<solve(h)<<endl;
}

Measured memory_bytes: 256