akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



void solve(){
    ll a,b,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[5];
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    sort(a,a+5);
    for(int i=4;i>=0;i--){
        if(i==0){
            cout<<a[i]<<endl;
        }
        else{
        cout<<a[i]<<" ";
        }
    }
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ");
		int N = Integer.parseInt(line[0]);
		int K = Integer.parseInt(line[1]);
		int[] h = Arrays.stream(sc.nextLine().split(" ")).mapToInt(s -> Integer.parseInt(s)).toArray();
		int[] dp = Arrays.stream(new int[N]).map(s -> Integer.MAX_VALUE / 2).toArray();

		for (int i = 0; i < N; i++) {
			if (i == 0) {
				dp[i] = 0;
			} else {
				for (int j = 1; j <= K; j++) {
					if (i - j >= 0) {
						dp[i] = Math.min(dp[i], Math.abs(h[i] - h[i - j]) + dp[i - j]);
					}
				}
			}
		}
		System.out.println(dp[N - 1]);
	}
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    sort(a, a+n, greater<ll>());
    ll edge = 0;
    int cnt = 1;
    vll cand;
    rep(i, n){
        if(edge != a[i])
            edge = a[i];
        else{
            ++cnt;
            if(cnt >= 4){
                ppp(edge*edge);
                return 0;
            }
            else if(cnt >= 2){
                cand.push_back(edge);
                cnt = 1;
                --edge;
            }
        }
    }

    if(cand.empty())
        ppp(0);
    else
        ppp(cand[0]*cand[1]);


    return 0;
}


Measured memory_bytes: 1660
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a,b;
	cin>>a>>b;
	if(a%3==b%3&&a%3!=0){
		cout<<"Impossible";
	}
	else cout<<"Possible";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  int H, W;
  cin >> H >> W;
  if(H == 1 || W == 1){
    cout << 1 << endl;
    return 0;
  }
  cout << (H * W + 1)/2 << endl;
}

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

using namespace std;
typedef long long LL;


int main()
{
	int a,b ,c;
	cin >> a >> b >> c;
	if(a <= c && a + b >= c)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  auto input = readln.split.to!(int[]);
  int H = input[0], W = input[1], A = input[2], B = input[3];

  bool[] reversed = new bool[H];
  foreach(i; 0..B) {
    reversed[i] = true;
  }

  foreach(i; 0..H) {
    foreach(j; 0..A) {
      write(reversed[i] ? 0 : 1);
    }
    foreach(j; A..W) {
      write(reversed[i] ? 1 : 0);
    }
    writeln;
  }
}


Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>

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

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

  std::sort(l.begin(), l.end(), std::greater<int>());

  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      auto begin = l.begin() + j + 1;
      auto val = l[i] - l[j];
      res += std::lower_bound(begin, l.end(), val, std::greater<int>()) - begin;
    }
  }

  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        long sum = 0;
        sum += b / c + b / d - b / lcm(c, d);
        sum -= (a - 1) / c + (a - 1) / d - (a - 1) / lcm(c, d);
        System.out.println((b - a + 1) - sum);
    }

    static long lcm(long a, long b) {
        long gcd = gcd(a, b);
        return a / gcd * b;
    }

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


Measured memory_bytes: 22996
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, A[N];
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i ++)
        scanf("%d", &A[i]);
    sort(A, A + n);
    reverse(A, A + n);
    int nw = 0;
    while (nw + 1 < n && nw + 1 < A[nw + 1])
        nw ++;
    int hrz = 1;
    while (A[nw + hrz] > nw)
        hrz ++;
    int vrt = A[nw] - nw;
    if (hrz % 2 == 1 && vrt % 2 == 1)
        return !printf("Second\n");
    return !printf("First\n");
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 998244353;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;


signed main(){

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

    auto mpow = [](auto x, i64 y){
     auto z = x;
     decltype(x) val = y & 1 ? x : decltype(x)(1);
     while(z *= z, y >>= 1)
      if(y & 1)
       val *= z;
     return val;
    };

    constexpr int m = 1000007;
    vector<mint> w(m + 1, 0);

    vector<vector<int>> d(m + 1);
    for(int i = 1; i <= m; ++i){
        for(int j = i * 2; j <= m; j += i)
            d[j].push_back(i);
    }
    for(int i = 1; i <= m; ++i){
        mint p = mpow(mint(i), MOD - 2);
        for(auto x : d[i])
            p -= w[x];
        w[i] = p;
    }

    // a[k]=iになるkがいくつあるか
    vector<int> cnt(m, 0);
    for(int i = 0; i < n; ++i)
        ++cnt[a[i]];

    mint two_div = mpow(mint(2), MOD - 2);

    mint ans = 0;
    for(int i = 1; i < m; ++i){
        mint sigma = 0;
        mint pow_sigma = 0;
        for(int j = i; j <= m; j += i){
            sigma += mint(j) * cnt[j];
            pow_sigma += mint(j) * mint(j) * cnt[j];
        }
        mint val = (sigma * sigma - pow_sigma) * two_div;
        ans += w[i] * val;
    }
    cout << ans << endl;
}



Measured memory_bytes: 127232
//~ #include <cmath>
//~ #include <cassert>
#include <iostream>
//~ #include <iomanip>
//~ #include <map>
//~ #include <set>
//~ #include <vector>
//~ #include <algorithm>
#include <queue>
//~ #include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second
#define dbg(x) cerr << #x << " = " << x << endl

string s; 

//100000000

bool doable(int size) {
	int from_left = 2 * size;
	deque<int> current;
	
	forn(i, s.size()) {
		if (!current.empty() && (i - current.front()) == size) { current.pop_front(); from_left++; }
		if (((s[i] == '1') ^ (((int)current.size()) % 2)) ^ (from_left % 2)) {
			if (i + size <= (int)s.size()) {
				current.push_back(i);
			} else {
				if (from_left && i >= size) {
					from_left--;
				} else {
					return false;
				}
			}
		}
	}
	
	return true;
}

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

	cin >> s;
	
	int left = 1, right = s.size() + 1;
	while (left + 1 < right) {
		int middle = (left + right) / 2;
		if (doable(middle)) {
			left = middle;
		} else {
			right = middle;
		}
	}
	
	cout << left << endl;
}


Measured memory_bytes: 512
/**In the name of Allah, the Most Merciful, the Most Merciful.**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 9223372036854775806
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define EPS 1e-9
ll max(ll a,ll b) {if(a>b) return a; else return b;}
ll min(ll a,ll b) {if(a<b) return a; else return b;}

int main()
{
    ll n,k;
    scanf("%lld %lld",&n,&k);
    ll a[n+1];
    ll l=1,r=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        r=max(r,a[i]);
    }
    //cout<<l<<" "<<r<<endl;
    while(l<=r){
        ll mid=(l+r)/2;
        ll cnt=0;
        for(int i=1;i<=n;i++){
            cnt+=((a[i]-1)/mid);
        }
        //cout<<l<<" "<<r<<" "<<mid<<" "<<cnt<<endl;
        if(cnt<=k){
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    cout<<l<<endl;

    return 0;
}




Measured memory_bytes: 5328
#include<cstdio>
#define N 3005
#define ll long long
int n,a[N];
ll dp[N][N][2];
int vis[N][N][2];
void chk(ll &x,ll y){if(y>x)x=y;}
ll DP(int l,int r,int i){
	if(l>r)return 0;
	if(vis[l][r][i])return dp[l][r][i];
	vis[l][r][i]=1;
	dp[l][r][i]=-1e18;
	chk(dp[l][r][i],a[l]-DP(l+1,r,i^1));
	chk(dp[l][r][i],a[r]-DP(l,r-1,i^1));
	return dp[l][r][i];
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)scanf("%d",&a[i]);
	printf("%lld\n",DP(0,n-1,0));
	return 0;
}

Measured memory_bytes: 211328
#include <bits/stdc++.h>
using namespace std;
#define INF 1LL<<60
typedef long long ll;
typedef pair<ll,int> P;
vector<ll> dif;
vector<P> dif2;

class segtree{
public:
	static const int N=1<<17;
	ll dp[1<<18];
	int cnt[1<<18];
	segtree(){
		memset(dp,0,sizeof(dp));
		memset(cnt,0,sizeof(cnt));
	}

	void update(int k,P p){
		k+=N-1;
		cnt[k]+=p.first;
		dp[k]+=p.second;
		while(k>0){
			k=(k-1)/2;
			dp[k]=dp[k*2+1]+dp[k*2+2];
			cnt[k]=cnt[k*2+1]+cnt[k*2+2];
		}
	}

	int find(ll v){
		if(dp[0]<v)return -1;
		int k=0,l=0,r=N;
		ll sum=0;
		int cc=0;
		while(r-l>1){
			if(dp[k*2+2]>=v){
				l=(l+r)/2;
				k=k*2+2;
			}else{
				v-=dp[k*2+2];
				cc+=cnt[k*2+2];
				r=(l+r)/2;
				k=k*2+1;
			}
		}
		return cc+1;
	}
};

class segtree2{
public:
	static const int N=1<<17;
	ll dp[1<<18];
	segtree2(){
		for(int i=0;i<N*2;i++){
			dp[i]=INF;
		}
	}

	void update(int k,ll p){
		k+=N-1;
		dp[k]=p;
		while(k>0){
			k=(k-1)/2;
			dp[k]=min(dp[k*2+1],dp[k*2+2]);
		}
	}
	ll query(int a,int b,int k=0,int l=0,int r=N){
		if(r<=a || b<=l)return INF;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		ll vl=query(a,b,k*2+1,l,mid);
		ll vr=query(a,b,k*2+2,mid,r);
		return min(vl,vr);
	}
};


segtree seg;
segtree2 segsum;
segtree2 segsum2;

int n;
ll l;
ll a[100005],b[100005];
ll c[100005];

int main(void){
	scanf("%d%lld",&n,&l);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]-b[i]>0)dif.push_back(a[i]-b[i]);
		if(a[i]-b[i]>0)dif2.push_back(P(a[i]-b[i],i));
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&c[i]);
	}
	sort(dif.begin(),dif.end());
	sort(dif2.begin(),dif2.end());
	ll sum=0;
	for(int i=0;i<dif.size();i++){
		sum+=dif[dif.size()-1-i]-c[i];
		//printf("sum %lld\n",sum);
		segsum.update(i,sum);
		if(i+1<dif.size()){
			segsum2.update(i,sum+dif[dif.size()-2-i]);
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]-b[i]>0){
			int v=lower_bound(dif2.begin(),dif2.end(),P(a[i]-b[i],i))-dif2.begin();
			seg.update(v,P(1,a[i]-b[i]));
		}
	}
	int ans=n+1;
	for(int i=0;i<n;i++){
		ll rest=l-a[i];
		if(rest<=0){
			ans=1;
		}else{
			int v=lower_bound(dif2.begin(),dif2.end(),P(a[i]-b[i],i))-dif2.begin();
			if(a[i]-b[i]>0)seg.update(v,P(-1,-a[i]+b[i]));
			int co=seg.find(rest);
			if(a[i]-b[i]>0)seg.update(v,P(1,a[i]-b[i]));
			if(co==-1)continue;
			v=lower_bound(dif.begin(),dif.end(),a[i]-b[i])-dif.begin();
			v=dif.size()-1-v;
			if((a[i]-b[i]<=0 && segsum.query(0,co)>0) || (a[i]-b[i]>0 && segsum.query(0,min(v,co))>0 && segsum2.query(v,co)>a[i]-b[i])){
				//printf("%d %d %lld %lld %lld\n",i,co,rest,segsum.query(0,min(v,co)),segsum2.query(v,co));
				ans=min(ans,co+1);
			}
		}
	}
	printf("%d\n",ans==(n+1)?-1:ans);
	return 0;
}


Measured memory_bytes: 15132
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int main() {
	int m, d;
	int count;

	cin >> m >> d;
	count = 0;

	for (int i = 1; i <= m; i++) {
		for (int j = 10; j <= d; j++) {
			if (j / 10 >= 2 && j % 10 >= 2 && i == (j / 10) * (j % 10)) {
				count++;
			}
		}
	}

	cout << count << endl;
}

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

public class Main{
  static final int INF = Integer.MAX_VALUE / 2;
  static int n;
  static int[] t, v;
  static final boolean DEBUG = true;

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

    n = sc.nextInt();
    t = new int[n];
    for(int i = 0; i < n; i++){
      t[i] = sc.nextInt();
    }
    v = new int[n];
    for(int i = 0; i < n; i++){
      v[i] = sc.nextInt();
    }

    int[] st = new int[n + 1];
    for(int i = 1; i <= n; i++){
      st[i] = st[i - 1] + t[i - 1];
    }

    double[] mv = new double[2 * st[n] + 1];
    for(int i = 0; i <= 2 * st[n]; i++){
      double k = 0.5 * i;
      double min = Math.min(k, (double)st[n] - k);
      for(int j = 0; j < n; j++){
        min = Math.min(min, f(j, st, k));
      }
      mv[i] = min;
    }

    double sum = 0;
    for(int i = 0; i < 2 * st[n]; i++){
      sum += 0.25 * (mv[i] + mv[i + 1]);
    }

    System.out.println(sum);
  }

  static double f(int i, int[] st, double k){
    if(k < st[i]){
      return (double)v[i] + ((double)st[i] - k);
    }
    else if(k > st[i + 1]){
      return (double)v[i] + (k - (double)st[i + 1]);
    }
    else{
      return v[i];
    }
  }
}

Measured memory_bytes: 24020
S = input()

sum = 0
for i in range(2 ** (len(S) - 1)):
    P = ["+" if (i >> j) & 1 else "" for j in range(len(S) - 1)] + [""]
    T = "".join(s + p for s, p in zip(S, P))
    sum += eval(T)
print(sum)

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

const string YES = "Possible";
const string NO = "Impossible";

auto solve(long long A, long long B){ 
    return (((A % 3) == 0) || ((B % 3) == 0) || (((A + B) % 3) == 0)) ? YES : NO;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    auto result = solve(A, B);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(long long *)a-*(long long *)b;
}

int main(void){
	int n,m,a[1000],i,j,ans;
	while(1){
		ans=0;
		n=in();
		m=in();
		if(!n) break;
		rep(i,n){
			a[i]=in();
		}
		rep(i,n){
			for(j=i+1;j<n;j++){
				if(a[i]+a[j]<=m&&a[i]+a[j]>ans){
					ans=a[i]+a[j];
				}
			}
		}
		if(ans){
			print(ans);
		}
		else{
			puts("NONE");
		}
	}
	return 0;
}

Measured memory_bytes: 612
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		int a=sc.nextInt();
		double p=3.14;
		System.out.println(2*a*p);
		//String S=sc.next();
		//int v[]=new int[a];
		
		
		 
		
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 35900
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i).sort {|x, y| y <=> x }
res = 0

n.times do |i|
  if (i % 2).zero?
    res += a[i]
  else
    res -= a[i]
  end
end
puts res

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


// struct st{
//     int data;
//     int pos;
//     st(int a,int b){
//         data=a;
//         pos=b;
//     }
// };
// bool cmp(st a,st b){
//     return a.data>b.data;
// }

// vector<int> histry;
// int calc_hist(int pos){
//     int ans=pos;
//     for(int i=0;i<histry.size();i++){
//         if(pos>histry[i]){
//             ans-=2;
//         }
//     }
//     return ans;
// }

int main(){
    int n,k;
    cin>>n>>k;
    getchar();

    vector<int> v;
    int cnt=0;
    int temp=0;
    char old='1';
    for(int i=0;i<n;i++){
        if(getchar()!=old){
            v.push_back (cnt);
            cnt=1;
            old='1'-(old-'0');
        }else{
            cnt++;
        }
    }
    if(cnt!=0){
        v.push_back (cnt);
    }
    // for(int i=0;i<v.size();i++){
    //     cout<<v[i]<<" ";
    // }
    // cout<<"\n";

    vector<int> sumst;

    for(int i=0;i<v.size();i+=2){
        int temp=v[i];
        for(int j=0;j<k*2;j++){
            if(i+j+1>=v.size()){
                break;
            }
            temp+=v[i+j+1];
        }
        sumst.push_back(temp);
    }

    // for(int i=1;i<v.size();i+=2){
    //     if(i==v.size()-1){//end of v
    //         sumst.push_back(st(v[i-1]+v[i],i));
    //     }else{//usual
    //         sumst.push_back(st(v[i-1]+v[i]+v[i+1],i));
    //     }
    // }

    // for(int i=0;i<sumst.size();i++){
    //     cout<<sumst[i].data<<" "<<sumst[i].pos<<"\n";
    // }
    // cout<<"\n";


    sort(sumst.begin(), sumst.end(), std::greater<int>() );

    // for(int i=0;i<sumst.size();i++){
    //     cout<<sumst[i].data<<" "<<sumst[i].pos<<"\n";
    // }


    // if(v.size()==1){//もし１しかない時
    //     cout<<v[0]<<"\n";
    //     return(0);
    // }

    // for(int i=0;i<k-1;i++){
    //     int tempos=calc_hist(sumst[0].pos)
    //     //一番くっつける効果の大きいものをくっつける
    //     v[tempos]=sumst[0].data;
    //     //その前後を消す
    //     if(tempos<v.size-1){
    //         v.erase(v.begin() + tempos+1);
    //     }
    //     v.erase(v.begin() + tempos-1);
    //     //再度計算して挿入する
    //     int sum=v[tempos-1]+;
    //     if(tempos<v.size()){
    //         sum+=v[tempos];
    //     }
    //     if(tempos>1){
    //         sum+=v[tempos-2];
    //     }
    //     int k=0;
    //     tempos=sumset[0].pos;
    //     sumst.erase(sumset.begin());
    //     for(;k<sumst.size();k++){
    //         if(sumst[k].data<sum){
    //             sumset.insert(sumset.bigin()+k,st(sum,tempos))
    //             break;
    //         }
    //     }
    // }



    cout<<sumst[0]<<"\n";
    return(0);
}

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

#include <math.h>
#include <stdlib.h>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    
    cout << n * 800 - n/15 * 200 << endl;

    return 0;
}



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

int main() {
	int N, K;
	cin >> N >> K;
	int ans;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
	}
	if((N - 1) % (K - 1) == 0){
		ans = (N - 1) / (K - 1);
	}
	else{
		ans = (N - 1) / (K - 1) + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 2000ll * 1000 * 1000 * 1000 * 1000 * 1000 ;
const int MAXN = 200000 + 4;
const int MLOG = 22;
const int NMAX = 350; // ios_base :: sync_with_stdio(false);

int a[MAXN];

signed main() {
	ios_base :: sync_with_stdio(false);
	a[0] = -1;
	int n;
	cin >> n;
	bool p = true;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		if(a[i] > a[i - 1] + 1) {
			p = false;
		}else if(a[i] == a[i - 1] + 1) {
			ans += (i > 1);
		}else 
			ans += a[i];
	}
	if(p)
		cout << ans;
	else 
		cout << -1;
}


Measured memory_bytes: 1792
#include <iostream>
#define int long long
using namespace std;

int mod = 1000000007;
int N, K;

int exp(int a, int b) {
  if (b == 1) return a;
  
  int x = exp(a, b / 2);
  if (b % 2 == 0) return x * x % mod;
  else return x * x % mod * a % mod;
}

int combination(int n, int r) {
  int ans = 1;
  for (int i = n; i > n - r; --i) {
    ans *= i;
    ans %= mod;
  }
  for (int i = 1; i < r + 1; ++i) {
    ans *= exp(i, mod - 2);
    ans %= mod;
  }
  return ans;
}

int ball(int i) {
  if (K + i - 1 > N) return 0LL;
  
  int ans = 1;
  ans *= combination(K - 1, i - 1);
  ans *= combination(N - K + 1, N - K - i + 1);
  ans %= mod;
  return ans;
}

signed main() {
  cin >> N >> K;
  
  for (int i = 1; i < K + 1; ++i) cout << ball(i) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final int[] D = IntStream.generate(s::nextInt).limit(N).sorted().toArray();

			int lhs = D[N / 2 - 1];
			int rhs = D[N / 2];

			System.out.println(Math.max(0, rhs - lhs));
		}
	}
}


Measured memory_bytes: 53520
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		Collections.sort(list);
		int distance = Integer.MIN_VALUE;
		for(int i = 1; i < list.size(); i++) {
			int start = list.get(i - 1);
			int end = list.get(i);
			int tmpDistance = end - start;
			distance = Math.max(distance, tmpDistance);
		}
		//始点と終点の差チェック
		distance = Math.max(distance, list.get(0) + (K - list.get(N - 1)));

		int ans = K - distance;
		System.out.println(ans);

	}

}

Measured memory_bytes: 63568
n=int(input())
num=[0]*60001

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      i=x*x+y*y+z*z+x*y+y*z+z*x
      if i <= n:
        num[i]+=1
        
for i in range(n):
  print(num[i+1])

Measured memory_bytes: 9656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

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

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    cout << accumulate(a.begin(), a.begin()+k, 0) << '\n';
    return 0;
}

Measured memory_bytes: 3596
S = input()
T = input()

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    flag = 1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == '?':
            continue
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T):]
        ans = ans.replace('?', 'a')
    
print(ans)

Measured memory_bytes: 3060
temp = 0
height = Array.new(10,0)
for i in 1..10 do
	height[i] = gets.to_i
end

for i in 1..10 do
	for j in i+1..10 do
		if height[i] < height[j] then
			temp = height[i]
			height[i] = height[j]
			height[j] = temp
		end
	end
end
for i in 1..3 do
	print(height[i],"\n")
end

Measured memory_bytes: 8576
/*
Author : Hocky Yudhiono
Min 26 Jan 2020 07:04:17  WIB

1. You can sort the query if offline!
2. Don't bring the dp remaining state when dfsing on DP on Tree.
3. Try to reverse (Think from the back) if you stuck.
4. Be careful when submitting Div. 2 D-F, dont waste it on stupid WAs.
5. Try to reduce a problem
*/

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
//If the time limit is strict, try not to use long double

#define popf pop_front
#define pf push_front
#define popb pop_back
#define mp make_pair
#define pb push_back
#define remove erase
#define fi first
#define se second

//Remember to undefine if the problem is interactive
#define endl '\n'
#define DEBUG(X) cout << ">>> DEBUG(" << __LINE__ << ") " << #X << " = " << (X) << endl

const double eps = 1e-9;
const int INFMEM = 63;
const int INF = 1061109567;
const LL LINF = 4557430888798830399LL;
const double DINF = numeric_limits<double>::infinity();
const LL MOD = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1};
const int dy[8] = {0,1,0,-1,1,-1,1,-1};
const double PI = 3.141592653589793;

inline void open(string a){
    freopen((a+".in").c_str(),"r",stdin);
    freopen((a+".out").c_str(),"w",stdout);
}

inline void fasterios(){
    //Do not use if interactive
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

LL n,k;
LL isi[200005]; 

int main(){
    cin >> n >> k;
    for(int i = 1;i <= n;i++){
        cin >> isi[i];
    }
    sort(isi+1,isi+1+n,greater<LL>());
    LL sum = 0;
    for(int i = min(n,k)+1;i <= n;i++){
        sum += isi[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<map>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=1e5+5;
ll n,tt,prime[maxn],vis[maxn],ans,cnt;
ll a[maxn];
map<ll,int>mp;
struct pt{
	ll x,lx;
	pt(ll _x=0,ll _lx=0):x(_x),lx(_lx){};
	friend bool operator <(pt a,pt b){
		return a.x < b.x;
	}
}p[maxn];

inline ll rd(){
	ll ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

void pre(){
	go(i,1e5+1,2){
		if(!vis[i]) prime[++tt]=i;
		for(rg int j=1;j<=tt && i*prime[j]<=1e5;j++){
			vis[i*prime[j]]=1;
			if(i % prime[j] == 0) break;
		}
	}
}

inline ll qpow(ll x,ll k){
	ll ss=1,tmp=x;
	while(k > 0){
		if(k&1) ss*=tmp;
		tmp*=tmp; k/=2;
	}
	return ss;
}

inline bool check(ll x){
	return floor(sqrt(x))*floor(sqrt(x)) == x;
}

inline void work(ll x){
	ll ss=1,tss=1;
	go(i,tt+1,1){
		if(qpow(prime[i],3) > x) break;
		if(x%prime[i] != 0) continue;
		int j=0;
		while(x%prime[i] == 0) x/=prime[i],j++;
		j%=3;
		ss*=qpow(prime[i],j); tss*=qpow(prime[i],(3-j)%3);
	}
	if(check(x)) ss*=x,tss*=floor(sqrt(x));
	else ss*=x,tss*=(ll)x*(ll)x;
	if(mp.count(ss)) mp[ss]=mp[ss]+1;
	else{
		p[++cnt]=pt(ss,tss); mp[ss]=1;
	}
	return ;
}

int main(){
	pre(); n=rd(); 
	go(i,n+1,1) 
		work(rd());
	sort(p+1,p+cnt+1);
	go(i,cnt+1,1){
		if(p[i].x == p[i].lx) ans++;
		else{
			int ss=0;
			if(mp.count(p[i].x)) ss=max(mp[p[i].x],ss),mp[p[i].x]=0;
			if(mp.count(p[i].lx)) ss=max(ss,mp[p[i].lx]),mp[p[i].lx]=0;
			ans+=ss;
		}
	}
	printf("%d",ans);
	return 0;
}//Faze


Measured memory_bytes: 8960
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int unsigned long long
#define hh putchar('\n')
#define kg putchar(' ')
#define lowbit(x) ((x)&(-x))
using namespace std;
const int maxn=1000005,mod=998244353;
int n,isprime[maxn],prime[maxn],num;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
		if(ch=='-')
			f=-1;
		ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		putchar('-');
		putchar('1');
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}
int calc(int xx,int yy)
{
	return n*(xx-1)+yy-1;
}
int fo()
{
	int kotae=1;
	for(int i=1;i<=18;++i)
		kotae*=10;
	return kotae;
}
void make_prime()
{
    for(int i=1;i<maxn;++i)
		isprime[i]=1;
    isprime[0]=isprime[1]=0;
    for(int i=2;i<=maxn;++i)
    {
        if(isprime[i])
            prime[++num]=i;
        for(int j=1;j<=num&&i*prime[j]<maxn;++j)
        {
            isprime[i*prime[j]]=0;
            if(!(i%prime[j]))
                break;
        }
    }
    return;
}
signed main()
{	
	int a,b;
	int bb;
	cin>>a;
	b=read(),bb=read();
	b=b*100+bb;
	cout<<a*b/100<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main()
{
	int a,b;
	int i,j;
	int m,n;
	char s[101][101];
	scanf("%d%d",&a,&b);
	for(i = 0;i<a;i++)
	{
	   scanf("%s",&s[i]);
	}
	for(i = 0;i<a;i++)
	{
	   printf("%s\n",s[i]);
	   printf("%s\n",s[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int n_, t_;
  int c[100], t[100];
  int min_cost=1100;

  scanf("%d %d", &n_, &t_);

  for(int i=0;i<n_;i++){
    scanf("%d %d", &c[i], &t[i]);
  }

  for(int i=0;i<n_;i++){
    if(t[i]<=t_){
      if(c[i]<min_cost){
        min_cost = c[i];
      }
    }
  }

  if (min_cost==1100){
    printf("TLE\n");
  }else{
    printf("%d\n", min_cost);
  }
    
  return 0;
}


Measured memory_bytes: 128
main(){float a;for(;~scanf("%f",&a);)puts(a>91?"heavy":a>81?"light heavy":a>75?"middle":a>69?"light middle":a>64?"welter":a>60?"light welter":a>57?"light":a>54?"feather":a>51?"bantam":a>48?"fly":"light fly");exit(0);}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace Finding_Missing_Cards
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            bool[] S = new bool[13];
            bool[] H = new bool[13];
            bool[] D = new bool[13];
            bool[] C = new bool[13];
            for (int i = 0; i < n; ++i)
            {
                var card = Console.ReadLine().Split(' ');
                int num = int.Parse(card[1]);
                switch (card[0])
                {
                    case "S":
                        S[num - 1] = true;
                        break;
                    case "H":
                        H[num - 1] = true;
                        break;
                    case "D":
                        D[num - 1] = true;
                        break;
                    case "C":
                        C[num - 1] = true;
                        break;
                    default:
                        Environment.Exit(-1);
                        break;
                }
            }
            for (int i = 0; i < 13; ++i)
                if (!S[i]) Console.WriteLine("S " + (i + 1));
            for (int i = 0; i < 13; ++i)
                if (!H[i]) Console.WriteLine("H " + (i + 1));
            for (int i = 0; i < 13; ++i)
                if (!C[i]) Console.WriteLine("C " + (i + 1));
            for (int i = 0; i < 13; ++i)
                if (!D[i]) Console.WriteLine("D " + (i + 1));
        }
    }
}


Measured memory_bytes: 9212
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
int N,K; cin >> N >> K;
  vector<int> A(N); for(int i = 0; i < N; i++){ cin >> A[i];}
  sort(A.begin(),A.end());
  
  int j = 0;
    vector<int> vec;
  while( j < A.size()){
    int cnt = 1;
    while( j < A.size() - 1 && A[j] == A[j+1]){
      cnt++;  j++;}
    vec.push_back(cnt); j++;}
  
  sort(vec.begin(),vec.end());
  int sum = 0;
  if(vec.size() > K){
  for(int i = 0; i < vec.size() - K; i++){//vec.size() - K 種類書き換えたい
    sum += vec[i];}}
  
  cout << sum << endl; return 0;}
    
      


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i=0; i<n; ++i) {
        cin >> a.at(i);
    }

    vector<ll> mini(n, LINF);
    ll res = LINF;
    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) chmin(mini.at(j), a.at((n+j-i)%n));
        ll tmp = 0;
        for (ll y : mini) tmp += y;
        chmin(res, tmp + x * i);
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>

using namespace std;

int main(){
	int N;
	int x,y,z,tp;
	int p1=0,p2=0;
	vector<int> a,b,c;
	
	scanf("%d",&N);
	scanf("%d",&x);
	for(int i=0;i<x;i++){
		scanf("%d",&tp);
		a.push_back(tp);
	}
	sort(a.begin(),a.end());
	scanf("%d",&y);
	for(int i=0;i<y;i++){
		scanf("%d",&tp);
		b.push_back(tp);
	}
	sort(b.begin(),b.end());
	scanf("%d",&z);
	for(int i=0;i<z;i++){
		scanf("%d",&tp);
		c.push_back(tp);
	}
	sort(c.begin(),c.end());
	for(int i=0;i<x;i++){
		for(int j=0;j<z;j++){
			if(a[i]<c[j])
			break;
			if(a[i]==c[j]){
				p1++;
				break;
			}
		}
	}
	p1=z-p1;
	for(int i=0;i<x;i++){
		for(int j=0;j<y;j++){
			if(a[i]<b[j])
			break;
			if(a[i]==b[j]){
				for(int k=0;k<z;k++){
					if(b[j]<c[k])
					break;
					if(b[j]==c[k])
					p2++;
				}
			}
		}
	}
	printf("%d\n",p1+p2);
}


Measured memory_bytes: 3244
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int a, b, h;
    cin >> a >> b >> h;

    cout << (a + b) * h / 2 << endl;
}

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


int main() {
	int n;
	cin >> n;
	int *x = new int[n];
	int *y = new int[n];
	int t = 0;

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

		cin >> x[i];

		y[i] = x[i];
	}
		sort(x, x + n);
		int a = x[n / 2];
		int b = x[n / 2 - 1];

		
		for (int i = 0;i < n;i++)
		if (y[i] <= x[n/2-1]) {
			cout << a << endl;
		}
		else {
			cout << b << endl;
		}
	
	system("pause");

}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define x first
#define y second
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mem(i) memset((i), (-1), (sizeof(i)))
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

const int MN = 1e5 + 5;
int n, a[MN][3], dp[MN][3];

int f(int x, int y)
{
	if (x == n) return 0;
	int &ret = dp[x][y];
	if (ret != -1) return ret;

	ret = 0;
	rep(i, 0, 3)
	{
		if (i == y) continue;
		ret = max(ret, f(x + 1, i) + a[x][y]);
	}

	return ret;
}

int main()
{
	fastio;
	cin >> n;
	rep(i, 0, n) rep(j, 0, 3) cin >> a[i][j];
	mem(dp);
	cout << max({ f(0, 0), f(0, 1), f(0, 2) });
}

Measured memory_bytes: 8832
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
const double eps = 1e-10;
clock_t START, END;

//basic defitition
struct Point {
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}
};
typedef Point Vector;
Vector operator + (Vector A, Vector B) { return Vector(A.x + B.x, A.y + B.y); }
Vector operator - (Point A, Point B) { return Vector(A.x - B.x, A.y - B.y); }
Vector operator * (Vector A, double p) { return Vector(A.x * p, A.y * p); }
Vector operator / (Vector A, double p) { return Vector(A.x / p, A.y / p); }
bool operator < (const Point& a, const Point& b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }
int dcmp(double x) { if (fabs(x) < eps)return 0; else return x < 0 ? -1 : 1; }
bool operator == (const Point& a, const Point& b) { return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0; }
// basic operator
double Dot(Vector A, Vector B) { return A.x * B.x + A.y * B.y; }
double Length(Vector A) { return sqrt(Dot(A, A)); }
double Angle(Vector A, Vector B) { return acos(Dot(A, B) / Length(A) / Length(B)); }
double Cross(Vector A, Vector B) { return A.x * B.y - A.y * B.x; }
//point and line
Point GetLineIntersection(Point P, Vector v, Point Q, Vector w) {
	Vector u = P - Q;
	double t = Cross(w, u) / Cross(v, w);
	return P + v * t;
}//two lines only have one intersection and Cross(v,w) is not zero
double ConvexPolygonArea(vector<Point>& p, int n) {
	double area = 0;
	for (int i = 1; i < n; i++) {
		area += Cross(p[i] - p[0], p[i + 1] - p[0]);
	}
	return area / 2;
}

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	};
	bool ok = true;
	int n;
	double x, y;
	vector<Point> p;
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x, &y);
		p.push_back(Point(x, y));
	}
	p.push_back(p[0]);
	p.push_back(p[1]);
	for (int i = 1; i <= n; i++) {
		if (dcmp(Cross(p[i + 1] - p[i], p[i - 1] - p[i])) < 0) {
			ok = false;
			break;
		}
	}
	printf("%d\n", ok);
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> P;
typedef pair<ll,P> PP;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

vector<vector<ll>> groups;

void solve(long long N){
    if(N%2){
        vector<ll> tmp;
        tmp.push_back(N);
        groups.push_back(move(tmp));
        N--;
    }
    REP(N/2){
        vector<ll> tmp;
        tmp.push_back(i+1);
        tmp.push_back(N-i);
        groups.push_back(move(tmp));
    }
    vector<P> ans;
    For(i,groups.size()){
        for(auto&& l : groups[i])
        {
            FOR(j,i+1,groups.size()){
                for(auto&& r : groups[j])
                {
                    ans.push_back(P(l,r));
                }
                
            }
        }
        
    }
    cout<<ans.size()<<endl;
    for(auto&& i : ans)
    {
        cout<<i.first<<" "<<i.second<<endl;
    }
    
}

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


Measured memory_bytes: 512