akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
	int i,j;
	int a,b,c;
	int tmp;
		
	scanf("%d\n",&j);
	
	for(i=0;i<j;i++){
		scanf("%d %d %d\n",&a,&b,&c);
		if(a>b){
			tmp = a;
			a=b;
			b=tmp;
		}
		if(b>c){
			tmp=b;
			b=c;
			c=tmp;
		}
		if(c*c==a*a+b*b){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int sum1 = a + b;
    int sum2 = b + c;
    int sum3 = a + c;
    cout << min(min(sum1, sum2), sum3) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, m; cin >> n >> m;
  if(max(n,m)-min(n,m) >= 2){
    cout << 0 << endl;
    system("pause");
    return 0;
  }
  ll ans = 1;
  if(n == m){
    //2bai
    //ans += n! * m! * 2
    for(int i = 2; i <= n; i++){
      ans *= i;
      ans %= MOD;
    }
    for(int i = 2; i <= m; i++){
      ans *= i;
      ans %= MOD;
    }
    ans = ans*2 % MOD;
  }
  else{
    //ans += n!*m!
    for(int i = 2; i <= n; i++){
      ans *= i;
      ans %= MOD;
    }
    for(int i = 2; i <= m; i++){
      ans *= i;
      ans %= MOD;
    }
  }
  cout << ans << endl;
  system("pause");
}

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

int main()
{
    char a;

    cin >> a;
    if((a <= 'Z') and (a >= 'A' ))
    {
        cout << 'A' << endl;
    }else{
        cout << 'a' << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n;
    cin>>n;
    ll t[110]={},v[110]={};
    double dp[110][110];
    rep(i,110)rep(j,110) dp[i][j]=0.0;
    rep(i,n) cin>>t[i];
    rep(i,n) cin>>v[i];
    v[n]=0,v[n+1]=0;
    dp[0][0]=1;
    rep(i,n){
        rep(V,105){
            if(dp[i][V]>0&&V<=v[i]){
                rep(vv,105)if(vv<=v[i]){
                    ll a=v[i]-V;
                    ll b=v[i]-vv;
                    if(a+b<=t[i]){
                        double up=1.0*(V+v[i])*a/2.0;
                        double stay=v[i]*(t[i]-a-b);
                        double down=1.0*(vv+v[i])*b/2.0;
                        chmax(dp[i+1][vv],dp[i][V]+up+stay+down);
                    }
                    else if(t[i]<abs(V-vv)){}
                    else{
                        double x=1.0*(vv-V+t[i])/2.0;
                        double y=1.0*(t[i]-vv+V)/2;
                        double v2=V+x;
                        double up=1.0*(V+v2)*x/2;
                        double down=1.0*(vv+v2)*y/2;
                        chmax(dp[i+1][vv],dp[i][V]+up+down);
                    }                  
                }
            }
            
        }
    }
    cout<<dp[n][0]-1<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_power_socket(void) {
	int a, b;
	cin >> a >> b;

	int sum = 1;
	int cnt = 0;
	while (sum < b) {
		sum += (a - 1);
		cnt++;
	}

	cout << cnt << endl;
}
int main()
{
    b_power_socket();

    return 0;
}


Measured memory_bytes: 3556
#include<stdio.h>
int main(void){
    int m,f,r;
    while(1){
        scanf("%d%d%d",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1) break;
        if(m==-1||f==-1) puts("F");
        else if((m+f)>=80) puts("A");
        else if((m+f)>=65) puts("B");
        else if((m+f)>=50||((m+f)>=30&&r>=50)) puts("C");
        else if((m+f)>=30) puts("D");
        else puts("F");
    }
    return 0;
}


Measured memory_bytes: 2040
var obj={};
var abc="AB,AD,BA,BE,BC,CB,CF,DA,DE,DG,EB,ED,EH,EF,FC,FE,FI,GD,GH,HE,HG,HI,IF,IH".split(",");
abc.forEach(function(v){obj[v]=true;});
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
for(var I=0;I<1000;I++){
   var arr=Arr[I].split("");
   var x=arr[0];
   var flag=true;
   for(var i=1;i<arr.length;i++){
      if(obj.hasOwnProperty(x+arr[i])){
         x=arr[i];
      }else {
         flag=false;
         break;
      }
   }
   if(flag)console.log(Arr[I]);
}

Measured memory_bytes: 10148
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char **argv)
{
	int n;
	while (scanf("%d", &n) != EOF)
	{
		n %= 39;
		if (n == 0)
			n = 39;

		printf("3C%02d\n", n);
	}

	return 0;
}

Measured memory_bytes: 1740
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// # pragma GCC optimize "-O3"
# define int long long
using namespace std;
  
const int N = 2e5 + 7;
const int mod = 998244353;

int fact[N], fin[N];

int binpow( int a, int b ) {
	int r = 1;
	while ( b ) {
		if ( b & 1 ) {
			r = r * a % mod;
		}
		a = a * a % mod;
		b >>= 1;
	}
	return r;
}

int inv( int x ) {
	return binpow( x, mod - 2 );
}

int nCr( int a, int b ) {
	if ( b < 0 || b > a ) {
		return 0;
	}
	return (fact[a] * fin[b] % mod) * fin[a - b] % mod;
}

int32_t main() {
    speed;
    int n, m, k;
    cin >> n >> m >> k;
    fact[0] = 1;
    for ( int i = 1; i < N; i++ ) {
    	fact[i] = fact[i - 1] * i % mod;
    }
    fin[N - 1] = inv(fact[N - 1]); 
    for ( int i = N - 2; i >= 0; i-- ) {
    	fin[i] = fin[i + 1] * (i + 1) % mod;
    }
    int ans = 0;
    for ( int i = 0; i <= k; i++ ) {
    	ans += (m * binpow( m - 1, n - 1 - i ) % mod) * nCr( n - 1, i ) % mod;
    	ans %= mod;
    }
    cout << ans;
}


Measured memory_bytes: 6728
#include <iostream>
#include <stdio.h>
using namespace std;

//sは昇順
bool contains_with_binarySearch(int v, int S[], int n){
    
    int l = 0;
    int r = n;
    
    while( l < r ){
        int m = (l+r)/2;
        if(S[m]==v)
            return true;
        if(v<S[m]){
            r = m;
        }else{
            l = m+1;
        }
    }
    
    return false;
    
}

int main(int argc, const char * argv[]) {
    
    int n;
    scanf("%d", &n);
    
    int S[n];
    for(int i=0; i<n; i++){
        scanf("%d", &S[i]);
    }
    
    int q;
    scanf("%d", &q);
    
    int T[q];
    for(int i=0; i<q; i++){
        scanf("%d", &T[i]);
    }
    
    //search
    int count = 0;
    for(int i=0; i<q; i++){
        if(contains_with_binarySearch(T[i], S, n)){
            count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}



Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

vector<P> edge[1100000];

int v, e,r;
int s,t,d;

vector<Int> dijkstra(int start){
    priority_queue<P, vector<P>, greater<P>> pq;
    vector<Int> dist(v, LINF);
    dist[start] = 0;
    pq.push(P(dist[start], start));

    while(!pq.empty()){
        auto p = pq.top();pq.pop();
        Int d = p.first;
        int from = p.second;
        if(dist[from] < d)continue;
        for(auto nxt: edge[from]){
            int to = nxt.first;
            Int c = nxt.second;
            if(dist[from] + c < dist[to]){
                dist[to] = dist[from] + c;
                pq.push(P(dist[to], to));
            }
        }
    }
    return dist;
}

int main(){
    cin >> v >> e >> r;
    for(int i = 0;i < e;i++){
        cin >> s >> t >> d;
        edge[s].push_back(P(t, d));
    }
    auto dist = dijkstra(r);
    for(int i = 0;i < v;i++){
        if(dist[i] == LINF)cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 42868
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 300000+50
#define maxm 30000
#define ll long long
#define mod 1000000000+7
#define mian main
#define mem(a,b) memset(a,b,sizeof a)
#ifndef ONLINE_JUDGE
   #define dbg(x) cout<<#x<<"="<<x<<endl;
#else 
   #define dbg(x) 
#endif
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=10*x+ch-'0';
        ch=getchar();
    }
    return x*f;
}
inline void Out(int a) 
{
    if(a>9)
        Out(a/10);
    putchar(a%10+'0');
}
int main()
{
    int n;
    n=read();
    int k;
    k=read();
    cout<<n-k+1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
signed main(){
    string s;
    cin>>s;
    stack<char> st;
    rep(i,s.size()){
        if(s[i]=='S'){
            st.push('S');
        }
        else if(!(st.empty())&&st.top()=='S'){
            st.pop();
        }
        else st.push('T');
    }
    cout<<st.size()<<endl;
}

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

int main() {
	int X, Y, asi;
	cin >> X >> Y;

	for(int i=0; i<=X; i++){
		asi = 2*i + 4*(X-i);
		if(asi == Y){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


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

int n;
double dn;
int main()
{
    char point;
    double h;
    double m=1000000000, M=0;
    while(cin >> n >> point >> dn)
    {
        h = dn/10 + n;
        M = max(M, h);
        m = min(m, h);
    }
    cout << M-m << endl;
}

Measured memory_bytes: 1288
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long[] a = new long[3];
		for (int i = 0; i < 3; i++)
			a[i] = Integer.parseInt(sc.next());
		Arrays.sort(a);
		int k = Integer.parseInt(sc.next());
		for (int i = 0; i < k; i++)
			a[2] *= 2;
		System.out.println(a[0] + a[1] + a[2]);
	}
}

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

using namespace std;
#define int long long int
#define vi vector<int>
#define pi pair<int,int>
#define ff first
#define ss second
//#define vlli vector<long long int>
#define si set<int>
#define loop(i,k,n) for(int i=k;i<n;i++)
#define MOD 1000000007
#define r0 return 0
/*
//gcd in O(log(a))
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
*/
/*
int gcd, x, y;

void extendedEuclid (int a, int b)
{
    if (b==0)
    {
        x=1;
        y=0;
        gcd=a;
        return;
    }
    extendedEuclid(b, a%b);
    int x1=y;
    int y1=x-(a/b)*y;
    x=x1;
    y=y1;
}

int nCr (int n, int r)
{
    int p=1, k=1, modInv;
    if (n-r<r)
        r=n-r;
    if (r!=0)
    {
        while (r)
        {
            p=(p*n)%MOD;
            k*=r;
            n--;
            r--;
        }
        extendedEuclid(k, MOD);
        modInv=(x+MOD)%MOD;
        p=(p*modInv)%MOD;
    }
    else
        p=1;
    return p;
}
*/

int32_t main(void)
{
    int t=1;
    //cin>>t;

    while(t--)
    {
        int n,W;
        cin>>n>>W;
        vi w(n+1);
        vi v(n+1);
        int dp[n+1][W+1];
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=W;j++)
                dp[i][j]=0;
        }
        for(int i=1;i<=n;i++)
            cin>>w[i]>>v[i];
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=W;j++)
            {
                if(w[i]>j)
                    dp[i][j]=dp[i-1][j];
                else
                {
                    dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
                }
            }

        }
        cout<<dp[n][W];


    }

}


Measured memory_bytes: 79104
n, m, x = map(int, input().split())
c = []
a = []
for i in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp[0])
    a.append(tmp[1:])

min_cost = -1

for i in range(2**n):
    cost = 0
    skills = [0] * m

    for j in range(n):
        if (i >> j) & 1:
            cost += c[j]
            skills = [skills[k] + a[j][k] for k in range(m)]

    if min(skills) >= x and (cost < min_cost or min_cost == -1):
        min_cost = cost

print(min_cost)


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

int main() {
  
  int X,Y;
  cin >> X >> Y ;
  
  for(int i=0;i<=X;i++){
  	if(Y == i*2 +(X-i)*4){
    	cout << "Yes" << endl;
      	return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
  
}


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

int main(){
	int n;
	cin >> n;
	int ans = 0;
	if(n/1000 == 2) ans++;
	n %= 1000;
	if(n/100 == 2) ans++;
	n %= 100;
	if(n/10 == 2) ans++;
	if(n % 10 == 2) ans++;
	cout << ans << endl;
	return 0;
}

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

int main(){
int i,n;
string s,t;
cin >> s;
n = s.size();
for(i=0;i<n;i++){
    t.push_back(s[n-1-i]);
}
for(i=0;i<10;i++){
    t.push_back('k');
}
i = 0;
while(i<n){
    if(t.substr(i,5) == "maerd"){
        i += 5;
    }else if(t.substr(i,5) == "esare"){
        i += 5;
    }else if(t.substr(i,7) == "remaerd"){
        i += 7;
    }else if(t.substr(i,6) == "resare"){
        i += 6;
    }else{
        cout << "NO" << endl;
        return 0;
        }
    }
cout <<"YES" << endl;
return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int cnt[200010];

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

	int N, K;
	cin >> N >> K;
	int A;
	rep(i, 0, N)
	{
		cin >> A;
		cnt[A]++;
	}

	sort(cnt, cnt + N + 1);

	int ans = 0;
	rep(i, 0, N + 1 - K)
	{
		ans += cnt[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int x, y;
  cin >> x >> y;
  FOR(i, 0, 50) FOR(j, 0, 25) {
    if (i + j == x && 2 * i + 4 * j == y) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    int a,b;
    string s="";
    cin >> a >> b;
    if(a<b) s="a < b";
    if(a>b) s="a > b";
    if(a==b) s="a == b";
    cout << s << endl;
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<bool, int> P;

int a[10];
int v[1025][10];
int used[10];

void comv(int i, int s)
{
    if (i == 10)
    {
        rep(j, 10) v[s][j] = used[j];
        return;
    }

    used[i] = 0;
    comv(i + 1, s);
    used[i] = 1;
    comv(i + 1, s + a[i]);
}

int main()
{
    rep(i, 10)
        a[i] = pow(2, 9 - i);

    comv(0, 0);
    int n;
    while (cin >> n)
    {
        int t;
        for (int i = 9; i >= 0; i--)
            if (v[n][i] == 1)
                t = i;
        for (int i = 9; i >= 0; i--)
        {
            if (v[n][i] == 1)
                t != i ? cout << a[i] << " " : OP(a[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 3284
import java.io.*;
public class Main
{
	public static void main(String[] args) throws IOException
	{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    int n=Integer.parseInt(br.readLine());
	    
		System.out.println(n+(n*n)+(n*n*n));
	}
}


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

// <editor-fold>

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
// vector出力
template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}
// vector入力
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
struct Pos {
  int x, y;
};
// 任意の個数の変数をスペース区切りで出力します
void dump() {
  cout << endl;
}
template <class Head, class... Tail>
void dump(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail) != 0)
    cout << " ";
  dump(std::move(tail)...);
}
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl;
// </editor-fold>

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();

  vector<int> v1(n), v2(n);
  map<char, int> m1, m2;
  for (int i = 0; i < n; i++) {
    if (m1[s[i]] == 0) {
      m1[s[i]] = m1.size();
    }
    v1[i] = m1[s[i]];
  }

  for (int i = 0; i < n; i++) {
    if (m2[t[i]] == 0) {
      m2[t[i]] = m2.size();
    }
    v2[i] = m2[t[i]];
  }

  Yes(v1 == v2);
}


Measured memory_bytes: 2312
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int w[102];
int v[102];
ll dp[102][100100];
int main()
{
    memset(dp, -1, sizeof(dp));
    int n, W;
    scanf("%d", &n);
    scanf("%d", &W);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &w[i]);
        scanf("%d", &v[i]);
    }
    dp[0][0] = 0;
    dp[0][w[0]] = v[0];
    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j <= W; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i])
            {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
            }
        }
    }
    ll mx = LLONG_MIN;
    for (int j = 0; j <= W; j++)
        mx = max(mx, dp[n - 1][j]);
    cout << mx;
    return 0;
}

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

int main() {
  int a, b;
  std::cin >> a >> b;

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


Measured memory_bytes: 256
//abc044_a.cpp
//Fri Oct 19 22:32:24 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,k,x,y;
	cin >> n >> k >> x >> y;

	int ans = 0;
	if (n>k){
		ans = k*x+(n-k)*y;
	}else{
		ans = n*x;
	}

	cout << ans << endl;
}

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

int n;
string s[500];

bool isExistAnswer() {
	for (int r = 0; r < n; r++) for (int c = 0; c < n; c++) if (s[r][c] == '#') return true;
	return false;
}

int getCost(int r) {
	int cnt = 0;
	for (int c = 0; c < n; c++) if (s[r][c] == '.') cnt++;
	for (int i = 0; i < n; i++) if (s[i][r] == '#') return cnt;
	return cnt + 1;
}

int main() {
	int r, c;
	
	cin >> n;
	for (r = 0; r < n; r++) cin >> s[r];
	if (!isExistAnswer()) { cout << -1 << endl; return 0; }
	
	int colNum = 0;
	for (c = 0; c < n; c++) {
		for (r = 0; r < n; r++) {
			if (s[r][c] == '.') {
				break;
			}
		}
		if (r < n) {
			colNum++;
		}
	}
	
	int rowCost = n + 1;
	for (r = 0; r < n; r++) {
		rowCost = min(rowCost, getCost(r));
	}
	
	cout << rowCost + colNum << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	int i;
	int n;
	int a[10000], b[10000];
	int asum = 0, bsum = 0;

	while (scanf("%d", &n), n != 0){
		for (i = 0; i < n; i++){
			scanf("%d %d", &a[i], &b[i]);
			
			if (a[i] < b[i]){
				bsum += b[i] + a[i];
			}
			else if (a[i] > b[i]){
				asum += b[i] + a[i];
			}
			else {
				asum += a[i];
				bsum += b[i];
			}
		}
		printf("%d %d\n", asum, bsum);
		asum = 0;
		bsum = 0;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 676
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
use std::cmp::*;
//use std::num;

fn main() {
    input! {
        N:usize,M:usize,K:i64,
        A:[i64;N],
        B:[i64;M]
    }
    // それぞれa冊、b冊読むとする。
    let mut a = 0usize;
    let mut b = 0usize;
    let mut time = 0i64;
    // 全部Aから読む。
    for i in 0..N {
        let d = A[i];
        if time + d <= K {
            time += d;
            a += 1;
        } else {
            break;
        }
    }
    let mut ma = a;
    for i in 0..M {
        let d = B[i];
        while time + d > K && a > 0 {
            time -= A[a - 1];
            a -= 1;
        }
        if time + d <= K {
            time += d;
            b += 1;
            ma = max(ma, a + b);
        } else {
            break;
        }
    }
    println!("{}", ma);
}


Measured memory_bytes: 9244
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	template<typename T> bool IN(T x,T l,T r){if(l>r)swap(l,r);return l<=x and x<=r;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=998244353;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}

	const int N=1e6+10;
	//------------------FIXED------------------
	pii a[N];
	void main()
	{
		int n=qread();fo(i,1,n) a[i].FR=qread(),a[i].SE=qread();ll ans=mm(qpower(2,n)+MOD-1-n);
		fo(i,1,n) fo(j,1,n) if(a[i]<a[j])
		{
			int cnt=0;
			fo(k,1,n) if(k!=i and k!=j and IN(a[k].FR,a[i].FR,a[j].FR) and IN(a[k].SE,a[i].SE,a[j].SE) and
				(a[j].SE-a[i].SE)*(a[k].FR-a[i].FR)==(a[k].SE-a[i].SE)*(a[j].FR-a[i].FR) )
					cnt++,debug("%d on (%d,%d)\n",k,i,j);
			add(ans,MOD-qpower(2,cnt));
			debug("i=%d j=%d cnt=%d\n",i,j,cnt);
		}write(ans);
 	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int,int> P;
#define fi first
#define se second
int main(){
    int n,ans=0;
    cin >> n;
    vector<pair<int,int>> r(n);
    vector<pair<int,int>> b(n);
    for(int i=0;i < n;i++){
        cin >> r.at(i).fi >> r.at(i).se;
    }
    for(int i=0;i < n;i++){
        cin >> b.at(i).se >> b.at(i).fi;
    }
    sort(r.begin(),r.end());
    sort(b.begin(),b.end());

    for(int i=n-1;i>=0;i--){
        for(int j=0;j < b.size();j++){
            if(r.at(i).fi < b.at(j).se && r.at(i).se<b.at(j).fi){
                ans++;
                r.erase(r.begin()+i);
                b.erase(b.begin()+j);
                break;
            }
        }
    }
    cout << ans << endl;
}


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

int main()
{
    ll n, counter=1;
    cin >> n;
    string s;
    cin >> s;
    char last=s[0];
    for(ll i=1; i<n; i++){
        if(last==s[i]){
            counter --;
        }
        last=s[i];
        counter ++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdlib>
#include <climits>
using namespace std;

int main(){
    int n; cin >> n;
    vector<vector<int>> v(2, vector<int>(n));
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < n; ++j){
            cin >> v[i][j];
        }
    }

    vector<vector<int>> dp(2, vector<int>(n, -1));
    dp[0][0] = v[0][0];

    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < n; ++j){
            if(dp[i][j] == -1) continue;
            // 下方向への遷移
            if(i+1 < 2) dp[i+1][j] = max(dp[i][j] + v[i+1][j], dp[i+1][j]);
            // 右方向への遷移
            if(j+1 < n) dp[i][j+1] = max(dp[i][j] + v[i][j+1], dp[i][j+1]);
        }
    }

    cout << dp[1][n-1] << endl;
    return EXIT_SUCCESS;
}


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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main() {
	
int k  ;    
cin >> k ;
long long ans =  0 ;

for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
        for(int l=1;l<=k;l++){
          ans += gcd(gcd(i,j),l) ;
        }
    }
}

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n],ans=0,p=0,s=0;
  r(i,n)cin>>a[i];
  r(i,n){
    if(a[i]%4==0)ans++;
    else if(a[i]%2==0)p++;
  }

  if(p>=2&&n!=p)n-=p-1;
  n-=ans;
  if(ans>=n||(ans&&ans+1>=n)||(n==p))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
bool vis[nsz + 5];
int n, a[nsz + 5], fst[nsz + 5], lst[nsz + 5], nxt[nsz + 5];
num m;
vector<int> s, ans;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    cont (i, n) {
        cin >> a[i];
        fst[a[i]] = fst[a[i]] ? fst[a[i]] : i;
    }
    for (int i = n; i >= 1; --i) {
        nxt[i] = lst[a[i]] ? lst[a[i]] : fst[a[i]];
        lst[a[i]] = i;
    }
    for (int cur = 1; !vis[cur]; cur = nxt[cur] + 1) {
        if (nxt[cur] <= cur) {
            s.push_back(cur);
            vis[cur] = 1;
        }
    }
    --m;
    m %= s.size();
    for (int i = s[m]; i <= n;) {
        if (nxt[i] <= i) {
            ans.push_back(a[i]);
            ++i;
        } else {
            i = nxt[i] + 1;
        }
    }
    loop (i, ans.size()) {
        cout << ans[i] << ' ';
    }
    cout << ln;
}


Measured memory_bytes: 6516
n=int(input())
sum=[0]*4
for i in range(n):
    a=input()
    if a=='AC':
        sum[0]=sum[0]+1
    elif a=='WA':
        sum[1]=sum[1]+1
    elif a=='TLE':
        sum[2]=sum[2]+1
    elif a=='RE':
        sum[3]=sum[3]+1

print('AC x ',sum[0])
print('WA x ',sum[1])
print('TLE x ',sum[2])
print('RE x ',sum[3])

    

Measured memory_bytes: 9104
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    int k = sc.nextInt();

    if(b-a<=k && c-a<=k && d-a<=k && e-a<=k && c-b<=k && d-b<=k && e-b<=k && d-c<=k && e-c<=k && e-d<=k){
      System.out.println("Yay!");
    }else{
      System.out.println(":(");
    }
  }
}


Measured memory_bytes: 21972
import math
from itertools import permutations
n = int(input())
xy = [[int(i) for i in input().split()] for _ in range(n)]
arr = list(permutations(range(n), n))
ans = 0
for i in range(len(arr)):
    for j in range(1, n):
        ans += math.sqrt(pow(xy[arr[i][j]][0] - xy[arr[i][j-1]][0], 2) + pow(xy[arr[i][j]][1] - xy[arr[i][j-1]][1], 2))
ans /= len(arr)
print(ans)


Measured memory_bytes: 8052
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define INF 10000000000000000
int n,m;
ll start[100005];
ll goal[100005];
ll d[100005];
pair<ll,ll> qwe[100005];
struct edge{
	int to; ll cost;
	edge(int a,int b):to(a),cost(b){}
};
vector<edge>vec[100005];
void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> > que;
	que.pu(mp(0,s));
	fill(d,d+n,INF);
	d[s]=0;
	while(!que.empty()){
		P p=que.top(); que.pop();
		int V=p.second;
		if(d[V]<p.first) continue;
		for(int i=0;i<vec[V].size();i++){
			edge e=vec[V][i];
			if(d[e.to] > d[V]+e.cost){
				d[e.to]=d[V]+e.cost;
				que.push(mp(d[e.to],e.to));
			}
		}				
	}
}
vector<ll>seg[1<<18];
ll limits,limite;
void update1(vector<ll> x,int a){
	seg[a+(1<<17)-1]=x;
}
void update(){
		for(int i=(1<<17)-2;i>=0;i--){
			seg[i].resize(seg[i*2+1].size()+seg[i*2+2].size());
			int be=0,en=0;
				for(int j=0;j<seg[i].size();j++){
					if(en==seg[i*2+2].size()){ seg[i][j]=seg[i*2+1][be]; be++;}
					else if(be==seg[i*2+1].size()){ seg[i][j]=seg[i*2+2][en]; en++;}
					else if(seg[i*2+1][be]<=seg[i*2+2][en]){ seg[i][j]=seg[i*2+1][be]; be++;}
					else{ seg[i][j]=seg[i*2+2][en]; en++;}
				}
		}
}
int sum(int a,int b,int k,int l,int r){
	if(l>b || a>r){
		return 0;
	}else if(a<=l && r<=b){
		int rp=lower_bound(seg[k].begin(),seg[k].end(),limite)-seg[k].begin();
		return seg[k].size()-rp; 
	}else{
		return sum(a,b,k*2+1,l,(l+r)/2)+sum(a,b,k*2+2,(l+r)/2+1,r);
	}
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b;
		ll c;
		scanf("%d %d %lld",&a,&b,&c);
		vec[a].pb(edge(b,c)); vec[b].pb(edge(a,c));
	}
	dijkstra(0);
	for(int i=0;i<n;i++){
		start[i]=d[i];
	}
	dijkstra(n-1);
	for(int i=0;i<n;i++){
		goal[i]=d[i];
		qwe[i]=mp(start[i],goal[i]);
	}
	sort(qwe,qwe+n);
	for(int i=0;i<n;i++){
		vector<ll>er; er.pb(qwe[i].second);
		update1(er,i); start[i]=qwe[i].first;
	}
	update();
	int Q;
	scanf("%d",&Q);
	for(int i=0;i<Q;i++){
		scanf("%lld %lld",&limits,&limite);
		int eo=upper_bound(start,start+n,limits)-start;
		printf("%d\n",sum(0,eo-1,0,0,(1<<17)-1));
	}
}

Measured memory_bytes: 36452
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int h, k;
  cin >> h;
  cin >> k;
  long hp[h], sum;
  sum = 0;
  for(int i=0; i<h; i++){
    cin >> hp[i];
  }
  sort(hp, hp+h);
  for(int i=0; i<h-k; i++){
    sum += hp[i];
  }
  cout << sum;
}

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

long long int poow(long long int a,long long int b)
{
    //long long int p=1000000007;
    long long int res=1;
    while(b)
    {
        if(b&1)
        res=(res*a);
        a=(a*a);
        b=b>>1;
    }
    return res;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    string s;
    cin>>n>>s;
    int k=0;
    for(int i=0;i<n;i++)
        if(s[i]=='1')
        k++;

    if(k==0)
    {
        for(int i=0;i<n;i++)
            cout<<1<<endl;
        
        return 0;
    }

    int kp=0;
    for(int i=0;i<n;i++)
        {
            kp=kp<<1;
            if(s[i]=='1')
                kp++;
            kp=kp%(k+1);
        }
    int kn=0;
    if(k!=1)
    {
        for(int i=0;i<n;i++)
        {
            kn=kn<<1;
            if(s[i]=='1')
                kn++;
            kn=kn%(k-1);
        }
    }
    vector<int>vp,vn;
    vp.push_back(1%(k+1));
    for(int i=1;i<n;i++)
        vp.push_back((2*vp[i-1])%(k+1));
    reverse(vp.begin(),vp.end());
    
    if(k!=1)
    {
        vn.push_back(1%(k-1));
        for(int i=1;i<n;i++)
            vn.push_back((2*vn[i-1])%(k-1));
        reverse(vn.begin(),vn.end());
    }
    vector<int> v;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        {
            if(k!=1)
            v.push_back((kn-vn[i]+(k-1))%(k-1));
            else
            v.push_back(-1);
        }
        else
            v.push_back((kp+vp[i])%(k+1));
    }
    for(int i=0;i<n;i++)
    {
        int g=v[i];
        int ans=1;
        if(g==-1)
        ans=0,g=0;
        while(g)
            g=g%__builtin_popcount(g),ans++;
        cout<<ans<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 6568
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	while(cin>>n>>m,n+m){
		vl a(n),b(m);
		cin>>a>>b;
		sort(all(b));

		vl c(1<<n,0);
		vvl dp(2,vl(1<<n,0));

		rep(i,m){
			int cur=i%2, nxt=1-i%2;
			fill(all(dp[nxt]),LINF);
			rep(s,1<<n){
				rep(j,n)if(!(s&(1<<j))){
					int ns=s|(1<<j);
					c[ns]=c[s]+a[j];
					chmin(dp[cur][ns],dp[cur][s]);
				}
				chmin(dp[nxt][s],dp[cur][s]+abs(b[i]-c[s]));
			}
		}
		puta(min(dp[m%2]));
	}
	return 0;
}


Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vi a(n);
  ll ans;
  rep(i, n){
    cin >> a[i];
    if(i==0){
      ans = a[0];
      continue;
    }
    ans=gcd(ans,a[i]);
  }
  print(ans);
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const* argv[]){
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);

    if (a+b==c || b+c==a || c+a==b) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

map<string, int> cnt;

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int ans = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        cnt[s]++;
        ans = max(ans, cnt[s]);
    }
    set<string> s;
    for (auto u : cnt) {
        if (u.y == ans) {
            s.insert(u.x);
        }
    }
    for (auto u : s) cout << u << '\n';
    return 0;
}

Measured memory_bytes: 33280
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n; cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++){
        cin >> x[i];
        y[i] = x[i];
    }

    sort(y, y + n);
    int mc_1 = y[n/2 - 1];
    int mc_2 = y[n/2];

    for (int i = 0; i < n; i++){
        if (x[i] <= mc_1) cout << mc_2 << endl;
        else cout << mc_1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define pb push_back
using namespace std;
typedef long long ll;
int n,ans=0;
int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
int main()
{
	n=read();
	FOR(i,1,n)
		if ((1<=i&&i<=9)||(100<=i&&i<=999)||(10000<=i&&i<=99999)||(1000000<=i&&i<=9999999)) ans++;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
	int n; cin>>n;
	int d,x; cin>>d>>x;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(int i=0;i<n;i++){
		int j=0;
		while(a[i]*j+1<=d){
			j++;
			sum++;
		}
	}
	cout<<sum+x<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());scan.nextLine();
		int a;
		int[] count = new int [100003];
		Arrays.fill(count, 0);
		for (int i =0;i < n; ++i){
			a=Integer.parseInt(scan.next());
			++count[a];
			++count[a+1];
			++count[a+2];
		}

		int ans =0;
		for (int i :count)ans=Math.max(i, ans);

		System.out.print(ans);



	}
}
//end


Measured memory_bytes: 49520
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    string s, acgt;
    acgt = "ACGT";
    cin >> s;
    int count = 0, res = 0;
    for(int i = 0; i < s.size(); ++i){
        bool isAcgt = false;
        for(int j = 0; j < 4; ++j){
            if(s[i]==acgt[j]){
                isAcgt = true;
            }
        }
        if(isAcgt){
            ++count;
        }else{
            res = max(res, count);
            count = 0;
        }
    }
    res = max(res, count);
    cout << res << endl;
}


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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    double l;
    cin >> l;
    double v = pow(l/3,3);
    printf("%lf",v);
}

int main()
{
    ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int r = tmp[0], d = tmp[1], x2000 = tmp[2];

        long x = (long) x2000;

        for (int i = 1; i <= 10; i++)
        {
            x = r*x - d;
            WriteLine(x);
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
const ll MOD = 1e9+7;
ll powmod(ll x, ll n){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret*=x;
         
            n-=1;
        }
        else{
            x*=x;
           
            n>>=1;
        }
    }
    return ret;
}

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n; cin >> n;
    string ans="";
    while(n){
        int x=n%26;
        if(x==0) x=26;
        ans+=(char)('a'+x-1);
        n=(n-x)/26;
    }
    reverse(ALL(ans));
    cout << ans << endl;
}


Measured memory_bytes: 3596