akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python
# -*- Coding: utf-8 -*-

def main():
    sample = raw_input()
    arr = []
    length = 0
    ans = 0
    for s in sample:
        arr.append(s)
    for t in arr:
        if t == 'A' or t == 'C' or t == 'G' or t == 'T':
            length += 1
        else:
            if ans < length:
                ans = length
                length = 0
    if ans < length:
        ans = length
        length = 0
    return ans

print(main())


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
    fast;
    string s,t;cin>>s>>t;
    ll ans=0;
    for(ll i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3728
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main() {
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        char c = i % 2 == 0 ? 'g' : 'p';
        if (c > s[i]) ans++;
        if (c < s[i]) ans--;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    ll N;
    cin >> N;
    ll A[N];
    ll sum = 0;
    rep(i, N){
        cin >> A[i];
        sum += A[i];
    }
    ll s = 0;
    ll i = 0;
    while(s < sum/2){
        s += A[i];
        i++;
    }
    ll t = s - A[i-1];
    ll ans1 = max(2*s - sum, sum- 2*s);
    ll ans2 = max(2*t - sum, sum - 2*t);
    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

string s,t="keyence";

int a,b;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
#ifdef LOCAL_DEFINE
	ifstream cin("input.in");
#endif
	
	cin >> s;
	for(int i=0;i<min(s.lg,t.lg);i++){
		if(s[i]!=t[i]) break;
		a++;
	}
	for(int i=0;i<min(s.lg,t.lg);i++){
		if(s[s.lg-i-1]!=t[t.lg-i-1]) break;
		b++;
	}
	if(a+b>=t.lg) cout << "YES";
	else cout << "NO";
	
#ifdef LOCAL_DEFINE
	cerr << "\nTime elapsed: " << 1.0*clock()/CLOCKS_PER_SEC << " \n";
#endif
}


Measured memory_bytes: 256
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
const int MAX_N = 1 << 10; 
int N, M, a[MAX_N][MAX_N], c[MAX_N][MAX_N]; 
int cnt[MAX_N]; 
/////////////////////////////////////////////////////////
int main () { 
	cin >> N >> M; 
	for (int i = 1; i < 1 << max(N, M); i++) cnt[i] = cnt[i ^ (i & -i)] + 1; 
	for (int i = 1; i < 1 << N; i++) 
		for (int j = 1; j < 1 << M; j++) c[i][j] = cnt[i & j] & 1; 
	for (int i = 1; i < 1 << N; i++) 
		for (int j = 1; j < 1 << M; j++) 
			a[i][j] = c[i][j] ^ c[i - 1][j] ^ c[i][j - 1] ^ c[i - 1][j - 1]; 
	for (int i = 1; i < 1 << N; i++, putchar('\n')) 
		for (int j = 1; j < 1 << M; j++) putchar(a[i][j] + '0'); 
    return 0; 
} 

Measured memory_bytes: 11768
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc =  new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();
		sc.close();
		
		int sum = 0;
		
		for(int i=a;i<=t+0.5;i+=a)
			sum += b;
	
		System.out.println(sum);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 

inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
const ll N=1e9+7;
int main()
{
   int n,k;
   cin>>n>>k;
   int arr[n];
   forl(i,0,n)cin>>arr[i];
   ll dp[k+1];//k
   forl(j,0,k+1)
   {
       if(j>arr[0]) dp[j]=0;
       else dp[j]=1;
   }
   //n*k*k
   forl(i,1,n)
   {
       int ps[k+1];
       ps[0]=dp[0];
       forl(t,1,k+1) ps[t]=modadd(ps[t-1],dp[t],N);
       rfor(j,k,0)
       {
           ll val=0;
           ll mini=j-min(j,arr[i]);
           if(mini==0)val=modadd(val,ps[j],N);
           else val=modadd(val,modsub(ps[j],ps[j-min(j,arr[i])-1],N),N);
        //   forl(t,0,arr[i]+1)
        //   {
        //       if(j>=t)val=modadd(val,dp[j-t],N);
        //   }
          dp[j]=val;    
       }
   }
   cout<<dp[k]<<endl;
}



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

int main() {
  int N;
  cin>>N;
  vector<int> p(N);
for (int i = 0; i < N; i++) {
  cin >> p.at(i);
}
  int X,P;
  X=0;
  P=0;
  for(int i=0;i<N;i++){
    X+=p.at(i);
  }
  while(2*P*N-2*X+N<0){
    P++;
  }
  int Z=0;
  for(int i=0;i<N;i++){
    Z+=(p.at(i)-P)*(p.at(i)-P);
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 256
from itertools import combinations

n,d = map(int,input().split())
count = 0

X = []
for i in range(n):
    X.append(list(map(int,input().split())))

for a,b in combinations(X,2):
    if (sum((a[i]-b[i])**2 for i in range(d))) ** (1/2) % 1 == 0:
        count += 1
print(count)





Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, Q; cin >> N >> Q;
  string S; cin >> S;
  vector<int> n(N, 0);
  rep(i, N-1) {
    if(S[i] == 'A' && S[i+1] == 'C') n[i+1] = n[i] + 1;
    else n[i+1] = n[i];
  }
  //rep(i, N) cout << n[i] << endl;
  
  rep(i, Q) {
    int l, r; cin >> l >> r;
    cout << n[r-1]-n[l-1] << endl;
  }
  


}

Measured memory_bytes: 4292
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int W[] = new int[N];
        for (int i=0;i<N;i++) {
            W[i] = sc.nextInt();
        }

        int ans = 1000000;
        int sum[] = new int[N+1];
        sum[0] = 0;
        for (int i=0;i<N;i++) {
            sum[i+1] = sum[i] + W[i];
        }

        for (int t=1;t<N;t++) {
            ans = Math.min(ans, Math.abs((sum[N] - sum[t]) - sum[t]));
        }

        System.out.println(ans);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

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

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

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

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

Measured memory_bytes: 22100
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// === debug ===
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// === end ===

int main() {
  int K;
  ins(K);

  int n = 0;
  rep(i, K) {
    n *= 10;
    n += 7;
    n %= K;
    if (n % K == 0) {
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3624
//By Bibi
///                 .-~~~~~~~~~-._       _.-~~~~~~~~~-.
///             __.'              ~.   .~              `.__
///           .'//                  \./                  \`.
///        .'//                     |                     \`.
///       .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \`.
///     .'//.-"                 `-.  |  .-'                 "-.\`.
///   .'//______.============-..   \ | /   ..-============.______\`.
/// .'______________________________\|/______________________________`.
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define dep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
const int MAXN=1010;
typedef long long ll;
int read(){
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int n,m;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();m=read();
	if(m%n==0){
		printf("%d\n",m/n );
		return 0;
	}
	dep(i,100000000,1){
		if(m%i!=0) continue;
		if(m/i>=n){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;

bool no_twins(const vi &xs, const int i) {
    const int sz = xs.size();
    const int l = i > 0 ? xs[i - 1] : -1;
    const int r = i < sz - 1 ? xs[i + 1] : -1;
    return l != xs[i] && r != xs[i];
}

void mark_multiples(const int max_a, vb &taken, const int x) {
    for (int y = x; y <= max_a; y += x) taken[y] = true;
}

int solve_on_sorted(const vi &xs) {
    if (xs.empty()) return 0;
    const int sz = xs.size();

    vb taken(xs.back() + 1, false);
    int ans = 0;

    for (int i = 0; i < sz; ++i) {
        if (i > 0 && xs[i] == xs[i - 1]) continue;
        if (!taken[xs[i]] && no_twins(xs, i)) ++ans;
        mark_multiples(xs.back(), taken, xs[i]);
    }

    return ans;
}

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

    int sz;
    cin >> sz;
    vi xs(sz, 0);
    for (auto &x : xs) cin >> x;
    sort(xs.begin(), xs.end());
    cout << solve_on_sorted(xs) << '\n';

    return 0;
}


Measured memory_bytes: 4264
#include <bits/stdc++.h>
using namespace std;
long long inf=1000000007,dp[1005][1005]={};
signed main(){
  bool nantyara;
  int h,w;
  char grid[1005][1005];
  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>grid[i][j];
    }
  }
  nantyara=true;

  for(int i=1;i<=h;i++){
    if(grid[i][1] == '#'){
      nantyara=false;
    }
    dp[i][1]=nantyara;
  }
  nantyara=true;

  for(int i=1;i<=w;i++){
    if(grid[1][i] == '#'){
      nantyara=false;
    }
    dp[1][i]=nantyara;
  }

  for(int i=2;i<=h;i++){
    for(int j=2;j<=w;j++){
      dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%inf;
      if(grid[i][j] == '#'){
	dp[i][j]=0;
      }
      dp[i][j]%=inf;
    }
  }
  cout<<dp[h][w]<<endl;
  return(0);
}


Measured memory_bytes: 9088
//A smoothe sea never made a skilled sailor.
//KEEP IT SIMPLE STUPID
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<n;i++)

int main()
{
   string s;
  cin>>s;
  if(s[2]==s[3] and s[4]==s[5])
    cout<<"Yes\n";
  else
    cout<<"No\n";
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
	int k;
	string s;
	cin >> k >> s;
	if (s.size() <= k) cout << s;
	else {
		while (s.size() > k) s.pop_back();
		cout << s << "...";
	}
}
void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define mem(a,b) memset(a,b,sizeof a)
using ll=long long;
using namespace std;
const int maxn=1e5+9;
int a[maxn]={};
int main() {
    int n;
	scanf("%d",&n);
	rep(i,0,n) scanf("%d",a+i);
	sort(a,a+n,greater<int>());
	int i=0;
	while(i<n-1&&a[i+1]>i+1) i++;
	int t1=a[i]-i-1,t2=0;
	while(i+t2<n-1&&a[i+t2+1]>i) t2++;
	if(t1&1||t2&1) puts("First");
	else puts("Second");
}

Measured memory_bytes: 4112
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner( System.in );
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int cnt = 1;
        if ( b != a ){
            cnt++;
        }
        if ( c != a ){
            if ( c != b ){
                cnt++;
            }
        }
        System.out.println( cnt );
    }
}

Measured memory_bytes: 9680
#include <iostream>

using namespace std;

int main()
{
    long long n, a[200010], xs=0, sum=0, cnt=0;
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    int right=0;
    for (int left=0; left<n; left++)
    {
        if (left>right) right++;
        while (right<n && (xs^a[right])==(sum+a[right]))
        {
            xs^=a[right];
            sum+=a[right];
            right++;
        }
        cnt+=right-left;
        sum-=a[left];
        xs^=a[left];
    }
    cout<<cnt<<'\n';
    return 0;
}


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

int main(){
    long int n,min,max,sum = 0;
    cin >> n;
    int a[10000];
    cin >> a[0];
    min = a[0];
    max = a[0];
    sum += a[0];
    for(int i = 1; i < n; i++){
        cin >> a[i];
        if(a[i]<min) min = a[i];
        if(a[i]>max) max = a[i];
        sum += a[i];
    }
    cout << min << " " << max << " " << sum << endl;
}


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

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

int main(){
  int N;
  cin >> N;
  
  N %= 10;
  
  if(N == 3) cout << "bon" << endl;
  else if(N == 0 || N == 6 || N == 1 || N == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

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

using namespace std ;

#define ll long long

int n ;
ll a = 1 , b = 1 ;

int main() {
	scanf( "%d" , &n ) ;
	for( int i = 1 ; i <= n ; i ++ ) {
		ll x , y ;
		scanf( "%lld%lld" , &x , &y ) ;
		ll t = max( ( a - 1 ) / x + 1 , ( b - 1 ) / y + 1 ) ;
		a = x * t ; b = y * t ;
 	}
	printf( "%lld\n" , 1ll * ( a + b ) ) ;
	return 0 ;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lol long long
#define mp(x,y) make_pair(x,y)
using namespace std;

const lol mod=1e9+7;

/*  author: H3XoRuSH  */

lol dp[1011][1011];
char x[1011][1011];

int main() {
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lol a,b;
    string temp;
    cin >> a >> b;
    for(lol i=0; i<a; i++){
        cin >> temp;
        for(lol j=0; j<b; j++) x[i][j]=temp[j];
    }
    for(lol i=0; i<a+1; i++){
        for(lol j=0; j<b+1; j++){
            if(i==0 || j==0) dp[i][j]=0;
            else if(x[i-1][j-1]=='#') dp[i][j]=0;
            else if(i==1 && j==1) dp[i][j]=1;
            else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }
    cout << dp[a][b];
    return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    LCIN(H);LCIN(W);
    LL ans = LINF;
    if(H%3==0){
       ans = min(0LL,ans);
    }
    if( W % 3==0 ){
        ans = min(0LL,ans);
    }
    for(int a = 0;a < H;a++){
        if(W%2==0){
            ans = min(max(a*W,(H-a)*(W/2))-min(a*W,(H-a)*(W/2)),ans);
          //  cout<<a*W<<" "<<(H-a)*(W/2)<<endl;

        }else{
            ans = min(max({a*W,(H-a)*(W/2),(H-a)*(1+W/2)})-min({a*W,(H-a)*(W/2),(H-a)*(1+W/2)}),ans);
         //   cout<<a*W<<" "<<(H-a)*(W/2)<<" "<<(1+W/2)*(H-a)<<endl;
        }
        if((H-a)%2 == 0){
            ans = min(max((H-a)/2*W,a*W)-min((H-a)/2*W,a*W),ans);
        }
    }
    for(int a = 0;a < W;a++){
        if(H%2 == 0){
            ans = min(max(a*H,(W-a)*(H/2))-min(a*H,(W-a)*(H/2)),ans);
        }else{
            ans = min(max({a*H,(W-a)*(H/2),(W-a)*(1+H/2)})-min({a*H,(W-a)*(H/2),(W-a)*(1+H/2)}),ans);
        }
        if((W-a)%2 == 0){
            ans = min(max((W-a)/2*H,a*H)-min((W-a)/2*H,a*H),ans);
        }
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n,i;
     double sum=0.0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
       scanf("%d",&a[i]);
    }
   sort(a,a+n);
   sum=sum+a[0];
   for(i=1;i<n;i++)
   {
       sum = (sum+a[i])/2;
   }

   printf("%lf",sum);

    return 0;
}





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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI h(n);
    REP(i, n) cin >> h[i];

    int ans = 0;
    int move_count = 0;
    REP(i, n - 1) {
        if (h[i] >= h[i + 1]) {
            move_count++;
        } else {
            ans = max(ans, move_count);
            move_count = 0;
        }
    }
    ans = max(ans, move_count);
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
const int MM = 1e9 + 7;
 
int n, m;
int K;
ll pw[2222];
ll sum[2222][2222];
 
void solve(int casi){
	cin>>n>>K;
	pw[0] = 1;
	for(int i = 1; i <= 2000; i++){
		pw[i] = (2 * pw[i-1]) % MM;
	}
	for(int i = 0; i <= n; i++)
		sum[0][i] = 1;
	for(int i = 1; i < K; i++){
		sum[i][0] = sum[i - 1][1];
		for(int j = 1; j <= n - i; j++){
			sum[i][j] = (sum[i][j-1] + sum[i-1][j+1]) % MM;
		}
	}
	cout<<((K!=n)?(sum[K - 1][n - K] * pw[n-K-1] % MM):sum[K - 1][n - K])<<endl;
}
 
 
int main(){
	solve(1);
	return 0;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    char a, b, c;
    cin>>a>>b>>c;
    Yes(a=='7'||b=='7'||c=='7');
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int n,i;
  cin>>n>>i;
  cout(n-i+1);
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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 dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a,b,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int sunu[] = new int[N];
    for(int i=0;i<K;i++){
      int d =  sc.nextInt();
      // System.out.println(i+"iii"); 
      for(int j=0; j<d; j++){
        // System.out.println(j+"ssd");  
        sunu[sc.nextInt()-1]++;
        // System.out.println(j+"aaa"); 
      }
    }
    int count = 0;
    for(int i=0;i<N;i++){
      if(sunu[i]==0){
        count++;
      }
    }
    System.out.println(count);  
  }
}





Measured memory_bytes: 46256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aman Kumar Singh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DDisjointSetOfCommonDivisors solver = new DDisjointSetOfCommonDivisors();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDisjointSetOfCommonDivisors {
        int MAXN = 1000005;
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            long a = nl();
            long b = nl();
            long gcd = gcd(a, b);
            long i = 0, cnt = 1;
            TreeSet<Long> tset = new TreeSet<>();
            for (i = 2; i < MAXN; i++) {
                boolean ok = true;
                while (gcd > 1 && gcd % i == 0) {
                    gcd /= i;
                    ok = false;
                }
                if (!ok)
                    cnt++;
            }
            if (gcd > 1)
                cnt++;
            pn(cnt);

        }

        long nl() {
            return in.nextLong();
        }

        void pn(long zx) {
            out.println(zx);
        }

        long gcd(long a, long b) {
            return (b == 0) ? a : gcd(b, a % b);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 22484
N = int(input())
Bs = list(map(int, input().split()))
As = []

for i in range(N):
    if i == N-1:
        As.append(Bs[i-1])
    elif i == 0:
        As.append(Bs[0])
    else:
        As.append(min([Bs[i-1],Bs[i]]))

print(sum(As))

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int[] a = new int[10];
		for (int i = 0; i < 10; i++)
		{
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[9]);
		System.out.println(a[8]);
		System.out.println(a[7]);
	}
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  string ans = S.size() <= K ? S : S.substr(0, K) + "...";
  cout << ans << endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int a,b,c,k;
	std::cin >> a >> b >> c >> k;
	int x=0;
	while(b<=a) { x++; b*=2; }
	while(c<=b) { x++; c*=2; }
	if(x<=k) print("Yes");
	else print("No");
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    
  int  P1,P2,R;
  string s;
  
    cin >>s;
R=stoi(s);
P1=(R/100);
P2=(R%100);
 
    if((P1>12 || P1==0) && (P2>12|| P2==0))
        cout << "NA";
        
     else 
        if (P1 == 0 || P1 > 12) 
        cout << "YYMM";
     else
        if (P2 == 0 || P2 > 12) 
        cout << "MMYY";
     else 
     cout <<"AMBIGUOUS";
     return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Function
import Data.Char
import Data.List
import Text.Read
import Text.ParserCombinators.ReadPrec

import qualified Data.ByteString.Char8 as B

newtype Pair a b = Pair { getPair :: (a, b) }

instance (Read a, Read b) => Read (Pair a b) where
  readPrec = Pair `dot` (,) <$> readPrec <* get <*> readPrec

instance (Show a, Show b) => Show (Pair a b) where
  show (Pair (a, b)) = show a ++ " " ++ show b

infixr 8 `dot`
dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d
dot = ((.).(.))

main :: IO ()
main = do
  n <- readLn
  putStrLn $ solve n

solve :: Int -> String
solve = reverse . map (chr . (+ ord '`')) . decode
 where
  decode n
    | q == 0    = [r]
    | otherwise = r : decode q
   where
    (q, r0) = (n - 1) `quotRem` 26
    r = r0 + 1


Measured memory_bytes: 3916
n, m = map(int, input().split())
mod = 10**9 + 7
dp = [1]*(n+1)
 
for _ in range(m):
    a = int(input())
    dp[a] = 0
 
for i in range(2, n+1):
    if dp[i]>0:
        dp[i] = (dp[i-1]+dp[i-2])%mod
 
print(dp[n])

Measured memory_bytes: 6900
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long n;
  cin>>n;
  long long u[n - 1], v[n - 1];
  REP(i, n - 1){
    cin>>u[i]>>v[i];
    u[i]--; v[i]--;
    if(u[i] > v[i]) swap(u[i], v[i]);
  }
  
  long long ans = 0;
  for(long long l = 1; l <= n; l++){
    ans += (n + l)*(n - l + 1) / 2 - (l - 1)*(n - l + 1);
  }
  REP(i, n - 1){
    ans -= (u[i] + 1) * (n - v[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6784
N = int(input())
B = list(map(int,input().split()))
A = []
while B:
    flag = 0
    for i in range(len(B)-1,-1,-1):
        if B[i] == i+1:
            A.append(B.pop(i))
            flag = 1
            break
    if flag==0:
        break
if len(B)>0:
    print(-1)
else:
    for i in range(len(A)-1,-1,-1):
        print(A[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long k,ans=0;
    string s;
    cin >> s>>k;
    long long snum[s.size()]={};
    for(int i =0;i<s.size();i++){
        snum[i] = (long long)s[i]-48;
        // cerr<<snum[i]<<endl;
    }

    if(k==1){
        ans = snum[0];
    }else{
        if(snum[0]!=1){
            ans = snum[0];
        }else{
            bool flag=true;
            long long counter =0;
            while(flag){
                if(snum[counter]==1){
                    counter++;
                }else{
                    flag=false;
                }
            }
            if(counter>=k){
                ans =1;
            }else{
                ans = snum[counter];
            }
            cerr << counter<<endl;
        }
        
    }

    cout << ans<<endl;
}

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

public class Main{
	static int N,K;
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		N=sc.nextInt();
		K=sc.nextInt();
		long[] bunbo=new long[N+1];
		Arrays.fill(bunbo,0);

		for(int i=1; i<=N; i++) {
			if(i>=K) {
				bunbo[i]=((long)N);
			}
			else {
				bunbo[i]=kettei(i);
			}
		}
		long bunsi=0;
		for(int i=1; i<=N; i++) {
			bunsi+=bunbo[1]/bunbo[i];
		}
		pl(((double) bunsi)/((double) bunbo[1]));
	}
	static long kettei(int ten) {
		int kaisu=0;
		while(ten<K) {
			ten*=2;
			kaisu++;
		}
		long ans=1;
		for(int i=0; i<kaisu; i++) {
			ans*=2L;
		}
		ans*=((long)N);
		return ans;
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}



Measured memory_bytes: 21332
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Integer n = scanner.nextInt();
        Integer d = scanner.nextInt();
        
        int result = 0;
        List<List<Integer>> points = new ArrayList<List<Integer>>();
        
        for(int k = 0 ; k < n ; k++) {
          List<Integer> point = new ArrayList<Integer>();
          for(int j = 0 ; j < d; j++) {
            point.add(scanner.nextInt());
          }
          points.add(point);
        }
        
        
        for(int f = 0; f < n-1 ; f++) {
          for(int s = f + 1; s< n ;s++) {
            if(hasIntDist(points.get(f),points.get(s))) {
               result++;
            }
          }
        }
        System.out.println(result);
    }
    
    static boolean hasIntDist(List<Integer> p1, List<Integer>p2) {
      int sum = 0;
      for(int a = 0 ; a < p1.size();a++) {
        sum += (p1.get(a) - p2.get(a)) * (p1.get(a) - p2.get(a));
      }
      
      return isSquare(sum);
    }
    static boolean isSquare(int num) {
      double root = Math.sqrt(num);
      
      int castedRoot = (int) (root / 1.0);
      return (castedRoot *castedRoot) == (num) ;
    }
}

Measured memory_bytes: 22228
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

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

  int maxv = -MAX * MAX;
  int minv = R[0];

  for ( int i = 1; i < n; i++ ) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }                                                                             

  cout << maxv << endl;

  return 0;
}
  

Measured memory_bytes: 1940
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=5001;
long long a[maxn],b[maxn],c[maxn];
long long ab[maxn*maxn],ans[maxn*maxn];
bool cmp(long long x,long long y){
	return x>y;
}

int main(){
	long long x,y,z,k;
	cin>>x>>y>>z>>k;
	for (int i=0;i<x;i++){
		cin>>a[i];
	}
	for (int i=0;i<y;i++){
		cin>>b[i];
	}
	for (int i=0;i<z;i++){
		cin>>c[i];
	}
	int m=0;
	for (int i=0;i<x;i++)
	for (int j=0;j<y;j++){
		ab[m]=a[i]+b[j];
		m++;
	}
	sort(ab,ab+m,cmp);
	sort(c,c+z,cmp);
	if (m>k) m=k;
	int n=0;
	for (int i=0;i<m;i++)
	for (int j=0;j<z;j++){
		ans[n]=ab[i]+c[j];
		n++;
	}
	sort(ans,ans+n,cmp);
	for (int i=0;i<k;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
} 

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

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

  vector<int>number(N); //配列初期化
  for(int i = 0; i < N; i++){
    cin >> number.at(i); //配列に代入
  }
  sort(number.begin(), number.end()); //ソートする
  reverse(number.begin(), number.end()); //降順に並べる

  //Aliceの得点
  int sum_A = 0;
  for(int k = 0; k < N; k += 2){
     sum_A += number.at(k);
  }

  //Bobの得点
  int sum_B = 0;
  for(int k = 1; k < N; k += 2){
    sum_B += number.at(k);
  }

  cout << sum_A - sum_B << endl;
  
}


Measured memory_bytes: 256
import sys
from collections import defaultdict


def main():
    N, A, *xlst = map(int, sys.stdin.read().split())
    x_p = []
    x_n = []
    x_z = 0
    for i in xlst:
        if A < i:
            x_p.append(i - A)
        elif i < A:
            x_n.append(A - i)
        else:
            x_z += 1
    x_p.sort(), x_n.sort()

    x_p_sum, x_n_sum = defaultdict(int, {0: 1}), defaultdict(int, {0: 1})

    for i in range(len(x_p)):
        for j in sorted(x_p_sum, reverse=1):
            x_p_sum[j + x_p[i]] += x_p_sum[j]

    for i in range(len(x_n)):
        for j in sorted(x_n_sum, reverse=1):
            x_n_sum[j + x_n[i]] += x_n_sum[j]

    res = sum(x_n_sum[i] * x_p_sum[i] for i in x_p_sum if i in x_n_sum)
    res *= 1 << x_z
    res -= 1
    print(res)


if __name__ == '__main__':
    main()

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

int main(){
    int64_t H,W;
    cin >> H >> W;

    int64_t ans;

    if (W == 1 || H == 1){
        ans = 1;
    } else {
        ans = (H*W+1)/2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
//  Floor Function 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

ll a, b, n;

ll f(ll x){
    ll A=floor(a*x/b);
    //cout << A << endl;
    ll B=floor(x/b);
    return A-a*B;
}



int main(){
    cin >> a >> b >> n;
    ll ans=0;
    if(b-1<=n){ans=f(b-1);}
    else{
        ans=f(n);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

char bit(int _n) {
	if (_n == 0) return '0';
	else return '1';
}

string ten2two(int ten_num) {
	string two_num = "0000000000";
	for (int i = 0; i < 10; ++i) {
		if (i < 9) {
			two_num[i] = bit(ten_num % 2);
			ten_num /= 2;
		}
		else {
			two_num[9] = bit(ten_num);
		}
	}
	return two_num;
}

int main() {
	int N;
	cin >> N;
	bool F[100][10];
	REP(i, N) {
		REP(j, 10) cin >> F[i][j];
	}
	ll P[100][11];
	REP(i, N) {
		REP(j, 11) cin >> P[i][j];
	}

	// 全探索
	ll ans = -mod;
	REPS(i, 1, pow(2, 10)) {
		string s = ten2two(i);

		ll prof = 0;
		REP(j, N) {
			int count = 0;
			REP(k, 10) {
				if (F[j][k] == true && s[k] == '1') count++;
			}
			prof += P[j][count];
		}
		ans = max(ans, prof);
	}
	cout << ans;
	system("pause");
	return 0;
}

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


 int main(){
     long long X,Y,A,B,C,Anum,Bnum,Cnum=0;
     long long tmp;
     cin >> X >> Y >> A >> B >> C;
     Anum =X;
     Bnum = Y;

     vector<long long> p,q,r,s;
     rep(i,A){
         cin >> tmp;
         p.push_back(tmp);
     }
     rep(i,B){
         cin >> tmp;
         q.push_back(tmp);
     }
     rep(i,C){
         cin >> tmp;
         r.push_back(tmp);
     }
     sort(p.rbegin(),p.rend());
     sort(q.rbegin(),q.rend());
     sort(p.rbegin(),p.rend());

     rep(i,X) s.push_back(p[i]);
     rep(i,Y) s.push_back(q[i]);
     rep(i,C) s.push_back(r[i]);
     sort(s.rbegin(),s.rend());
     long long sum = 0;
     rep(i,X+Y) sum += s[i];
     
     /*
     rep(i,C){
         if(Anum-1>=0 &&p[Anum-1] < r[i] && (Bnum-1 ==0 ||p[Anum-1] <= q[Bnum-1] )){
             Anum--;
             Cnum++;
         }
         else if (Bnum-1 >= 0&& q[Bnum -1] < r[i] && (Anum-1 ==0 || q[Bnum-1] < p[Anum-1])){
             Bnum--;
             Cnum++;
         }
         else{
             break;
         }
     }
     long long sum=0;
     rep(i,Anum) sum += p[i];
     rep(i,Bnum) sum += q[i];
     rep(i,Cnum) sum += r[i];
     */
    /*
    long long a=0,b=0,c=0,sum=0;
    rep(i,X+Y){
        if(a<X && p[a]>=q[b]&& p[a]>=r[c]){
            sum+= p[a];
            a++;
        }else if (b < Y && q[b] >= p[a] && q[b] >=r[c]){
            sum+= q[b];
            b++;
        }
        else{
            sum+= r[c];
            c++;
    }
    }
*/

     cout << sum << endl;
     return 0;
 }
 



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

int main() {
  ll n;
  ll ans=1;
  cin>>n;
  for(int i=1; i<=n; i++){
    ans*=i;
    ans%=1000000007;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256