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

int main()
{
	int n,m;
	int i,j;
	while(scanf("%d %d",&n,&m),(n&&m))
	{
		int* data = malloc(sizeof(int)*m);
		for(i = 0;i < m;i++)
		{
			data[i] = 0;
		}
		for(i = 0;i < n;i++)
		{
			for(j = 0;j < m;j++)
			{
				int tmp;
				scanf("%d",&tmp);
				if(tmp)
				{
					data[j]++;
				}
			}
		}
		for(i = 0;i < m;i++)
		{
			int max = -1;
			int maxi = 0;
			for(j = 0;j < m;j++)
			{
				if(max < data[j])
				{
					max = data[j];
					maxi = j;
				}
			}
			if(i != (m-1))
			{
				printf("%d ",maxi+1);
			}
			else
			{
				printf("%d\n",maxi+1);
			}
			data[maxi] = -1;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	
	cin>>n;
	int s;
	int a[300020]={0,0};
	for (int i=0;i<n;i++){

		cin>>s;
		if(s!=0){a[s-1]++;}
		a[s]++;a[s+1]++;
		
//	for(int j=0;j<=20;j++){
//		cout<<a[j]<<" ";
//	}	
//	cout<<endl;	
//		
	}
	int max=-1;
	for(int i=0;i<=100005;i++){
		if(a[i]>max)max=a[i];
	}
	cout<<max<<endl;
}

Measured memory_bytes: 1408
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>


using namespace std;

typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vld vector<ld>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define vvld vector<vector<ld>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M = 1000000007;
const ll MM = 998244353;
const ll inf = INT_MAX;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
//#define _Find_next
//#define _Find_first

//#define trace(...)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

template<typename T, typename F>
void chmax( T &a, F b) {
  if (b > a)a = b;
}

template<typename T, typename F>
void chmin( T &a, F b) {
  if (b < a)a = b;
}



ll powM(ll a, ll b, ll m)
{
  if (a <= 0)return 0;
  a %= m;
  ll ans = 1LL;
  while (b)
  {
    if (b & 1)ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }

  return ans;
}



ll poww(ll a, ll b)
{

  ll ans = 1;
  while (b)
  {
    if (b & 1)ans = ans * a;
    a = a * a;
    b >>= 1;
  }

  return ans;

}


string tostring(ll x) {
  stringstream sss;
  sss << x;
  string ans = sss.str();
  return ans;
}



const ll N = 1e6 + 5;




int main() {

  IOS;

#ifndef ONLINE_JUDGE

  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);

#endif


  ll n; cin >> n;

  vl d, g;

  FOR(i, n) {
    ll x, y;
    cin >> x >> y;
    ll t = abs(x + y);
    d.pb(t);
    ll q = x - y;
    g.pb(q);
  }

  sort(all(d));

  sort(all(g));

  ll ans1 = abs(g[sz(g) - 1] - g[0]);


  ll ans = abs(d[0] - d[sz(d) - 1]);

  chmax(ans, ans1);


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6716
/*
  AtCoder Beginner Contest 104
  A - Rated for Me
*/

#include<iostream>
using namespace std;

int R;

int main() {
  scanf("%d", &R);

  if (R < 1200) printf("ABC\n");
  else if (R < 2800) printf("ARC\n");
  else printf("AGC\n");
  
  return 0;
}


Measured memory_bytes: 256
n,m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
aa = []
aa[0] = a[0]
1.upto(n-1) do |i|
    aa[i] = a[i] + aa[i-1] 
end
h = {}
aa.each_with_index do |v, i|
    h[v%m] = [] if !h.has_key?(v%m)
    h[v%m] << i
end

ans = 0
h.each do |key, val|
    ans += val.size if key == 0
    if val.size > 1
        ans += val.size * (val.size-1) / 2
    end
end
puts ans

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

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

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin >> a >> b;
    if(a==2||b==2) cout << "No" << "\n";
    else cout << "Yes" << "\n";

    return 0;
}

Measured memory_bytes: 3608
def printing(a_start, a_2, n):

    a_3 = []
    mod_list = []
    for i in range(len(a_2)):
        if a_2[i][1] % a_start[1] not in mod_list and a_2[i][1] % a_start[1] != 0:
            a_3.append(a_2[i])
            mod_list.append(a_2[i][1] % a_start[1])
    a_3.sort(key=lambda x: x[1], reverse=True)


    if len(a_3) >= 2:
        if a_start[0] + a_3[-1][0] < n and a_3[0][0] < a_3[1][0] and a_3[1][0] > a_start[0]:
            a_3.pop(0)


    ans = ""
    while n % a_start[1] != 0:
        for i in range(len(a_3)):
            if n % a_start[1] >= a_3[i][1] % a_start[1]:
                n -= a_3[i][1]
                ans += str(a_3[i][0])
                break
            elif n % a_start[1] == 0:
                break
        else:
            n -= a_3[0][1]
            ans += str(a_3[0][0])

    ans = ans + str(a_start[0]) * (n // a_start[1])
    ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)
    print("".join(ans_list))

def main():
    n, m = [int(i) for i in input().split()]
    a = sorted([int(i) for i in input().split()], reverse=True)
    number = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    a_list = []
    a_2 = []

    for i in range(m):
        if number[a[i]] not in a_list:
            a_2.append([a[i], number[a[i]]])
            a_list.append(number[a[i]])
    a_2.sort(key=lambda x: x[1])
    a_start = a_2.pop(0)
    printing(a_start, a_2, n)

main()

Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> c(n);
  vector<int> t(n);
  bool judge=false;
  int min=i_INF;
  rep(i,0,n)cin>>c[i]>>t[i];
  rep(i,0,n){
    if(t[i]<=m&&c[i]<min){
      min=c[i];
      judge=true;
    }
  }
  if(judge==false)cout<<"TLE"<<endl;
  else cout<<min<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
int cnt[2][105];
int h, w;
bool flag[110][110];

int main() {
	string s;
	cin >> s;
	char target = s[0];
	int n = s.length();
	int ans = 0;
	for (int i = 1;i < n;++i) {
		if (target != s[i]) {
			target = s[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <cmath>
#include <cassert>
using namespace std;

int gcd(int a, int b)
{
  return b ? gcd(b, a%b) : a;
}

int main()
{
  int a, b;
  while (cin >> a >> b) {
    cout << gcd(a, b) << endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
  char s[200001], t[200001];
  scanf("%s", s);
  scanf("%s", t);
  
  int i = 0, count = 0;
  while (s[i] != '\0') {
    if (s[i] != t[i]) {
      count++;
    }
    i++;
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 605;

short sm1[MAX_N][MAX_N], sm2[MAX_N][MAX_N];
short f[MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            f[i+j][h-1-i+j] = (s[j] == '#');
        }
    }
    rep(i,h+w-1){
        rep(j,h+w-1){
            sm1[i][j+1] = sm1[i][j] + f[i][j];
        }
    }
    rep(j,h+w-1){
        rep(i,h+w-1){
            sm2[i+1][j] = sm2[i][j] + f[i][j];
        }
    }
    int one = 0, two = 0;
    rep(i,h+w-1){
        rep(j,h+w-2){
            if(f[i][j] == 0) continue;
            srep(k,j+1,h+w-1){
                if(f[i][k] == 0) continue;
                if(i-k+j >= 0) one += sm1[i-k+j][k] - sm1[i-k+j][j+1], two += f[i-k+j][k] + f[i-k+j][j];
                if(i+k-j < h+w-1) one += sm1[i+k-j][k] - sm1[i+k-j][j+1], two += f[i+k-j][k] + f[i+k-j][j];
            }
        }
    }
    rep(j,h+w-1){
        rep(i,h+w-2){
            if(f[i][j] == 0) continue;
            srep(k,i+1,h+w-1){
                if(f[k][j] == 0) continue;
                if(j-k+i >= 0) one += sm2[k][j-k+i] - sm2[i+1][j-k+i], two += f[k][j-k+i] + f[i][j-k+i];
                if(j+k-i < h+w-1) one += sm2[k][j+k-i] - sm2[i+1][j+k-i], two += f[k][j+k-i] + f[i][j+k-i];
            }
        }
    }
    cout << one + two/2 << "\n";
    return 0;
}


Measured memory_bytes: 2432
/* be careful of cases "p=1" */

#include <stdio.h>
#define N_MAX (50+1)

/* ---------------------------------------------------------------------------- */

/* if no cards exist under the card "N", list[N] = 0.
 * otherwise, list[N] is value of the card just under "N".
 * list[0] indicates value of the card on the top of deck */
int next[N_MAX];

void init(int n)
{
    int i;

    /* the top card is "n" */
    next[0] = n;

    /* the card just under "i" is "i-1" */
    for(i=1; i<=n; i++) next[i] = i-1;
}

void cut(int p, int c)
{
    int p_lst, c_fst, c_lst, rest, i;

    /* search for key cards */

    /* +-------+
     * |  NULL |
     * +-------+
     * |  ...  | <--+
     * | p_lst |    |
     * +-------+    |
     * | c_fst |    |
     * |  ...  | <--+
     * | c_lst |
     * +-------+
     * |  rest |
     * |  ...  | */

    p_lst = 0;
    for(i=0; i<p-1; i++) p_lst = next[p_lst];

    c_lst = c_fst = next[p_lst];
    for(i=0; i<c-1; i++) c_lst = next[c_lst];

    rest = next[c_lst];

    /* exchange */

    next[p_lst] = rest;
    next[c_lst] = next[0];
    next[0] = c_fst;
}

int main(void)
{
    int n, r, p, c;

    while(scanf("%d %d", &n, &r), n + r)
    {
        init(n);

        while(r--)
        {
            scanf("%d %d", &p, &c);
            cut(p, c);
        }

        printf("%d\n", next[0]);
    }

    return 0;
}

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

int main(){
    while( true ){
        int n, k, arr[100000];
        cin >> n >> k;
        if( !n && !k ) break;
        int t;
        for(int i = 0; i < k; i++){
            cin >> arr[i];
        }
        sort(arr, arr+k);
        int s = !(arr[0]);
        int maxv = 0, pv = -100, ccnt = 0, pcnt = 0; 
        for(int i = s; i < k; i++){
            if( arr[i] == pv + 1 ){
                ccnt++;
                pcnt++;
            }else{
                if( ccnt > maxv ) maxv = ccnt;
                if( s ){
                    if( pcnt > maxv ) maxv = pcnt;
                    pcnt = 1;
                    if( arr[i] == pv + 2 ) pcnt = ccnt + 2;
                }
                ccnt = 1;
            }
           // cout << ccnt << ' ' << pcnt << endl;
            pv = arr[i];
        }
        if( ccnt > maxv ) maxv = ccnt;
        if( s && pcnt > maxv ) maxv = pcnt;
        cout << maxv << endl;
    }
    return 0;
}

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

inline int readInt(){
  int ret = 0;
  char c;
  //  while((c=getchar()) && '0' <= c && c <= '9'){
  while((c=getchar()) && isdigit(c)){
    ret = ret * 10 + (c-'0');
  }
  return ret;
}

main(){
  int n,s;
  while(true){
    n = readInt();
    if (n==0)break;
    s = readInt();
    int r[101]={0};
    for(int i=0;i<n;i++){
      int tmp;tmp=readInt();r[tmp]++;
    }
    int ans = 0;
    for(int i=100;i;i--){
      if (r[i] && i+i > s)ans += r[i]*(r[i]-1)/2;
      if (!r[i])continue;
      for(int j=100;j > i;j--){
	if (i+j <= s)break;
	ans += r[i]*r[j];
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll X, Y,Z;
    cin >> X >> Y >> Z;
    ll ans = 1;
    while(Z + ans * (Y+Z) <= X) {
        ans++;
    }
    print(ans-1);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <cctype>
#include <sstream>
using namespace std;
typedef string::const_iterator State;
int len;
string inpro;
string in[50000];
string str;
vector<string> property;

void split(const string &str,char delim){
	istringstream iss(str);
	string tmp;
	getline(iss,tmp,delim);
	while(getline(iss,tmp,delim))property.push_back(tmp);
	len=property.size();
}

string func(State &begin,int depth,int indent){
	if(begin==str.end())return "no such property";
	int cnt=0;
	while(*begin==' '){
		begin++;
		cnt++;
	}
	if(indent==-1)indent=cnt;
	else if(indent!=cnt){
		while(*begin!='\n' && begin!=str.end())begin++;
		if(cnt<indent || begin==str.end())return "no such property";
		return func(++begin,depth,indent);
	}
	string key="";
	while(*begin!=':'){
		key+=*begin;
		begin++;
	}
	begin++;
	if(key==property[depth]){
		if(depth==len-1){
			if(*begin=='\n')return "object";
			else{
				string res="";
				begin++;
				while(*begin!='\n'){
					res+=*begin;
					begin++;
				}
				string ans="string ";
				ans+='"';
				ans+=res;
				ans+='"';
				return ans;
			}
		}else{
			if(*begin=='\n'){
				return func(++begin,++depth,-1);
			}else return "no such property";
		}
	}else{
		while(*begin!='\n' && begin!=str.end())begin++;
		if(begin==str.end())return "no such property";
		return func(++begin,depth,indent);
	}
}

int main(void){
	getline(cin,inpro);
	split(inpro,'.');
	int cnt=0;
	while(getline(cin,in[cnt]))cnt++;
	for(int i=0;i<cnt;i++){
		str+=in[i];
		str+='\n';
	}
	State begin=str.begin();
	cout << func(begin,0,-1) << endl;
	return 0;
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < long long > vll;
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef vector < int > vi;
typedef vector <vector<int>> vvi;
#define deb(x) cout << #x << " : " << x << endl
#define deb2(x , y) cout << #x << " : " << x << " , "<< #y << " : " << y << endl
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,a,n) for(int i = a; i < n; i++)
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define s(n) cin >> n
#define ls(x) ((2*(x)) + 1)
#define rs(x) ((ls(x)) + 1)
#define md(a,b) ((b)+((a) - (b))/2)
#define INF (1e9 + 7)
#define endl '\n'

void solve() {
	int n;
	cin>>n;
	vvi arr(n,vi(3));
	rep(i,n){
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	}
	vvi dp(n,vi(3));
	rep(i,n){
		rep(j,3){
			if(i==0){
				dp[i][j]=arr[i][j];
				continue;
			}
			rep(k,3){
				if(j!=k){
					dp[i][j]=max(dp[i][j],arr[i][j]+dp[i-1][k]);
				}
			}
		}
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

int main() {
	csl;
	int testcase=1;
//	cin >> testcase;
	for (int i = 0; i < testcase; i++) {
		solve();
	}
	return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  long long ans = 1000;
  for(int i = 1; i < N; ++i){
    ans = max(ans, (ans/A[i-1]*A[i])+ans%A[i-1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
H,W = map(int,input().split())
if (H*W)%3==0:
    dif = 0
else:
    dif = min(H,W)
    for i in range(1,W//2+1):
        s1 = H*i
        s2 = (W-i)*(H//2)
        s3 = (W-i)*(H-H//2)
        d = max(s1,s2,s3)-min(s1,s2,s3)
        dif = min(dif,d)
    for j in range(1,H//2+1):
        s1 = W*j
        s2 = (H-j)*(W//2)
        s3 = (H-j)*(W-W//2)
        d = max(s1,s2,s3)-min(s1,s2,s3)
        dif = min(dif,d)
print(dif)

Measured memory_bytes: 40304
from sys import exit
n=int(input())
p=list(map(int,input().split()))
s=sorted(p)
if p==s:
	print("YES")
	exit(0)
for i in range(n-1):
	for j in range(i+1,n):
		p[i],p[j] = p[j],p[i]
		if p == s:
			print("YES")
			exit(0)
		p[i],p[j] = p[j],p[i]
print("NO")

Measured memory_bytes: 9168
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int h = a/3600;
        a -= 3600*h;
        int m = a/60;
        a -= 60*m;
        int s = a;
        System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26388
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ss[3];
    for(int i=0;i<3;i++) cin>>ss[i];
    if(ss[0]=='S'&&ss[1]=='A') printf("1");
    if(ss[0]=='M'&&ss[1]=='O') printf("6");
    if(ss[0]=='T'&&ss[1]=='U') printf("5");
    if(ss[0]=='W'&&ss[1]=='E') printf("4");
    if(ss[0]=='T'&&ss[1]=='H') printf("3");
    if(ss[0]=='F'&&ss[1]=='R') printf("2");
    if(ss[0]=='S'&&ss[1]=='U') printf("7");
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "O3"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define POP pop_back
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define F first
#define S second
#define X real()
#define Y imag()
#ifndef LOCAL
    #define endl "\n"
#endif

using namespace std;
using namespace chrono;
using namespace __gnu_pbds;

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef long long C;
typedef complex<C> P;

const int INF = 1e9;
const long long LLINF = 1e18;
const double PI = 3.14159265358979323;
const long long PRIME = (1ll << 31) - 1;
const long long PRIME2 = 269;
const long long MOD = 1e9 + 7;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class U> using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using hash_set = gp_hash_table<T, null_type>;
template <class T, class U> using hash_map = gp_hash_table<T, U>;
template <class T, class U> ostream& operator<< (ostream &out, pair<T, U> p) { return out << "(" << p.F << ", " << p.S << ")"; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T, class U> ostream& operator<< (ostream &out, map<T, U> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, ordered_set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T, class U> ostream& operator<< (ostream &out, ordered_map<T, U> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, hash_set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T, class U> ostream& operator<< (ostream &out, hash_map<T, U> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> int sign (T x) { return (x > 0) - (x < 0); }
inline ll mod (ll a, ll b) { return a%b + (a < 0) * b; }
inline ll mod (ll a) { return mod(a, MOD); }
C dot (P a, P b) { return a.X * b.X + a.Y * b.Y; }
C cross (P a, P b) { return a.X * b.Y - b.X * a.Y; }

double startTime;
double currTime() { return duration_cast<nanoseconds>(system_clock::now().time_since_epoch()).count() / 1e9; }
double execTime() { return currTime() - startTime; }

int main() {
#ifndef LOCAL
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    srand(time(0));
    startTime = currTime();

    char c;
    cin >> c;
    cout << char(c + 1) << endl;
}

Measured memory_bytes: 256
w, h, n = map(int, input().split())
S = [[1 for k in range(w)] for k in range(h)]
for k in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        for j in range(h):
            for l in range(x):
                S[j][l] = 0
    if a == 2:
        for j in range(h):
            for l in range(x, w):
                S[j][l] = 0
    if a == 3:
        for j in range(y):
            for l in range(w):
                S[j][l] = 0
    if a == 4:
        for j in range(y, h):
            for l in range(w):
                S[j][l] = 0
ans = 0
for k in range(h):
    for j in range(w):
        ans += S[k][j]
print(ans)
                



Measured memory_bytes: 3064
#include<stdio.h>

int main(){

	int A,B,C,X,Y,Z;
	
	scanf("%d %d %d",&A,&B,&C);
	
	X=C;
	Y=A;
	Z=B;
	
	printf("%d %d %d",X,Y,Z);
	
return 0;

}



Measured memory_bytes: 128
import java.util.*;
public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int price = 700;
		String s = sc.next();
		for(int i = 0; i < 3; i++){
			String a = s.substring(i,i+1);
			if(a.equals("o")){
				price += 100;
			}
		}
		System.out.println(price);
	}
}

Measured memory_bytes: 21972
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = list(map(int, input().split()))

x = max(A)
A = list(filter(lambda a: a != x, A))
med = x / 2

num = INF
y = 0
for a in A:
    if abs(med - a) < num:
        num = abs(med - a)
        y = a
print(x, y)


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

#define set fixed << setprecision(8)
#define d (int)(a / b)
#define r (int)a % (int)b
#define f a / b

int main() {
	double a, b;
	cin >> a >> b;
	cout << set << d << " " << r << " " << f << endl;
	return 0;
}


Measured memory_bytes: 3280
from collections import *;M=lambda:map(int,input().split());r=range;n,k,l=M()
def f(m):
 *a,=r(n)
 def g(i):
  if a[i]==i:return i
  a[i]=g(a[i]);return a[i]
 for _ in r(m):p,q=M();a[g(q-1)]=g(p-1)
 return g
x,y=f(k),f(l);c=Counter((x(i),y(i))for i in r(n));print(*((c[x(i),y(i)])for i in r(n)))

Measured memory_bytes: 55644
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; a++) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ex++;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}


void solve() {
    long long N; cin >> N;

    vector<pair<long long, long long>> A = prime_factorize(N);

    long long ans = 0;
    for (long long i = 0; i < A.size(); i++) {
        long long ex = A[i].second;
        long long cnt = 1;
        while (ex >= cnt) {
            ex -= cnt;
            ans++;
            cnt++;
        }
    }

    cout << ans << endl;

}


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

Measured memory_bytes: 3616
s=input()
n=0
for i in range(len(s)):
        if 2*i<=len(s)-1: 
            if s[2*i]=="R" or s[2*i]=="U" or s[2*i]=="D":n+=1
for i in range(len(s)):
        if 2*i+1<=len(s)-1:
            if s[2*i+1]=="L" or s[2*i+1]=="U" or s[2*i+1]=="D":n+=1
print("Yes" if n==len(s) else "No")


Measured memory_bytes: 3060
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans+=1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define fo(i, n) for(int i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); ++ it)
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
template<typename tp> inline void arr(tp *a, int n) {
  for(int i = 1; i <= n; i ++)
    cout << a[i] << " ";
  puts("");
}
const int mo = 1e9 + 7;
const int N = 1e6 + 233;
int fac[N], inv[N], fac_inv[N];
int ans = 0, n;
inline int C(int n, int m) {
  return fac[n] * fac_inv[m] % mo * fac_inv[n - m] % mo;
}

main(void) {
  read(n); int has = 0;
  fac[0] = fac[1] = 1; for(int i = 1; i < N; i ++) fac[i] = fac[i - 1] * i % mo;
  inv[1] = 1; for(int i = 2; i < N; i ++) inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo;
  fac_inv[0] = fac_inv[1] = 1; for(int i = 2; i < N; i ++) fac_inv[i] = fac_inv[i - 1] * inv[i] % mo;
  // arr(inv, 10); arr(fac, 10); arr(fac_inv, 10);
  for(int add1 = 0; add1 <= n - 1; add1 ++) {
    if((n - add1) % 2) continue;
    int add2 = (n - add1) / 2 - 1;
    int res = C(add2 + add1, add1) * 
      fac[add2 + add1 + 1] % mo * fac[n - 1 - (add2 + add1 + 1)] % mo;
    res -= has; if(res < 0) res += mo;
    has += res; has %= mo;
    // out(res); cout << add1 << " " << add2 << "\n";
    (ans += res * (add2 + add1 + 1) % mo) %= mo;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <utility>
using namespace std;


typedef long long ll;

int main(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  cout << min(a, b)+min(c, d) << endl;
  return 0;
  return 0;
}


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

template <class T>
void chmax(T &x,T y)
{
    x=max(x,y);
}

const int mod=1e9+7;
long long mpow(long long x, int y)
{
    long long res=1;
    while(y)
    {
        if(y&1) (res*=x)%=mod;
        x*=x;
        x%=mod;
        y/=2;
    }
    return res;
}

main()
{
    int n; cin>>n;
    i64 fi,se; cin>>fi>>se;
    i64 sum=fi+se;
    i64 xo=0;
    for(int i=2; i<n; ++i)
    {
        i64 a; cin>>a;
        xo^=a;
    }
    i64 fi2=0,se2=0;
    for(int i=0; i<40; i++)
    {
        if(xo>>i&1)
        {
            sum-=1ll<<i;
            se2|=1ll<<i;
        }
    }
    for(int i=0; i<40; i++)
    {
        if(!(xo>>i&1))
        {
            if(sum>>(i+1)&1)
            {
                sum-=1ll<<(i+1);
                fi2|=1ll<<i;
                se2|=1ll<<i;
            }
        }
    }
    if(sum!=0) cout << -1 << "\n";
    else
    {
        // cerr << fi2 << " " << se2 << "\n";
        i64 dif=fi2^se2;
        i64 bas=se2^dif;
        for(int i=39; i>=0; i--)
        {
            if(dif>>i&1)
            {
                if((bas|1ll<<i)>fi) continue;
                bas|=1ll<<i;
            }
        }
        if(bas>fi or !bas or !(bas^dif)) cout << -1 << "\n";
        else
        {
            cout << fi-bas << "\n";
        }
    }
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;
const ll mod = 1000000007;

int main()
{
  ll n,k; cin>>n>>k;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];
  sort(a.begin(),a.end());

  ll g = a[0];
  rep(i, n) g = gcd(g, a[i]);
  if (a[n-1]>=k && (a[n-1]-k)%g==0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  string S;
  cin >> N >> S;
  string S_left = "", S_right = "";
  int left = 0, right = 0;
  REP(i, N)
  {
    if (S[i] == '(')
      left++;
    else
      right++;
    if (left < right)
    {
      S_left += "(";
      left++;
    }
  }
  REP(i, left - right)
  S_right += ")";
  cout << S_left + S + S_right << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}

bool paralell(P a, P b, P c, P d){
  auto check=[](P a, P b, P c, P d){
    b = P(b.first - a.first, b.second - a.second);
    d = P(d.first - c.first, d.second - c.second);
    //b.second / b.first == d.second / d.first;
    return b.second * d.first == d.second * b.first;
  };
  return check(a, b, c, d) || check(a, b, d, c);
}

int n;

vector<P> A;

int used[1<<16], mem[1<<16];
int dfs(int bit){
  if(used[bit]++) return mem[bit];
  
  int res = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if((bit >> i & 1) || (bit >> j & 1)) continue;
      int cnt = 1;
      int nbit = bit | (1<<i) | (1<<j);
      for(int k=0;k<n;k++)
	for(int l=k+1;l<n;l++){
	  if((nbit>>k&1) || (nbit>>l&1)) continue;
	  if(!paralell(A[i], A[j], A[k], A[l])) continue;
	  nbit |= (1<<k) | (1<<l);
	  cnt++;
	}
      Max(res, dfs(nbit) + cnt * (cnt - 1) / 2);
    }
  }
  return mem[bit] = res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  cin>>n;
  A.resize(n);
  cin>>A;

  int ans = dfs(0);
  cout<<ans<<endl;  
  return 0;
}



Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=100000;

int main(){
    
    int n;
    cin >> n;
    int f_multiple=0,t_multiple=0;
    int non_even=0;
    rep(i,n){
        int x;cin >> x;
        if(x%4==0){
            f_multiple++;
        }else if(x%2==0){
            t_multiple++;
        }else{
            non_even++;
        }
    }
    
    non_even;
    
    if((t_multiple>0&&non_even<=f_multiple)||(t_multiple==0&&non_even<=1+f_multiple)||(non_even==0&&t_multiple+1<=f_multiple)){
        Yes;
    }else{
        No;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	int counter = 0;
	if(N<10) {counter = N;}
	else if (N <100) {counter = 9;}
	else if (N <1000) {counter = 9+N-100+1;}
	else if (N <10000) {counter = 9+999-100+1;}
	else if (N<100000) {counter = 9+999-100+1+N-10000+1;}
	else {counter = 9+999-100+1+99999-10000+1;}
	
	
	System.out.println(counter);
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const ll INF = 1e+18;


int main(){
	ll s;
	cin>>s;
	set<ll>st;
	st.insert(s);
	ll x=s;
	ll i;
	for(i=2;i<=1000000;i++){
		s=(s&1?s*3+1:s/2);
		if(st.find(s)!=st.end())break;
		else st.insert(s);
	}
	cout<<i<<endl;;
}


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

using namespace std;

string balancedBrackets(string str)
{
     int dep = 0;
     int mindep = 0;
     for(int i=0;i<(int)str.length();i++)
     {
          if(str[i] == '(')
               dep++;
          else
               dep--;
          
          if(mindep>dep)
               mindep = dep;
     }
     
     if(mindep<0)
     {
          for(int i=0;i<abs(mindep);i++)
               str = '(' + str;
     }
     
     dep = 0;
     
     for(int i=0;i<(int)str.length();i++)
     {
          if(str[i]=='(')
               dep++;
          else
               dep--;
     }
     
     if(dep!=0)
     {
          for(int i=0;i<dep;i++)
               str = str + ')';
     }
     
     return str;
     
}

int main() {
     
     int n;
     string str;
     cin>>n>>str;
     cout<<balancedBrackets(str);
    
     return 0;
}

Measured memory_bytes: 256
def bubble_sort(c, n):
    for i in range(n):
        for j in range(n-1, i, -1):
            if int(c[j][1]) < int(c[j-1][1]):
                c[j], c[j-1] = c[j-1], c[j]
    return c

def selection_sort(c, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if int(c[j][1]) < int(c[minj][1]):
                minj = j
        c[i], c[minj] = c[minj], c[i]
    return c

def is_stable(original_list, sorted_list):
    for target in sorted_list:
        for original in original_list:
            if target[1] == original[1]:
                if target[0] != original[0]:
                    return "Not stable"
                original_list.remove(original)
                break
    return "Stable"
                
if __name__ == "__main__":
    import copy
    n = int(input())
    c = input().split()
    bubble_list = bubble_sort(copy.deepcopy(c), n)
    print(*bubble_list)
    print(is_stable(copy.deepcopy(c), bubble_list))
    selection_list = selection_sort(copy.deepcopy(c), n)
    print(*selection_list)
    print(is_stable(copy.deepcopy(c), selection_list))


Measured memory_bytes: 6344
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

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

ll a, b, n;
ll func(ll x) {
    return floor((double)(a*x)/b) - a * floor((double)x/b);
}

int main(void) {
    cin >> a >> b >> n;
    cout << func(min(b-1, n)) << endl;
    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <limits>
#include <unordered_map>

using namespace std;

bool ATGC(char c)
{
	return (c == 'A') || (c == 'T') || (c == 'G') || (c == 'C');
}

bool allATGC(const string &S, size_t left, size_t right)
{
	for (size_t i = left; i < right; i++)
	{
		if (!ATGC(S[i])) return false;
	}
	return true;
}

int syakutori(const string &S)
{
	int max_length = 0;
	size_t left = 0, right;
	while (left < S.size())
	{
		if (!ATGC(S[left]))
		{
			left++;
			continue;
		}
		for (right = left + 1; right <= S.size(); right++)
		{
			if (!ATGC(S[right])) break;
		}
		max_length = std::max<int>(max_length, right - left);
		left = right;
	}
	return max_length;
}

int zentansaku(const string& S)
{
	int max_length = 0;
	for (size_t left = 0; left < S.size(); left++)
	{
		for (size_t right = left + 1; right <= S.size(); right++)
		{
			if (allATGC(S, left, right))
			{
				max_length = std::max<int>(max_length, right - left);
			}
		}
	}
	return max_length;
}

int main()
{
	std::string S;
	std::cin >> S;

//	std::cout << syakutori(S);
//	std::cout << std::endl;
	std::cout << zentansaku(S);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(void) {
	int Q, H, S, D;
	int N;
	cin >> Q >> H >> S >> D;
	cin >> N;

	vector<tuple<double, double, int> > v;
	v.pb(make_tuple((double)Q / 0.25, 0.25, Q));
	v.pb(make_tuple((double)H / 0.5, 0.5, H));
	v.pb(make_tuple((double)S / 1.0, 1.0, S));
	v.pb(make_tuple((double)D / 2.0, 2.0, D));
	sort(all(v));

	double nokori = N;
	ll ans = 0;
	rep(i, 4) {
		double tmp, vol;
		ll cost;
		tie(tmp, vol, cost) = v[i];
		ll cnt = (double)nokori / vol;
		
		// printf("%f %f %lld %lld\n", tmp, vol, cost, cnt);

		ans += cnt * cost;
		nokori -= cnt * vol;
		if(nokori <= 0) break;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N, K; cin >> N >> K;
	cout << N - K + 1 << endl;

	return 0;
}

Measured memory_bytes: 892
import java.util.*;
public class Main {
    Scanner sc = new Scanner(System.in);
    void doIt() {
	int n =	sc.nextInt();
	HashSet<Integer> hs = new HashSet<Integer>();
	for(int i = 0; i < n; i++) {
            hs.add(sc.nextInt());
        }
	System.out.println(hs.size());
    }
    public static void main(String args[]) {
	new Main().doIt();
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X, T;
    cin >> N >> X >> T;
    cout << T * ((N + X - 1) / X) << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{

    int N;
    cin >> N;

    vector<int> W(0);
    vector<int> R(0);

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

        char ccc;
        cin >> ccc;

        if (ccc == 'R')
        {

            R.push_back(i);
        }
        else
        {

            W.push_back(i);
        }
    }

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

    int num = min(R.size(), W.size());

    int count = 0;

    if (num != 0)
    {
        for (int i = 0; i < num; i++)
        {

            if (W[i] > R[i])
            {

                break;
            }
            count++;
        }
    }
    else{


        cout << 0 << endl;

        return 0;
    }


    cout << count << endl;

    return 0;
}

Measured memory_bytes: 4688
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = c - a;
    int y = d - b;
    cout << c - y << " " << d + x << " " << a - y << " " << b + x << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")
#define MAX 1100
#define MAX_V MAX

struct edge{ int to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];

int V, E;
int n, m;
int a[MAX], b;

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to,cap,(int)G[to].size()});
	G[to].push_back((edge){from, 0, (int)G[from].size()-1});
}

int dfs(int v, int t, int f){
	if(v == t) return f;
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			int d = dfs(e.to, t, min(f,e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for(;;){
		memset(used, 0,sizeof(used));
		int f = dfs(s,t,INF);
		if(f == 0) return flow;
		flow += f;
	}
}

signed main(){
	cout<<fixed<<setprecision(7);
	
	while(true){
	
	cin>>m>>n;
	
	if(!n&&!m) break;
	
	for(int i = 0; i <= n+m+1; i++) G[i].clear();
	
	for(int i = 1; i <= m; i++){
		cin>>a[i];
		add_edge(0,i,1);
	}
	
	for(int i = 1; i <= n; i++){
		cin>>b;
		for(int j = 1; j <= m; j++){
			if(__gcd(a[j],b) != 1){
				add_edge(j,i+m,1);
			}
		}
		add_edge(i+m,n+m+1,1);
	}
	
	cout<<max_flow(0,n+m+1)<<endl;
	
	}
	
	return 0;
}


Measured memory_bytes: 15804