akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define MAX 100
  
typedef struct{
  int width;
  int height;
}CAKE;
  
//bool operator<( const CAKE& left, const CAKE& right ) {
//  return left.width * left.height< right.width * right.height;
//}
  
int main() {
  int n,w,d;
  
  while( cin >> n >> w >> d, n || w || d ) {
  
    vector< CAKE > cake;
    CAKE tmp = {w,d};
    cake.push_back(tmp);
    int p,s;
    while( n-- ){
      cin >> p >> s;
      p--;
  
      int cnt = 0;
      while( true ){
	// assert( s!=cake[p].width);
        if ( s-cake[p].width <= 0) break;
        s -= cake[p].width;
        cnt++;
  
	//assert( s!=cake[p].height);
        if ( s-cake[p].height <= 0) break;
        s -= cake[p].height;
        cnt++;
      }
  
  
      cnt %= 4;
      pair < CAKE,CAKE > P;
      if ( cnt % 2 == 0 ) {
  
        CAKE tmp = {s,cake[p].height};
        P.first = tmp;
        tmp.width = cake[p].width - s;
        P.second = tmp;
  
      } else {
        CAKE tmp = {cake[p].width,s};
        P.first = tmp;
        tmp.height = cake[p].height - s;
        P.second = tmp;
      }
  
      if (  P.first.width * P.first.height > P.second.width * P.second.height ) {
        cake.push_back(P.second);
        cake.push_back(P.first);
    cake.erase(cake.begin()+p);
      }else{
        cake.push_back(P.first);
        cake.push_back(P.second);
    cake.erase(cake.begin()+p);
      }
  
    }
  
    //    sort( cake.begin(),cake.end() );

    for ( int i = 0; i < cake.size(); i++ ) {
      for ( int j = 0; j < cake.size()-1; j++ ) {
	if ( cake[j].width * cake[j].height >
	     cake[j+1].width * cake[j+1].height ) 
	  swap( cake[j] , cake[j+1] );
      }
    }
  
    for ( int i = 0; i < cake.size()-1; i++ ) {
      cout << cake[i].width * cake[i].height << " ";
    }
    cout << cake[cake.size()-1].width * cake[cake.size()-1].height << endl;
  
  
  }
  
  return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <ll mod>
class modint
{
public:
    constexpr modint(ll value = 0) : _value(value >= 0 ? value % mod : (value % mod) + mod) {}

    constexpr modint operator+() const { return *this; }
    constexpr modint operator-() const { return modint(-_value); }

    constexpr modint &operator+=(const modint &rhs) {
        if ((_value += rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
        if ((_value += mod - rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
        (_value *= rhs._value) %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
        *this *= rhs.inv();
        return *this;
    }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }

    constexpr modint operator++() { *this += 1; return *this; }
    constexpr modint operator--() { *this -= 1; return *this; }
    constexpr modint operator++(int) { modint tmp = *this; ++*this; return tmp; }
    constexpr modint operator--(int) { modint tmp = *this; --*this; return tmp; }

    constexpr bool operator==(const modint &rhs) const { return _value == rhs._value; }
    constexpr bool operator!=(const modint &rhs) const { return _value != rhs._value; }

    constexpr modint inv() const {
        ll a = _value, b = mod, u = 1LL, v = 0LL;
        while (b > 0) {
            ll tmp = a / b;
            a -= tmp * b; swap(a, b);
            u -= tmp * v; swap(u, v);
        }
        return modint(u);
    }

    constexpr modint pow(ll n) const {
        modint e = *this, res = 1;
        while (n) {
            if (n & 1) res *= e;
            e *= e, n >>= 1;
        }
        return res;
    }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m._value;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }

private:
    ll _value;
};
using mint = modint<1000000007>;

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

    int n, k; cin >> n >> k;
    mint ans = 0;
    for (int i = k; i <= n + 1; i++) {
        ll mx = (ll)i * (2 * n - i + 1) / 2;
        ll mn = (ll)i * (i - 1) / 2;
        ans += mx - mn + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, cnt[1005];
ll ans = 1LL;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    fill(cnt, cnt+1005, 0);
    erep(i, 2, n) {
        int tmp = i;
        for (int j = 2; j * j <= 1000; j++) {
            while (tmp % j == 0) {
                cnt[j]++;
                tmp /= j;
            }
        }
        cnt[tmp]++;
    }
    rep(i, 2, 1001) {
        ans = ans * (cnt[i] + 1) % MOD;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int a, n, m;
    cin >> a >> n >> m;

    int ret = 0;
    for (int i = 1; true; i++) {
        long long x = pow(i, n);
        if (x > m)break;

        string s = to_string(x);
        int digit = 0;
        for (int j = 0; j < s.size(); j++)digit += s[j] - '0';

        if (digit + a == i) ret++;
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3400
#include <stdio.h>
int main()
{
	int a[200001],b[200001];
	int c[200001]={0};
	int n,m,i,j,k,g;
	scanf ("%d%d",&n,&m);
        g=0;
	for (i=0;i<m;i++)
	{
		scanf ("%d%d",&a[i],&b[i]);
		if (b[i]==n) c[a[i]]++;
		if (a[i]==1) c[b[i]]++;
	}
		for (i=0;i<n;i++)
		{
		if (c[i]>=2) 
		{
			g=1;
			break;
		}
	}
if (g==1) printf ("POSSIBLE\n");
else printf ("IMPOSSIBLE\n");
return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
template <class X> void print(X x) { cout << x << endl; }
void print(vl x) {
    for(ll i : x) {
        cout << i << " ";
    }
    cout << endl;
}
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v, m;
ll codeforces = 1;
string S, T;
vl A, B;
void input() {
cin>>a>>b>>c;
cin>>k;
}
void solve() {
    while(k--){
        if(a>=b){
            b*=2;
            continue;
        }
        if(b>=c){
            c*=2;
            continue;
        }
    }
    if(a<b&&b<c)print("Yes");
    else print("No");
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    while(codeforces--) {
        solve();
    }
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	h, n := nextInt(), nextInt()
	a, b := make([]int, n), make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
		b[i] = nextInt()
	}

	fmt.Println(solve(n, h, a, b))
}

func solve(n, hp int, damage, cost []int) int {
	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, hp+1)
		for j := 0; j < hp+1; j++ {
			dp[i][j] = 100000000
		}
	}

	for i := 0; i < n; i++ {
		for j := 1; j <= hp; j++ {
			if j <= damage[i] {
				dp[i+1][j] = min(dp[i][j], cost[i])
			} else {
				dp[i+1][j] = min(dp[i][j], dp[i+1][j-damage[i]] + cost[i])
			}
		}
	}

	return dp[n][hp]
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

Measured memory_bytes: 83456
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
ll now,n,k;
ll ans;

vector<vector<pair<int, int>>> g;
const int N = 1e5;
int used[N];
//ll col[N];

ll dfs(int i,int deep) {
    if (used[i]!=0){
        return 0LL;
    }
    used[i] = deep;
    //col[i] = c;
    ll j=0;
    for(auto to : g[i]) {
        j+=dfs(to.first,deep+1);
        //cout<<j<<" "<<deep<<endl;
    }
    REP(ii,j){
        ans=ans*(k-2+(deep==1)-ii)%MOD;
    }
    
    return 1LL;
}


int main() {
    cin >>n>>k;
    
    if (n==1LL){
        cout<<k<<endl;
        return 0;
    }

    g.resize(n*2+1);
    
    for(int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b, 0);
        g[b].emplace_back(a, 0);
    }

    
    if (k==1LL){
        if (n==1)cout<<1<<endl;
        if (n>=2)cout<<0<<endl;
        return 0;
    }
    

    ans=k;
    ll bans=dfs(0,1);

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

Measured memory_bytes: 11904
#include <iostream>
#include <bitset>
#include <cmath>
#include <iomanip>
using namespace std;
string syodu(int s){
  int ret = 78125*s;
  while(ret % 10 == 0)ret/=10;
  string zero;
  if(s == 1)zero = "00";
  else if(s <= 12)zero = "0";
  return zero+to_string(ret);
}
int main(){
  int q;cin>>q;
  for(int i = 0; q > i; i++){
    long long ans = 0;
    int syosu = 0;
    bool seihu = true;
    char b[8];for(int j = 0; 8 > j; j++)cin>>b[j];
    for(int j = 0; 8 > j; j++){
      bitset<4>tm = b[j];
      if(b[j] >= 'a'){
        tm = 10+(b[j]-'a');
      }
      if(tm[3]){
        if (j == 0) {
          seihu = false;
        }else if(j <= 6){
          ans += pow(2,(6-j)*4);
        }else{
          syosu+=8;
        }
      }
      if(tm[2]){
        if(j <= 5){
          ans += pow(2,((5-j)*4+3));
        }else{
          if(j == 6)syosu+=64;
          if(j == 7)syosu+=4;
        }
      }
      if(tm[1]){
        if(j <= 5){
          ans += pow(2,((5-j)*4+2));
        }else{
          if(j == 6)syosu += 32;
          if(j == 7)syosu += 2;
        }
      }
      if(tm[0]){
        if(j <= 5){
          ans += pow(2,((5-j)*4+1));
        }else{
          if(j == 6)syosu += 16;
          if(j == 7)syosu += 1;
        }
      }
      
    }
    if(!seihu)cout << '-';
    if(syosu == 0){
      cout << fixed << ans << ".0" << endl;
    }else{
      cout << fixed << ans << "." << syodu(syosu)  << endl;
    }
  }
}


Measured memory_bytes: 3408
import java.util.*;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();
        int sum = 0;
        for (int i=0; i<n; i++) sum += arr[i];

        if (h<=sum){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }

    }
}






Measured memory_bytes: 50024
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int array[3];
    for (int i=0; i<3; i++) scanf("%d", &array[i]);
    for (int i=2; i>0; i--){
        for (int j=0; j<i; j++){
            if (array[j] > array[j+1]) swap(array[j], array[j+1]);
        }
    }
    printf("%d %d %d\n", array[0], array[1], array[2]);

    return 0;
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    string s;
    cin >> s;

    int res = 0;
    rep(i, s.size()){
        if(s[i] == '1') ++res;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100

int main(){

  int A[N],flag=1,kazu,i,j,kari,kou;

  scanf("%d",&kazu);
  if(kazu>100)exit(1);
  for(i=0;i<kazu;i++){
    scanf("%d",&A[i]);
  }

  while (flag){
    flag = 0;
       for(j=1; j<kazu;j++){
	
	 if (A[j] < A[j-1]){
	   kari=A[j-1];
	   A[j-1]=A[j];
	   A[j]=kari;
	   flag = 1;
	   kou++;
	 }
	 
       }
  }
  for(i=0;i<kazu;i++){
    printf("%d",A[i]);
    if(i<kazu-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",kou);
  
  return 0;
}
  



Measured memory_bytes: 2752
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

string s[8];
void explode(int y, int x) {
    rep(i, max(0, y-3), min(8, y+4)) {
        if(s[i][x] == '1') {
            s[i][x] = '0';
            explode(i, x);
        }
    }

    rep(j, max(0,x-3), min(8, x+4)) {
        if(s[y][j] == '1') {
            s[y][j] = '0';
            explode(y, j);
        }
    }
}

int main() {
    int n; cin >> n;
    rep(k,0,n) {
        rep(i,0,8) cin >> s[i];
        int x, y; cin >> x >> y; x--; y--;

        explode(y, x);

        printf("Data %d:\n", k+1);
        rep(i,0,8) {
            rep(j,0,8) {
                cout << s[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a,b,c,k,fl=1;
	cin>>a>>b>>c;
	cin>>k;
	while(b<=a) {
		b*=2;
		k--;
		if(k==-1) {
			fl=0;
			break;
		}
	}
	while(c<=b) {
		c*=2;
		k--;
		if(k==-1) {
			fl=0;
			break;
		}
	}
	if(fl==1) cout<<"Yes";
	else cout<<"No";	
}

Measured memory_bytes: 3648
def LI():
  return [int(s) for s in input().split()]

N = int(input())
p_s = LI()
p_s_sort = sorted(p_s)

diff_count = 0

for i in range(N):
  if p_s[i] != p_s_sort[i]:
     diff_count += 1
    
if diff_count <= 2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3064
n=gets.to_i
a=$<.read.chomp.split.map{|i|i.split("")}
b=a.transpose
r=[]
n.times do |i|
  c=1
  c-=1 if b[i].include? ?#
  n.times do |j|
    if a[i][j]==?.
      c+=1
    end
  end
  r<< c
end
if r.all?{|e|e==n+1}
  p -1
else
  p r.min+n-b.count{|e|e==[?#]*n}
end

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  size_t N;
  cin >> N;
  multiset<int, greater<int>> s(greater<int>{});
  auto num = pow(2, N);
  for (size_t i = 0; i < num; ++i) {
    int S;
    cin >> S;
    s.emplace(S);
  }
  vector<int> done;
  done.reserve(num / 2);

  vector<int> adding;
  adding.reserve(num / 2);

  auto it = s.begin();
  adding.emplace_back(*it);
  s.erase(it);

  while (!s.empty()) {
    copy(adding.cbegin(), adding.cend(), back_inserter(done));
    adding.clear();
    sort(done.rbegin(), done.rend());
    for (int val : done) {
      auto it = s.upper_bound(val);
      if (it == s.end()) {
        cout << "No" << endl;
        return 0;
      }
      adding.emplace_back(*it);
      s.erase(it);
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 13568
def main():
    n = int(input())

    ans = []

    def fanc(i, s):
        if len(s) == n:
            ans.append(s)
        else:
            for x in range(i + 2):
                # print(x,i,s)
                fanc(max([x, i]), s + chr(97 + x))
                # fanc(x + 1, s + chr(97 + x))

    fanc(0, "a")
    ans.sort()
    for i in ans:
        print(i)

    # print(len(ans))
main()


Measured memory_bytes: 12668
#include <bits/stdc++.h>
using namespace std;
 
#define IOS  cin.tie(0),cout.tie(0); ios::sync_with_stdio(false);
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
 
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    IOS
    
    int h, a, ans = 0;
    cin >> h >> a;
    while(h > 0) {
		h -= a;
		ans++;
	}
	cout << ans << '\n';
    return 0;
}



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

ll dp[101][101][2];
ll digitDp(ll pos, ll nonzero, bool islimit, string num, ll k){
    if(pos > (int)num.size()){
        return (nonzero == k) ? 1 : 0;
    }
    if(dp[pos][nonzero][islimit]!=-1) return dp[pos][nonzero][islimit];
    ll res = 0, limit = 9;
    if(islimit) limit = (num[pos-1] - '0');
    for(ll i=0;i<=limit;i++){
        if(i == limit && islimit){
            if(i > 0) res += digitDp(pos+1, nonzero+1, true, num, k);
            else      res += digitDp(pos+1, nonzero, true, num, k);
        }
        else{
            if(i > 0) res += digitDp(pos+1, nonzero+1, false, num, k);
            else      res += digitDp(pos+1, nonzero, false, num, k);
        }
    }
    return dp[pos][nonzero][islimit] = res;
}

int main(void) {
	// your
	for(ll i=0;i<101;i++) for(ll j=0;j<101;j++) for(ll k=0;k<2;k++) dp[i][j][k] = -1;
	ll  k;
	string num;
	cin >> num;
	cin >> k;
	cout << digitDp(1, 0, true, num, k);
  //  cout << num << endl;
}


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

#define szv(V) ((int)(V).size())
#define allv(V) ((V).begin(), ((V).end()))
#define sortv(V) sort(allv(V))
#define uniquev(V) (V).erase(unique(allv(V)), (V).end())
#define compv(V) sortv(V), uniquev(V)
#define fs first
#define se second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int mod = 1e9 + 7;
const ll inf = 4e18;

ll gcd(ll x, ll y) { while (y) x %= y, swap(x, y); return x; }
pll operator+(pll a, pll b) { return pll(a.fs + b.fs, a.se + b.se); }
pll operator-(pll a, pll b) { return pll(a.fs - b.fs, a.se - b.se); }
ll operator*(pll a, pll b) { return a.fs * b.se - a.se * b.fs; }
int sign(ll x) { return x < 0 ? -1 : x > 0 ? 1 : 0; }
int ccw(pll a, pll b, pll c) { return sign((b - a) * (c - b)); }
template <class T> void setmin(T &x, T y) { if (x > y) x = y; }
template <class T> void setmax(T &x, T y) { if (x < y) x = y; }
template <class T> void addval(T &x, T y) { x += y; x %= mod; }

int idx[1 << 24];
int rev[40320];
int dp[40320];
int tp[40320];
int nw = 0;

int H, W, K;
int used[8];
void initIdx(int i, int bit) {
    if (i == W) {
        rev[nw] = bit;
        idx[bit] = nw++;
        return;
    }
    for (int j = 0; j < W; j++) {
        if (used[j]) continue;
        used[j] = 1;
        initIdx(i + 1, bit | ((1 << (i * 3)) * j));
        used[j] = 0;
    }
}

int bitswap(int bit, int i, int j) {
    int x = (bit >> (i * 3)) & 7;
    int y = (bit >> (j * 3)) & 7;
    bit &= ~(7 << (i * 3));
    bit &= ~(7 << (j * 3));
    return bit | (x << (j * 3)) | (y << (i * 3));
}

void swapping(int i, int bit, int v) {
    addval(tp[idx[bit]], v);
    for (int j = i; j < W - 1; j++) {
        swapping(j + 2, bitswap(bit, j, j + 1), v);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> H >> W >> K;
    --K;
    initIdx(0, 0);
    dp[0] = 1;
    for (int i = 1; i <= H; i++) {
        for (int j = 0; j < nw; j++) {
            if (dp[j] == 0) continue;
            swapping(0, rev[j], dp[j]);
        }
        for (int j = 0; j < nw; j++) {
            dp[j] = tp[j];
            tp[j] = 0;
        }
    }
    int ans = 0;
    for (int i = 0; i < nw; i++) {
        if (((rev[i] >> (K * 3)) & 7) == 0) addval(ans, dp[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 64384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void write(ll x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,n_=1;
ll dat[530004];
int h[200004],a[200004];
void upd(int id,ll num){
	dat[id]=num;
	if (id!=0) while (1){
		id=(id-1)/2;
		dat[id]=max(dat[id*2+1],dat[id*2+2]);
		if (id==0) break;
	}
}
ll recovery(int l,int r,int id,int a,int b){
	if (r<a || b<l) return 0;
	if (a<=l && r<=b) return dat[id];
	return max(recovery(l,(l+r)/2,id*2+1,a,b),recovery((l+r)/2+1,r,id*2+2,a,b));
}
int main(){
	read(n);while (n_<n) n_<<=1;
	for (int i=1;i<=n;i++) read(h[i]),h[i]--;for (int i=1;i<=n;i++) read(a[i]);
	for (int i=1;i<=n;i++){
		if (h[i]==0){
			upd(n_-1,a[i]);
		}else{
			upd(h[i]+n_-1,recovery(0,n_-1,0,0,h[i]-1)+a[i]);
		}
	}
	write(dat[0]);
}

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

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

int main()
{
    int N, L;
    string S[110];
    vector<int> index;

    cin >> N >> L;

    REP(i, N)
    {
        cin >> S[i];
        index.push_back(i);
    }
    sort(S, S+N);


    string comb;
    for(auto i:index)
    {
        comb += S[i];
    }
    
    cout << comb << endl;
}

Measured memory_bytes: 256
import Data.Array.Unboxed
import Data.List
import Data.Maybe

import qualified  Data.ByteString.Char8 as BC8

main :: IO ()
main = do
    n  <- read <$> getLine :: IO Int
    as <- listArray (0,n-1) . sort . map (fst . fromJust . BC8.readInt) . BC8.words <$> BC8.getLine :: IO (UArray Int Int)
    bs <- map (fst . fromJust . BC8.readInt) . BC8.words <$> BC8.getLine :: IO [Int]
    cs <- listArray (0,n-1) . sort . map (fst . fromJust . BC8.readInt) . BC8.words <$> BC8.getLine :: IO (UArray Int Int)
    let sm = foldr (\x s -> s + (lowerBound as x * (n - upperBound cs x))) 0 bs
    print $ sm

lowerBound' :: UArray Int Int
            -> (Int, Int)
            -> Int
            -> Int
lowerBound' arr (first, last) n =
    let mid = div (first+last) 2
    in if last - first <= 1
        then if (arr!first) < n then last else first
        else if (arr!mid) < n
            then lowerBound' arr (mid, last)  n
            else lowerBound' arr (first, mid) n

lowerBound :: UArray Int Int -> Int -> Int
lowerBound arr n = let
    (start, last) = bounds arr
    in if (arr!last) < n then last+1
              else lowerBound' arr (start, last) n

upperBound :: UArray Int Int -> Int -> Int
upperBound arr n = lowerBound arr (n+1)


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    int upper = 0;
    int num_conbination;
    
    while(1){
        cin >> n >> x;
        num_conbination = 0;
        if( n == 0 && x == 0) break;
        if(x - 3 <= 2){
            cout << 0 << endl;
            continue;
        }
        upper = min(n, x - 3);
        for(int i = 1; i <=  upper; i++){
            for(int j = i + 1; j <= upper; j++){
                for(int k = j + 1; k <= upper; k++){
                    if(i + j + k == x) num_conbination++;
                }
            }
        }
        cout << num_conbination << endl;
    }
}



Measured memory_bytes: 3204
from scipy.sparse.csgraph import *;from scipy.sparse import *;H,W,*S=open(0).read().split();H,W=int(H),int(W);m=H*W;A=[]
for i in range(m):
 h,w=divmod(i,W)
 if S[h][w]=='S':A=[m*2,h,m*2,w+m]+A
 elif S[h][w]=='T':A=[h,m*3,w+m,m*3]+A
 elif S[h][w]=='o':A+=[h,w+m,w+m,h]
f=maximum_flow(csr_matrix(([9**9]*4+[1]*(len(A)//2-4),(A[::2], A[1::2])),shape=(m*4,m*4)),m*2,m*3).flow_value;print(f if f<9**9 else -1)

Measured memory_bytes: 40712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

void show(vector<ll>& vc)
{
    for(auto it:vc)cout<<it<<" ";
    cout<<endl;
}
#define M 300014



/**
int marked[M/64 + 2];

#define on(x) (marked[x/64] & (1<<((x%64)/2)))
#define mark(x)  marked[x/64] |= (1<<((x%64)/2))

void bitwiseSieve() {
  for (int i = 3; i * i <=M; i += 2) {
    if (!on(i)) {
      for (int j = i * i; j <= M; j += i + i) {
        mark(j);
      }
    }
  }
}

bool isPrime(int num) {
  return num > 1 && (num == 2 || ((num & 1) && !on(num)));
}
**/


/**
vector<ll>phi(M+2);
bool p[M+2];

void euler_phi(void)
{

    for(ll i=0;i<=M;i++)phi[i]=i;
    memset(p,0,sizeof p);
    p[1]=1;
    p[0]=1;
    phi[1] = 0;

    for(ll i=2; i<=M; i++)
    {

        if(!p[i])
        {

            for(ll j=i; j<=M; j+=i)
            {
                p[j]=1;
                phi[j]/=i;
                phi[j]*=(i-1);

            }
            p[i]=0;
        }
    }


}
//**/


/**
bool p[M+2];
vector<ll>prime;
void seive(void)
{

    memset(p,0,sizeof p);
    p[1]=1;
    p[0]=1;

    for(ll i=4; i<=M; i+=2)
    {
        p[i]=1;

    }

    for(ll i=3; i*i<=M; i+=2)
    {

        if(!p[i])
        {

            for(ll j=i*i; j<=M; j+=2*i)
            {
                p[j]=1;

            }
        }
    }

    prime.push_back(2);
    for(ll i=3; i<=M; i+=2)prime.push_back(i);
}
//**/


/**
ll dx[] = {-1,-1,0,-1,1,0,1,1};
ll dy[] = {-1,0,-1,1,-1,1,0,1};
**/

/**
typedef pair<ll, ll> pii;
#define x first
#define y second


pii extendedEuclid(ll a, ll b)   // returns x, y | ax + by = gcd(a,b)
{
    if(b == 0) return pii(1, 0);
    else
    {
        pii d = extendedEuclid(b, a % b);
        return pii(d.y, d.x - d.y * (a / b));
    }
}

ll modularInverse(ll a, ll n)
{
    pii ret = extendedEuclid(a, n);
    return ((ret.x % n) + n) % n;
}
//**/


/**
ll bigmod(ll a, ll b, ll c)
{
    if(b==0)return 1;
    if(b%2)
    {
        ll p = bigmod(a,b-1,c);
        return (a*p)%c;
    }
    else
    {
        ll p = bigmod(a,b/2,c);
        return (p*p)%c;
    }
}
//**/



void solve(ll t)
{


   ll n;
   cin>>n;
   cout<<(n*(n+1))/2<<endl;





}


int main()
{
//     freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);

    /**seive();        //**/
    /** euler_phi();    //**/
    /** show(phi);      //**/
    /** bitwiseSieve(); //**/





    ll t=1;
    //scanf("%lld",&t);
    ll T=t;



    while(t--)
    {


        solve(T-t);

    }
    return 0;
}


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

#define ll long long

int const N = 101, K = 1e5 + 1;

int n, k;
int arr[N];

int dp[K][2];
bool vis[K][2];

int pound(int stones, int turn)
{
    if (stones < 0)
        return turn;
    
    if (stones < arr[0])
        return 1 - turn;
    
    if (vis[stones][turn])
        return dp[stones][turn];
        
    vis[stones][turn] = 1;
    
    dp[stones][turn] = 1 - turn;
    for (int i = 0; i < n; ++i)
    {
        if (turn)
            dp[stones][turn] = max(dp[stones][turn], pound(stones - arr[i], 1 - turn));
        else
            dp[stones][turn] = min(dp[stones][turn], pound(stones - arr[i], 1 - turn));
    }
    
    return dp[stones][turn];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> arr[i];
        
    if (pound(k, 1))
        cout << "First";
    else cout << "Second";
    
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, prod = 1;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    if (a[0] == 0)
    {
        cout << 0;
        return 0;
    }
    prod = a[0];
    for (int i = 1; i < n; i++)
    {
        if (prod > 1000000000000000000 / a[i])
        {
            cout << -1;
            return 0;
        }
        else
        {
            prod *= a[i];
        }
    }
    cout << prod;
    return 0;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll k;
    cin>>k;

    cout<<50<<endl;
    ll r = k % 50;
    ll p = k / 50;
    rep(i, 50 - r) cout<<49 + p - r<<endl;
    rep(i, r) cout<<49 + p + 50 - r + 1<<endl;
}

Measured memory_bytes: 256
n,m,x,y=map(int,input().split())
l_x=list(map(int,input().split()))
l_y=list(map(int,input().split()))
l_x.append(x)
l_y.append(y)
print("No War" if  min(l_y) - max(l_x)>= 1 else "War")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    if(s.size() < 4) No();
    else (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') ? Yes() : No();
}

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

int main(){
  string S;
  
  cin >> S;
  
  if(S=="Sunny"){
    cout << "Cloudy" << endl;
  }else if(S=="Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }

  return 0;
}


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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#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 ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,m;
    cin>>n>>m;
    ll s=0;
    vi v(n);
    rep(i,0,n-1) cin>>v[i],s+=v[i];
    ll lim=ceil(s/(4*m*1.0));
    ll ans=0;
    rep(i,0,n-1) if(v[i]>=lim) ans++;
    // cout<<ans;
    if(ans>=m) cout<<"Yes";
    else cout<<"No";
    // cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF (int)1e18

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

int a,b,c,d,k;
signed main() {
  IO;
  cin >> a >> b >> c >> d >> k;
  int nxt = a * 60 + b;
  int now = c * 60 + d;
  int len = now - nxt;
  int ans = len - k;
  cout << ans << '\n';
  return 0;
}

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

int main(){
  string a;
  int N,b=0,c=0,d=0,e=0,sum=0;
  cin >> N;
  
  for(int i=0;i<N;i++){
    cin >> a;
    if(a=="P"){
      b++;}
    else if(a=="G"){
      c++;}
    else if(a=="W"){
      d++;}
    else if(a=="Y"){
      e++;}
  }
 
  sum =b*c*d*e;
  if(sum==0){
    cout<<"Three"<<endl;}
  else {
    cout<<"Four"<<endl;}
}

Measured memory_bytes: 3572
from collections import Counter

n = int(input())
s = [Counter(input()) for _ in range(n)]

cnt = s[0]
for scnt in s:
    for str in (scnt | cnt):
        cnt[str] = min(cnt[str], scnt[str])

a = ord('a')
ans = [chr(a + i) * cnt[chr(a + i)] for i in range(26)]
print(*ans, sep='')


Measured memory_bytes: 9416
//written by NewbieChd
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <queue>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    bool b = 1;
    char c;
    while (!isdigit(c = getChar()))
        if (c == 45)
            b = 0;
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return b ? f : ~f + 1;
}

const int maxN = 100003;
int a[maxN];
priority_queue <int, vector <int>, greater <int> > que;

int main() {
    int n = read(), k = read(), lim = min(n, k), i, j, t, sum, ans = 0;
    for (i = 1; i <= n; ++i)
        a[i] = read();
    for (i = 0; i <= lim; ++i)
        for (j = 0; j <= lim - i; ++j) {
            for (t = 1; t <= i; ++t)
                que.push(a[t]);
            for (t = n - j + 1; t <= n; ++t)
                que.push(a[t]);
            for (t = k - i - j; t && !que.empty() && que.top() < 0; --t)
                que.pop();
            sum = 0;
            while (!que.empty())
                sum += que.top(), que.pop();
            ans = max(ans, sum);
        }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    ll n, k; cin >> n >> k;
    if(k % 2 == 0){
        ll a = n / k;
        ll b = (n + (k / 2)) / k;
        cout << a * a * a + b * b * b << endl;
    }else{
        ll a = n / k;
        cout << a * a * a << endl;
    }
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int n;
	cin >> n;
//	vector<int> v;
	ld ret = 0;
	for (int i = 0, t; i < n; i ++) {
		cin >> t;
		ret += (ld) 1.0 / t;
//		v.push_back(t);
	}
	cout << 1.0 / ret << endl;

	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  int cnt=1,ans=0;
  REP(i,n){
    cin>>a[i];
    if(i!=0){
      if(a[i-1]==a[i]){
        cnt++;
        if(cnt%2==0) ans++;
      }else cnt=1;
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
ans = [1]*D
for i in range(D):
    for k in range(26):
        manzoku_down = 0
        ans[i] = k+1
        for j in range(26):
            last = 0
            for l in range(0,i+1):
                if ans[l] == j+1:
                    last = j+1
            manzoku_down += C[j]*((i+1)-last)
        if S[i][k]-manzoku_down >= 0:
            ans[i] = k+1
            break
for i in ans:
    print(i)

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

int main() {
    string S;
    cin >> S;
    if (S == "SUN") {
        cout << 7 << endl;
    } else if (S == "MON") {
        cout << 6 << endl;
    } else if (S == "TUE") {
        cout << 5 << endl;
    } else if (S == "WED") {
        cout << 4 << endl;
    } else if (S == "THU") {
        cout << 3 << endl;
    } else if (S == "FRI") {
        cout << 2 << endl;
    } else if (S == "SAT") {
        cout << 1 << endl;
    }
    return 0;
}

// SUN,MON,TUE,WED,THU,FRI,SAT

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int player[205][6] = {0};
        rep(i, n){
            rep(j, 3){
                cin >> player[i][j];
            }
        }
        rep(k,3){
            rep(i,n){
                range(j, i + 1, n){
                    if(player[i][k] == player[j][k]){
                        player[i][k + 3] = -1 * player[i][k];
                        player[j][k + 3] = -1 * player[j][k];
                    }
                }
            }
        }
        rep(i, n){
            int sum = 0;
            rep(j, 6){
                sum+= player[i][j];
            }
            cout << sum << endl;
        }
    }
}

Measured memory_bytes: 1164
use std::io::Read;
struct Scanner<R> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader }
    }

    fn next<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|r: Result<u8, std::io::Error>| -> char { r.unwrap() as char })
            .skip_while(|c: &char| -> bool { c.is_whitespace() })
            .take_while(|c: &char| -> bool { !c.is_whitespace() })
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

use std::io;

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin);

    let n: usize = sc.next();
    let mut v: Vec<i32> = (0..n).map(|_| sc.next()).collect();
    let mut swaps: i32 = 0;

    for i in 0..n {
        let mut idx = i;
        let mut min = v[i];
        for j in i..n {
            if v[j] < min {
                idx = j;
                min = v[j];
            }
        }
        if i != idx {
            swaps += 1;
            v.swap(i, idx);
        }
    }

    for i in 0..n - 1 {
        print!("{} ", v[i]);
    }
    println!("{}", v[n - 1]);
    println!("{}", swaps);
}



Measured memory_bytes: 5032
/* ****Ragnar7 _Lawliet_**** */
/* First, solve the problem.Then write the code. */
#include<bits/stdc++.h>
#define ll          long long
#define ld 			long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen ("input.txt","r",stdin);
	// freopen ("output.txt","w",stdout);
	#endif
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		vector<ld> v(n,0);
		for(ll i=0;i<n;i++)
			cin>>v[i];
		ll ans = 0;
		ld x;
		for(ll i=0;i<n;i++)
			for(ll j=i+1;j<n;j++)
				for(ll k=j+1;k<n;k++)
				{
					if(v[i]+v[j]>v[k] and v[j]+v[k]>v[i] and v[k]+v[i]>v[j])
					{
						// x = v[i]/(v[j]+v[k]) + v[j]/(v[k]+v[i])+v[k]/(v[i]+v[j]);
						// if(x>=1.5 and x<2.00)
						if(v[i]!=v[j] and v[j]!=v[k] and v[i]!=v[k])
						ans++;
					}
				}
		cout<<ans;
		
	}

	
	time
	return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll first = (w + 1) / 2;
  ll second = w / 2;
  ll res = first * ((h + 1) / 2) + second * (h / 2);
  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long N;
    cin>>N;
	long long pow=1;
	const int INF = 1e9+7;
	for (long long i = 1; i <= N; i++) {
		pow = pow * i;
		pow = (pow%INF);
	}
	cout << pow << endl;
}

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

using namespace std;

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

	int k;
	cin >> k;


	if (A[N - 1] - A[0] <= k)
	{
		cout << "Yay!" << endl;
	}
	else
	{
		cout << ":(" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        if (A >= 1 && A <= 9 && B >= 1 && B <= 9) {
            System.out.println(A * B);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 22740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;
namespace AOJ {
    internal class Program {
        public static void Main(string[] args) { new Program().solve(); }
        void solve() {
            Func <double, double, double, double, double> dis = (x1, y1, x2, y2) =>
                Math.Sqrt(Math.Pow((y2 - y1),2) + Math.Pow((x2 - x1),2));
            double[] inputs = Console.ReadLine().Split().Select(v => double.Parse(v)).ToArray();
            Console.WriteLine(dis(inputs[0],inputs[1],inputs[2],inputs[3]));
        }        
    }
}



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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];
 
int main () {
    int X, N;
    cin >> X >> N;

    if(N == 0){
        cout << X << endl;
        return 0;
    }

    vector<int>p(N);

    rep(i,N){
        cin >> p[i];
    }

    sort(p.begin(),p.end());

    int ans= 0;
    int aa = 100;
    int j = 0;
    repr(i,-300,300){
        if(i >= 0){
        if(i == p[j]){
            j+=1;
            continue;
        }
        }

        if(abs(X-i) < aa){
            ans = i;
            aa = abs(X-i);
        }

    }

    cout << ans << endl;

 
}

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


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

	//freopen("input.txt","r",stdin);

	int a,b,c;
	cin>>a>>b>>c;

	cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    string S; cin>>S;
    int S_len = S.size();
    vector<int> ans(S_len, 0);
    int cnt=0;
    for (int i = 0; i < S_len; ++i) {
        cnt++;
        if(S[i]!=S[i+1] || i==S_len-1) {
            if (S[i] == 'R') {
                ans[i] += (cnt+1) / 2;
                ans[i+1] += cnt / 2;
            } else if (S[i] == 'L') {
                ans[i - cnt + 1] += (cnt+1) / 2;
                ans[i - cnt] += cnt / 2;
            }
            cnt = 0;
        }
    }

    for (int i = 0; i < S_len; ++i) {
        cout<<ans[i]<<" ";
    }


    return 0;
}

Measured memory_bytes: 1024