akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

class BIT {
public:
  int n;
  vector<int> bit;
  BIT(int n_) {
    n = n_;
    bit.resize(n + 1);
  }
  void add(int a, int w) {
    a += 1;
    if (a == 0 || a > n)
      return;
    for (int x = a; x <= n; x += x & -x)
      bit[x] += w;
  }
  int sum(int a) {
    a += 1;
    if (a == 0)
      return 0;
    int ret = 0;
    for (int x = a; x > 0; x -= x & -x)
      ret += bit[x];
    return ret;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ps(n);
  for (int i = 0; i < n; i++)
    cin >> ps[i].first >> ps[i].second;
  map<int, vector<pair<int, int>>> mp;
  for (int i = 0; i < n; i++)
    mp[ps[i].second - ps[i].first + 1].push_back(ps[i]);
  BIT bit(1 << 20);
  int sum = n;
  for (int i = 1; i <= m; i++) {
    if (mp.find(i - 1) != mp.end()) {
      for (int j = 0; j < mp[i - 1].size(); j++) {
        bit.add(mp[i - 1][j].first, 1);
        bit.add(mp[i - 1][j].second + 1, -1);
        sum--;
      }
    }
    int ans = sum;
    for (int j = 0; j <= m; j += i) {
      ans += bit.sum(j);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 17280
#define HAVE_STRUCT_TIMESPEC
#include <bits/stdc++.h>
using namespace std;
int a[107];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int flag=0;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        if(a[i]%2==0){
            if(a[i]%3&&a[i]%5){
                flag=1;
            }
        }
    }
    if(flag)
        cout<<"DENIED";
    else
        cout<<"APPROVED";
    return 0;
}


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

int n,m,a[100100];
bool b[100100]={0,1};

int main(){
  cin >>n >>m;
  for(int i = 1; i<=n; i++) a[i]=1;
  for(int i = 1; i<=m; i++){
    int x,y; cin >>x >>y;
    if(b[x]) {
      b[y]=1;
      if(a[x]==1) b[x]=0;
    }
    a[y]++; a[x]--;
  }
  int cnt = 0;
  for(int i = 1; i<=n; i++) if(b[i]) cnt++;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4020
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=1e6+4;

ll fac[N],infac[N];
 
ll me(ll a,ll b)
{
    ll res=1;
 
    if(b<0)
    return 0;
 
    while(b)
    {
        if(b&1)
        res=(res*a)%mod;
 
        b>>=1;
 
        a=(a*a)%mod;
    }
 
    return res;
}
 
ll mi(ll a)
{
    return me(a,mod-2);
}
 
void factorial()
{
   fac[0]=1;
 
   for(ll i=1;i<N;i++)
   fac[i]=(i*fac[i-1])%mod;
 
   infac[N-1]=mi(fac[N-1]);
 
   for(ll i=N-1;i>=1;i--)
   infac[i-1]=(i*infac[i])%mod;
}
 
ll ncr(ll n,ll r)
{
    if(n<r)
    return 0;
 
    ll val=fac[n];
 
    val=(val*infac[r])%mod;
 
    val=(val*infac[n-r])%mod;
 
    return val;
}
 
int main()
{	
	factorial();

	int n,m; scn(n); scn(m);

	ll ans=0,sign=1;

	rep(i,0,n+1)
	{
		ll here,val,temp;

		val=ncr(n,i);

		temp=(ncr(m-i,n-i)*fac[n-i])%mod;

		here=(val*temp)%mod; here*=sign;

		ans=(ans+here+mod)%mod;

		sign*=-1;
	}

	ans=(ans*ncr(m,n))%mod; ans=(ans*fac[n])%mod;

	lpri(ans);

	return 0;
}                   

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

a = 2
prime = [ 1 ] * 55559
prime[0] = 0
prime[1] = 0
while a < 55556:
  if prime[a] == 1:
    b = a + a
    while b < 55556:
      prime[b] = 0
      b += a
  a += 1
d = []
n = 0
for i in range(55556):
  if prime[i] == 1:
    if i%5==1:
      d.append(i)
      n += 1
      if n == N:
        break
      
for i in d:
  print(str(i)+" ", end="")
print("")


Measured memory_bytes: 3444
#include<iostream>
 
using namespace std;
static const int MAX = 1000;
 
int main()
{
    int A[MAX], N, i, j, k, v;
     
    cin >> N;
    for (i=0; i<N; i++)  cin >> A[i];
     
    for (i=0; i<N; i++){
    	if(i>0)cout << " ";
    	cout << A[i];
    }
    cout << endl;
     
    for (i=1; i<N; i++){
        v = A[i];
        j = i-1;
        while (j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for (k=0; k<N; k++){
        	if(k>0)cout << " ";
        	cout << A[k];
        }
        cout << endl;
    }
     
     
     
     
    return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>
int main(void){
    int i,a=0;
    char s[1000000];
    scanf("%s",s);
    for(i=0;s[i]!='\0';i++){
        if(s[i]==s[i+1]){
            if(s[i]=='0'){
                s[i+1]='1';
                a++;
            }
            else{
                s[i+1]='0';
                a++;
            }
        }
    }
    printf("%d",a);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine().trim();
        int s = Integer.parseInt(line);
        int h = s / 3600;
        s -= 3600 * h;
        int m = s / 60;
        s -= 60 * m;
        System.out.println(h + ":" + m + ":" + s);
        br.close();
    }
     
}

Measured memory_bytes: 24120
/**
 *    author:  milos
 *    created: 04.08.2020 22:37:08      
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }    
  vector<long long> dp(n, 1e9);
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= min(k, i); j++) {
      dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
    } 
  }
  cout << dp[n - 1] << '\n';
  return 0;   
}

Measured memory_bytes: 4520
#include<math.h>
#include<stdio.h>
int main(void)
{
  double x1,x2,y1,y2;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2); 

  printf("%lf",sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
  return 0;
}

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

int counter(int x) {
    if(x == 0) {
        return 0;
    }
    return counter(x >> 1) + (x & 1);
}

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

    rep(i, 0, n) {
        cin >> a[i];
        rep(j, 0, a[i]) {
            int x, y;
            cin >> x >> y;
            xy[i].push_back(make_pair(x, y));
        }
    }

    int ans = 0;
    rep(bit, 1, (1<<n)) {
        bool ok = true;
        vector<bool> person(n);
        rep(i, 0, n) {
            person[i] = (bit >> i) & 1;
        }
        
        bool judge = false;
        int sum = 0;
        int count = 0;
        int trueman = 0;
        rep(i, 0, n) {
            if(person[i] == 1) {
                trueman++;
                sum += a[i];
                rep(j, 0, a[i]) {
                    if(person[xy[i][j].first-1] != xy[i][j].second) {
                        count = 0;
                        continue;
                    }
                    else {
                        count++;
                    }
                }
            }
        }

        if(count == sum) {
            ans = max(ans, trueman);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.range;
import std.array;
import std.conv;
import std.string;

long h, w;
string[] field;
long[][] used;

void dfs(long y, long x, char m, ref long a, ref long b) {
  if (field[y][x] == m) {
    a++;
  } else {
    b++;
  }
  used[y][x] = 1;

  if (y - 1 >= 0 && field[y][x] != field[y-1][x] && used[y-1][x] == 0) { 
    dfs(y - 1, x, m, a, b);
  }
  if (x - 1 >= 0 && field[y][x] != field[y][x-1] && used[y][x-1] == 0) {
    dfs(y, x - 1, m, a, b);
  }
  if (y + 1 < h && field[y][x] != field[y+1][x] && used[y+1][x] == 0) { 
    dfs(y + 1, x, m, a, b);
  }
  if (x + 1 < w && field[y][x] != field[y][x+1] && used[y][x+1] == 0) {
    dfs(y, x + 1, m, a, b);
  }

}


void main() {
  readf("%d %d\n", &h, &w);
  used = new long[][](h, w);

  foreach (_; 0..h) {
    field ~= readln.strip;
  }

  long r = 0;
  foreach (y; 0..h) {
    foreach (x; 0..w) {
      if (used[y][x] == 0) {
        long a, b;
        dfs(y, x, field[y][x], a, b);
        r += a * b;
      }
    }
  }
  writeln(r);
}


Measured memory_bytes: 18812
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    string S;
    cin>>S;
    int len=S.size();
    ll val=0;
    //+があるなら1ないなら0
    //
    //繰り返し回数は2^(len-1);
    for(ll i=0;i<(1<<(len-1));i++){
        ll now=S[0]-'0';
        REP(j,len-1){
            if(i&(1<<j)){
                val+=now;
                now=S[j+1]-'0';
            }else{
                now=10*now+S[j+1]-'0';
            }
        }
        val+=now;
    }
    cout<<val<<endl;
    return 0;
}

Measured memory_bytes: 256
import { readFileSync } from 'fs'

const range = (n: number) => Array(n).fill(null).map((_, i) => i)

function main(input: string) {
  const [[N, M], ...lines] = input.split('\n').map(v => v.split(' ').map(Number))

  const set = new Set(lines.map(([v]) => v))
  const memo = {} as Record<number, number>

  const fn = (n: number) => {
    if (n < 0) return 0
    if (n == 0) return 1
    if (n in memo) return memo[n]

    const list = [n - 1, n - 2].filter(v => !set.has(v))
    const result = list.map(v => fn(v)).reduce((a, b) => a + b, 0)

    return memo[n] = result % 1000000007
  }

  // メモ化を利用して、再帰上限を回避
  range(N).forEach(v => fn(v))

  console.log(fn(N))
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 58096
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main(){
    int N,K;
    cin >>  N >> K;
    int D[K];
    FOR(i,0,K) cin >> D[i];

    FOR(i,N,1000000){
    	int p = i;
    	bool ok = true;
    	while(p != 0){
    		int m = p%10;
    		FOR(j,0,K){
    			if (D[j] == m) {
    				ok = false;
    				break;
    			}
    		}
    		if (!ok) break;
    		p = p/10;
    	}
    	if (ok){
    		cout << i <<  endl;
    		return 0;
    	}
    }
    return 0;
}

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

using namespace std;

int main()
{
  string a;
  int b;
  string c;
  int tarou = 0,hanako = 0;
  int max;
  cin >> b;
  for(int i = 0; i < b ;i ++)
  {
    cin >> a >> c;
    if(a.size() > c.size())max = c.size();
    else max = a.size();
    for(int j = 0; j < max; j++)
    {
      if(a[j] > c[j])
      {
        tarou += 3;
        break;
      }
      else if(a[j] < c[j])
      {
        hanako += 3;
        break;
      }
      if(j == (max - 1))
      {
        if(a.size() == c.size())
        {
          tarou += 1;
          hanako += 1;
          break;
        }
        else if(a.size() > c.size())
        {
          tarou += 3;
          break;
        }
        else
        {
          hanako += 3;
          break;
        }
      }
    }

  }
  cout << tarou << ' ' << hanako<< endl;
  return 0;
}


Measured memory_bytes: 3208
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<int> cnt(128, INT_MAX);
    for(int i=0; i<n; ++i){
        string s;
        cin >> s;
        vector<int> v(128, 0);
        for(char c : s)
            ++ v[c];
        for(char c='a'; c<='z'; ++c)
            cnt[c] = min(cnt[c], v[c]);
    }

    string ans;
    for(char c='a'; c<='z'; ++c){
        while(cnt[c] > 0){
            ans += c;
            -- cnt[c];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
操作の逆順を考える
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
 */

int main() {
    int a,b;
    cin >> a >> b;
    int sum=0;
    if(a==3)sum+=100000;
    if(b==3)sum+=100000;
    if(a==2)sum+=200000;
    if(b==2)sum+=200000;
    if(a==1)sum+=300000;
    if(b==1)sum+=300000;
    if(a==1 && b==1)sum+=400000;
    cout << sum;
 


}

/*
cout << fixed;
cout << setprecision(n) << ans;
*/



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
inline long long readInt() {
	long long f=1,x=0; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main () {
	long long A = readInt(), B = readInt(), K = readInt();
	for(int i = 1; i <= K; i ++) {
			if(i%2==1) A=A/2,B+=A;
			else B=B/2,A+=B;
	}

	printf("%lld %lld", A, B);
	return 0;
}

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



int main(void)
{
    int n, element;
    char com[20];
    scanf("%d", &n);

    list<int> L;
    list<int>::iterator it;

    for(int i = 0; i < n; i++)
    {
        scanf("%s", com);

        if(com[0] == 'i'){
            scanf("%d", &element);
            L.push_front(element);
        } 
        else if(com[6] == 'F') L.pop_front();
        else if(com[6] == 'L') L.pop_back();
        else if(com[0] == 'd')
        {
            scanf("%d", &element);
            for(it = L.begin(); it != L.end(); it++)
            {
                if(*it == element){
                    L.erase(it);
                    break;
                }
            }
        }
        
    }

    for(it = L.begin(); it != L.end(); it++)
    {
        if(!(it == L.begin())) printf(" ");
        printf("%d", *it);
    }
    printf("\n");


    return 0;
}


Measured memory_bytes: 33892
# atan

a,b,x=map(int,input().split())
from math import*

if a*a*b/2<=x:
    c=2*x/a/a-b
    theta=atan((b-c)/a)
    print(theta*180/pi)
else:
    d=a-2*x/b/a
    theta=atan(b/(a-d))
    print(theta*180/pi)

Measured memory_bytes: 3188
require 'set'
h, w, N = gets.split.map(&:to_i)

cols = (1..h).map { gets.chomp.split("") }.transpose.map(&:reverse)
GOAL = [ [?.] * h ] * w

def check_swap(cols, c1, r1, c2, r2)
    return nil if cols[c1][r1] == cols[c2][r2]

    copy = cols.map(&:dup)
    copy[c1][r1], copy[c2][r2] = copy[c2][r2], copy[c1][r1]

    drop(copy)
    drop(copy) while changed = erase(copy) 

    return copy == GOAL
end

def erase(cols)
    to_be_erased = Set.new
    (0..cols.size-1).each do |i|
        x = nil
        n = 0
        cols[i].each.with_index do |y, j|
            if y == ?.
                n = 0
            elsif y == x
                n += 1
            else
                x = y
                n = 1
            end
            if n == N
                (0..n-1).each do |k|
                    to_be_erased << [i, j-k]
                end
            elsif n > N
                to_be_erased << [i, j]
            end
            x = y
        end
    end

    (0..cols[0].size-1).each do |j|
        x = nil
        n = 0
        (0..cols.size-1).each do |i|
            y = cols[i][j]
            if y == ?.
                n = 0
            elsif y == x
                n += 1
            else
                x = y
                n = 1
            end
            if n == N
                (0..n-1).each do |k|
                    to_be_erased << [i-k, j]
                end
            elsif n > N
                to_be_erased << [i, j]
            end
            x = y
        end
    end

    to_be_erased.each do |i, j|
        cols[i][j] = ?.
    end

    return ! to_be_erased.empty?
end

def drop(cols)
    cols.map! do |col|
        n = col.size
        col.delete(?.)
        col += [?.] * (n - col.size)
    end
end

(0..w-2).each do |c|
    (0..h-1).each do |r|
        if check_swap(cols, c, r, c+1, r)
            puts 'YES'
            exit
        end
    end
end

puts 'NO'

Measured memory_bytes: 9092
#!/usr/bin/env ruby
n = gets.chomp.to_i

hash = Hash.new(0)

hash['AC'] = 0
hash['WA'] = 0
hash['TLE'] = 0
hash['RE'] = 0

n.times do
  s_i = gets.chomp
  hash[s_i] += 1
end

puts "AC x #{hash['AC']}"
puts "WA x #{hash['WA']}"
puts "TLE x #{hash['TLE']}"
puts "RE x #{hash['RE']}"



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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int n;
ll a[100100];

int main(){
  cin >> n;
  rep(i,1,n+1)cin >> a[i];
  ll check = 0;
  ll ans=0;
  //正負正負正負、、、のパターン
  rep(i,1,n+1){
    check +=a[i];
    if(i%2!=0 && check <=0){
      ans += abs(1-check);
      check = 1;

    }else if(i%2==0 && check >=0){
      ans += abs(check+1);
      check = -1;
    }
  }
  //負正負正負正負正のパターン
  check = 0;
  ll tmp = 0;
  rep(i,1,n+1){
    check += a[i];
    if(i%2!=0 && check >= 0){
      tmp += abs(check+1);
      check = -1;
    }else if(i%2==0 && check <= 0){
      tmp +=abs(1-check);
      check = 1;
    }
    // cout << a[i] <<"\t"<< check << endl;
  }
  cout << min(tmp,ans)<< endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

const ll inf = 1e18;
ll dp[405][405], s[405][405];
int a[405];
ll dfs(int l, int r){
    if (r-l == 1) {
        dp[l][r] = 0;
        return dp[l][r];
    }
    if (dp[l][r] != inf) return dp[l][r];
    repran(i, l+1, r){
        dp[l][r] = min(dp[l][r], dfs(l, i)+dfs(i, r)+s[l][i]+s[i][r]);
    }
    return dp[l][r];
}
int main()
{
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) {
        repran(j, i+1, n+1){
            dp[i][j] = inf;
            s[i][j] = s[i][j-1]+a[j-1];

        }
    }
    dfs(0, n);
    cout << dp[0][n] << endl;
}   

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

using namespace std;

const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;

int add(int a, int b) {
	return a + b < mod ? a + b : a + b - mod;
}
int sub(int a, int b) {
	return a < b ? a + mod - b : a - b;
}
int mul(int a, int b) {
	return 1LL * a * b % mod;
}
int fpow(int x, int n) {
	int res = 1;
	while(n) {
		if(n & 1) res = mul(res, x);
		n >>= 1;
		x = mul(x, x);
	}
	return res;
}

int fac[maxn];
int x[maxn], sum[maxn];

int main() {
	int n;
	scanf("%d", &n);
	fac[0] = 1;
	for(int i = 1;i < n;++i) fac[i] = mul(fac[i - 1], i);
	int tmp, ans = 0;
	for(int i = 1;i <= n;++i) scanf("%d", &x[i]);
	for(int i = 1;i <= n;++i) sum[i] = add(sum[i - 1], x[i]);
	for(int i = 1;i < n;++i) ans = add(ans, mul(sub(x[n], x[n - i]), fpow(i, mod - 2)));
	for(int i = 2;i < n;++i) ans = sub(ans, mul(x[n - i], mul(i - 1, fpow(i, mod - 2))));
	for(int i = 1;i <= n - 2;++i) {
		int inv = mul(fpow(i + 1, mod - 2), fpow(i, mod - 2));
		ans = add(ans, mul(inv, sub(sum[n - 1], sum[i])));
	}
	printf("%d\n", mul(ans, fac[n - 1]));
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include <cmath>
#define PI 3.14159265358979323846264338327950L
int main(){
    int A,  B, H, M;
    long double a_x, a_y, b_x, b_y;
    long double a_sita, b_sita;
    long double result;
    std::cin >> A >> B >> H >> M;
    //a_sita = (2*M_PI)/12/60*(H*60+M);
    a_sita = (2*PI)/12/60*(H*60+M);
    //b_sita = (2*M_PI)/60*(H*60+M);
    b_sita = (2*PI)/60*(H*60+M);
    a_x = A*sin(a_sita+PI/2);
    a_y = A*cos(a_sita+PI/2);
    b_x = B*sin(b_sita+PI/2);
    b_y = B*cos(b_sita+PI/2);

    result = sqrt(pow(a_x - b_x, 2) + pow(a_y - b_y, 2));
    printf("%.20Lf\n", result);
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX 55
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


int n;
int X[55];
int Y[55];



int solve(int p,int q){
    set<int> tmp;
    int cnt = 0;
    REP(i,n){
        int hoge = q * X[i] - p * Y[i];
        if( tmp.find(hoge) == tmp.end()){
            cnt ++;
            tmp.insert(hoge);
        }
    }
    return cnt;

}




int solve2(int p, int q){
    int vis[55] = {};
    int res = 0;
    REP(i,n){
        if(vis[i] == 0){
            res ++;
            vis[i] = 1;
        }

            FOR(j,i+1,n){
                if( abs(X[j] - X[i])  == p and abs(Y[j] - Y[i])  == q) vis[j] = 1; 
            }

    }
    return res;
}


struct UnionFind{
    int par[MAX];
    int kosuu[MAX];
    UnionFind(int n){
        REP(i,n) par[i]=i;
        REP(i,n) kosuu[i] = 1;
    }

    int root(int x){
        int tmp;
        if(par[x]==x) return x;
        else{
            tmp=root(par[x]);
            par[x]=tmp;
            return tmp;
        }
    }

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

    int unite(int x,int y){
        if(not same(x,y)){ 
        kosuu[root(y)] += kosuu[root(x)];
        par[root(x)] = root(y);
        return true;
        }
        return false;
    }

    int renketu_kosuu(int x){
        return kosuu[root(x)];
    }
};


int solve3(int p , int q){
    UnionFind U(n);
    REP(i,n){
        REP(j,n){
            if(i ==j) continue;
            if( X[j] - X[i]  == p and Y[j] - Y[i]  == q){
                U.unite(i,j);
            }
        }
    }
    int vis[n] = {};
    int res = 0;
    REP(i,n){
        if(vis[U.root(i)] == 0){
            res ++;
            vis[U.root(i)] = 1;
        }
    }
    return res;
}






signed main(){


    cin >> n;
    REP(i,n){
        cin >> X[i] >> Y[i];
    }
    int res = 100000;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    REP(i,n){
        FOR(j,i+1,n){
            int p = X[i] - X[j];
            int q = Y[i] - Y[j];
            res = min(res, solve3(p,q));
            res = min(res,solve3(-p,-q));
            res = min(res,solve3(p,-q));
            res = min(res,solve3(-p,q));

        }
    }
    cout << res << endl;

}

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

ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
// n= 200000までのやつ
void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
ll COM(int n, int k){
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  COMinit();
  ll ans = 0;
  for (ll i = 0; i <= k; i++){
    ll num =  m  * modpow(m - 1, n - 1 - i, MOD) % MOD;
    num *= COM(n - 1, i) % MOD;
    ans += num;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 10680
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
int n;
long long k,c[100100];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)c[i]=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        c[a]+=b;
    }
    int i;
    for(i=1;k>0;i++)k-=c[i];
    cout<<i-1<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define el '\n'
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define repd(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define large 1000000007
#define pb push_back()
using namespace std;
int series(long long int k, ll A, ll a)
{
    long long int n = (k - A) / a;
    if (n * a == k - A)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}
int main()
{

    string s1;
    string s2;
    cin>>s1;
    if (s1=="ABC")
    {
        cout<<"ARC"<<el;
    }
    else if (s1=="ARC")
    {
        cout<<"ABC"<<el;
    }
    
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#include <cmath>
#include <cstdlib>
#include <climits>

//#include <stdio.h>
//#include <stdlib.h>


using namespace std;

#define debug false

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

  int N;
  cin >> N;
  vector<int> r(N);
  for(int i = 0; i < N; i++)
    cin >> r[i];

  sort(r.begin(), r.end());
  int same = 0;
  for(int i = 1; i < N; i++){
    if(r[i] == r[i-1]) same++;
  }
  cout << (N-same) << endl;

  return 0;
}


Measured memory_bytes: 256
n,h=map(int,input().split())
g=[[0]*2 for i in range(n)]
for i in range(n):
  g[i]=list(map(int,input().split()))
a=0
for i in range(n):
  if g[i][0]>a:
    a=g[i][0]
g.sort(key=lambda x:x[1],reverse=True)
ans=0
i=0
while h>0 and i<n:
  if g[i][1]<a:
    break
  h=h-g[i][1]
  ans=ans+1
  i=i+1
if h<=0:
  print(ans)
else:
  ans=ans+((h-1)//a+1)
  print(ans)

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

int main()
{
	long long N;
	cin >> N;

	vector<long long> a( N + 1, 1 );
	for( long long i = 2; i <= N; i++ ) {
		for( long long j = i; j <= N; j += i ) {
			a[j]++;
		}
	}
	long long ans = 0;
	for( long long i = 1; i <= N; i++ ) {
		ans += a[i] * i;
	}

	cout << ans << endl;
}


Measured memory_bytes: 81404
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	int i,j,k;int sum=0;
	for(i=1;i<n;i++)
	{
		for(j=1;;j++)
		{
			if(i*j<n)
			sum++;
			else
			break;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

#define MAX 512

int main(void){
	char words[MAX][33];
	int wcnt=0;
	int f[MAX], len[MAX];
	char word[33];
	int longest, mostf;
	
	while (scanf("%s", word)!=EOF){
		int wid=-1;
		for (int i=0; i<wcnt; i++){
			if (strcmp(word, words[i])==0){
				wid = i;
			}
		}
		if (wid==-1){
			strcpy(words[wcnt], word);
			len[wcnt] = strlen(word);
			f[wcnt] = 1;
			wcnt++;
		} else {
			f[wid]++;
		}
	}
	longest = mostf = 0;
	for (int i=0; i<wcnt; i++){
		if (len[longest] < len[i]) longest = i;
		if (f[mostf] < f[i]) mostf = i;
//		printf("%s: %d %d\n", words[i], f[i], len[i]);
	}
	printf("%s %s\n", words[mostf], words[longest]);
	
	return 0;
}

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

int main(){
    
    int m, f, r, sum;
    
    while(1){
        
        cin >> m >> f >> r;
        
        if(m== -1 && f==-1 && r==-1) break;
        
        sum = m + f ;
        
        if(m==-1 | f==-1){
           cout << "F" << endl; 
        }else if(sum >= 80){
            cout << "A" << endl;
        }else if(sum >=65 && sum<80){
            cout << "B" << endl;
        }else if(sum >=50 && sum<65){
            cout << "C" << endl;
        }else if(sum >=30 && sum< 50){
            if(r >=50){
                cout << "C" << endl;
            }else{
                cout << "D" << endl;
            }
        }else if(sum<30){
            cout << "F" << endl;
        }
        
    }
    
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	double x1, y1, x2, y2, ans;

	cin >> x1 >> y1 >> x2 >> y2;

	ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	printf("%.10lf\n", ans);

	return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define N 100005

using namespace std;

int n;

struct stu {
	int id, val;
}a[N];

inline bool cmp(stu aa, stu bb) {
	return aa.val < bb.val;
}

int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i].val, a[i].id = i;
	sort(a + 1, a + 1 + n, cmp);
	for(int i = 1; i <= n; ++i) {
		cout << a[i].id << ' ';
	} cout << endl;
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
long long int dp[3001][3001];
long long int v[3001][3001]; 
long long int a[3001];
long long int solve(int l, int r){
    if(v[l][r]==1){
        return dp[l][r];
    }
    v[l][r]=1;
    if(l==r){
        dp[l][r]=a[l];
        return a[l];
    }
    long long int ret;
    ret=max(a[l]-solve(l+1,r),a[r]-solve(l,r-1));
    dp[l][r]=ret;
    return ret;
}

int main(){
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<3001; i++){
        for(int j=0; j<3001; j++){
            v[i][j]=0;
        }
    }
    cout<<solve(0,n-1)<<endl;
    return 0;
}



Measured memory_bytes: 120288
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin, s;
    print(s.substr(0, 3));
    return 0;
}


Measured memory_bytes: 3672
N, K = map(int, input().split())
P = list(map(int, input().split()))

wa = sum(P[:K])
tmp = wa
ind = 0
for i in range(1, N - K+1, 1):
    tmp +=P[i+K-1]
    tmp -= P[i-1]
    if tmp > wa:
        wa = tmp
        ind = i
    else:
        pass

# 期待値を求める
ans = 0

for i in range(ind, ind+K, 1):
    now = P[i]
    ans += (now+1) /2
print("{:.10f}".format(ans))

Measured memory_bytes: 25060
// Problem Code: abc176_e

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int bomber(int H, int W, int M, vector<int>& h, vector<int>& w) {
	int max_bombs, r, c;
	set<int> seen;
	vector<int> rows(H), cols(W);
	
	for (int i = 0; i < M; i++) {
		rows[h[i]]++;
		cols[w[i]]++;
	}
	
	r = distance(rows.begin(), max_element(rows.begin(), rows.end()));
	max_bombs = rows[r];
	for (int i = 0; i < M; i++)
		if (h[i] == r)
			seen.insert(w[i]);
	
	for (c = 0; c < W; c++) {
		int bombs = rows[r] + cols[c] - seen.count(c);
		max_bombs = max(bombs, max_bombs);
	}
	
	seen.clear();
	c = distance(cols.begin(), max_element(cols.begin(), cols.end()));
	max_bombs = max(max_bombs, cols[c]);
	for (int i = 0; i < M; i++)
		if (w[i] == c)
			seen.insert(h[i]);
	
	for (r = 0; r < H; r++) {
		int bombs = rows[r] + cols[c] - seen.count(r);
		max_bombs = max(bombs, max_bombs);
	}
	
	return max_bombs;
}

int main() {
	int H, W, M;
	cin >> H >> W >> M;
	vector<int> h(M), w(M);
	for (int i = 0; i < M; i++) {
		cin >> h[i] >> w[i];
		h[i]--, w[i]--;
	}
	cout << bomber(H, W, M, h, w);
	return 0;
}

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

const int MAXN = 10;
int n, k, d[MAXN];

bool check(int a) {
	while (a) {
		if (d[a % 10])
			return 1;
		a /= 10;
	}
	return 0;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int a;
		cin >> a;
		d[a] = 1;
	}
	for (int i = n;  i < 1e8; i++) {
		if (check(i))
			continue;
		cout << i;
		break;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a[100005];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    int l=a[n/2];
    int r=a[n/2+1];
    //cout<<l<<" "<<r<<endl;
    cout<<r-l;
}


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

int main(){
    vector< vector<int> > data(3, vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> data.at(i).at(j);
        }
    }

    vector< vector<int> > diff(3, vector<int>(2));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 2; j++){
            diff.at(i).at(j) = data.at(i).at(j+1) - data.at(i).at(j);
        }
    }

    if((diff.at(0).at(0) == diff.at(1).at(0) && diff.at(0).at(0) == diff.at(2).at(0))
    && (diff.at(0).at(1) == diff.at(1).at(1) && diff.at(0).at(1) == diff.at(2).at(1))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	ll n, a[210], b[210] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j >= 0; j++) {
			if (a[i] % 2 == 0) {
				b[i]++;
				a[i] /= 2;
			}
			else break;
		}
	}
	sort(b, b + n);
	cout << b[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#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 int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    string s;
    cin >> s;
    if(s[0] == s[s.size() - 1]){
        if(s.size() % 2 == 1){
            cout << "Second" << endl;
        }else{
            cout << "First" << endl;
        }
    }else{
        if(s.size() % 2 == 1){
            cout << "First" << endl;
        }else{
            cout << "Second" << endl;
        }
    }
}

Measured memory_bytes: 512
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        results: [(usize1, String); m]
    }
    let mut solves = vec![false; n];
    let mut penalties = vec![0; n];

    for (p, s) in results {
        if s == "AC" {
            solves[p] = true;
        }
        if !solves[p] && s == "WA" {
            penalties[p] += 1;
        }
    }
    let ans_solve = solves.iter().filter(|s| **s).count();
    let ans_penalty: usize = solves
        .iter()
        .zip(penalties.iter())
        .map(|(s, p)| if *s { *p } else { 0 })
        .sum();

    println!("{} {}", ans_solve, ans_penalty);
}


Measured memory_bytes: 10492
#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 <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int A, B;
        cin >> A >> B;

        for (int i = 0;; ++i) {
            Int a = i * 8 / 100, b = i * 10 / 100;
            if (a == A && b == B) {
                cout << i << endl;
                return;
            } else if (a > A && b > B) {
                cout << -1 << endl;
                return;
            }

        }
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>

int main(void){
  char S[100001];
  int N;
  int i;
  int A=0,B=0;
  int ans;
  
  scanf("%s",S);
  
  for(i=0;i<100001;i++){
    if(S[i]=='\0'){
      N=i;
      break;
    }
    else{}
  }
  
  for(i=1;i<N;i++){
    if(S[i-1]=='0'&&S[i]=='0'){
      S[i]='1';
      A++;
	}
    else if(S[i-1]=='1'&&S[i]=='1'){
      S[i]='0';
      A++;
	}
    else{}
  }
  
  B = N-A;
  
  if(A<=B) ans=A;
  else ans=B;

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


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

int main()
{
    int n, m;
    cin >> n >> m;
    int a[50] = {0};
    int b[50] = {0};
    int c[50] = {0};
    int d[50] = {0};
    
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    
    for(int i = 0; i < m; i++)
    {
        cin >> c[i] >> d[i];
    }
    
    for(int i = 0; i < n; i++)
    {
        long long int min = 2000000000, minAns = 0;
        
        for(int j = 0; j < m; j++)
        {
            if(abs(a[i] - c[j]) + abs(b[i] - d[j]) < min)
            {
                min =abs(a[i] - c[j]) + abs(b[i] - d[j]);
                minAns = j;
            }
        }
        
        cout << minAns + 1 << endl;
        min = 2000000000;
        minAns = 0;
    }
    
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>t(n+1),x(n+1),y(n+1);
    bool flag=true;
    t[0]=0,x[0]=0,y[0]=0;
    for(int i=1;i<=n;i++){
        cin>>t[i]>>x[i]>>y[i];
        if(t[i]-t[i-1]>=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])){
            if((t[i]-t[i-1])%2!=0&&(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2==0){flag=false;}
            else if((t[i]-t[i-1])%2==0&&(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2!=0){flag=false;}
        }else{
            flag=false;
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 4156
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int a[100000];
signed main()
{
	int n, k, q;
	scanf("%d%d%d", &n, &k, &q);
	for(int i = 0, j; i < q; ++i)
	{
		scanf("%d", &j);
		++a[j - 1];
	}	
	for(int i = 0; i < n; ++i)
	{
		printf(a[i] > q - k ? "Yes\n" : "No\n");
	}
}


Measured memory_bytes: 4172
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

n, m = map(int, input().split())

ans = [-1] * n
safe = True

for i in range(m):
    s,c = map(int, input().split())

    if (n!=1 and s==1 and c==0) or (ans[s-1]!=-1 and c != ans[s-1]):
        safe = False

    ans[s-1] = c


if safe:
    for i in range(n):
        if n!=1 and ans[0]==-1 and i==0:
            ans[0] = 1

        elif ans[i] == -1:
            ans[i] = 0
    print(''.join(str(n) for n in ans))

else: print(-1)


Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5+10;
int n, a[N], b[N], c[2], d[N];
char s[N];
int Abs(int x){return x > 0 ? x : -x;}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d", &a[i], &b[i]);
		++c[(a[i] + b[i]) & 1];
    }
    if (c[0] != n && c[1] != n)
    {
    	puts("-1");
		return 0;
    }
    printf("%d\n", 31 + (c[0] != 0));
	for (int i = 0; i <= 30; i++)
		printf("%d ", 1 << i);
	if (c[0])
		printf("1 ");
	putchar(10);
	for (int i = 1; i <= n; i++)
	{
		int x = a[i], y = b[i];
		if (c[0])
			--x, s[31] = 'R';
		int f = 0;
        for (int i = 30; i >= 0; i--)
        {
            if (Abs(x) < Abs(y))
            	swap(x, y), f ^= 1;
			if (x > 0)
				x -= 1 << i, s[i] = "RU"[f];
			else
				x += 1 << i, s[i] = "LD"[f];
		}
		puts(s);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
int main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<string>s(h);
  rep(i,h)cin >> s[i];
  int sum = 0,ans = 0;
  rep(i,h)rep(j,w)if(s[i][j] == '#')sum++;
  rep(i,(1 << h))rep(j,(1 << w)){
    bool used[10][10];
    rep(I,10)rep(J,10)used[I][J] = false;
    int cnt = 0;
    rep(I,h)if(i & (1 << I))rep(J,w)if(s[I][J] == '#' && !used[I][J])cnt++,used[I][J] = true;
    rep(I,w)if(j & (1 << I))rep(J,h)if(s[J][I] == '#' && (!used[J][I]))cnt++,used[J][I] = true;
    if(sum - cnt == k)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::string S;
	std::cin >> N;
	std::cin >> S;
	
	int x = 0;
	int result = 0;
	for (auto ch : S) {
		if (ch == 'I') {
			++x;
		} else {
			--x;
		}
		result = std::max(result, x);
	}
	std::cout << result << "\n";
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var l, r int
	fmt.Scan(&l, &r)

	var min int
	ans := 2020

	for i := l; i < r; i++ {
		for j := i + 1; j <= r; j++ {
			min = i * j % 2019
			if min < ans {
				ans = min
			}
			if min == 0 {
				fmt.Println(0)
				return
			}
		}
	}

	fmt.Println(ans)
}


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

int main() {
  int N,K;
  cin>>N>>K;
  
    vector<int>p(N);
    
    for (int i = 0; i < N; i++) {
       cin>>p.at(i);
    }
  
    sort(p.begin(), p.end()); 
  int i=0;
  int S=0;
  
  while(i<K){
    S+=p.at(i);
    i++;
  }
  cout<<S<<endl;
}
    



Measured memory_bytes: 3572