akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

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

    if (n == m) {
        std::cout << "Draw" << '\n';
    } else if (n == 1) {
        std::cout << "Alice" << '\n';
    } else if (m == 1) {
        std::cout << "Bob" << '\n';
    } else if (n > m) {
        std::cout << "Alice" << '\n';
    } else {
        std::cout << "Bob" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

int main(){
	ll n,k;
	cin>>n>>k;
	P a[n];
	for(int i=0; i<n; i++)cin>>a[i].first>>a[i].second;
	ll cnt=0;
	sort(a,a+n);
	for(int i=0; i<n; i++){
		cnt+=a[i].second;
		if(cnt>=k){
				cout<<a[i].first<<endl;
				return 0;
		}
	}
}


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.size() <= k) {
    cout << s << endl;
  }
  else {
    rep(i, k) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,q,i,temp;
    cin>>n>>k>>q;
    ll a[n];
    for(i=0;i<n;i++)
    a[i]=k;
    for(i=0;i<q;i++)
    {
        cin>>temp;
        a[temp-1]++;
        
    }
    for(i=0;i<n;i++)
    {
        if(a[i]-q>0)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
    }


     

  return 0;
    
}
    


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

int N, ai;
int main(){
	scanf("%d", &N);
	
	map <int, int> mp;
	for(int i = 0; i < N; i++){
		scanf("%d", &ai);
		mp[ai]++;
	}
	
	if(N % 3 == 0){
		if(mp.size() == 1){
			if(mp.begin()->first == 0)printf("Yes\n");
			else printf("No\n");
		}else if(mp.size() == 2){
			if(mp.begin()->first == 0 && mp.begin()->second * 2 == next(mp.begin())->second)printf("Yes\n");
			else printf("No\n");
		}else if(mp.size() == 3){
			if((mp.begin()->first ^ next(mp.begin())->first ^ next(next(mp.begin()))->first) != 0)printf("No\n");
			else if(mp.begin()->second != next(mp.begin())->second || next(mp.begin())->second != next(next(mp.begin()))->second)printf("No\n");
			else printf("Yes\n");
		}else printf("No\n");
	}else{
		if((int)mp.size() > 1 || mp.begin()->first != 0)printf("No\n");
		else printf("Yes\n");
	}
	
	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
const ld EPS=1e-10;
ll n;
ld a[100010], b[100010], c[100010];
int tr[400010], lf, rt;
int qry(int x, int st, int nd){
  if(st>rt||nd<lf)
    return 0;
  if(st>=lf&&nd<=rt)
    return tr[x];
  int md=(st+nd)/2;
  return qry(x*2, st, md)+qry(x*2+1, md+1, nd);
}
void updt(int x, int st, int nd){
  if(st>rt||nd<lf)
    return;
  if(st==nd){
    tr[x]=1;
    return;
  }
  int md=(st+nd)/2;
  updt(x*2, st, md);
  updt(x*2+1, md+1, nd);
  tr[x]=tr[x*2]+tr[x*2+1];
}
bool chck1(ld x){
  vector< pair<ld, int> > v;
  for(int i=0; i<n; ++i){
    v.push_back(mk ((c[i]-a[i]*x)/b[i] , i));
  }
  sort(v.begin(), v.end());
  ll tmp=0;
  memset(tr, 0, sizeof tr);
  for(int i=0; i<v.size(); ++i){
    lf=v[i].sc;rt=n-1;
    tmp+=qry(1,0,n-1);
    lf=rt=v[i].sc;
    updt(1,0,n-1);
  }
  ll tmp1=n*(n-1)/2;
  tmp1=tmp1-tmp;
//  if((tmp1+tmp)%2){
//    return tmp>=tmp1-1;
//  }
  return tmp>=tmp1;
}

bool chck2(ld x){
  vector< pair<ld, int> > v;
  for(int i=0; i<n; ++i){
    v.push_back(mk ((c[i]-b[i]*x)/a[i] , i));
  }
  sort(v.begin(), v.end());
  ll tmp=0;
  memset(tr, 0, sizeof tr);
  for(int i=0; i<v.size(); ++i){
    lf=v[i].sc;rt=n-1;
    tmp+=qry(1,0,n-1);
    lf=rt=v[i].sc;
    updt(1,0,n-1);
  }
  ll tmp1=n*(n-1)/2;
  tmp1=tmp1-tmp;
//  if((tmp1+tmp)%2){
//    return tmp>=tmp1-1;
//  }
  return tmp>=tmp1;
}
vector < pair< ld , int> > v, v2;
ll aa[100010], bb[100010], cc[100010];
int main(){
  ll x, y, z;
  while(cin>>n){
    v.clear();v2.clear();
    for(int i=0; i<n; ++i){
      scanf("%lld%lld%lld",&x,&y,&z);
      aa[i]=x;bb[i]=y;cc[i]=z;
      v.push_back(mk(z/(ld)(y)-x/(ld)(y)*(-2e9), i));
      v2.push_back(mk(z/(ld)(x)-y/(ld)(x)*(-2e9), i));
    }
    sort(v.begin(), v.end());
    sort(v2.begin(), v2.end());
    for(int i=0; i<n; ++i){
      int f=v[i].sc;
      a[i]=aa[f];
      b[i]=bb[f];
      c[i]=cc[f];
    }
    cout<<fixed<<setprecision(10);
    ld st=-1e9, nd=1e9, md;
    ld tmp1, tmp2;
    bool tmp;
    while(nd-st>EPS){
      md=(st+nd)/2.0;
      tmp=chck1(md);
      if(tmp){
        nd=md;
      }
      else{
        st=md;
      }
    }
    tmp1=(st+nd)/2;
    for(int i=0; i<n; ++i){
      int f=v2[i].sc;
      a[i]=aa[f];
      b[i]=bb[f];
      c[i]=cc[f];
    }
    st=-1e9;nd=1e9;
    while(nd-st>EPS){
      md=(st+nd)/2.0;
      tmp=chck2(md);
      if(tmp){
        nd=md;
      }
      else{
        st=md;
      }
    }
    tmp2=(st+nd)/2;
    cout<<fixed<<setprecision(10)<<tmp1<<" "<<tmp2<<endl;
  }
  return 0;
}


Measured memory_bytes: 15208
// 2011/12/01 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){

	int n;
	cin >> n;

	if(n==0)
		break;

	int m = 1000-n;

	int sum = 0;

	sum += m/500;
	m %= 500;

	sum += m/100;
	m %= 100;

	sum += m/50;
	m %= 50;

	sum += m/10;
	m %= 10;

	sum += m/5;
	m %= 5;

	sum += m;

	cout << sum << endl;

	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    int n;
    int p[n],q[n];
    int psum=0,qsum=0,cnt=0,pcnt=0,qcnt=0;
    cin>>n;
    REP(i,n){
        cin>>p[i];
        psum+=p[i]*pow(10,n-i-1);
    }
    REP(i,n){
        cin>>q[i];
        qsum+=q[i]*pow(10,n-i-1);
    }

    vector<int> v(n);
    iota(v.begin(), v.end(), 1);
    ll perm[50000];
    REP(i,50000){
        perm[i]=0;
    }
    int j=0;
    do
    {
        /* code */
        for (int i = 0; i < n; i++)
        {
            /* code */
            perm[j]+=v[i]*pow(10,n-i-1);
        }
        
        if (perm[j]==qsum)
        {
            /* code */
            qcnt=j+1;
        }
        if (perm[j]==psum)
        {
            /* code */
            pcnt=j+1;
        }
        j++;
        
        
    } while (next_permutation(v.begin(), v.end()));
    
    

    cout<<abs(pcnt-qcnt)<<endl;

}
    

Measured memory_bytes: 896
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

int n,x;//nまでの重複なし、合計x
int main()
{
  while( scanf("%d %d",&n,&x)){
    int ans = 0;

  if(n ==0 &&x ==0)
    break;
  for(int i = 1;i <= n-2;i++){
    for(int j =i+1;j <= n-1;j++){
      for(int k =j+1;k <= n;k++){
	if(i+j+k ==x)
	  ans++;
      }
    }
  }
  cout <<ans<<endl;
  }
  return 0;
}

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

int main(){
  int N; cin >> N;
  int A[200000];
  for(int i=0; i<N; i++) cin >> A[i];
  
  long long res=0;
  int right=1;
  int sum=A[0];
  for(int left=0; left<N; left++){
    while(right<N&&(right<=left||(sum^A[right])==sum+A[right])){
      sum+=A[right];
      right++;
    }
    res+=(right-left);
    if(left!=right){
      sum-=A[left];
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
const int MX = 100000+7;
// int dist[MX];
int ans[MX];
bool visited[MX];
int n,m;
queue<int> que;
vector<vector<int>> edges(MX);

void bfs() {
    int cur = que.front(); que.pop();
    for(auto x: edges[cur]) {
        if (visited[x] == false) {
            // dist[x] = dist[cur] + 1;
            visited[x] = true;
            ans[x] = cur;
            que.push(x);
        }
    }
    if(que.size() >= 1) bfs();
}

int main(){
    cin >> n >> m;
    FOR(i,1,m) {
        int a,b; cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    que.push(0);
    visited[0] = true;
    // dist[0] = 0;

    bfs();

    cout << "Yes" << endl;
    FOR(i,1,n-1) {
        cout << ans[i]+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 10316
program prob3
    implicit none
    integer::n, i
    integer, allocatable::a(:)
    integer(16)::ans, tmp, t
    read(*,*) n
    allocate(a(n))
    read(*,*) a
    ans = 0
    do i = 1, n
        ans = ans + a(i) - 1
    end do
    write(*,*) ans
    stop
contains
    function gcd(x,y) result(z)
        implicit none
        integer::x, y, z, i, a, b, c
        a = y
        b = x
        do while(mod(a,b) > 0)
            c = mod(a,b)
            a = b
            b = c
        end do
        z = b
    end function
end program

Measured memory_bytes: 2824
from collections import *;M=lambda:map(int,input().split());r=range;n,k,l=M()
def f(m):
 *a,=r(n)
 def g(i):
  if a[i]==i:return i
  a[i]=g(a[i]);return a[i]
 for _ in r(m):p,q=M();a[g(q-1)]=g(p-1)
 return g
x,y=f(k),f(l);c=Counter((x(i),y(i))for i in r(n));print(*(c[x(i),y(i)]for i in r(n)))

Measured memory_bytes: 55688
o[256],z[257];main(N,S,A,C,s,a,c,r,i){for(;scanf("%d",&N),N;printf("%d %d %d\n",S,A,C)){
	double H=99,h,n=N;
	for(i=1;i<=N;i++)scanf("%d",z+i);
	for(s=0;s<16;s++)for(a=0;a<16;a++)for(c=0;c<16;c++){
		for(r=s,h=0,i=1;i<=N;i++)o[(z[i]+(r=(a*r+c)%256))%256]++;
		for(i=0;i<256;i++)if(o[i])h-=o[i]/n*log(o[i]/n),o[i]=0;
		if(h+1e-9<H)H=h,S=s,A=a,C=c;
	}
}exit(0);}

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

int main()
{
  char a;
  std::cin >> a;
  if ('a' <= a && a <= 'z')
  {
    std::cout << "a" << std::endl;
  }
  else
  {
    std::cout << "A" << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();
        String ans = "";
        for(int i = 0; i < n; i++) {
            if(s.charAt(i) == s.charAt(k-1)) {
                ans += String.valueOf(s.charAt(i));
            } else {
                ans += "*";
            }
        }

        System.out.println(ans);

    } 
}

Measured memory_bytes: 23252
#!/usr/bin/ruby
while(l=gets.to_f)>=0 do
	if l==0 then next end
	a=l*16;
	if a==0 then raise 'zero' end
	puts a!=(a=a.to_i)||a>4095?'NA':sprintf('%08b.%04b',a/16,a%16)
end

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

int N,M,Q;
vector<int> a,b,c,d;
int ans = 0;

void dfs(vector<int> A){
  //ベースライン
  if(A.size() == N+1){
    int now = 0;
    for(int i = 0; i < Q;i++){
      if(A.at(b.at(i)) - A.at(a.at(i)) == c.at(i)) now += d.at(i);
    }
    ans = max(ans,now);
    return;
  }
  //再帰ステップ
  A.push_back(A.back());
  while(A.back() <= M){
    dfs(A);
    A.back()++;
  }
}

int main(){
  cin >> N >> M >> Q;
  a = b = c = d = vector<int>(Q);
  for(int i = 0; i < Q; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
}
  

Measured memory_bytes: 3608
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        sc.close();
        int n = s.length;
        long sum = 0;
        long tmpSum = 0;
        long tmp = 0;
        for(int i=0;i<1<<(n-1);i++){
            tmpSum = 0;
            tmp = 0;
            for(int j=0;j<n-1;j++){
                if(((i>>j)&1)==1){
                    tmpSum+=tmp*10+s[j]-'0';
                    tmp = 0;
                }else{
                    tmp = tmp*10+s[j]-'0';
                }
            }
            tmpSum+=tmp*10+s[n-1]-'0';
            sum+=tmpSum;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23124
#include <iostream>
using namespace std;
int N, K;

int p1;
int main(void) {
    // insert code here...
    cin >> N >> K;
//    for(int i = 0; i < N; i++){
//        char a;
//        cin >> a;
//        if(a == '1'){
//            p1 = i + 1;
//        }
//    }
    
//    int x, y;
//    if((p1-1) % (K-1) == 0){
//        x = (p1-1) / (K-1);
//    }else{
//        x = (p1-1) / (K-1) + 1;
//    }
//
//    if((N-p1)%(K-1)==0){
//        y = (N-p1)/(K-1);
//    }else{
//        y = (N-p1)/(K-1) + 1;
//    }
//
//    cout << x + y << endl;
    int x;
    int n = N - 1;
    if(n%(K-1)==0){
        x = n/(K-1);
    }else{
        x = n/(K-1) + 1;
    }
    
    cout << x << endl;
    
    return 0;
}


Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    lines = [input() for j in range(m)]
 
    cities = {}
    for i in range(m):
        p, y = map(int, lines[i].split())
        if p in cities:
            cities[p].append((i, y))
        else:
            cities[p] = [(i, y)]
 
    outputs = [None] * m
    for pref, city_list in cities.items():
        city_list.sort(key=lambda x: x[1])
        #print(pref, city_list)
        city_no = 1
        for city in city_list:
            outputs[city[0]] = "{:06d}{:06d}".format(pref, city_no)
            city_no += 1
 
    for output in outputs:
        print(output)
    return
 
 
main()

Measured memory_bytes: 49988
def Same_Integers(abc):

    ans = 0
    abc.sort()
    count = abc[2]*3 - abc[0] - abc[1] - abc[2]

    if count % 2 == 0:
        ans = int(count / 2)
    else:
        ans = int((count + 3) // 2)

    return ans

def main():
    abc = list(map(int , input().split()))
    print(Same_Integers(abc))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int N,M,a[10001],sum = 0;

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++) {
    cin >> a[i];
    sum += a[i]; 
    }
    if (N-sum>=0){
        cout << N-sum << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3664
print(*[2,7,17,37,47,67,97,107,127,137,157,167,197,227,257,277,307,317,337,347,367,397,457,467,487,547,557,577,587,607,617,647,677,727,757,787,797,827,857,877,887,907,937,947,967,977,997,1087,1097,1117,1187,1217,1237,1277,1297][:int(input())])

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n, vector<int> (n, 0));
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        edge[a - 1][b - 1] += 1;
        edge[b - 1][a - 1] += 1;
    }
    for(int i = 0; i < n; i++){
        int ans = 0;
        for(int x : edge[i]){
            ans += x;
        }
        cout << ans << endl;
    }
}

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

int main(void){

	int a , b;
	cin >> a >> b;
	int ans = 0;

	if(a > b) ans = a + a-1;
	else if(b > a) ans = b + b-1;
	else ans = a+b;
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

const string YES = "Yes";
const string NO = "No";
void solve(ll N){
    Yes((N / 100 == 7) || ((N % 100) / 10 == 7) || N % 10 == 7);
}

int main() {
    ll N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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; }


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double n,m,d;
    cin>>n>>m>>d;
    double ans=0;
    if(d==0) ans=1.0*(m-1)/n;
    else ans=2.0*(n-d)*(m-1)/n/n;
    printf("%.8f\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,x;
  cin>>k>>x;
  int l=max(-1000000,x-(k-1));
  int r=min(1000000,x+(k-1));
  for(int i=l; i<=r; i++)
    cout<<i<<" ";
}

Measured memory_bytes: 256
#include <stdio.h>

#define X 1000000007

int main(void){
  int i,N;
  long long int power = 1;
  scanf("%d", &N);

  for(i=1;i<=N;i++){
    power = i*(power%X);
  }
  printf("%lld\n", power%X);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define i64 long long 

using namespace std;

int main()
{

    int n;
    cin>>n;
    vector<int> f(n);
    for(auto&z:f)cin>>z;
    vector<int> pos(n+1,0);
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(f[i]>f[i-1])continue;
        int cnt=0;
        while(i<n&&f[i]<=f[i-1])
        {
            i++;
            cnt++;
        }
        ans=max(ans,cnt);
    }
    cout<<ans;
}
/*
 
Code written by a random fan of Tokyo_Square 
gb_DH_VNU

 */


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

int main(){
    int N, W;
    cin >> N >> W;
    ll w[N], v[N];

    int V=0;
    rep(i, N){
        cin >> w[i] >> v[i];
        V += v[i];
    }

    int INF = 1000000005;
    V += 5;

    ll dp[N+1][V] = {};

    int sumV = 0;
    rep(i, N){
        sumV += v[i];
        rep(j, V){
            if(i==0){
                dp[i][j] = INF;
            }

            if(j-v[i]>=0){
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
            }else{
                dp[i+1][j] = min(dp[i][j], w[i]);
            }
            // cout << dp[i][j] << " ";
        }
        // cout << endl;
    }
    int MAX = 0;
    for(int i=V-1;i>=0;i--){
        if(dp[N][i]<=W){
            MAX = i;
            // printf("%d\n", dp[N][i]);
            break;
        }
    }
    printf("%d\n", MAX+1);
    return 0;
}

Measured memory_bytes: 79104
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
//#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
#define base 1000000000000000000ll
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=mul(ans,a,c);a=mul(a,a,c),b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ld pi = acos(-1);
const ull ba=233;
const db eps=1e-8;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=300000+10,maxn=1000000+10,inf=0x3f3f3f3f;

int a[N],b[N],c[N];
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        a[x]++;
    }
    for(int i=1;i<=n;i++)b[a[i]]+=a[i],c[a[i]]++;
    for(int i=1;i<=n+1;i++)b[i]+=b[i-1],c[i]+=c[i-1];
    auto ok=[&](int l,int k)
    {
        return (c[n]-c[k])*k+b[k]>=l*k;
    };
    int ans=n+1;
    for(int i=1;i<=n;i++)
    {
        while(ans&&!ok(i,ans))ans--;
        printf("%d\n",ans);
    }
    return 0;
}
/********************

********************/


Measured memory_bytes: 4352
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	long long a,b,c,d,ans1,ans2,ans3,ans4,ans5,ans6,ans7;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	 ans1=a*c;
	 ans2=a*d;
	 ans3=b*c;
	 ans4=b*d;
	 ans5=max(ans1,ans2);
	 ans6=max(ans3,ans4);
	 ans7=max(ans5,ans6);
	 printf("%lld\n",ans7);
}

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

const int M = 5050;
const int64_t INF = 1LL << 60;

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

class UnionFind {
public:
    vector<int> uni;
    UnionFind(int s) : uni(s, -1) {}
    int root(int a) {
        return uni[a] < 0 ? a : uni[a] = root(uni[a]);
    }
    bool connect(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] = uni[a] + uni[b];
        uni[b] = a;
        return true;
    }
    bool isConnect(int a, int b) {
        return root(a) == root(b);
    }
    int size(int a) {
        return -uni[root(a)];
    }
};

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    for(auto &e : P) cin >> e, e--;
    for(auto &e : C) cin >> e;
    vector<vector<int64_t>> dp(N, vector<int64_t>(M));
    UnionFind uf(N);
    rep(i, N) {
        auto dfs = [&](auto &&dfs, int cur, int depth) -> void {
            if(depth == M) return;
            if(depth) dp[i][depth] = dp[i][depth - 1] + C[cur];
            uf.connect(i, cur);
            dfs(dfs, P[cur], depth + 1);
        };
        dfs(dfs, i, 0);
    }
    int64_t ans = -INF;
    rep(i, N) {
        int n = uf.size(i);
        int64_t cost = dp[i][n];
        if(cost <= 0) {
            for(int j = 1; j < min(M, K + 1); ++j) chmax(ans, dp[i][j]);
        } else {
            int64_t k = K / n;
            int m = K % n;
            if(k && m == 0) k--, m = n;
            int64_t score = cost * k;
            if(m == 0) chmax(ans, score);
            for(int j = 1; j <= m; ++j) chmax(ans, score + dp[i][j]);
        }
    }
    cout << ans << '\n';
    return 0;
}


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

int main()
{
    int a,b,N;
    cin>>a>>b>>N;
    bool Z=0;
    for(int i=0;i<N;i++)
    {
        int x,y;
        cin>>x>>y;
        if((a<y&&x<b)||(a<y&&x<b))
        Z=1;
    }
    cout<<Z<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, t, dp_l[3001][8001], dp_r[3001][8001];
vector<i64> a, b;
int main() {
  cin >> n >> t;
  a.resize(n);
  b.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];

  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= t; ++j) {
      dp_l[i + 1][j] = max(dp_l[i][j], dp_l[i + 1][j - 1]);
      if (j >= a[i]) {
        dp_l[i + 1][j] = max({
          dp_l[i + 1][j],
          dp_l[i][j - a[i]] + b[i]
        });
      }
    }
  }

  for (int i = n - 1; i >= 0; --i) {
    for (int j = 1; j <= t; ++j) {
      dp_r[i][j] = max(dp_r[i + 1][j], dp_r[i][j - 1]);
      if (j >= a[i]) {
        dp_r[i][j] = max({
          dp_r[i][j],
          dp_r[i + 1][j - a[i]] + b[i]
        });
      }
    }
  }

  i64 ans = 0;
  for (int i = 0; i < n; ++i) {
    i64 y = 0;
    for (int j = 0; j < t; ++j) {
      y = max(y, dp_l[i][j] + dp_r[i + 1][t - j - 1] + b[i]);
    }
    // cerr << i << ' ' << y << endl;
    ans = max(ans, y);
  }

  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){
    /*
    height + 2
    width + 2
    */
    int x,y;
    cin>>x>>y;
    char arr[x+2][y+2];
    for(int i = 0; i < x+2; i++){
        for(int j = 0; j < y+2; j++){
            arr[i][j] = '#';
        }
    }
    for(int i = 0; i < x; i++){
        for(int j = 0; j < y; j++){
            cin>>arr[i+1][j+1];
        }
    }
    for(int i = 0; i < x+2; i++){
        for(int j = 0; j < y+2; j++){
            cout<<arr[i][j];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3664
#include<stdio.h>
int main(void)
{
	int x;
	int n;
		scanf("%d %d",&x,&n);
		char ch;
		ch=getchar();
		int l=2*x;
	
//	int l=2*x;
	int number[l];
	for(int jj=0;jj<l;jj++)
	{
	    number[jj]=0;
	}
	int t=0;
//	scanf("%d %d",&x,&n);
	for(int i=0;i<x;i++)
	{
	    
		scanf("%d",&number[i]);
		
	}
	for(int m=0;m<x;m++)
	{
	    if(number[m]>=n)
		t++;
	}
	printf("%d",t);
	
	return 0;
	} 

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int d[200000],a[200000];
int sum[200000];

int main(){
	int n,K;cin>>n>>K;
	rep(i,n){
		scanf("%1d",&d[i+1]);
	}
	for(int i=1;i<=n;i++)a[i]=(d[i]^d[i-1]);
	sum[0]=0;
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+a[i];
	}
	int b=0;
	int Max=0;
	for(int i=1;i<=n;i++){
		b^=a[i];
		int x=upper_bound(sum,sum+n+1,K*2-(!b)+sum[i])-sum;
		Max=max(Max,x-i);
	}
	cout<<Max<<endl;
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int) 1e5 + 7;
int n, a[3], p1[N], p2[N], sol[N];


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a[0] >> a[1] >> a[2];
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    p1[i] = s[0] - 'A';
    p2[i] = s[1] - 'A';
  }
  for (int it = 1; it <= n; it++) {
    int i = p1[it];
    int j = p2[it];
    if (a[i] == 0 && a[j] == 0) {
      cout << "No\n";
      return 0;
    }
    if (a[i] == 0) {
      sol[it] = i;
      a[i]++;
      a[j]--;
      continue;
    }
    if (a[j] == 0) {
      sol[it] = j;
      a[j]++;
      a[i]--;
      continue;
    }
    if (a[i] == 1 && a[j] == 1) {
      if (p1[it + 1] == i || p2[it + 1] == i) {
        sol[it] = i;
        a[i]++;
        a[j]--;
        continue;
      } else {
        sol[it] = j;
        a[j]++;
        a[i]--;
        continue;
      }
    }
    if (a[i] == 1) {
      sol[it] = i;
      a[i]++;
      a[j]--;
      continue;
    }
    if (a[j] == 1) {
      sol[it] = j;
      a[j]++;
      a[i]--;
      continue;
    }
    sol[it] = i;
    a[i]++;
    a[j]--;
  }
  cout << "Yes\n";
  for (int i = 1; i <= n; i++) {
    cout << (char) ('A' + sol[i]) << "\n";
  }
  return 0;
}


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

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

    int a, b;
    cin >> a >> b;

    int ans = -100;
    for (int i = 10 * b; i < 10 * (b + 1); i++) {
        if (floor(i * 0.08) == a) {
            ans = i;
            break ;
        }
    }

    if (ans == -100) cout << -1 << '\n';
    else cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    FAST();
    ll n,i,j,k=1;
    string a,b;
    cin>>a;
    cin>>b;
    j=stoi(a+b);
    for(i=0;i<=j/2;i++)
    {
        if(i*i==j)
        {

            cout<<"Yes"<<endl;
          return 0;
        }
    }
    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
s = gets.chomp

n = s.size + 1
a = Array.new(n, 0)
b = Array.new(n, 0)

cnt = 0
for i in 0...s.size
    if s[i] == '<'
        cnt += 1
    else
        cnt = 0
    end
    a[i+1] = cnt
end

cnt = 0
for i in 1..s.size
    if s[s.size - i] == '>'
        cnt += 1
    else
        cnt = 0
    end
    b[s.size - i] = cnt
end

ans = 0
for i in 0...n
    ans += a[i] > b[i] ? a[i] : b[i]
end

puts ans

Measured memory_bytes: 10764
#include<iostream>

using namespace std;
int main() {
	int a, b, c, k, count = 0;
	cin >> a >> b >> c >> k;

	if (k - a <= 0)count += k * 1;
	else if (k - a > 0) {
		count += a * 1;
		if ((k - a) - b <= 0) {}
		else if ((k - a) - b > 0) {
			count += (k - a - b) * (-1);
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <numeric>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 2100;

vector<int> eds[MAXN];
vector<pair<int, int> > ed;
int n;
int k;
int was[MAXN];
int was1[MAXN];

void dfs1(int v, int d) {
	was[v] = 1;
	if (d == 0)
		return;
	for (int u: eds[v]) {
		if (!was[u])
			dfs1(u, d - 1);
	}
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		eds[a].push_back(b);
		eds[b].push_back(a);
		ed.push_back(make_pair(a, b));
	}
	int ans = 0;
	if (k % 2 == 0) {
		for (int i = 0; i < n; ++i) {
			memset(was, 0, sizeof(was));
			dfs1(i, k / 2);
			ans = max(ans, accumulate(was, was + n, 0));
		}
	}
	else {
		for (int i = 0; i < (int)ed.size(); ++i) {
			memset(was, 0, sizeof(was));
			dfs1(ed[i].first, k / 2);
			memcpy(was1, was, sizeof(was));
			memset(was, 0, sizeof(was));
			dfs1(ed[i].second, k / 2);
			int cnt = 0;
			for (int j = 0; j < n; ++j)
				cnt += was1[j] | was[j];
			ans = max(ans, cnt);
		}
	}
	cout << n - ans << "\n";
	return 0;
}




Measured memory_bytes: 384
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
using namespace std;

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() {return x * x + y * y; }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

};

typedef Point Vector;

double dot(Vector a, Vector b) {
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
  return a.x * b.y - a.y * b.x;
}

struct Segment {
  Point p1, p2;
};

typedef Segment Line;

typedef vector<Point> Polygon;

void swap(Point& a, Point& b) {
  Point tmp = a;
  a.x = b.x;
  a.y = b.y;
  b.x = tmp.x;
  b.y = tmp.y;
}

int contains(Polygon& g, Point& p) {
  int n = g.size();
  bool x = false;
  for (int i = 0; i < n; i++) {
    Point a = g[i] - p, b = g[(i+1) % n] - p;
    if (abs(cross(a, b)) < EPS && dot(a, b) < EPS) return 1;
    if (a.y > b.y) {
      swap(a, b);
    }
    if (cross(a, b) > EPS && a.y < EPS && b.y > EPS) {
      x = !x;
    }
  }
  return (x ? 2 : 0);
}


int main() {
  Polygon poly;
  int n;
  cin >> n;
  poly.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> poly[i].x >> poly[i].y;
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    Point p;
    cin >> p.x >> p.y;
    cout << contains(poly, p) << endl;
  }
  return 0;
}



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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  int x, y;
  cin >> x >> y;
  ll ans = INF;
  REP(i, max(x, y)+1){
    ll tmp = c*i*2;
    tmp += a*max(0, x-i);
    tmp += b*max(0, y-i);
    ans = (ans>tmp?tmp:ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int *p = new int[n];

	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	long max = 0;
	long sum = 0;

	for (int i = 0; i < n; ++i) {
		sum += p[i];

		if (i >= k) {
			sum -= p[i - k];
		}

		if (sum > max) {
			max = sum;
		}
	}


	max += k;

	cout << setprecision(10) << ((double)max / 2.00000000000);

	free(p);

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define N 100010
ll n,x[N];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>x[i];
    ll m=0,k=0,ans=1;
    for(int i=0;i<n;i++){
	for(;k<n;k++){
	    if(m*2+1<=x[k])m++;
	    else break;
	}
	ans=ans*(m+(k<n))%mod;
	m--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
//#include "inspect.hpp"
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
  
int main(){
	vector<pair<int,pair<int,int>>> vx,vy;
	int i=0,r=0,n,x1,y1,x2,y2;
	for(scanf("%d",&n);i<n;i++){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if(x1>x2)swap(x1,x2);
		if(y1>y2)swap(y1,y2);
		if(x1==x2)vy.emplace_back(make_pair(x1,make_pair(y1,y2)));
		else vx.emplace_back(make_pair(y1,make_pair(x1,x2)));
	}
	//sort(vx.begin(),vx.end());
	sort(vy.begin(),vy.end());
	for(auto &e:vx){
		auto it1=lower_bound(vy.begin(),vy.end(),make_pair(e.second.first,make_pair(-2000000000,-2000000000)));
		auto it2=lower_bound(vy.begin(),vy.end(),make_pair(e.second.second+1,make_pair(-2000000000,-2000000000)));
		
		for(;it1!=it2;++it1){
			auto &f=*it1;
			if(f.second.first<=e.first&&e.first<=f.second.second)r++;
		}
	}
	printf("%d\n",r);
}

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

int main() {
    int D, G, p[11], c[11];
    cin >> D >> G;
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }

    int ans = 1e9;

    for(int bit = 0; bit < (1<<D);++bit){
        int s = 0, num = 0, rest_max = -1;
        for(int i = 0; i < D; ++i){
            if((bit >> i) & 1){
                s += 100*(i+1)*p[i]+c[i];
                num += p[i];
            } else {
                rest_max = i;
            }
        }

        if(s < G){
            int s1 = 100*(rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if (need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans,num);
    }

    cout << ans << endl;
}

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

using namespace std;

int main(){
  long long T1, T2;
  cin >> T1 >> T2;
  long long A1, A2;
  cin >> A1 >> A2;
  long long B1, B2;
  cin >> B1 >> B2;
  
  long long count = 0;
  long long sa = T1 * A1 + T2 * A2;
  long long sb = T1 * B1 + T2 * B2;
  if(A1 > B1 && sa > sb){
    cout << count << endl;
    return 0;
  }
  if(A1 < B1 && sa < sb){
    cout << count << endl;
    return 0;
  }
  if(sa == sb){
    cout << "infinity" << endl;
    return 0;
  }
  
  if(A1 < B1){
    swap(A1, B1);
    swap(A2, B2);
    swap(sa, sb);
  }
  
  long long x = sb - sa;
  count++;
  
  long long y = T1 * A1 - T1 * B1;
  count += 2 * ((y - 1) / x);
  if(y % x == 0) count++;
  
  cout << count << endl;
  
  return 0;
}

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

bool d1[10], d2[100], d3[1000];

int main() {
  int N; std::string S; std::cin >> N >> S;
  std::fill_n(d1, 10, false);
  std::fill_n(d2, 100, false);
  std::fill_n(d3, 1000, false);
  for(int i = 0; i < N; ++i) {
    int d = S[i]-'0';
    for(int j = 0; j < 100; ++j) if(d2[j]) d3[j*10+d] = true;
    for(int j = 0; j < 10; ++j) if(d1[j]) d2[j*10+d] = true;
    d1[d] = true;
  }
  int ans = 0;
  for(int j = 0; j < 1000; ++j) if(d3[j]) ++ans;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		while (n-- > 0) {
			int num = Integer.MAX_VALUE;
			int num2 = (1 << 8) - 1;
			long s = Long.parseLong(scanner.next(), 16);
			int x = (int) (s & num) >> 7;
			double y = (s & num2) * Math.pow(2, -7);
			String a = String.valueOf(y).substring(2);
			if (s >> 31 > 0)
				System.out.print("-");
			System.out.printf("%d.%s\n", x, a);
		}
	}
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	for (int n; cin >> n&&n;) {
		vector<int> v(n); rep(i, 0, n) { cin >> v[i]; }
		int ans = INF;
		for (int mask = 0; mask < (1 << n) / 2 + 1; mask++) {
			int a = 0, b = 0;
			rep(i, 0, n) {
				if (mask&(1 << i))a += v[i];
				else b += v[i];
			}
			chmin(ans, abs(a - b));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
x, k, d = map(int, input().split())
ans = 0

if x < 0:
    x = (-1)*x
if k*d <= x:
    ans = x-k*d
else:
    sho = x//d
    now = x-d*sho
    k -= sho
    if d-now < now:
        k -= 1
        now = d-now
    if k%2 == 0:
        ans = now
    else:
        ans = d-now
print(ans)

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

typedef long long ll;

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

    ll a,b,c;
    cin >> a >> b >> c;
    long double u = 2*sqrtl(a*b);
    long double x = c - a - b;
    if(u<x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#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 FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b) // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main()
{
  ll s;
  cin >> s;
  unordered_set<ll> nums{ s };
  ll ans = 1;
  while (true) {
    if (s % 2 == 0) {
      s /= 2;
    } else {
      s = 3 * s + 1;
    }
    ans++;
    if (nums.find(s) != nums.end()) {
      break;
    }
    nums.insert(s);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin>>p[i];

    vector<int> ans(n);
    for(int i=1; i<=n; i++){
        ans[i-1] = i;
    }

    bool valid = true;
    for(int i=0; i<n; i++){
        if(ans[i] != p[i]) valid = false;
    }

    if(valid){
        cout << "YES" << endl;
        return 0;
    }

    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            auto q = p;
            swap(q[i], q[j]);

            valid = true;
            for(int k=0; k<n; k++){
                if(ans[k] != q[k]) valid = false;
            }

            if(valid){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val input = readLine()!!.split(' ')
                            .map  { it.toInt() }
                            .toTypedArray()
    val result = D1015B(
                    numberOfBall  = input[0]
                   ,numberOfPaint = input[1]
                 ).judge()
    println(result)
}
 
class D1015B(
  val numberOfBall:  Int
 ,val numberOfPaint: Int
){
    fun judge(): Int{
        return numberOfPaint * 
               Math.pow(numberOfPaint - 1.toDouble(), numberOfBall-1.toDouble())
                   .toInt()
    }
}

Measured memory_bytes: 36468
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class ANumberOfMultiples {
public:
  static void solve(istream &cin, ostream &cout) {
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    REP(i, L, R + 1) {
      if (i % d == 0) ans++;
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  ANumberOfMultiples solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main(){
  int a,cou,m[101];
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>m[i];
  }
  cou=0;
  for(int i=0;i<a;i++){
    for(int j=0;j<=a-2-i;j++){
      if(m[j]>m[j+1]){
	swap(m[j],m[j+1]);
	cou++;
      }
    }
  }
  for(int i=0;i<a;i++){
    cout<<m[i];
    if(i<a-1)cout<<" ";
  }
  cout << endl << cou << endl;
  return 0;
}
  
  

Measured memory_bytes: 1160