akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int k, x;

int main() {
	cin >> k >> x;
	
	k--;
	incII(i, x - k, x + k) { cout << i << " "; }
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int pS[100005][2];

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

	cin >> N >> M;

	ll ans1 = 0, ans2 = 0;
	for (int i = 0; i < M; i++) {
		int p;
		string S;

		cin >> p >> S;
		if (pS[p][1]) {
			continue;
		}
		if (S == "WA") {
			pS[p][0]++;
		
		} else {
			pS[p][1]++;
			ans1++;
			ans2 += pS[p][0];
		}
	}

	printf("%lld %lld\n", ans1, ans2);

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll =long long ;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(5);
  vec={2,3,5,7,11};
  if(a<11){
    for(ll i=0;;i++){
      if(vec.at(i)>=a){
        cout<<vec.at(i)<<endl;
        return 0;
      }
    }
  }
  for(ll i=13;;i++){
    for(ll j=0;j<vec.size();j++){
      if(i%vec.at(j)==0)break;
      if(j==vec.size()-1){
        vec.push_back(i);
        if(a<=i){
          cout<<i<<endl;
          return 0;
        }
      }
    }
  }
    
    
}


Measured memory_bytes: 3720
s = input()

a = [0]*(len(s)+1)

for i in range(len(s)):
    if s[i] == "<":
        a[i+1] = max(a[i]+1, a[i+1])

for i in range(len(s))[::-1]:
    if s[i] == ">":
        if a[i] <= a[i+1]:
            a[i] = a[i+1] + 1

print(sum(a))


Measured memory_bytes: 73456
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

int main(){
    int x;
    cin >> x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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


int main ()
{
   int N,K;
   string S;
   cin >>N>>K;
   cin >>S;
   char t=S.at(K-1);
   t += 32;
   string a;
   a=t;
   S.replace(K-1,1,a);
   cout << S<< endl;
}
   

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main(){
	int n = read(), sum = 0, h = read(), w = read();
	for (int i = 0; i < n; i++) {
		if (read() >= h & read() >= w) {
			sum++;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    W="dream dreamer erase eraser".split(" ")
    #print(W)
    S=input()
    t=[S]
    while(t!=[]):
        temp=t.pop()
        for w in W:
            m=len(w)
            if(temp[-m:])==w:
                f=temp[:-m]
                if f=="":
                    print("YES")
                    return
                t.append(f)
    print("NO")
#%%submit!
resolve()

Measured memory_bytes: 134424
#include <stdio.h>

int main () {
    int ab = 0;
    int bc = 0;
    int ca = 0;
    int area = 0;
    
  
    scanf("%d %d %d", &ab, &bc, &ca);

    
    area = ((ab*bc)/2);
    
    printf("%d\n", area);
    
    return 0;
}

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


int main() {
	int N, M, D; cin >> N >> M >> D;
	vector<string>field(N);
	for (int i = 0; i < N; ++i) {
		cin >> field[i];
	}
	int ans = 0;
	for (int y = 0; y < N; ++y) {
		for (int a = 0; a <= M - D; ++a) {
			bool ok = true;
			for (int x = a; x < a + D; ++x) {
				if (field[y][x] == '#')ok = false;
			}
			if (ok)ans++;
		}
	}
	for (int x = 0; x<M; ++x) {
		for (int a = 0; a <= N - D; ++a) {
			bool ok = true;
			for (int y = a; y < a + D; ++y) {
				if (field[y][x] == '#')ok = false;
			}
			if (ok)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int N = 100000 + 7;

int dp[N];

int main() {
       dp[0] = 1;
       for(int i = 1; i < N; i++) {
            for(int j = 0; j <= 5; j++) {
                    if(i >= 100 + j) dp[i] |= dp[i - 100 - j];
            }
       }
       int n; cin >> n; cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int h,w,n;
    cin >> h >> w >> n;
    VVI s(w);
    int x,y;
    REP(i,0,n) {
        cin >> x >> y;
        --x; --y;
        s[y].push_back(x);
    }
    REP(i,0,w) sort(all(s[i]));
    int cnt = 0;
    VI add(w);
    REP(i,0,w) {
        REP(j,0,s[i].size()) if (s[i][j] - cnt == i) {
            //cout << i << " " << j << " " << s[i][j] << endl;
            ++cnt;
            while (j + 1 < s[i].size() && s[i][j+1] == s[i][j] + 1) {
                //cout << i << " " << j << " " << s[i][j] << endl;
                ++cnt;
                ++j;
            }
            break;
        }
        add[i] = cnt;
    }

    int ans = h;
    REP(i,0,w) {
        if (s[i].size() == 0) continue;
        auto it = upper_bound(all(s[i]), i + add[i]);
        if (it == s[i].end()) continue;
        ans = min(ans, *upper_bound(all(s[i]), i + add[i]));
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
#include<string.h>
#define M 1046527
#define NIL (-1)
#define L 14
char H[M][L];
int getChar(char ch){
    if(ch=='A')return 1;
    else if(ch=='C')return 2;
    else if(ch=='G')return 3;
    else if(ch=='T')return 4;
    else return 0;
}
long long getKey(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++){
        sum+=p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}
int h1(int key){return key%M;}
int h2(int key){
    return 1+(key%(M-1));}
int find(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}
int insert(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}
int main(){
    int i,n,h;
    char str[L],com[9];
    for(i=0;i<M;i++)H[i][0]='\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",com,str);   
        if(com[0]=='i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
        }
        return 0;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 300005
using namespace std;

int main()
{
    FLASH
    ll n,m,k,s1 = 0,s2 = 0;
    cin >> n >> m >> k;
    ll a[n],b[m],pa[n];
    vector<ll> pb(m);

    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i],s1 += a[i],pa[i] = s1;
        if(s1 <= k){
            ans = i + 1;
        }
    }
    for(int i = 0; i < m; i++){
        cin >> b[i],s2 += b[i],pb[i] = s2;
        if(s2 <= k){
            ans = max(ans,i + 1);
        }
    }
    for(int i = 0; i < n; i++)
    {
        ll val = k - pa[i];
        if(val < 0)
            break;
        int pos = (upper_bound(pb.begin(),pb.end(),val) - pb.begin());
        
        if(pos != 0){
            if(pos > 0 && val < pb[pos - 1])
                pos--;
        }
        ans = max(ans,pos + i + 1);
    }
    cout << ans;
    return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    int n,r;cin >> n >> r;
    if(n>=10)cout << r << endl;
    else cout << r + 1000 - 100*n << endl;
    return 0;
}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> d(n, 0);
	int amax = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		d[a]++;
		amax = max(a, amax);
	}
	bool flag = true;

	if (amax % 2 == 0) {
		for (int i = 1; i < amax / 2; i++) flag &= (d[i] == 0);
		flag &= (d[amax / 2] == 1);
		for (int i = amax / 2 + 1; i <= amax; i++) flag &= (d[i] >= 2);
	} else {
		for (int i = 1; i < (amax + 1) / 2; i++) flag &= (d[i] == 0);
		flag &= (d[(amax + 1) / 2] == 2);
		for (int i = (amax + 1) / 2 + 1; i <= amax; i++) flag &= (d[i] >= 2);
	}
	cout << (flag ? "Possible" : "Impossible") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	string a,b,c;
	cin >> a >> b >> c;
	
	cout << (char)(a[0]+('A'-'a')) << (char)(b[0]+('A'-'a')) << (char)(c[0]+('A'-'a')) << endl;
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++) {
    cin >> A[i];
  }

  int max = 0;

  for(int i=0;i<N;i++) {
    for(int j=i+1;j<N;j++) {
      if(abs(A[i]-A[j]) > max) {
        max = abs(A[i]-A[j]);
      }
    }
  }

  cout << max << endl;
}

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

int main(){
  string s;
  cin >> s;
  
  for (int i=0; i<s.size()-2; i++){
    if (s.at(i) == s.at(i+1)){
      if (s.at(i+1) == s.at(i+2)){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  
  cout << "No" << endl;
  

    
  
      
      
  return 0;
      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    ll S;
    cin>>S;
    ll x2=1e9,x3,y2=1,y3;
    //S=|x2*y3-x3*y2|
    //y3を決める,Sをx2で割った商が欲しいけど,余りは切り上げとしたいので(a+b-1)/bする
    //(絶対値を考慮するとx2*y3<Sの場合にx3>x2になってしまう.切り上げるとx2*y3>=Sにできる)
    y3=(S+x2-1)/x2;
    x3=x2*y3-S;
    cout<<0<<" "<<0<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
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; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




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

    int N;
    while (cin >> N) {
        vector<long long> a(N);
        for (int i = 0; i < N; ++i) cin >> a[i];
        int num = 0;
        long long mi = 1LL<<60;
        long long sum = 0;
        for (int i = 0; i < N; ++i) {
            if (a[i] < 0) num += 1;
            chmin(mi, abs(a[i]));
            sum += abs(a[i]);
        }
        if (num % 2 == 0) cout << sum << endl;
        else cout << sum - mi*2 << endl;
    }
}



















Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); i++){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    uint N, K; cin >> N >> K;
    
    vector<int> vXm, vXp; // minus, plus
    vXp.push_back(0);
    for(uint i=0; i<N; ++i){
        int x; cin>>x;
        if(x<0){ vXm.push_back(abs(x));
        } else { vXp.push_back(x);
        }
    }
    vXm.push_back(0);
    reverse(vXm.begin(), vXm.end());
    
    int64 time=INT64_MAX;
    for(uint i=0; i<K; ++i){
        if(  i>=vXm.size()){ continue; }
        if(K-i>=vXp.size()){ continue; }
        int64 time_m=0;
        int64 time_p=0;
        if(i<vXm.size()){ time_m = vXm[i]; }
        time_p = vXp[K-i] - vXp[0];
        time = min(time, time_m*2 + time_p);
    }
    for(uint i=0; i<K; ++i){
        if(  i>=vXp.size()){ continue; }
        if(K-i>=vXm.size()){ continue; }
        int64 time_p=0;
        int64 time_m=0;
        if(i<vXp.size()){ time_p = vXp[i]; }
        time_m = vXm[K-i];
        time = min(time, time_p*2 + time_m);
    }
    
    cout << time << endl;
    
    return 0;
}


Measured memory_bytes: 1020
#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 n, r;
  cin >> n >> r;

  int result;
  if (n < 10) {
    result = r + 100 * (10 - n);
  } else {
    result = r;
  }

  cout << result << endl;

  return 0;
}


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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000'000'007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//




int main() {
    IOS

    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(all(a));
    vector<pll > ans;
    ll pos_ind = -1;
    for (int i = 0; i < n; ++i) {
        if (a[i] >= 0) {
            pos_ind = i;
            break;
        }
    }
    ll cur_val = 0;
    if (pos_ind != -1 && pos_ind != n - 1) {
        if(pos_ind == 0) {
            cur_val = a[pos_ind];
            for (int i = pos_ind + 1; i < n - 1; ++i) {
                ans.push_back({cur_val, a[i]});
                cur_val = cur_val - a[i];
            }
            ans.push_back({a.back(), cur_val});
            cur_val = a.back() - cur_val;
        }else{
            cur_val = a[pos_ind - 1];
            for (int i = pos_ind; i < n - 1; ++i) {
                ans.push_back({cur_val, a[i]});
                cur_val = cur_val - a[i];
            }
            ans.push_back({a.back(), cur_val});
            cur_val = a.back() - cur_val;
        }
    } else {
        cur_val = a.back();
        pos_ind = n;
    }
    for (int i = 0; i < pos_ind - 1; ++i) {
        ans.push_back({cur_val, a[i]});
        cur_val = cur_val - a[i];
    }
    cout << cur_val << '\n';
    for (auto i : ans) {
        cout << i.first << ' ' << i.second << '\n';
    }
    return 0;
}

Measured memory_bytes: 4336
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
	int a, b, C;
	double S, L, h;

	S = L = h = 0;
	cin >> a >> b >> C;

	S = 0.5 * a * b * sin((C * M_PI) / 180);
	L = a + b + sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos((C * M_PI) / 180)));
	h = (2 * S) / a;

	cout << setprecision(16) << S << endl;
	cout << L << endl;
	cout << h << endl;

	return 0;
}

Measured memory_bytes: 1284
N,A,B = map(int,input().split())
s = 0
ans = 0
for i in range(1,N+1):
    s=0
    n = i
    while True:
        s += n%10
        n = n//10
        if n ==0:
            break
    if s >=A and s <=B:
        ans+=i

print(ans)


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

void solve (int n)
{
    int cnt = 0;
    forn (i, n)
    {
        int a;
        cin >> a;
        cnt += (a % 2 == 1);
    }

    if (cnt % 2 == 1)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
}

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

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if a[i+k][j:j+m] != b[k]:
                break
        else:
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3064
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();
        if (a == b && b == c && c == a) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> a(N);
  rep(i, N)
    cin >> a[i];
  vector<ll> psum(N, 0);
  psum[0] = 0;
  for (ll i=1; i<N; i++) {
    psum[i] = psum[i-1] + (a[i] >= a[i-1]);
  }
  //cout << "a   : "; rep(i, N) { cout << a[i] << " "; } cout << endl;
  //cout << "psum: "; rep(i, N) { cout << psum[i] << " "; } cout << endl;

  ll ans = 1;
  bool sorted = psum[K-1] == psum[0] + K-1;
  set<ll> s;
  rep(i,K)
    s.insert(a[i]);
  for (ll i=1; i<=N-K; i++) {
    bool already_exist = false;
    // a[i .. i+k-1] がソート済みかつ、すでにソート済みのものが存在
    if (psum[i+K-1] == psum[i] + K-1) {
      if (sorted) {
        already_exist = true;
      }
      sorted = true;
    }

    // xが最小値 かつ yが最大値
    ll x = a[i-1], y = a[i+K-1];
    if (x <= *s.begin() && x <= y && y >= *s.rbegin() && y >= x) {
      already_exist = true;
    }
    s.insert(y);
    s.erase(s.find(x));

    if (!already_exist)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
//vector<ll> vll;
ll num[ten52];
ll path[ten52];

int main(void)
{
    //double ans=0.0,d,d1,d2;
    long long int m,n,i,j,k=0,h,save;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    //char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>a1>>a2;
    cout<<a1*a2;
    return 0;
}





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

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	string s,t;cin>>s>>t;
	reverse(all(t));
	if(s == t)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 3536
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int n, k;
        cin >> k >> n;
        int a[n];
        loop(0, n) {
            cin >> a[i];
        }
        sort(a, a + n);
        int ans = 0;
        int i = 0;
        while (true) {
            if (binsearch(a, 0, n - 1, k - i) == -1) {
                ans = k - i;
                break;
            }
            if (binsearch(a, 0, n - 1, k + i) == -1) {
                ans = k + i;
                break;
            }
            i++;
        }

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


Measured memory_bytes: 3684
n,x,y = map(int,input().split())
l = [0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        dis = min(j-i, 1+abs(x-i)+abs(y-j))
        l[dis-1] += 1
for i in l:
    print(i)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <tuple>
#include <functional>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;
typedef tuple<int, int, int> tp;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

class UnionFind {
public:
    vector<int> par;
    int cnt;
    UnionFind(int n) {
        par.resize(n);
        REP(i, 0, n) {
            par[i] = i;
        }
        cnt = n;
    }
    int Find(int n) {
        return (n == par[n] ? n : par[n] = Find(par[n]));
    }
    bool Union(int a, int b) {
        a = Find(a);
        b = Find(b);
        if (a == b) return false;
        par[a] = b;
        cnt--;
        return true;
    }
    int getCnt() {
        return cnt;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H;
    cin >> W >> H;
    priority_queue<tp, vector<tp>, greater<tp>> pq;
    UnionFind uf[2] = {UnionFind(W + 1), UnionFind(H + 1)};

    REP(i, 0, W) {
        int p;
        cin >> p;
        pq.emplace(p, i, 0);
    }
    REP(i, 0, H) {
        int q;
        cin >> q;
        pq.emplace(q, i, 1);
    }
    lli ans = 0;

    while (pq.size()) {
        int ind, t;
        lli c;
        tie(c, ind, t) = pq.top();
        pq.pop();
        ans += (uf[!t].getCnt()) * c;
        uf[t].Union(ind, ind + 1);
    }

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


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

int main() {
	// your code goes here
	long long int n,i,j,c=0,l=0;
	cin >> n;
	string s,ss="";
	cin >> s;
	l=s.length();
	if(l<=n)
	{
		cout << s << endl;
	}
	else{
		for(i=0;i<n;i++)
		{
			cout << s[i];
		}
		cout << "...";
	}
	
	return 0;
}

Measured memory_bytes: 3628
def root(i):
    if par[i] < 0:
        return i
    else:
        return root(par[i])

def size(a):
    return -par[root(a)]

def union(a,b):
    a = root(a)
    b = root(b)
    if a == b:#親が等しい
        return False
    if size(a) < size(b):#サイズが大きい方に繋げる
        a,b = b,a
    par[a] += par[b]
    par[b] = a
    return True

n,m = map(int,input().split())
bridge = []
for i in range(m):
    bridge.append([int(j)-1 for j in input().split()])
ans = 0
for i in range(m):
    par = [-1 for _ in range(n)]
    for j in range(m):
        if j != i:
            union(bridge[j][0],bridge[j][1])
    cnt = [ i for i in par if i < 0]
    if len(cnt) > 1:
        ans += 1
print(ans)

Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    int mx=*max_element(a,a+n);
    int sum=0;
    for(int i=0;i<n-1;i++){
        sum+=a[i];
    }
    if(sum>mx){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
import time

class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

def insert(z):
    global root
    y = None
    x = root
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def find(node, key):
    if node is None:
        return False
    elif node.key == key:
        return True
    elif node.key > key:
        return find(node.left, key)
    else:
        return find(node.right, key)

def inorderTreeWalk(node):
    global In
    if node:
        inorderTreeWalk(node.left)
        In.append(str(node.key))
        inorderTreeWalk(node.right)

def preorderTreeWalk(node):
    global Pre
    if node:
        Pre.append(str(node.key))
        preorderTreeWalk(node.left)
        preorderTreeWalk(node.right)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    del lines[0]

    root = None
    for line in lines:
        if line[0] == "p":
            In = []
            Pre = []
            inorderTreeWalk(root)
            print " " + " ".join(map(str, In))
            preorderTreeWalk(root)
            print " " + " ".join(map(str, Pre))
        else:
            com = line.split()
            if com[0][0] == "i":
                insert(Node(int(com[1])))
            else:
                if find(root, int(com[1])):
                    print "yes"
                else:
                    print "no"

Measured memory_bytes: 244300
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if (x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0)
	printf("Yes\n");
	else
	printf("No\n");
	
	return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=310;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int pri[7]={2,3,5,7,11,13,17};
int c[7],m[399],x[399],n;
int ans;
inline void dfs(int now) {
	int i,k,t,p;
	if (now==7) {
		map<int,int>s;
		for (i=1;i<=n;i++) {
			k=m[i];
			for (t=0;t<7;t++) {
				for (p=0;!(k%pri[t]);p++,k/=pri[t]);
				if (p>c[t]) break;
			}
			if (t==7) s[k]+=x[i];
		}
		t=s[1];s[1]=0;
		for (auto &it:s) t+=max(0,it.second);
		upmax(ans,t);
	} else for (c[now]=0,k=1;k<=300;k*=pri[now],c[now]++) dfs(now+1);
}
int main()
{
	n=gi();
	for (int i=1;i<=n;i++)
		m[i]=gi(),x[i]=gi();
	dfs(0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
import sys
input=sys.stdin.readline

N,M = map(int, input().split())

l = set()
r = set()
for i in range(M):
    li,ri = map(int, input().split())
    l.add(li)
    r.add(ri)
x = min(r) - max(l)
if x<0:
    print(0)
else:
    print(x+1)


Measured memory_bytes: 18844
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(int argc, char const *argv[])
{
    int A,B,C,D;
    int ans=0;
    cin>>A>>B>>C>>D;
    ans=min(A,B)+min(C,D);
    cout<<ans;
    /* code */
    return 0;
}


Measured memory_bytes: 256
il1 = [int(k) for k in input().split()]
N = il1[0]
K = il1[1]
H = [int(k) for k in input().split()]

H.sort(reverse=True)

if len(H) <= K:
    counter = len(H)
else:
    counter = K

for k in range(counter):
    H[k] = 0

S = sum(H)

print(S)


Measured memory_bytes: 26764
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, m, k;

ll mod_pow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

ll mod_inverse(ll x) {
    return mod_pow(x, mod-2);
}

const int max_n = 200100;
ll fact[max_n];
ll fact_inv[max_n];
void calc_fact() {
    fact[0] = 1;
    for (ll i = 1; i < max_n; i++)
        fact[i] = (fact[i-1] * i) % mod;
    fact_inv[max_n-1] = mod_inverse(fact[max_n-1]);
    for (ll i = max_n-2; i >= 0; i--)
        fact_inv[i] = (fact_inv[i+1] * (i+1)) % mod;
}
ll mod_comb(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return (fact[n] * fact_inv[k] % mod) * fact_inv[n-k] % mod;
}

ll solve() {
    calc_fact();
    ll base = 0;
    for (int i = 1; i < m; i++) {
        base += i * (m-i) * n * n;
        base %= mod;
    }
    for (int i = 1; i < n; i++) {
        base += i * (n-i) * m * m;
        base %= mod;
    }
    return base * mod_comb(n*m-2,k-2) % mod;
}

void input() {
    cin >> n >> m >> k;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define INF 2000000000
#define ull unsigned long long

int compare_bigorder(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main(){
    int n,i,a[101]={},Alice=0,Bob=0;
    scanf("%d",&n);
    for (i=0; i<n; i++) scanf("%d",&a[i]);
    qsort(a, n, sizeof(a[0]), compare_bigorder);
    for (i=0; i<n; i+=2) Alice+=a[i];
    for (i=1; i<n; i+=2) Bob+=a[i];
    printf("%d",Alice-Bob);
    return 0;
}



Measured memory_bytes: 128
program prob4
    implicit none
    integer::N, i, j, ans, tmp, k
    character(len=30005)::S
    character(len=3)::t
    read(*,*) N
    read(*,*) S

    ans = 0
    do i = 0, 999
        k = 2
        tmp = i
        do j = 1, N
            if(S(j:j) .eq. char(ichar('0') + tmp/10**k)) then
                tmp = tmp - tmp/10**k*10**k
                k = k-1
            end if
            if(k == -1) then
                ans = ans + 1
                exit
            end if
        end do
    end do
    write(*,*) ans

    stop
end program

Measured memory_bytes: 3020
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;
static const int M = 22370000;
bool Hash[M];

inline int convertChartoNum(char c)
{
	if (c == 'A')
	{
		return(1);
	}
	else if (c == 'C')
	{
		return(2);
	}
	else if (c == 'G')
	{
		return(3);
	}
	else if (c == 'T')
	{
		return(4);
	}
}

int getKey(string s)
{
	int sum = 0;
	int p = 1;
	for (int i = 0; i < s.size(); ++i)
	{
		sum += p * convertChartoNum(s[i]);
		p *= 4;
	}
	return(sum);
}

int find(string s)
{
	int key = getKey(s);
	if (Hash[key])
	{
		return(1);
	}
	else
	{
		return(0);
	}
}

void insert(string s)
{
	int key = getKey(s);
	if (Hash[key])
	{
		return;
	}
	else
	{
		Hash[key] = true;
		return;
	}
}

void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		string command, str;
		cin >> command >> str;
		if (command[0] == 'i')
		{
			insert(str);
		}
		else
		{
			if (find(str) == 1)
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 2544
N,K = map(int,input().split())
TD = [[int(j) for j in input().split()] for i in range(N)]
TD = sorted(TD,key=lambda x:-x[1])
point = 0
stack = []
kind = set()

for t,d in TD[:K]:
  point+=d
  if t in kind:
    stack.append(d)
  else:
    kind.add(t)

point+=len(kind)**2
ans = point

for t,d in TD[K:]:
  if not stack:
    break
  if not t in kind:
    point+=d-stack.pop()+2*len(kind)+1
    kind.add(t)
    ans=max(ans,point)

print(ans)

Measured memory_bytes: 31104
#include<iostream>
#include<algorithm>
#include<memory.h>
#include<string> 
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
const int maxn=5e5+10;
ll a[maxn];

int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	ll last=a[1];ll ans=0;
	for(int i=2;i<=n;i++){
		if(a[i]<last) ans+=last-a[i];
		if(a[i]>last) last=a[i];
	}
	cout<<ans;
	return 0;	
} 

Measured memory_bytes: 4700
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int dp[1010][1010] = {};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int H,W;
  cin>>H>>W;
  char a[H][W];
  REP(i,H)REP(j,W) cin >> a[i][j];
  REP(j,W){
    if(a[0][j] =='.') dp[0][j] = 1;
    else break;
  }
  REP(i,H){
    if(a[i][0] =='.') dp[i][0] = 1;
    else break;
  }
  REP2(i,1,H)REP2(j,1,W){
    if(a[i][j] == '#'){
      dp[i][j] = 0;
      continue;
    }
    dp[i][j] = dp[i][j-1] + dp[i-1][j];
    dp[i][j] %= MOD;
  }
  cout << dp[H-1][W-1];
  
  return 0;
}

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

using namespace std;

const double INF = 1000000000;

struct UnionFind {  // The range of node number is u 0 v n-1
	vector<int> rank, parents;
	UnionFind() {}
	UnionFind(int n) {  // make n trees.
		rank.resize(n, 0);
		parents.resize(n, 0);
		for (int i = 0; i < n; i++) {
			makeTree(i);
		}
	}
	void makeTree(int x) {
		parents[x] = x;  // the parent of x is x
		rank[x] = 0;
	}
	bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
	void unite(int x, int y) {
		x = findRoot(x);
		y = findRoot(y);
		if (rank[x] > rank[y]) {
			parents[y] = x;
		}
		else {
			parents[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}
	int findRoot(int x) {
		if (x != parents[x]) parents[x] = findRoot(parents[x]);
		return parents[x];
	}
};

// 辺の定義
struct Edge {
	int u;
	int v;
	double cost;
};

//セル定義
struct cell {
	double x;
	double y;
	double z;
	double r;
};

bool comp_e(const Edge &e1, const Edge &e2) { return e1.cost < e2.cost; } // 辺を直接比較するための関数

double Kruskal(vector<Edge> &edges, int v) {

	double sum = 0;  // 最小全域木の重みの総和

	sort(edges.begin(), edges.end(), comp_e); // 辺の重みでソート

	UnionFind uft = UnionFind(v);

	for (unsigned int i = 0; i < edges.size(); i++) {
		if (!uft.isSame(edges[i].u, edges[i].v)) { // 閉路にならなければ加える
			uft.unite(edges[i].u, edges[i].v);
			sum += edges[i].cost;
		}
	}

	return sum;
};

int main() {

	while (1) {
		int n;
		cin >> n;
		if (n == 0) { break; }

		vector<cell> cell(n);
		for (int i = 0; i < n; i++) {
			cin >> cell[i].x >> cell[i].y >> cell[i].z >> cell[i].r;
		}

		vector<Edge> edges;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {

				if (i == j) { continue; }

				double dist = pow(
					(cell[i].x - cell[j].x)*(cell[i].x - cell[j].x)
					+ (cell[i].y - cell[j].y)*(cell[i].y - cell[j].y)
					+ (cell[i].z - cell[j].z)*(cell[i].z - cell[j].z)
					, 0.5)
					- cell[i].r - cell[j].r;
				if (dist < 0) { dist = 0; }

				edges.push_back({ i,j,dist });

			}
		}

		double krs = Kruskal(edges, n);

		cout << fixed << setprecision(3) << krs << endl;
	}
	return 0;
}


Measured memory_bytes: 3876
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
#define fcout cout<<fixed<<setprecision(10)
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    string s; cin>>s;
    int sl=s.size();
    cout<<((sl%2)^(s[0]==s[sl-1])?"First":"Second")<<endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
  int R,G,B,N;
  cin>>R>>G>>B>>N;
  int ans = 0;
  for(int i = 0;i <= N;i += R){
    for(int j = 0;j <= N - i;j += G){
		if((N - i - j) % B == 0)
          ans++;
    }
  }
  cout<<ans;
  return 0;
}

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

int main(){

  int N, num;
  cin >> N;
  bool prime;
  long ans = 1;

  for(int i=2; i<=N; i++){
    prime = true;
    for(int j=2; j<i; j++){
      if(i%j==0){
        prime = false;
        break;
      }
    }
    if(prime){
      num = 0;
      for(int k=1; k<10; k++) num += N/pow(i,k);
      ans *= num+1;
      ans %= 1000000007;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384