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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	ll N, K;
	cin >> N >> K;
	VL A(N);
	REP(i, N) cin >> A[i];
	sort(ALL(A));

	auto compExec = [&](ll mid) {
		ll cnt = 0;
		for (auto a : A) {
			if (mid < a) {
				cnt += (Ceil(a, mid) - 1);
			}
		}
		return (cnt <= K);
	};

	ll lb = 0;
	ll lu = A.back();
	ll mid = 0;
	while ((lb + 1) != lu) {
		mid = (lb + lu) / 2;
		if (!compExec(mid)) {
			lb = mid;
		} else {
			lu = mid;
		}
	}

	cout << lu << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 4708
import java.util.Scanner;

public class Main{
 public static void main(String[]args){
  try(Scanner sc = new Scanner(System.in)){
   int w = sc.nextInt();
   int n = sc.nextInt();   
   int[] values = new int[w];
   for(int i = 0;i < values.length;i++){
    values[i] = i+1;
   }
   for(int i = 0;i < n;i++){
    String str = sc.next();
    String[] ab = str.split(",");
    int a = Integer.parseInt(ab[0])-1;
    int b = Integer.parseInt(ab[1])-1;
    int value =values[a];
    values[a] = values[b];
    values[b] = value;
   }
   for(int i=0;i < w;i++){
    System.out.println(values[i]);
   }
  }
 }
}


Measured memory_bytes: 26352
S = list(input())
ans = 'No'
N = len(S)
if S==S[::-1]:
    if S[0:(N-1)//2] == S[0:(N-1)//2][::-1]:
        if S[(N+3)//2-1:] == S[(N+3)//2-1:][::-1]:
            ans ='Yes'
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;
class Main {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()) {

            int A = scanner.nextInt();

            int B = scanner.nextInt();

            int max = getMAX(A, B);

            int min = getMIN(A, B, max);

            System.out.println(max + " " + min);



        }
    }

    private static int getMAX(int A, int B) {
        for (int i = A; A > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                return i;
            }
        }
        return 1;
    }
    private static int getMIN(int A, int B, int max){
        return A/max*B;
    }
}


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

using namespace std;

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

  for(int i = 0;i < times;++i){
    //cout<<endl;
    int place[8][8];
    bitset<8> bomb;

    for(int j = 0;j < 8;++j){
      cin>>bomb;
      for(int k = 0;k < 8;++k){
        place[j][k] = bomb[7-k];
      }
    }

    int x_hit,y_hit;
    cin>>x_hit;
    cin>>y_hit;

    vector<pair<int,int>> bplace;
    bplace.push_back(make_pair(x_hit - 1,y_hit - 1));
    place[y_hit - 1][x_hit - 1] = 0;

    while(1){
      bool con = false;
      for(pair<int,int> e : bplace){
        int x = e.first;
        int y = e.second;

        // 
        for(int j = x - 1;j > x - 4 && j >= 0;--j){
          if(place[y][j] == 1){
            bplace.push_back(make_pair(j,y));
            place[y][j] = 0;
            con = true;
          }
        }
        // 
        for(int j = x + 1;j < x + 4 && j <= 7;++j){
          if(place[y][j] == 1){
            bplace.push_back(make_pair(j,y));
            place[y][j] = 0;
            con = true;
          }
        }
        // 
        for(int j = y - 1;j > y - 4 && j >= 0;--j){
          if(place[j][x] == 1){
            bplace.push_back(make_pair(x,j));
            place[j][x] = 0;
            con = true;
         }
        }
        // 
        for(int j = y + 1;j < y + 4 && j <= 7;++j){
          if(place[j][x] == 1){
            bplace.push_back(make_pair(x,j));
            place[j][x] = 0;
            con = true;
          }
        }
      }
      if(con == false){
        break;
      }
    }

    cout<<"Data "<<i+1<<":"<<endl;
    for(int j = 0;j < 8;++j){
      for(int k = 0;k < 8;++k){
        cout<<place[j][k];
      }
      cout<<endl;
    }
  }

  return 0;
} 


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  
  ll ans=100000000000;
  for(int i=1;i<=100;i++){
    ll s=0;
    for(int j=0;j<N;j++){
      s+=(i-a[j])*(i-a[j]);
      if(j==N-1){
        ans=min(ans,s);
      }
    }
  }
  cout << ans <<endl;
}

    
      

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

int main()
{
	int H, W, i, j;
	
	while(1)
	{
		cin >> H >> W;
		if (H == 0 && W == 0)
		{
			break;
		}
		for (i = 0; i < H; i++)
		{
			for (j = 0; j < W; j++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	} 
return 0;
}

Measured memory_bytes: 3092
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    static void solve() {
        int n = nextInt();
        int m = nextInt();

        long ans = (1900 * m + 100 * (n - m)) * pow(2, m);
        out.println(ans);
    }

    static PrintWriter out;
    static Scanner sc;

    static int[][] newIntArray(int h, int w, int value) {
        int[][] ret = new int[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                ret[i][j] = value;
            }
        }
        return ret;
    }

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

    static long nextLong() {
        return Long.parseLong(sc.next());
    }

    static String nextString() {
        return sc.next();
    }

    static int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    static List<Integer> nextIntList(int n) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextInt());
        }
        return list;
    }

    static List<Long> nextLongList(int n) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextLong());
        }
        return list;
    }

    static char[][] nextCharArray(int h, int w) {
        char[][] c = new char[h][w];
        for (int i = 0; i < h; i++) {
            String str = nextString();
            for (int j = 0; j < w; j++) {
                c[i][j] = str.charAt(j);
            }
        }
        return c;
    }

    static <T extends Comparable<? super T>> void sort(List<T> list) {
        Collections.sort(list);
    }

    // greatest common divisor
    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

    // return n^k mod m
    static long powMod(long n, long k, long m) {
        if (k == 0) {
            return 1;
        } else if (k % 2 == 1) {
            return powMod(n, k - 1, m) * n % m;
        } else {
            long tmp = powMod(n, k / 2, m);
            return tmp * tmp % m;
        }
    }

    // intをlength桁のbit文字列に変換
    static String toBinaryString(int input, int length) {
        return toBinaryString(input).substring(29 - length);
    }

    // intを29桁のbit文字列に変換
    static String toBinaryString(int input) {
        String ret = "";
        int max = 0x10000000;
        for (int i = 0; i < 29; i++) {
            int tmp = input / max;
            ret += tmp;
            input %= max;
            max /= 2;
        }
        return ret;
    }

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        sc = new Scanner(System.in);

        solve();

        out.flush();
        sc.close();
    }

}


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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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



int main(){
    
	int x;
	scanf("%d",&x);
	if(x){
		printf("0\n");
	}else{
		printf("1\n");
	}

	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3628
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vs SV(n);
  Vi POINT(n,0);
  VIN(SV)
  IN(m);
  Vs TV(m);
  VIN(TV)
  
  REP(i,n){
    // SV[i]について考える
    REP(j,n){
      if(SV[i]==SV[j]) POINT[i]++;
    }
    REP(k,m){
      if(SV[i]==TV[k]) POINT[i]--; 
    }
  }
  RSORT(POINT);
  if(POINT[0]<0) OUT(0);
  else OUT(POINT[0]);
}

Measured memory_bytes: 256
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
template<class T>
class UnionFind
{
private:
	vector<T> parentNo;
	vector<T> parentRank;
	vector<T> parentSize;

public:
	// コンストラクタ
	UnionFind(int n) 
	{
		parentNo.resize(n);
		parentRank.resize(n, 0);
		parentSize.resize(n, 1);
		for (int i = 0; i < n; i++) {
			// 始めは全部ROOT
			parentNo[i] = i;
		}
	}

	int root(T x) 
	{
		if (parentNo[x] == x) {
			return x;
		} else {
			T rootParentNo = root(parentNo[x]);
			parentNo[x] = rootParentNo;
			return rootParentNo;
		}
	}

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

	int size(T x) 
	{
		return parentSize[root(x)];
	}

	void unite(T xc, T yc) 
	{
		T xr = root(xc);
		T yr = root(yc);
		if (xr == yr) {
			return;
		}
		if (parentRank[xr] < parentRank[yr]) {
			parentNo[xr] = yr;
			parentSize[yr] += parentSize[xr];
		} else {
			parentNo[yr] = xr;
			parentSize[xr] += parentSize[yr];
			if (parentRank[xr] == parentRank[yr]) {
				parentRank[xr]++;
			}
		}
	}
};


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

	string S;
	cin >> S;
	int ans = 0;
	if (S == "SUN")			ans = 7;
	else if (S == "MON")	ans = 6;
	else if (S == "TUE")	ans = 5;
	else if (S == "WED")	ans = 4;
	else if (S == "THU")	ans = 3;
	else if (S == "FRI")	ans = 2;
	else if (S == "SAT")	ans = 1;

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



Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    V = [int(v) for v in input().split()]
    pre = [[]]
    prefix_sum = [0]
    for v in V:
        prefix_sum.append(prefix_sum[-1] + v)
        if v < 0: pre.append(pre[-1] + [v])
        else: pre.append(pre[-1])

    post = [[]]
    suffix_sum = [0]
    for v in V[::-1]:
        suffix_sum.append(suffix_sum[-1] + v)
        if v < 0: post.append(post[-1] + [v])
        else: post.append(post[-1])
    # print(prefix_sum, suffix_sum)
    # print(V)
    max_tot = 0
    for i in range(min(K, N)+1):
        for j in range(min(K, N)-i+1):
            tot = prefix_sum[i] + suffix_sum[j]
            # print(i, j, tot)
            # print(pre[i], post[i])
            if K > i+j:
                d = K-i-j
                neg = sorted(pre[i] + post[j])
                tot -= sum(neg[:d])
            max_tot = max(max_tot, tot)
    return max_tot


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3188
#include <stdio.h>
#include <math.h> 
int main(void){
  int A,B,C;
  double i=0;
  scanf("%d %d",&A,&B);
  if(A == B){
    printf("1");
  }else{
    i = ceil((double)(B-1)/(double)(A-1));
    C = i;
    printf("%d",C);
  }
  
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  puts(n<=999 ? "ABC" : "ABD");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,k;
   cin>>n>>k;
   int a[n];
   for(int i=0;i<n;i++)
    cin>>a[i];
   sort(a,a+n);
   int sum=0;
   for(int i=0;i<k;i++)
    sum+=a[i];
   cout<<sum<<endl;
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
typedef unsigned long long ullong;

ullong power(ullong x, ullong n, ullong M) {
  if (n == 0) return 1;
  ullong res = power(x * x % M, n / 2, M);
  if (n % 2 == 1) res = res * x % M;
  return res;
}

int main() {
  int m, n;
  cin >> m >> n;
  cout << power(m, n, 1000000007) << endl;
  return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,m,i,z,min=1000000,x,y,c,k;
  cin>>a>>b>>m;
  vector<long long> v1,v2;
  for(i=0;i<a;i++){
    cin>>z;
    v1.push_back(z);
  }
  for(i=0;i<b;i++){
    cin>>z;
    v2.push_back(z);
  }
  while(m--){
     cin>>x>>y>>c;
     k=v1[x-1]+v2[y-1]-c;
    if(k<min) min=k;
  }
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  if(min>(v1[0]+v2[0]))
    min=v1[0]+v2[0];
  cout<<min;
return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int s,n;

int main(){
	for(int i=0;i<4;i++){
		cin>>s>>n;
		if(s==1) cout<<6000*n<<endl;
		else if(s==2) cout<<4000*n<<endl;
		else if(s==3) cout<<3000*n<<endl;
		else cout<<2000*n<<endl;
	}
}

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

int main() {

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

    if(a * b % 2 == 0){
        cout << "Even" << endl;
    }
    else{
        cout << "Odd" << endl;
    }

    return 0;
}


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


using namespace std;

int allocation(int n, int k, deque<int> w) {
    int total = 0;
    int maxValue = 0;
    for (const int i : w) {
        total += i;
        if (i > maxValue) {
            maxValue = i;
        }
    }
    int result = max(total / k, maxValue);
    for ( ; ; ) {
        int trucks = 0;
        int weight = 0;
        for (const int i : w) {
            weight += i;
            if (weight == result) {
                ++trucks;
                weight = 0;
            }
            else if (weight > result) {
                ++trucks;
                weight = i;
            }
            if (trucks > k) {
                break;
            }
        }
        if (weight != 0) {
            ++trucks;
        }
        if (trucks <= k) {
            return result;
        }
        ++result;

    }
}

int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    int k;
    cin >> k;
    deque<int> w;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        w.push_back(x);
    }
    cout << allocation(n, k, w) << endl;

    return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int N, M;
vector<int> E[600];
double x[600];
double p[600];

int main() {
    scanf("%d%d", &N, &M);
    rep(i,M) {
        int s, t; scanf("%d%d", &s, &t);
        s--; t--;
        E[s].push_back(t);
    }
    x[N-1] = 0.0;
    for (int i = N-2; i >= 0; i--) {
        x[i] = 1.0;
        rep(j,E[i].size()) {
            x[i] += x[E[i][j]]/E[i].size();
        }
    }
    p[0] = 1.0;
    rep(i,N) {
        rep(j,E[i].size()) {
            p[E[i][j]] += p[i]/(double)E[i].size();
        }
    }
    double ans = x[0];
    rep(i,N) {
        if (E[i].size() <= 1) continue;
        double ma = 0.0;
        int mai = 0;
        rep(j,E[i].size()) {
            if (ma < x[E[i][j]]) {
                ma = x[E[i][j]];
                mai = j;
            }
        }
        double tmp = 1.0;
        rep(j,E[i].size()) {
            if (j == mai) continue;
            tmp += x[E[i][j]]/(E[i].size()-1);
        }
        ans = min(ans, x[0] - (x[i] - tmp)*p[i]);
    }
    printf("%.9f\n", ans);
}

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

int main()
{
    int k, n;
    cin >> k >> n;
    int a[200005];
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = a[n - 1] - a[0];
    for(int i = 0; i < n - 1; i++){
        ans = min(ans, k - (a[i + 1] - a[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int h, w;
	scanf("%d %d", &h, &w);
	int i, j, k;
	int c[11][11];
	for (i = 0; i < 10; i++)
		for (j = 0; j < 10; j++)
			scanf("%d", &c[i][j]);
	int a[202][202];
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			scanf("%d", &a[i][j]);
	for (k = 0; k < 10; k++)
		for (i = 0; i < 10; i++)
			for (j = 0; j < 10; j++)
				if (c[i][j] > c[i][k] + c[k][j])
					c[i][j] = c[i][k] + c[k][j];
	int ans = 0;
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			if (a[i][j] >= 0)
				ans += c[a[i][j]][1];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll A,B,C;
    string S,T;
    cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}


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

int sum(int a ){
  int ans = 0;
  for(int i =0 ; i < 5 ; i++ ){
    ans += a % 10 ;
    a /= 10 ;
  }
  return ans ;
}

int main () {
  int N , a , b ,ans = 0 ;
  cin >> N >> a >> b ;
  for(int i = 1 ; i <= N ; i++ ){
    int pre = sum (i) ;
    if(pre <= b && pre >= a) ans += i  ;
  }
  cout << ans << endl ;
}

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

int main(){
	using namespace std;
// 	ios_base::sync_with_stdio(false); 
//     cin.tie(NULL); 

// #ifndef ONLINE_JUDGE 
//     freopen("inputf.in", "r", stdin); 
//     freopen("outputf.in", "w", stdout); 
// #endif

	int n, a;
	cin >> n;

	vector<int> d(3, 0);


	for(int day = 0; day < n; day++) {
		vector<int> temp_d(3, 0);
		for(int i = 0; i < 3; i++) {
			cin >> a;
			for(int j = 0; j < 3; j++) {
				if(i != j) {
					temp_d[i] = max(temp_d[i], d[j] + a);
				}
			}
		}
		d = temp_d;
	}

	cout << max({d[0], d[1], d[2]});
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int h, w, d, q;
    int[][] ass;
    int[] ls, rs, xs, ys;

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

    void run() {
        FastReader sc = new FastReader();
        h = sc.nextInt();
        w = sc.nextInt();
        d = sc.nextInt();
        ass = new int[h][w];
        xs = new int[h * w];
        ys = new int[h * w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                ass[i][j] = sc.nextInt();
                int index = ass[i][j] - 1;
                xs[index] = j;
                ys[index] = i;
            }
        }
        q = sc.nextInt();
        ls = new int[q];
        rs = new int[q];
        for (int i = 0; i < q; i++) {
            ls[i] = sc.nextInt() - 1;
            rs[i] = sc.nextInt() - 1;
        }
        solve();
    }

    void solve() {
        int maxNum = h * w;
        long[][] dp = new long[d][maxNum / d + 1];
        for (int i = 0; i < dp.length; i++) {
            dp[i][0] = 0;
        }
        for (int i = 0; i < dp.length; i++) {
            for (int j = 1; j < dp[i].length; j++) {
                int x = d * j + i;
                if (x >= maxNum) {
                    continue;
                }
                dp[i][j] = dp[i][j - 1] + Math.abs(xs[x] - xs[x - d]) +
                        Math.abs(ys[x] - ys[x - d]);
            }
        }
        for (int i = 0; i < q; i++) {
            int indexLX = ls[i] / d;
            int indexLY = ls[i] % d;
            int indexRX = rs[i] / d;
            long cost = dp[indexLY][indexRX] - dp[indexLY][indexLX];
            System.out.println(cost);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

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


Measured memory_bytes: 54168
#include "bits/stdc++.h"

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

#define rep(i,n) for (ll i = 0; i < (n); i++)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;

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

	int ans = (n / 2) + (n % 2);


	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

const int MOD = 1e9+7;
class mint {
    ll x;
public:
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    
    mint operator -() const {
        return mint(-x);
    }
    
    mint &operator +=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator -=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator *=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator +(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator /=(const mint &a) {
        return (*this) *= a.inv();
    }

    mint operator /(const mint &a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};

const int MAX = 510000;
mint fac[MAX], finv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * mint(i);
        finv[i] = finv[i-1] * mint(i).inv();
    }
}

mint COM (int n, int k) {
    if (n < k) return mint(0);
    if (n < 0 || k < 0) return mint(0);
    // o(k)
    // if (k < MAX) {
    //    mint ret(1);
    //    Rep (i, k) {
    //        ret *= mint(n-i);
    //        ret /= mint(k-i);
    //    }
    //    return ret;
    //}

    return fac[n] * finv[k] * finv[n-k];
}


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

    ll N, M;
    cin >> N >> M;

    COMinit();

    mint ans(0);
    Rep (i, N+1) {
        mint tmp(1);
        if (i%2 == 1) tmp *= mint(-1);
        tmp *= COM(N, i) * fac[M] * finv[M-i] * fac[M-i] * finv[M-N] * fac[M-i] * finv[M-N];
        // cout << tmp << "\n";
        ans += tmp;
    }

    cout << ans << endl;
}

Measured memory_bytes: 11608
use std::io::*;
use std::str::*;

// const MOD: i32 = 1000000007;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let h: usize = read().unwrap();
    let w: usize = read().unwrap();

    let mut v: Vec<String> = Vec::new();
    for _ in 0..h {
        let tmp = read().unwrap();
        v.push(tmp);
    }

    // 0 initialize
    let mut a: [[i32; 55]; 55] = [[0; 55]; 55];

    for i in 0..h {
        for j in 0..w {
            //
            if v[i].chars().nth(j).unwrap() == '#' {
                a[i][j] = -1;
            }

        }
    }

    // //debug
    // for i in 0..h {
    //     for j in 0..w {
    //         if a[i][j] == -1 {
    //             print!("#");
    //         } else {
    //             print!("{}", a[i][j]);
    //         }
    //     }
    //     println!("");
    // }


    for i in 0..h {
        for j in 0..w {
            if a[i][j] != -1 {
                continue;
            }
            // println!("{} {} = {}", i, j, a[i][j]);
            // println!("--------------------");

            if i != 0 {
                if a[i - 1][j] != -1 {
                    a[i - 1][j] += 1;
                }
            }
            if j != 0 {
                if a[i][j - 1] != -1 {
                    a[i][j - 1] += 1;
                }
            }
            if i != h - 1 {
                if a[i + 1][j] != -1 {
                    a[i + 1][j] += 1;
                }
            }
            if j != w - 1 {
                if a[i][j + 1] != -1 {
                    a[i][j + 1] += 1;
                }
            }

            if j != 0 && i != 0 {
                if a[i - 1][j - 1] != -1 {
                    a[i - 1][j - 1] += 1;
                }
            }
            if i != 0 && j != w - 1 {
                if a[i - 1][j + 1] != -1 {
                    a[i - 1][j + 1] += 1;
                }
            }
            if i != h - 1 && j != w - 1 {
                if a[i + 1][j + 1] != -1 {
                    a[i + 1][j + 1] += 1;
                }
            }
            if i != h - 1 && j != 0 {
                if a[i + 1][j - 1] != -1 {
                    a[i + 1][j - 1] += 1;
                }
            }
        }
    }
    for i in 0..h {
        for j in 0..w {
            if a[i][j] == -1 {
                print!("#");
            } else {
                print!("{}", a[i][j]);
            }
        }
        println!("");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int64_t mod=1000000007;
int main(){
  int64_t n,i,j,k,ans=0;
  cin>>n;
  vector<int64_t> a(n),c(60),p2(60);
  for(i=0;i<n;i++){
    cin>>a.at(i);
    bitset<60> b(a.at(i));
    for(j=0;j<60;j++){
      if(b.test(j)) c.at(j)++;
      if(j==0) p2.at(j)=1;
      else p2.at(j)=2*p2.at(j-1)%mod;
    }
  }
  for(j=0;j<60;j++){
    k=c.at(j)*(n-c.at(j))%mod;
    k=k*p2.at(j)%mod;
    ans=(ans+k)%mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#!/usr/bin/env python3
import sys
from collections import deque

def solve(N, M, to, start, goal):
    costs = [float('inf')] * (3*N+3)
    costs[start] = 0

    q = deque([start])

    while len(q) != 0:
        u = q.popleft()
        for v in to[u]:
            if costs[u] + 1 < costs[v]:
                costs[v] = costs[u] + 1
                if v == goal: return costs[v] // 3
                q.append(v)
    return -1



def main():
    N, M = map(int, input().split())
    to = [ [] for _ in range(3*N+3) ]
    for _ in range(M):
        u, v = map(int, input().split())
        for i in range(3):
            to[u + (N+1)*i].append(v + (N+1) * ((i+1)%3))
    S, T = map(int, input().split())
    print(solve(N, M, to, S, T))

if __name__ == '__main__':
    main()


Measured memory_bytes: 60156
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    rr = []

    n = I()
    t = 0
    while t < n:
        t += 1
        s = S()
        e = set()
        for i in range(len(s)):
            s1 = s[:i]
            s2 = s[i:]
            sr1 = s1[::-1]
            sr2 = s2[::-1]
            e.add(s1+s2)
            e.add(sr1+s2)
            e.add(s1+sr2)
            e.add(sr1+sr2)
            e.add(s2+s1)
            e.add(sr2+s1)
            e.add(s2+sr1)
            e.add(sr2+sr1)


        rr.append(len(e))

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9132
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;


int sq(int x){ return x * x; }

int n;
int c[24];

int on[24];
signed char memo[1 << 24];

int dfs(int S){
	if(memo[S] == -1){
		vector<vector<int> > v(4);
		for(int i = 0; i < n; ++i){
			if(S >> i & 1) continue;
			if(on[i] & ~S) continue;
			
			v[c[i] - 1].push_back(i);
		}

		int ret = 0;
		for(int i = 0; i < 4; ++i){
			for(int j = 1; j < v[i].size(); ++j)
			for(int k = 0; k < j; ++k){
				int T = S | (1 << v[i][j]) | (1 << v[i][k]);
				ret = max(ret, dfs(T) + 2);
			}
		}
		memo[S] = ret;
	}
	return memo[S];
}


int main(){
	int x[24], y[24], r[24];
	while(scanf("%d", &n), n){
		for(int i = 0; i < n; ++i){
			scanf("%d%d%d%d", &x[i], &y[i], &r[i], &c[i]);
		}
		
		for(int i = 0; i < n; ++i){
			int a = 0;
			for(int j = 0; j < i; ++j){
				if(sq(x[i] - x[j]) + sq(y[i] - y[j]) < sq(r[i] + r[j])){
					a |= 1 << j;
				}
			}
			on[i] = a;
		}

		memset(memo, -1, sizeof memo);
		printf("%d\n", dfs(0));
	}
}

Measured memory_bytes: 17440
s = input()
data =[]
for i in range(len(s)):
  data.append(s[i])
array = []
for i in range(len(data)):
  if data[i] == "0":
    array.append("0")
  elif data[i] == "1":
    array.append("1")
  elif (len(array) != 0 and data[i]== "B"):
    array.pop(-1)
  else:
    pass

mojiretu = ''

for x in array:
    mojiretu += x

print(mojiretu)

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  string s;
  cin >> s;

  int maxv = 0;
  for (int i = 1; i <= (s.length() - 1) / 2 ; ++i) {
    string judge = s.substr(0, i);
    int len = i;
    if (s.substr(i, i) == judge) {
      len *= 2;
      chmax(maxv, len);
    }
  }

  cout << maxv << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int in;
    cin>>in;
    cout<<"Case"<<" "<<i<<":"<<endl;
    for(int j=0;j<10;j++){
      in*=in;
      in=in%1000000;
      in/=100;
      cout<<in<<endl;
    }


  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define x real()
#define y imag()
#define INF (1e9)
#define EPS (1e-5)
using namespace std;
typedef complex<double> point;
point s,g;
double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}

int ccw(point a,point b,point c){
  point d = b-a;
  point e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 2;//"ONLINE_BACK"
  if(abs(d)<abs(e)) return -2;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}

bool intersection(point a,point b,point c,point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}

//???????§???¢????????´??????????????????
int get_state(vector <point> a,point b){
  int n=a.size();
  for(int i=0;i<n;i++){
    int res=ccw(a[i],a[(i+1)%n],b);
    if(!res)return 0; //?¢???????
    if(res!=1) return 1;//?????´
  }
  return -1;//?????´
}


//???????§???¢??¨???????????¢????±??????????
double get_dis_sp(point a, point b, point c) {
  if (dot(b-a,c-a)<EPS) return abs(c-a);
  if (dot(a-b,c-b) <EPS) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}


//????????¨??????????????¢
double get_dis_sg_sg(point a,point b,point c,point d){
  if(intersection(a,b,c,d)) return 0;
  return min(min(get_dis_sp(a,b,c),get_dis_sp(a,b,d)),
	     min(get_dis_sp(c,d,a),get_dis_sp(c,d,b)));
}

//???????§???¢??¨??????????????¢
double get_dis_totsu_sg(vector <point> a,point b,point c){
  if(get_state(a,b) !=1||get_state(a,c)!=1)return 0;
  int n=a.size();
  double res=get_dis_sg_sg(a[0],a[1],b,c);
  for(int i=0;i<n;i++) res=min(res,get_dis_sg_sg(a[i],a[(i+1)%n],b,c));
  return res;
}


int main(){
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    double a,b,c,d,h;
    cin>>a>>b>>c>>d;
    s=point(a,b),g=point(c,d);

    double ans=INF;
    vector <point> v;
    v.resize(4);
    for(int i=0;i<n;i++) {
      cin>>a>>b>>c>>d>>h;
      v[3]=point(a,b);
      v[2]=point(a,d);
      v[1]=point(c,d);
      v[0]=point(c,b);
      double dis=get_dis_totsu_sg(v,s,g);
      if(dis>h) ans=min(ans,(dis*dis+h*h)/(2*h));
      else ans=min(ans,dis);
    }
    printf("%.10f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1264
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		int t = sc.nextInt();
		
		// 計算
		int result = 0;
		result = max(0, x - t); 
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 22996
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0

for i in range(n - 1):
	if a[i] == 0:
		continue
	if a[i] % 2 == 0:
		ans += a[i] // 2
		continue
	else:
		ans += a[i] // 2
		if a[i + 1] >= 1:
			ans += 1
			a[i + 1] -= 1

ans += a[n - 1] // 2

print(ans)

Measured memory_bytes: 7072
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] cnt = new int[n + 1];

        sc.close();

        int mod = 1000000007;

        for (int i = 1; i <= n; i++) {
            int num = i;
            for (int j = 2; j <= n; j++) {
                while (num % j == 0) {
                    cnt[j]++;
                    cnt[j] %= mod;
                    num /= j;
                }
            }
        }

        long ans = 1;
        for (int num : cnt) {
            ans = (ans * (num + 1)) % mod;
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,e,f,g,h,i,j;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>j;
  cout<<a+b+c+d+e+f+g+h+i+j<<'\n';
  
  return(0);
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;

int main(){
    string s;
    lint x=0,ans=0;;
    cin >>s;
    rep(i,s.size()){
        if(i==0){
            if(s[i]=='p') ans--;
            x++;
            continue;
        }
        if(s[i]=='g'&&x>0){
            ans++;
            x--;
        } else if(s[i]=='g'){
            x++;
        }else if(s[i]=='p'&&x>0){
            x--;
        }else if(s[i]=='p'){
            ans--;
            x++;
        }      
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
 
using namespace std;
 
void Solution()
{
    int n;
    int x[100] = {0};
    int y[100] = {0};
    
    double sum1 = 0;
    double sum2 = 0;
    double sum3 = 0;
    double sumMax = 0;
    
    
    cin>>n;
    
    for(int i = 0; i < n; i++)
    {
        cin>>x[i];
    }
    
     for(int i = 0; i < n; i++)
    {
        cin>>y[i];
    }
    
    for(int i = 0; i < n; i++)
    {
        sum1 = (double)fabs(x[i] - y[i]) + sum1;
        sum2 = (double)(x[i] - y[i]) * (x[i] - y[i]) + sum2;
        sum3 = (double)fabs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]))+ sum3;
        sumMax = max(sumMax, (double)fabs(x[i] - y[i]));  //"Max" in this question just means that who is bigger
    }
    
    cout<<fixed<<setprecision(5)<<sum1<<endl;
    cout<<fixed<<setprecision(5)<<sqrt(sum2)<<endl;
    cout<<fixed<<setprecision(5)<<pow(sum3, 1.0/3.0)<<endl;    //or cbrt(num)
    cout<<fixed<<setprecision(5)<<sumMax<<endl;
    
    
    
    
}
 
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1268