akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static int H, W, K;

  public static void main(String[] args) {
    H = sc.nextInt();
    W = sc.nextInt();
    K = sc.nextInt();
    int[][] F = new int[H][W];
    for (int i = 0; i < H; i++) {
      char[] row = sc.next().toCharArray();
      for (int j = 0; j < W; j++) {
        F[i][j] = row[j] - '0';
      }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        Board b = new Board(F);
        ans = Math.max(ans, b.simulate(i, j));
      }
    }
    System.out.println(ans);
  }

  static class Board {
    int[][] f;

    Board(int[][] o) {
      this.f = new int[H][];
      for (int i = 0; i < H; i++) {
        this.f[i] = o[i].clone();
      }
    }

    int simulate(int r, int c) {
      int score = 0;
      boolean[][] vanished = new boolean[H][W];
      vanished[r][c] = true;
      for (int i = 0; ; i++) {
        int sum = fall(vanished);
        if (i > 0) score += sum << (i - 1);
        if (!erase(vanished)) break;
      }
//      System.out.println(r + " " + c + " " + score);
      return score;
    }

    int fall(boolean[][] vanished) {
      int sum = 0;
      for (int i = 0; i < W; i++) {
        int to = H - 1;
        for (int j = H - 1; j >= 0; j--) {
          if (vanished[j][i]) {
            sum += f[j][i];
            continue;
          }
          f[to--][i] = f[j][i];
        }
        for (int j = to; j >= 0; j--) {
          f[j][i] = -1;
        }
      }
      return sum;
    }

    boolean erase(boolean[][] vanished) {
      boolean any = false;
      for (int i = 0; i < H; i++) {
        Arrays.fill(vanished[i], false);
        int start = 0;
        for (int j = 1; j < W; j++) {
          if (f[i][j] != f[i][j - 1] || f[i][j] == -1) {
            start = j;
          } else {
            if (j - start + 1 >= K) {
              for (int k = start; k <= j; k++) {
                vanished[i][k] = true;
                any = true;
              }
            }
          }
        }
      }

      return any;
    }

  }

}


Measured memory_bytes: 15440
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const int B=1500;

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

  int N,Q;
  cin>>N>>Q;
  vector<int> C(N);
  rep(i,N) cin>>C[i];
  vector<int> L(Q),R(Q);
  rep(i,Q) cin>>L[i]>>R[i];

  rep(i,Q) L[i]--;

  vector<int> ord(Q);
  rep(i,Q) ord[i]=i;
  sort(ord.begin(),ord.end(),[&](int a,int b){
    if((L[a]/B)!=(L[b]/B)) return L[a]<L[b];
    else return R[a]<R[b];
  });

  vector<int> exi(N,0);
  int pos=0;
  int lef=0,rig=0;
  vector<int> cnt(N+1,0);
  int sum=0;

  auto change = [&](int idx){
      if(exi[idx]){
          exi[idx]=0;
          cnt[C[idx]]--;
          if(cnt[C[idx]]==0) sum--;
      }else{
          exi[idx]=1;
          cnt[C[idx]]++;
          if(cnt[C[idx]]==1) sum++;
      }
  };

  auto go = [&](){
      if(pos==ord.size()) exit(0);
      int id=ord[pos];
      while(lef<L[id]) change(lef++);
      while(rig<R[id]) change(rig++);
      while(lef>L[id]) change(--lef);
      while(rig>R[id]) change(--rig);
      return ord[pos++];
  };

  vector<int> ans(Q,0);
  for(int i=0;i<Q;i++){
      int res=go();
      ans[res]=sum;
  }

  rep(i,Q) cout<<ans[i]<<"\n";

  return 0;
}


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

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

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<int> b(n, 0);

  for (int t = 0; t < k; t++) {
    for (int i = 0; i < n; i++) {
      const int l = max(0, i - a[i]);
      const int r = min(n - 1, i + a[i]);
      ++b[l];
      if (r + 1 < n) --b[r + 1];
    }

    for (int i = 0; i < n - 1; i++) {
      b[i + 1] += b[i];
    }

    int mi = b[0];
    for (int i = 0; i < n; i++) {
      a[i] = b[i];
      mi = min(mi, b[i]);
      b[i] = 0;
    }
    if (mi == n) break;
  }

  for (int i = 0; i < n - 1; i++) {
    cout << a[i] << ' ';
  }
  cout << a[n - 1] << endl;
}

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

  solve();
  return 0;
}


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


using namespace std;
using ll = long long;

#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define trav(a, x) for(auto& a: x)

const ll INF = 1e18;

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
  
    int n; cin >> n;
    vector<ll> h(n);
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    vector<ll> dp(n, INF);
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j <= 2; ++j) {
            if (i >= j)
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }cout << dp[n - 1] << '\n';

    return 0;
}



Measured memory_bytes: 4760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
using Graph = vector<vector<int>>;

int main() {
	int n, x, m, sum = 0, minm = INF;
	cin >> n >> x;
	rep(i, n) {
		cin >> m;
		sum += m;
		minm = min(minm, m);
	}
	cout << n + max(0, (x - sum)) / minm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n;
long double dp[3010][3010],x,ans;
void solve()
{
    cin>>n;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        dp[i][0]=dp[i-1][0]*(1-x);
        for(int j=1;j<=i;j++)
        {
            dp[i][j]=dp[i-1][j]*(1-x)+dp[i-1][j-1]*x;
            if(i==n&&j*2>i)ans+=dp[i][j];
        }
    }
    cout<<ans;
}
int32_t main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int t;cin>>t;while(t--)
    cout<<setprecision(10)<<fixed;
    solve();
    return 0;
}


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

using graph=vector<vector<int>>;

void add_undirected_edge(graph& G,int u,int v){
	G[u].emplace_back(v);
	G[v].emplace_back(u);
}

vector<vector<int>> connected_components(const graph& G){
	int n=G.size();
	vector<vector<int>> res;
	vector<bool> vis(n);
	rep(u,n) if(!vis[u]) {
		vis[u]=true;
		res.emplace_back();
		queue<int> Q; Q.emplace(u);
		while(!Q.empty()){
			int v=Q.front(); Q.pop();
			res.back().emplace_back(v);
			for(int w:G[v]) if(!vis[w]) {
				vis[w]=true;
				Q.emplace(w);
			}
		}
	}
	return res;
}

int main(){
	int n; scanf("%d",&n);
	graph G(n);
	vector<bool> to(n);
	rep(u,n){
		int v; scanf("%d",&v); v--;
		if(v<0) to[u]=true;
		else    add_undirected_edge(G,u,v);
	}

	int namori=0;
	vector<int> a; // 木の頂点数のリスト
	for(auto C:connected_components(G)){
		bool b=true;
		for(int u:C) if(to[u]) b=false;
		if(b) namori++;
		else  a.emplace_back(C.size());
	}
	int k=a.size();

	vector<mint> dp(k+1);
	dp[0]=1;
	rep(i,k) for(int j=k;j>0;j--) dp[j]+=a[i]*dp[j-1];

	mint ans=pow(mint(n-1),k)*(n-namori);
	for(int i=1;i<=k;i++){
		mint c=dp[i]; // i 個の木を使ってできるサイクルの総数
		if(i==1) c-=k;
		ans-=c*fact(i-1)*pow(mint(n-1),k-i);
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 4120
/***/





#include<bits/stdc++.h>

using namespace std;

#define fstinpt     ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll          long long
#define bn          1000090
#define sn          1010
#define mod         100000007
#define iii(i)      cin>>i
#define ooo(i)      cout<<i
#define sss         cout<<" "
#define nnn         cout<<"\n"/**
#define iii(i)      iii>>i
#define ooo(i)      ooo<<i
#define sss         ooo<<" "
#define nnn         ooo<<"\n"*/
#define ff          first
#define ss          second
#define psb         push_back

/**
        ifstream iii;iii.open("D:\\prgrms\\codechef cntst 1\\input.txt");
        ofstream ooo;ooo.open("D:\\prgrms\\codechef cntst 1\\my output.txt");

	ooo("c = "<<c);nnn;
*/




vector<char>v;

void aaaa(ll n)
{
	char c;
	c = n%26+96;
	if(c < 97) c = 122;
	v.psb(c);
	if(!(n%26) and n > 26)aaaa(n/26-1);
	else if(n > 26)aaaa(n/26);
}

int main()
{
	ll n; iii(n);
	aaaa(n);
	for(ll i = v.size()-1; i > -1; i--) ooo(v[i]);
	nnn;
        return 0;
}




/**

1000000000000001

123456789

475254


*/















/***/


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

int main() {
  int n; cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for(int i=0; i<n; i++) cin >> v[i];
  for(int i=0; i<n; i++) cin >> c[i];
  
  vector<int> sub(n);
  for(int i=0; i<n; i++) sub[i]=v[i]-c[i];
  
  int ans=0;
  for(int i: sub) {
    if(n==0) break;
    else if (i>0) ans+=i;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll X;
  cin >> X;
  ll ans = 0;
  ans = (X / 500) * 1000;
  ans += ((X % 500) / 5) * 5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	ll k;
	string s;
	cin >> k >> s;
	if (s.size() <= k) {
		return cout << s, 0;
	}
	for (int i = 0; i < k; i ++) {
		cout << s[i];
	}
	cout << "...";

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

bool expected_value(const tuple<int,int,int> &lhs,const tuple<int,int,int> &rhs) {
    auto l = get<0>(lhs) * get<1>(lhs) + get<2>(lhs);
    auto r = get<0>(rhs) * get<1>(rhs) + get<2>(rhs);
    return l/get<1>(lhs) < r/get<1>(rhs);
}


int D,G;
vector<pair<int,int>> v;
int dfs(int ndep,int cost,int score,const int &banned) {
    if (ndep==D+1) {
        // debug
        int g=G;
        int d=D;
        if (cost > 900)
        {
            cout << "!return! ";
            cout << " cost: " << cost << endl;
            cout << " dep:" << ndep << "  score:" << score << endl;
        }
        int av = (v[banned].first)*100*banned+v[banned].second;
        auto avails = av+score;
        // 条件を満たしてないならINFで返す。
        if (G>avails) return INF;
        if (G<score) return cost;
        int last = G-score;
        int pcts = min((last+(banned*100-1))/(banned*100),v[banned].first);
        auto ans = cost+pcts;
        return ans;
    }
    int use=INF;
    int ns = v[ndep].first*100*ndep+v[ndep].second;
    // use
    if (ndep!=banned) use=dfs(ndep+1,cost+v[ndep].first,score+ns,banned);
    int pass=dfs(ndep+1,cost,score,banned);

    //cout << "ns: " << ns;
    //cout << " cost: " << cost;
    //cout << " banned:" << banned << " use: " << use << " pass: " << pass;
    // cout << " dep:" << ndep << "  score:" << score << endl;
    return min(use,pass);
}

int main() {
    cin >> D >> G;
    v = vector<pair<int,int>>(D+1,make_pair(0,0));

    v[0] = make_pair(0,0);
    REP(i,D) {
        int p,c;
        cin >> p >> c;
        v[i+1]=make_pair(p,c);
    }
    int score=INF;
    FOR(i,1,D+1) {
        chmin(score,dfs(1,0,0,i));
    }
    cout << score << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
int main(void){
  int n, m;
  char s[10][10];
  bool f = false;
  while(scanf("%d", &n) != EOF){
    if(f) puts("");
    f = true;
    for(int i = 1;i <= 5; i++){
      m = n / (int)pow(10, i - 1) % 10;
      if(m == 0) strcpy(s[i], "* = ****");
      if(m == 1) strcpy(s[i], "* =* ***");
      if(m == 2) strcpy(s[i], "* =** **");
      if(m == 3) strcpy(s[i], "* =*** *");
      if(m == 4) strcpy(s[i], "* =**** ");
      if(m == 5) strcpy(s[i], " *= ****");
      if(m == 6) strcpy(s[i], " *=* ***");
      if(m == 7) strcpy(s[i], " *=** **");
      if(m == 8) strcpy(s[i], " *=*** *");
      if(m == 9) strcpy(s[i], " *=**** ");
    }
    for(int i = 0;i < 8; i++){
      for(int j = 5;j >= 1; j--)
	putchar(s[j][i]);
      puts("");
    }
  }
}


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

using namespace std;

int main() {


	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);

	if(a > b) {
		int temp = a;
		a = b;
		b = a;
	}

	if(c > d) {
		int temp = c;
		c = d;
		d = temp;
	}

	printf("%d\n", a + c);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int k, a, b; cin >> k >> a >> b;
  for (RI i = a; i <= b; ++i)
    if (i % k == 0) return puts("OK"), 0;
  puts("NG");

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 3632
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0LL)
#define srt(vec) sort(vec_all(vec))
#define rev(vec) reverse(vec_all(vec))
#define revsrt(vec) \
    srt(vec);       \
    rev(vec)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int min = 1000000001;
    int mindex;
    int tmp;
    rep(i, n) {
        cin >> a[i];
        tmp = abs(a[i]);
        if (tmp < min) {
            mindex = i;
            min = tmp;
        }
    }

    rep(i, mindex) {
        if (a[i] < 0) {
            a[i] = -a[i];
            a[i + 1] = -a[i + 1];
        }
    }

    repextrev(i, mindex + 1, n) {
        if (a[i] < 0) {
            a[i] = -a[i];
            a[i - 1] = -a[i - 1];
        }
    }

    cout << sum(a) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll X[MAX_N], Y[MAX_N], H[MAX_N];


void solve() {
	cin >> N;
	rep(i, 0, N) cin >> X[i] >> Y[i] >> H[i];
	rep(x, 0, 100 + 1) {
		rep(y, 0, 100 + 1) {
			ll h = 0;
			rep(i, 0, N) {
				if(H[i]) h = H[i] + abs(x - X[i]) + abs(y - Y[i]);
			}
			bool ok = true;
			rep(i, 0, N) {
				if(max(h - abs(x - X[i]) - abs(y - Y[i]), 0ll) != H[i]) ok = false;
			}
			if(ok) {
				cout << x << " " << y << " " << h << "\n";
				return;
			}
		}
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
using namespace std;

int main()
{
    int n, a, b;
    
    cin >> n >> a >> b;
    
    if((b-a) % 2 == 0) {
        cout << "Alice\n";
    } else {
        cout << "Borys\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	char[] ch=sc.next().toCharArray();
    int n=ch.length;
    for(int i=0;i<n;i+=2){
      System.out.print(ch[i]);
    }
  }
}


Measured memory_bytes: 28320
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main()
{
		int n, m;
		cin >> n >> m;
		vector<pair<int, int>> ab(m);
		for(int i = 0; i < m; i++)
		{
				int a, b;
				cin >> a >> b;
				ab[i] = make_pair(a, b);
		}
		vector<vector<int>> graph(n);
		for(auto elem : ab)
		{
				graph[elem.first - 1].push_back(elem.second - 1);
				graph[elem.second - 1].push_back(elem.first - 1);
		}
		vector<bool> flags(n, false);
		flags[0] = true;
		queue<vector<int>> q;
		vector<int> tempvec;
		tempvec.push_back(0);
		q.push(tempvec);
		while(!q.empty())
		{
				vector<int> currentvec = q.front();
				q.pop();
				int currentnode = currentvec[currentvec.size() - 1];
				for(int i = 0; i < graph[currentnode].size(); i++)
				{
						int tempnode = graph[currentnode][i];
						if(flags[tempnode]) continue;
						vector<int> tempvec = currentvec;
						tempvec.push_back(tempnode);
						flags[tempnode] = true;	
						if(tempnode == (n - 1))
						{
								if(tempvec.size() == 3)
								{
										cout << "POSSIBLE" << endl;
								}else{
										cout << "IMPOSSIBLE" << endl;
								}
								return 0;
						}else{
								q.push(tempvec);
						}		
				}
		}
		cout << "IMPOSSIBLE" << endl;
		return 0;
}


Measured memory_bytes: 19056
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;

const int mod = 1e9+7;
const int N = 6e5+2;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
ll pre[N], a[N];
map<int, queue<int> > _map;
int main() {
    _map[0].push(0);
    int n,k; scanf("%d%d",&n,&k);
    rep(i, 1, n + 1) scanf("%lld",a+i);
    rep(i, 1, n + 1) pre[i] = pre[i-1] + a[i];
    rep(i, 1, n + 1) pre[i] -= i, pre[i] %= k;
    ll ret = 0;
    rep(i, 1, n + 1) {
        int nd = 0;
        if(pre[i]) nd = pre[i];
        //dd(i);dd(pre[i]);dd(nd);
        while(sz(_map[nd])&&i-_map[nd].front()>=k) _map[nd].pop();
        ret += sz(_map[nd]);
        //de(sz(_map[nd]));
        _map[pre[i]].push(i);
    }
    printf("%lld\n",ret);
    return 0;
}


Measured memory_bytes: 149632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
//unionfind
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};
int main(){
  int n,k,l;
  cin >> n>>k>>l;
  UnionFind a(n);
  UnionFind b(n);
  rep(i,k){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    a.unite(x,y);
  }
  rep(i,l){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    b.unite(x,y);
  }
  vector<pair<pair<int,int>,int>> v(n);
  rep(i,n)
    v.at(i)=make_pair(make_pair(a.find(i),b.find(i)),i);
  sort(all(v));
  vector<int> check;
  vector<int> ans(n);
  check.push_back(-1);
  rep(i,n-1)
    if(v.at(i).first!=v.at(i+1).first)check.push_back(i);
  check.push_back(n-1);
  rep(i,check.size()-1){
    int j=check.at(i+1)-check.at(i);
    rep(la,j)
      ans.at(v.at(check.at(i)+la+1).second)=j;
  }
  rep(i,n)
    cout << ans.at(i) << " ";
  cout << endl;
}

Measured memory_bytes: 8872
from collections import Counter

N,K = list(map(int,input().split(" ")))
A = list(map(int,input().split(" ")))
A2 = dict(Counter(A))
ans=0
i = 0
r = sorted(A2.items(),key=lambda x:-x[1])
for k,v in r:
    i+=1
    ans+=v
    if i == K:
        break
print(N-ans)

Measured memory_bytes: 39340
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    string s; int q; cin >> s >> q;
    string mae, ato;
    bool rev = false;
    rep(i, q){
        int t; cin >> t;
        if(t==1) rev = rev ? false : true;
        else{
            int t; char c; cin >> t >> c;
            if(!rev && t == 1 || rev && t == 2) mae.push_back(c);
            else ato.push_back(c);
        }
    }
    reverse(all(mae));
    string res = mae + s + ato;
    if(rev) reverse(all(res));
    cout << res << ln;
}


Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;


struct S{
   int x, y, z;
};

S dp[1010], nxt[1010];
int x[1010], y[1010], z[1010];

int calc(S s){
    if(s.x == -INF) return -INF;
    return abs(s.x) + abs(s.y) + abs(s.z);
}

int calc2(S s, int k){
    if(s.x == -INF) return -INF;
    int tmp = 0;
    if(k & 1) tmp += s.x;
    else tmp -= s.x;
    if(k & 2) tmp += s.y;
    else tmp -= s.y;
    if(k & 4) tmp += s.z;
    else tmp -= s.z;
    return tmp;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    rep(i, 0, n){
        cin >> x[i] >> y[i] >> z[i];
    }
    int ans = 0;
    rep(k, 0, 8){
        rep(i, 0, n + 1) dp[i] = {-INF, -INF, -INF};
        dp[0] = {0, 0, 0};
        rep(i, 0, n){
            rep(j, 0, n + 1) nxt[j] = dp[j];
            rep(j, 0, m){
                if(dp[j].x == -INF) continue;
                S nxts = {dp[j].x + x[i], dp[j].y + y[i], dp[j].z + z[i]};
                int pre = calc2(nxt[j + 1], k);
                int aft = calc2(nxts, k);
                if(pre < aft) nxt[j + 1] = nxts;
            }
            rep(j, 0, m + 1) dp[j] = nxt[j];
        }
        chmax(ans, calc(dp[m]));
        // rep(i, 0, m + 1){
        //     cout << dp[i].x << ' ' << dp[i].y << ' ' << dp[i].z << endl;
        // }
    }
    cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  rep(i, 4) {
    if(s[i] == '+') cnt++;
    else if(s[i] == '-') cnt--;
  }
  
  cout << cnt << endl;
}

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

int main() {
    double N, K;
    cin >> N >> K;
    double answer = 0;
    for(int i = 1 ; i <= N; i++) {
        if(i > K) {
            answer += 1;
            continue;
        }
        int n;
        n = ceil(log(K / i) / log(2));
        answer += pow(0.5, n);
    }
    answer /= N;
    cout << setprecision(10) << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,ans;
  vector<int> a(50),b(50);
  cin>>n>>m;
  for(int i=0; i<m; i++)
    cin>>a.at(i)>>b.at(i);
  
  for(int i=1; i<=n; i++){
    ans=0;
    for(int j=0; j<m; j++){
      if(a.at(j)==i)ans++;
      if(b.at(j)==i)ans++;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
import math

list = []
indent = 0
memory = 9
for i in range(5):
  list.append(int(input()))
  if memory > list[i] % 10 and list[i] % 10 > 0:
    indent = i
    memory = list[i] % 10

count = 0
for i in range(5):
  if i == indent:
    count += list[i]
  else:
    count += 10 * math.ceil(list[i]/10)

print(count)

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M)
{
  int ret = n % m;
  if (ret < 0)
    ret += m;
  return ret;
}

int exp(int n, int k)
{
  if (k == 0)
    return 1;
  if (k == 1)
    return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2)
    ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b)
{
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution()
{
  int n;
  cin >> n;
  int v[n];
  for (int i = 0; i < n; i++)
    cin >> v[i];

  sort(v, v + n);
  int ans = 0;
  rep(i, 0, n, 1)
  {
    rep(j, i + 1, n, 1)
    {
      rep(k, j + 1, n, 1)
      {
        if (v[i] == v[j] || v[j] == v[k] || v[i] == v[k])
          continue;
        if (v[i] + v[j] > v[k])
        {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

int32_t main()
{
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--)
    solution();
}


Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
using namespace std;

int main(){


  int A,B,K=0,minimum,maximum,found=0;
  cin>>A>>B;

  if(A<B){
    minimum = A;
    maximum = B;
  }
  else{
    minimum = B;
    maximum = A;
  }
    for(int i=0;i<=maximum;i++){

        if(abs(minimum-i)==abs(maximum-i)){
            K = i;
            found++;
            break;
        }
        K++;
    }
        if(found==0){
            cout<<"IMPOSSIBLE"<<endl;
        }
        else{
            cout<<K<<endl;
        }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    
    vector<vector<int>> even_edge(n, vector<int>()), odd_edge(n, vector<int>());
    for (int i = 0; i < n - 1; i++) {
        int u, v, w; cin >> u >> v >> w; u--; v--;
        if (w % 2 == 0) {
            even_edge.at(u).push_back(v);
            even_edge.at(v).push_back(u);
        } else {
            odd_edge.at(u).push_back(v);
            odd_edge.at(v).push_back(u);
        }
    }
    
    vector<int> ans(n, -1);
    ans.at(0) = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int i = q.front();
        q.pop();
        int c = ans.at(i);
        for (int j : even_edge.at(i)) {
            if (ans.at(j) != -1) continue;
            ans.at(j) = c;
            q.push(j);
        }
        for (int j : odd_edge.at(i)) {
            if (ans.at(j) != -1) continue;
            ans.at(j) = 1 - c;
            q.push(j);
        }
    }
    
    for (int i = 0; i < n; i++) {
        cout << ans.at(i) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 9856
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

struct Team {
    int id, p, s;
    vector<int> wrong;
    Team(int _id, int num) : id(_id), wrong(num, 0), p(0), s(0) { }
    bool operator <(const Team& t) const {
        if(s != t.s) return s > t.s;
        if(p != t.p) return p < t.p;
        return id < t.id;
    }

    void solve(int pid, int t) {
        s++;
        p += wrong[pid] * 1200 + t;
    }
};

int main() {
    for(int T, P, R; cin >> T >> P >> R, T + P + R > 0; ) {
        vector<Team> teams(T, Team(0, P));
        for(int i = 0; i < T; i++) {
            teams[i].id = i + 1;
        }
        for(int i = 0; i < R; i++) {
            int tid, pid, tm; string res; cin >> tid >> pid >> tm >> res;
            tid--, pid--;
            if(res == "CORRECT") {
                teams[tid].solve(pid, tm);
            }
            else {
                teams[tid].wrong[pid]++;
            }
        }
        sort(teams.begin(), teams.end());
        for(int i = 0; i < T; i++) {
            cout << teams[i].id << ' ' << teams[i].s << ' ' << teams[i].p << endl;
        }
    }
}

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

bool topologicalSort(const vector<vector<int>>& adj, vector<int>& ord) {
    int N = adj.size();
    vector<int> deg(N);//??\?¬???°
    for(int i = 0; i < N; ++i)
      for(int nv : adj[i])
        ++deg[nv];
    ord.assign(N, -1);
    int t = 0;
    for(int v = 0; v < N; ++v) 
      if(deg[v] == 0)
        ord[t++] = v;

    for(int h = 0; h < t; ++h) {
        int v = ord[h];
        for(int nv : adj[v]) {
            --deg[nv];
            if(deg[nv] == 0)
              ord[t++] = nv;
        }
    }
    return t == N;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int V, E;
    cin >> V >> E;
    vector<vector<int>> adj(V);
    for(int i = 0; i < E; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].emplace_back(v);
    }
    vector<int> ord;
    topologicalSort(adj, ord);
    for(int x : ord) cout << x << endl;
}

Measured memory_bytes: 3652
from itertools import product,accumulate

H,W,K = map(int,input().split())

grid = tuple(tuple(map(int,input())) for _ in range(H))

def check(gids):
    cnt = 0
    s = [0]*(gids[-1]+1)
    for i in range(W):
        for h,gid in enumerate(gids):
            s[gid] += grid[h][i]
        if any(v > K for v in s):
            cnt += 1
            s = [0]*(gids[-1]+1)
            for h,gid in enumerate(gids):
                s[gid] += grid[h][i]
            if any(v > K for v in s):
                return float('inf')
    return cnt

def it():
    for p in product(range(2),repeat=H-1):
        gids = [0]+list(accumulate(p))
        yield check(gids)+gids[-1]

print(min(it()))


Measured memory_bytes: 45916
S=input()

if S=="SUN":
    print("7")
elif S=="MON":
    print("6")
elif S=="TUE":
    print("5")
elif S=="WED":
    print("4")
elif S=="THU":
    print("3")
elif S=="FRI":
    print("2")
elif S=="SAT":
    print("1")

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> l(n);

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

    int a, b, c;
    int count = 0;

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


    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                a = l[i];
                b = l[j];
                c = l[k];
                if (c < a + b) {
                    count++;
                } else {
                    break;
                }
            }
        }
    }

    printf("%d", count);

}


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

using namespace std;

#define MAX_H 100

// ??\??? 
int H, W;
char graph[MAX_H + 2][MAX_H + 2];

int visited[MAX_H + 2][MAX_H + 2];

bool dfs(int bx, int by, int x, int y) {
	int dx[] = { 1,-1, 0, 0 }, dy[] = { 0,0, 1, -1 };
	int nx = x, ny = y;
	bool res;

	if (bx == -1 && by == -1) {
		visited[nx][ny] = 1;
	}

	else {
		if (graph[bx][by] == graph[nx][ny]) {
			visited[nx][ny] = 1;
		}
		else {
			return false;
		}
	}
	
	for (int i = 0; i < 4; i++) {
		if (visited[nx+dx[i]][ny+dy[i]] == 0) {
			res = dfs(nx, ny, nx + dx[i], ny + dy[i]);
		}
	}

	return true;

}


int main()
{

	int cnt = 0;
	bool res;

	cin >> H >> W;

	while (H != 0 || W != 0) {

		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> graph[i][j];
				visited[i][j] = 0;
			}
		}

		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if (visited[i][j] == 0) {
					res = dfs(-1, -1, i, j);
					cnt++;
				}
			}
		}

		cout << cnt << endl;

		cnt = 0;

		cin >> H >> W;
	}

    return 0;
}

Measured memory_bytes: 3848
N = int(input())
A = [int(i) for i in input().split()]

bar_len = sum(A)

target = bar_len / 2

value = 0
index = 0
flag = 0
for i in range(len(A)):
    value += A[i]
    if value >= target:
        error1 = value - target
        error2 = target + A[i] - value
        if error1 < error2:
            top_list = A[: i+1]
            back_list = A[i+1 :]
            break
        else:
            top_list = A[: i]
            back_list = A[i :]
            break

top = sum(top_list)
back = sum(back_list)

result = max(top - back, back - top)
print(result)

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

typedef long long ll;

ll N;
vector<ll> X;
ll R = 1ll << 60;

int main() {
  cin >> N;
  X.resize(N);
  for (ll i = 0; i < N; ++i) cin >> X[i];
  for (ll p = 1; p <= 100; ++p) {
    ll s = 0;
    for (ll i = 0; i < N; ++i) s += (X[i] - p) * (X[i] - p);
    R = min(R, s);
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

public class AtCoder
{
    public static void Main()
    {
        string[] s;
        s = NextS();

        int n = int.Parse(s[0]);
        int c = int.Parse(s[1]);
        const int p = 1000000007;

        int[] a = new int[n];
        int[] b = new int[n];
        s = NextS();
        for (int i = 0; i < n; i++) a[i] = int.Parse(s[i]);
        s = NextS();
        for (int i = 0; i < n; i++) b[i] = int.Parse(s[i]);

        Mod mod = new Mod(410);

        long[][] mp = new long[410][];
        for (int i = 0; i < 410; i++)
        {
            mp[i] = new long[410];
            for(int j=0; j< 410; j++)
            {
                mp[i][j] = mod.Pow(i, j);
            }
        }        

        long[][] x = new long[n][];
        for (int i = 0; i < n; i++) {
            x[i] = new long[c + 1];
            for (int j = 0; j <= c; j++)
            {
                for(int k=a[i]; k<=b[i]; k++)
                {
                    x[i][j] += mp[k][j];
                    x[i][j] %= p;
                } 
            }
        }

        long[][] dp = new long[n][];
        dp[0] = new long[c + 1];
        for (int j = 0; j <= c; j++)
        {
            dp[0][j] = x[0][j];
        }
        for (int i = 1; i < n; i++)
        {
            dp[i] = new long[c + 1];
            for(int j=0; j<=c; j++)
            {
                for(int k=0; k<=j; k++)
                {
                    dp[i][j] += dp[i - 1][j - k] * x[i][k];
                    dp[i][j] %= p;
                }               
            }
        }

        Console.WriteLine(dp[n-1][c]);
    }

    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
    public static string[] NextS() { return Console.ReadLine().Trim().Split(' '); }
}

// Mod(int n)
// int[] fac: factors (1-indexed)
// int n: the length of fac

// int .Ncr(n,r): nCr
// int .Fac(n): n!%p
// int .Pow(n,m): n^m%p

public class Mod
{
    const int p = 1000000007;
    int[] fac;

    public Mod(int n)
    {
        fac = new int[n + 1];
        for (int i = 1; i <= n; i++) fac[i] = -1;
        fac[0] = 1;
    }

    public int Ncr(int n, int r)
    {
        if (n < r) return 0;
        if (r == 0 | n == r) return 1;
        long a = Fac(n);
        a = a * Pow(Fac(n - r), p - 2) % p;
        a = a * Pow(Fac(r), p - 2) % p;
        return (int)a;
    }

    public int Fac(int n)
    {
        if (fac[n] >= 0) return fac[n];
        long k = 1;
        for (long i = 1; i <= n; i++)
        {
            k = k * i % p;
        }
        fac[n] = (int)k;
        return fac[n];
    }

    public int Pow(int n, int m)
    {
        if (m == 0) return 1;
        if (m == 1) return n;
        long a = 1;
        if (m % 2 == 0)
        {
            a = Pow(n, m / 2);
            a = a * a % p;
        }
        else
        {
            a = Pow(n, m / 2);
            a = a * a % p;
            a = a * n % p;
        }
        return (int)a;
    }
}


Measured memory_bytes: 15316
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k;
  cin>>k;
  int a,b;
  cin>>a>>b;
  REP(i,1000) {
    if(a <= i*k && i*k <= b) {
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
  return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define POS(i,j) (((i)&1)*(2*k+2)+(j)+k+1)

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  const int mod=1000000007;
  int *dp=(int *)calloc(2*(k+1+1+k),sizeof(int));
  dp[POS(0,0)]=1;
  for(int i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    for(int j=0;j<=k;j++){
      dp[POS(i+1,j)]=((int64)dp[POS(i+1,j-1)]+dp[POS(i,j)]-dp[POS(i,j-1-a)]+mod)%mod;
    }
  }
  printf("%d\n",dp[POS(n,k)]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1664