akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			Team[] team = new Team[n];
			for (int i = 0; i < n; i++) {
				team[i] = new Team(
						sc.nextInt(),
						sc.nextInt(),
						sc.nextInt(),
						sc.nextInt());
			}
			Arrays.sort(team);
			
			int total = 0;
			int[] teamNum = new int[1000];
			for (int i = 0; i < n; i++) {
				if (total < 10) {
					if (teamNum[team[i].u] < 3) {
						out.println(team[i].i);
						total++;
						teamNum[team[i].u]++;
					}
				} else if (total < 20) {
					if (teamNum[team[i].u] < 2) {
						out.println(team[i].i);
						total++;
						teamNum[team[i].u]++;
					}
				} else if (total < 26) {
					if (teamNum[team[i].u] < 1) {
						out.println(team[i].i);
						total++;
						teamNum[team[i].u]++;
					}
				} else {
					break;
				}
			}
		}
		out.flush();
	}
	
	static class Team implements Comparable<Team> {
		int i, u, a, p;
		
		public Team(int i, int u, int a, int p) {
			this.i = i;
			this.u = u;
			this.a = a;
			this.p = p;
		}
		
		@Override
		public int compareTo(Team t) {
			if (this.a == t.a) {
				if (this.p == t.p) return this.i - t.i;
				return this.p - t.p;
			}
			return -(this.a - t.a);
		}
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) { return false; }
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) { throw new NumberFormatException(); }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 24316
#include<cstdio>
#include<algorithm>
using namespace std;

int n,a[605][605];

void work()
{
	int d,l=1;
	scanf("%d",&d);
	for(; d%4==0; d>>=2)
		l<<=1;
	if(~d&1)
	{
		for(int i=1; i<=n; i+=l)
			if(!(i/l&1))
				for(int k=i; k<=min(n,i+l-1); ++k)
					for(int j=1; j<=n; j++)
						a[k][j]++;
	}
	else if(d%4==1)
	{
		for(int i=1; i<=n; i+=l)
			for(int j=1; j<=n; j+=l)
				if((i/l&1)^(j/l&1)^1)
					for(int k=i; k<=min(n,i+l-1); ++k)
						for(int p=j; p<=min(n,j+l-1); ++p)
							a[k][p]++;
	}
	else
	{
		for(int i=1; i<=n; i++)
			for(int j=1; j<=n; j++)
				a[i][j]++;
	}
}

int main()
{
	scanf("%d",&n);
	n<<=1;
	work(); work();
/*	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
			printf("%d ",a[i][j]);
		puts("");
	}*/
	for(int s=0,i=1; i<=n; i++)
		for(int j=1; j<=n; j++)
			if(a[i][j]==2)
			{
				++s;
				printf("%d %d\n",i-1,j-1);
				if(s*4==n*n)
					return 0;
			}
	return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

/* オリジナル関数を追加 */
void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2036
#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC push_options
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
//auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint n;
    cin>>n;
    cout<<48-n<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string s,t;
   cin >> s >> t;

   cout << t<< s << endl;



   return 0;
}

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

const lint MOD = (lint)1e9 + 7;
int N, A[40];
lint ans, p31[40];
string S;
unordered_map<lint, unordered_map<lint, lint>> mp;

void dfs1(int cur, int left, int right){
    if(cur==right){
        int rc = 0, bc = 0;
        lint rs = 0, bs = 0;
        for(int i=left;i<right;i++){
            if(A[i]==0) rs = (rs+(S[i]-'a'+1)*p31[rc++]) % MOD;
            else bs = (bs+(S[i]-'a'+1)*p31[bc++]) % MOD;
        }
        mp[rs][bs]++;
        return;
    }
    dfs1(cur+1, left, right);
    A[cur] = 1;
    dfs1(cur+1, left, right);
    A[cur] = 0;
}

void dfs2(int cur, int left, int right){
    if(cur==right){
        int rc = 0, bc = 0;
        lint rs = 0, bs = 0;
        for(int i=right-1;left<=i;i--){
            if(A[i]==0) rs = (rs+(S[i]-'a'+1)*p31[rc++]) % MOD;
            else bs = (bs+(S[i]-'a'+1)*p31[bc++]) % MOD;
        }
        ans += mp[bs][rs];
        return;
    }
    dfs2(cur+1, left, right);
    A[cur] = 1;
    dfs2(cur+1, left, right);
    A[cur] = 0;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> N >> S;
    p31[0] = 1;
    for(int i=1;i<=N;i++) p31[i] = p31[i-1] * 31 % MOD;
    dfs1(N, N, 2*N);
    dfs2(0, 0, N);
    cout << ans << endl;
    return 0;
}

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

int main() {
  string S(4, '0');
  cin >> S;
  int digit = (int)S.size() - 1;
  
  for (int bit = 0; bit < (1 << digit); ++bit) {
    vector<char> operators(digit);
    for (int i = 0; i < digit; ++i) {
      if (bit & (1 << i)) {
        operators.at(i) = '+';
      } else {
        operators.at(i) = '-';
      }
    }
    
    int ans = 0;
    string f = "";
    
    for (int i = 0; i < S.size(); i++) {
      int n = S.at(i) - '0';

      if (i == 0) ans += n;
      if (i > 0) {
        char op = operators.at(i - 1);
        if (op == '+') ans += n;
        if (op == '-') ans -= n;
        f += op;
      }

      f += S.at(i);
    }
    
    if (ans == 7) {
      cout << f + '=' + to_string(ans) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 3456;
int dp[MAXN][MAXN];
char s[MAXN], t[MAXN];
pii pre[MAXN][MAXN];

int main() {
    scanf("%s", s + 1);
    scanf("%s", t + 1);
    int ls = strlen(s + 1), lt = strlen(t + 1);
    for (int i = 1; i <= ls; i++) {
        for (int j = 1; j <= lt; j++) {
            if (s[i] == t[j]) {
               dp[i][j] = dp[i - 1][j - 1] + 1;
               pre[i][j] = make_pair(i - 1, j - 1);
            } else if (dp[i - 1][j] >= dp[i][j - 1]) {
               dp[i][j] = dp[i - 1][j];
               pre[i][j] = make_pair(i - 1, j);
            } else {
               dp[i][j] = dp[i][j - 1];
               pre[i][j] = make_pair(i, j - 1);
            }
        }
    }
    int curt = lt, curs = ls;
    //printf("ans = %d\n", dp[ls][lt]);
    stack<char> stk;
    while (curs && curt) {
          if (s[curs] == t[curt]) stk.push(s[curs]);
          int tmp1 = curs, tmp2 = curt;
          curs = pre[tmp1][tmp2].first;
          curt = pre[tmp1][tmp2].second;
    }
    while (!stk.empty()) {
          printf("%c", stk.top());
          stk.pop();
    }
    puts("");
    return 0;
}


Measured memory_bytes: 125184
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

x, y = map(int, input().split())
if y < 2:
  print("No")
else:
  if y % 2 == 0:
    turtle = y / 2 - x
    crane = x - turtle
    if not is_integer(turtle) or crane < 0 or turtle < 0:
      print("No")
    else:
      print("Yes")
  else:
    print("No")

Measured memory_bytes: 9192
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	vector< vector<int> > v(300000);
	for (int i = 2; i < 300000; i++) {
		if (i % 7 != 1 && i % 7 != 6) continue;
		if (v[i].size() > 0) continue;
		for (int j = 1; i * j < 300000; j++) {
			if (j % 7 != 1 && j % 7 != 6) continue;
			v[i * j].push_back(i);
		}
	}
	for (;;) {
		int n; cin >> n;
		if (n == 1) break;
		cout << n << ':';
		for (int k = 0; k < v[n].size(); k++)
			cout << ' ' << v[n][k];
		cout << endl;
	}
}

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

int main(){
  vector<string> S(3);
  cin >> S.at(0);
  cin >> S.at(1);
  cin >> S.at(2);
  
  int len_a=S.at(0).length();
  int len_b=S.at(1).length();
  int len_c=S.at(2).length();
  
  int na=0,nb=0,nc=0;
  int turn=0;
  int k=na;
  while(1){
    if(na>len_a&&turn==0){
      cout << "A" << endl;
      break;
    }else if(nb>len_b&&turn==1){
      cout << "B" << endl;
      break;
    }else if(nc>len_c&&turn==2){
      cout << "C" << endl;
      break;
    }
    
    if(S.at(turn).at(k)=='a'){
      turn=0;
      k=na;
      if(na>0)na++;
    }else if(S.at(turn).at(k)=='b'){
      turn=1;
      k=nb;
      nb++;
    }else if(S.at(turn).at(k)=='c'){
      turn=2;
      k=nc;
      nc++;
    }
    if(na==0)na++;
  }
}
  

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

using namespace std;

int main()
{
    int i,lim,a,min=1000000,max=-1000000;
    long int sum=0;
    cin >> lim;
    for(i = 0;i < lim;i++)
    {
        cin >> a;
        sum += a;
        if(a < min){
            min = a;
        }if(a > max){
            max = a;
        }
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>

using namespace std;
 
int main(){
    int n;
 
    while(cin >> n ,n){
	string str;
	int d[] = {1,2,3,4,5,6};
 
	for(int i = 0 ; i < n ; i++){
	    cin >> str;
 
	    int tmp = d[0];
	    if(str == "north"){
		d[0] = d[4];
		d[4] = d[5];
		d[5] = d[1];
		d[1] = tmp;
	    }
	    else if(str == "east"){
		d[0] = d[2];
		d[2] = d[5];
		d[5] = d[3];
		d[3] = tmp;
	    }
	    else if(str == "west"){
		d[0] = d[3];
		d[3] = d[5];
		d[5] = d[2];
		d[2] = tmp;
	    }
	    else{
		d[0] = d[1];
		d[1] = d[5];
		d[5] = d[4];
		d[4] = tmp;
	    }
	}
	cout << d[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>

using namespace std;

template<typename T>
class LazySegTree {
public:
    explicit LazySegTree(int n, T init, T def) : N(calcN_(n)), def(def) {
        mVal.assign(2*N+1, init);
        mLazy.assign(2*N+1, 0);
        mDirty.assign(2*N+1, 0);
    }
    void update(int l, int r, T value){
        updateImpl_(l, r, value, 0, 0, N);
    }
    T get(int l, int r){
        return getImpl_(l, r, 0, 0, N);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void updateImpl_(int l, int r, T value, int idx, int rangeL, int rangeR){
        eval_(idx, rangeL, rangeR);
        if(r <= rangeL || rangeR <= l) return;
        if(l <= rangeL && rangeR <= r){
            setLazy_(idx, value);
            eval_(idx, rangeL, rangeR);
        } else {
            int rangeM = (rangeL+rangeR)/2;
            updateImpl_(l, r, value, 2*idx+1, rangeL, rangeM);
            updateImpl_(l, r, value, 2*idx+2, rangeM, rangeR);
            mVal[idx] = operate_(mVal[2*idx+1], mVal[2*idx+2]);
        }
    }
    void setLazy_(int idx, T value){
        mLazy[idx] += value;
        mDirty[idx] = 1;
    }
    T getImpl_(int l, int r, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return def;
        eval_(idx, rangeL, rangeR);
        if(l <= rangeL && rangeR <= r) return mVal[idx];
        int rangeM = (rangeL+rangeR)/2;
        T a = getImpl_(l, r, 2*idx+1, rangeL, rangeM);
        T b = getImpl_(l, r, 2*idx+2, rangeM, rangeR);
        return operate_(a, b);
    }
    void eval_(int idx, int rangeL, int rangeR){
        if(!mDirty[idx]) return;
        mVal[idx] += mLazy[idx];
        if(idx < N-1){
            setLazy_(2*idx+1, mLazy[idx]);
            setLazy_(2*idx+2, mLazy[idx]);
        }
        mLazy[idx] = 0;
        mDirty[idx] = 0;
    }
    T operate_(T a, T b) const { return min(a, b); }
    const int N;
    const T def;
    vector<T> mVal; 
    vector<T> mLazy;
    vector<int> mDirty;
};

int main(){
    int n, q;
    while(cin >> n >> q){
        LazySegTree<long long> seg(n, 0, 1LL << 60);
        for(int i=0;i<q;i++){
            int c; cin >> c;
            if(c == 0){
                int s, t, x; cin >> s >> t >> x;
                seg.update(s, t+1, x);
            } else {
                int s, t; cin >> s >> t;
                cout << seg.get(s, t+1) << endl;
            }
        }
    }
}



Measured memory_bytes: 7868
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

const int N = 524288;  // 2^19
int dat[2 * N - 1];

void init() {
  for (int i = 0; i < 2 * N - 1; ++i) {
    dat[i] = 0;
  }
}

void update(int i, int x) {
  i += N - 1;
  dat[i] = x;
  while (0 < i) {
    i = (i - 1) / 2;
    dat[i] = max(dat[2 * i + 1], dat[2 * i + 2]);
  }
}

int query(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) return 0;
  if (a <= l && r <= b) {
    return dat[k];
  } else {
    int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return max(vl, vr);
  }
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  init();
  for (int i = 0; i < n; ++i) {
    int hoge = query(max(0, a[i] - k), a[i] + k + 1, 0, 0, N);
    update(a[i], hoge + 1);
  }
  cout << query(0, N, 0, 0, N) << endl;
  return 0;
}

Measured memory_bytes: 8544
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int main() {
	int n, q, query, t, x;

	cin >> n >> q;

	priority_queue<int> Q[n];

	for (int i = 0; i < q; i++) {
		cin >> query >> t;

		if (query == 0) {
			cin >> x;
			Q[t].push(x);
		}
		else if (query == 1) {
			if (Q[t].size() != 0)
				cout << Q[t].top() << endl;
		}
		else {
			if (Q[t].size() != 0)
				Q[t].pop();		
		}	
	}
}




Measured memory_bytes: 4092
#include<stdio.h>
int main(void){
    int N,K,i,x=0;
    scanf("%d%d",&N,&K);
    int h[N];
    for(i=0;i<=N-1;i++){
        scanf("%d",&h[i]);
        if(h[i]>=K)x++;
    }
    printf("%d",x);
    return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;

#define init() ios::sync_with_stdio(false); cin.tie();
#define for0(i, n) for (int i=0; i<n; i++)
#define for1(i, n) for (int i=1; i<=n; i++)
#define for2(i, a, b) for (int i=a; i<=b; i++)
#define bac0(i, n) for (int i=n-1; i>=0; i--)
#define bac1(i, n) for (int i=n; i>0; i--)
#define bac2(i, a, b) for (int i=a; i>=b; i--)
#define PB push_back
#define MOD 1000000007
#define S second
#define F first
#define B 99997LL

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, char> ic;

const int N = (int) (1e6 + 5);

int n;
ll f[N];

void add(ll &a, ll b) {
    a = (a + b) % MOD;
}

ll mult(ll a, ll b) {
    return (a * b) % MOD;
}

ll powmod(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = mult(res, a);
        b >>= 1, a = mult(a, a);
    }
    return res;
}

ll inv(ll a) {
    return powmod(a, MOD - 2);
}

ll C(ll n, ll k) {
    if (n < k) return 0;
    return mult(f[n], inv(mult(f[k], f[n - k])));
}

int main() {
    init()

    cin >> n;
    f[0] = 1;
    for (ll i = 1; i <= n; i++) f[i] = mult(f[i - 1], i);
    --n;

    ll sum = 0, res = 0;
    for (ll i = (n + 1) / 2; i <= n; i++) {
        ll k = n - i;
        ll value = mult(C(n - 2 - k + 1, k), mult(f[i], f[k]));
        res = (res + mult((value - sum + MOD) % MOD, i)) % MOD;
        sum = value;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <tuple>

using namespace std;

using pos = tuple<int,int,int>;
int visited[500][500] = {};
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int H,W;

char G[500][500];

void dfs(int x, int y, char c, int cnt){
    queue<pos> Q;
    Q.push(make_tuple(x,y,c));
    visited[x][y] = cnt;
    while(!Q.empty()){
        auto cur = Q.front();
        Q.pop();
        char pc = get<2>(cur);
        for(int k=0;k<4;k++){
            int nx = get<0>(cur) + dx[k];
            int ny = get<1>(cur) + dy[k];

            if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if(visited[nx][ny] != 0) continue;
            if(G[nx][ny] == pc) continue;

            visited[nx][ny] = cnt;
            Q.push(make_tuple(nx,ny, G[nx][ny]));
        }
    }
}

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

    int cnt = 1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(visited[i][j] == 0 && G[i][j] == '#'){
                dfs(i,j,G[i][j], cnt++);
            }
        }
    }

    vector<pair<long long,long long> > count(cnt+1);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(G[i][j] == '#') count[visited[i][j]].first++;
            else               count[visited[i][j]].second++;
        }
    }

    long long ans = 0;
    for(auto t : count){
        ans += t.first * t.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
import sys
def readint():
    for line in sys.stdin:
        yield int(line)

def getprimes(maxn):
    sieve = [0 for i in range(0,maxn+1)]
    ps = set()
    for p in range(2,maxn+1):
        if sieve[p]:
            continue
        else:
            ps.add(p)
            for k in range(p,maxn+1,p):
                sieve[k] = 1
    return ps

ns = [x for x in readint()]
primes = getprimes(max(ns))
for n in ns:
    print len(filter(lambda x:n>=x, primes))

Measured memory_bytes: 59640
from itertools import accumulate
n, k = map(int,input().split())
p = list(map(int,input().split()))
kt = []
for i in range(n):
    kt.append((p[i]*(p[i]+1)/2/p[i]))
skt = sum(kt)

ac = [0] + list(accumulate(kt))
ans = -float('inf')
for i in range(n-k+1):
    ans = max(ans, ac[i+k] - ac[i])
print(ans)

Measured memory_bytes: 26236
#A
#Bellman-Ford法(最短距離)
def BellmanFord(edges,num_v,source):#（辺と重みのリスト、頂点の数、始点(1-index)）
    #グラフの初期化
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source]=0
    #辺の緩和
    for i in range(num_v):
        for edge in edges:
            if dist[edge[0]] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]:
                dist[edge[1]] = dist[edge[0]] + edge[2]
                if i==num_v-1: 
                  return -1 #負経路を検出
    return dist

V,E,r = map(int,input().split())
STD = [list(map(int,input().split())) for i in range(E)]

inf = float("inf")
dist = BellmanFord(STD,V,r)
if dist == -1:
    print("NEGATIVE CYCLE")
else:
    for d in dist:
        if d == inf:
          print("INF")
        else:
          print(d)


Measured memory_bytes: 6124
import std.stdio, std.string;

bool[] make_primes(int n) {
  bool primes[] = new bool[](n + 1);
  foreach(ref p; primes) p = true;
  primes[0] = primes[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if (primes[i])
      for(int j = i * 2; j <= n; j += i) {
        primes[j] = false;
    }
  }
  return primes;
}

void main() {
  bool[] primes = make_primes(60000);
  for(int n; readf("%d\n", &n);) {
    int max = n + 1, min = n - 1;
    while(!primes[min]) {min--;}
    while(!primes[max]) {max++;}
    writeln(min, " ", max);
  }
}

Measured memory_bytes: 1060
import java.util.Scanner;

public class Main {
	void print(int[][] a, int x, int y) {
		for (int i = 0; i < 21; i++) {
			for (int j = 0; j < 21; j++) {
				if (i == y && j == x) {
					System.out.print("@");
				} else {
					System.out.print(a[i][j] == 0 ? "^" : "*");
				}
			}
			System.out.println();
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int[] dx = new int['Z'];
		int[] dy = new int['Z'];
		dx['E'] = 1;
		dx['W'] = -1;
		dy['N'] = 1;
		dy['S'] = -1;
		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[][] a = new int[21][21];
			for (int i = 0; i < n; i++) {
				int kx = sc.nextInt();
				int ky = sc.nextInt();
				a[ky][kx] = 1;
			}
			int m = sc.nextInt();
			int x = 10, y = 10, sum = 0;
			for (int i = 0; i < m; i++) {
				char d = sc.next().toCharArray()[0];
				int l = sc.nextInt();
				for (int j = 0; j < l; j++) {
					sum += a[y][x];
					a[y][x]  = 0;
					x += dx[d];
					y += dy[d];
				}
				sum += a[y][x];
				a[y][x]  = 0;
			}

			System.out.println(sum == n ? "Yes" : "No");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

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

  vector<int> ty(6,0);
  for(int i=0;i<n;i++){
    int w;
    cin>>w;
    int a=1;
    int b=2;
    int c=3;

    for(int j=0;j<w;j++){
      int t;
      cin>>t;
      if(t==0){
        int tmp=a;
        a=b;
        b=tmp;
      }else{
        int tmp=b;
        b=c;
        c=tmp;
      }
    }
    if(a==1&&b==2)ty[0]++;
    if(a==2&&b==1)ty[1]++;
    if(a==1&&b==3)ty[2]++;
    if(a==3&&b==2)ty[3]++;
    if(a==2&&b==3)ty[4]++;
    if(a==3&&b==1)ty[5]++;
  }

  //for(int i=0;i<6;i++)cout<<ty[i]<<endl;


  if(ty[0]!=0){
    cout<<"yes"<<endl;
    return 0;
  }

  if(ty[1]>1||ty[2]>1||ty[3]>1){
    cout<<"yes"<<endl;
    return 0;
  }

  if(ty[4]>2||ty[5]>2){
    cout<<"yes"<<endl;
    return 0;
  }

  if(ty[4]==1&&ty[5]==1){
    cout<<"yes"<<endl;
    return 0;
  }

  vector<int> np;
  for(int i=1;i<6;i++){
    for(int j=0;j<ty[i];j++)np.push_back(i);
  }
  //for(int i=0;i<np.size();i++)cout<<np[i];

  do{
    int a=1;
    int b=2;
    int c=3;
    int tmp;
    for(int i=0;i<np.size();i++){
      if(np[i]==1){
        tmp=a;
        a=b;
        b=tmp;
      }

      if(np[i]==2){
        tmp=b;
        b=c;
        c=tmp;
      }

      if(np[i]==3){
        tmp=a;
        a=c;
        c=tmp;
      }

      if(np[i]==4){
        tmp=a;
        a=b;
        b=c;
        c=tmp;
      }

      if(np[i]==5){
        tmp=a;
        a=c;
        c=b;
        b=tmp;
      }
      if(a==1&&b==2){
        //for(int i=0;i<np.size();i++)cout<<np[i];
        cout<<"yes"<<endl;
        return 0;
      }
    }
  }while(next_permutation(np.begin(),np.end()));


  cout<<"no"<<endl;

}



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

int main(){
	int n;cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	
	sort(a.begin(),a.end());
	int count=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int y=upper_bound(a.begin()+i,a.begin()+j,a[i]+a[j])-upper_bound(a.begin()+i,a.begin()+j,a[j]-a[i]);
			count+=min(j-i-1,y);

		}
	}
	cout<<count<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Choose Integers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int g = __gcd(a, b);
  if (c % g == 0) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 2147483647;
typedef long long ll;


const int MAX_N = 1 << 17;
ll n,dat[2*MAX_N-1];

void init(int n_){
  // ????´????2???????????????
  n = 1;
  while(n < n_)  n*=2;
  //??¨????????????INF???
  for(int i = 0; i < 2 * n - 1; i++)  dat[i] = 0;
}

void update(int k, int a){
  k += n - 1;
  dat[k] += a;
  while(k > 0){
    k = (k-1)/2;
    dat[k] = dat[k*2+1]+dat[k*2+2];
  }
}

// ???????????????????????????query(a,b,0,0,n) [l,r)??????????????????????????¨????????????
int query(int a,int b,int k,int l,int r){
  if( r <= a || b <= l) return 0;
  
  //[a,b)???[l,r)????????¨???????????§????????°??????????????????
  if(a <= l && r <= b)  return dat[k];
  else{
    int vl = query(a,b,k*2+1,l,(l+r)/2);
    int vr = query(a,b,k*2+2,(l+r)/2,r);
    //cout << vl << "  " << vr << endl;
    return vl+vr;
  }
}

int main(){

  int o,q;
  cin >> o >> q;
  init(o);
  REP(i,q){
    int c,x,y;
    cin >> c >> x >> y;
    /*REP(j,2*n-1)
	cout << dat[j] << " ";
	cout << endl;*/
    if(c == 0){
      update(x-1,y);
    }
    else{
      int a = query(x-1,y,0,0,n);
      
      cout << a << endl;
    }
    
  }

}

Measured memory_bytes: 5092
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  bool f=0;
  for(int i=0;i<s.size();i++){
    if(s==t){
      f=1;
      break;
    }
    s=s.back()+s.substr(0,s.size()-1);
  }
  if(f)cout << "Yes";
  else cout << "No";
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define sqr(x) (x)*(x)
using namespace std;
vector<int>C(5000);
vector<int>x(100000);
int ans=0;
int n,m;
int main(){
  while(cin>>n>>m,n){
    ans=INF;
    int dp[n+20][260]={};
    for(int i=0;i<n+2;i++)
      for(int j=0;j<260;j++)
	dp[i][j]=INF;
    for(int i=0;i<m;i++)
      cin>>C[i];
    for(int i=0;i<n;i++){
      cin>>x[i];
    }

    dp[0][128]=0;
    for(int i=1;i<=n;i++){
      for(int j=0;j<260;j++){
	if(dp[i-1][j]!=INF){
	  for(int k=0;k<m;k++){
	    int num=j+C[k];
	    if(num>=255)num=255;
	    else if(num<0)num=0;
	    //cout<<i<<" "<<
	    dp[i][num]=min(dp[i-1][j]+((num-x[i-1])*(num-x[i-1])),dp[i][num]);
	  }
	}
      }
    }
    for(int i=0;i<260;i++){
      ans=min(dp[n][i],ans);
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 23596
#include <stdio.h>
int main()
{
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)
			break;
		else if(x<=y)
			printf("%d %d\n",x,y);
		else
			printf("%d %d\n",y,x);
	}
	return 0;
}

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

using namespace std;
 
//#define int long long
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)

ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll modm(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    if(b%a==0){
      cout << a+b << endl;
    }else{
      cout << b-a << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
N,M=map(int,input().split())
xy=[list(map(int,input().split()))for _ in range(M)]

countR=[0]+[1]+[0]*(N-1)
countBall=[0]+[1]*N

for x,y in xy:
    countBall[x]-=1
    countBall[y]+=1
    if countR[x]>0:
        countR[y]+=1
    if countBall[x]<1:
        countR[x]=0

print(sum(r*b>0 for r,b in zip(countR,countBall)))

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

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++)
    if((int)floor(i * 1.08) == n) {
      printf("%d\n", i);
      return 0;
    }
  printf(":(\n");
}

Measured memory_bytes: 256
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let a: u64 = splited.next().unwrap().parse().unwrap();
    let b: u64 = splited.next().unwrap().parse().unwrap();

    let ans = solve_(a, b);
    writeln!(&mut writer, "{}", ans).unwrap();
}

fn f(n: u64) -> u64 {
    if n % 2 == 0 {
        let m = n / 2;
        let k = if m % 2 == 0 { 0 } else { 1 };
        k ^ n
    } else {
        let m = (n + 1) / 2;
        if m % 2 == 0 {
            0
        } else {
            1
        }
    }
}

fn solve_(a: u64, b: u64) -> u64 {
    f(a - 1) ^ f(b)
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"2 4", br"5
",
        ),
        (
            br"123 456",
            br"435
",
        ),
        (
            br"123456789012 123456789012",
            br"123456789012
",
        ),
    ];

    #[test]
    fn test_d() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut h: [usize; n],
    }
    // 逆順にソート
    h.sort_by(|a, b| b.cmp(a));
    
    // 必殺技の回数をスキップして合計
    let sum: usize = h.iter().skip(k).sum();
    println!("{}", sum);
}


Measured memory_bytes: 6244
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <functional>
#include <cassert>

using namespace std;

using i64 = long long;
using P = pair<i64, i64>;

const i64 mod = 1e9 + 7;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

int main(){
    i64 n;
    cin >> n;
    vector<i64> a(n);
    i64 sum = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum += a[i];
    }
    i64 ans = std::numeric_limits<i64>::max();
    i64 s = 0;
    for(int i = 0; i < n; ++i){
        s += a[i];
        sum -= a[i];
        ans = min({ans, abs(sum - s)});
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
S = input()
N = len(S)
S = list(S)
Sr = S[::-1]
a = S[:(N-1)//2]
b = S[(N+1)//2:]
ar = a[::-1]
br = b[::-1]
if a==ar and b == br and S==Sr:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int res=0;
  for(int i=1;i<=n;i++)
  {
    int k;
    cin>>k;
      if(k%2==1&&i%2==1)
        res++;
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 3604
C = [list(map(int,input().split())) for _ in range(3)]
if C[1][0]-C[0][0]==C[1][1]-C[0][1]==C[1][2]-C[0][2] and C[2][0]-C[0][0]==C[2][1]-C[0][1]==C[2][2]-C[0][2] \
and C[0][1]-C[0][0]==C[1][1]-C[1][0]==C[2][1]-C[2][0] and C[0][2]-C[0][0]==C[1][2]-C[1][0]==C[2][2]-C[2][0]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    cout << 48 - m << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  char a[2],b[2];
  scanf("%s %s", a,b);
  if(strcmp(a,b)==0) printf("=\n");
  else if(strcmp(a,b)>0) printf(">\n");
  else printf("<\n");
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(string, s);
    var(int, X, Y);

    vector<int> a[2];
    {
        int cnt = 0;
        int dir = 0;
        s += "T";

        for (char c : s) {
            if (c == 'T') {
                a[dir].push_back(cnt);
                dir = dir ^ 1;
                cnt = 0;
            } else {
                ++cnt;
            }
        }
    }

    dump(a[0]);
    dump(a[1]);

    constexpr int I = 8080;
    const auto &xs = a[0];
    const auto &ys = a[1];
    bool okX, okY;

    {
        bitset<2 * I> dp;
        dp[xs[0] + I] = 1;
        rep(i, 1, xs.size()) { dp = (dp << xs[i]) | (dp >> xs[i]); }
        okX = dp[X + I];
    }
    {
        bitset<2 * I> dp;
        dp[0 + I] = 1;
        rep(i, 0, ys.size()) { dp = (dp << ys[i]) | (dp >> ys[i]); }
        okY = dp[Y + I];
    }

    print(okX && okY ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 3696
N = int(input())

N_list = list(map(int,input().split()))
max_n = 0
cnt = 0
for i in range(len(N_list)-1):
  if max_n < N_list[i]:
    max_n = N_list[i]
  if max_n > N_list[i+1]:
    cnt += max_n - N_list[i+1]
    
print(cnt)

Measured memory_bytes: 32288
num_str = input()
 
min_num = 753
for i in range(len(num_str) - 2):
  cur_num = int(num_str[i:i+3])
  sub_num = abs(753 - cur_num)
  min_num = min(sub_num, min_num)
  if min_num == 0:
    break
    
print(min_num)

Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>

using namespace std;

template <class RandomIt, class Comp>
RandomIt partition_(RandomIt first, RandomIt last, Comp comp) {
    using T=typename RandomIt::value_type;
    T x=last[-1];
    RandomIt it=first-1;
    for (RandomIt it2=first; it2<last-1; ++it2)
        if (!comp(x, *it2)) {
            ++it;
            swap(*it, *it2);
        }

    swap(*++it, last[-1]);
    return it;
}

template <class RandomIt, class Comp>
void qsort(RandomIt first, RandomIt last, Comp comp) {
    if (first >= last) return;

    RandomIt pivot=partition_(first, last, comp);
    qsort(first, pivot, comp);
    qsort(pivot+1, last, comp);
}

struct Card {
    int rank;
    char suit;
    size_t order;
};

bool operator<(const Card x, const Card y) {
    return x.rank < y.rank;
}

int main() {
    size_t n;
    scanf("%zu\n", &n);

    vector<Card> a(n);
    for (size_t i=0; i<n; ++i) {
        scanf("%c %d\n", &a[i].suit, &a[i].rank);
        a[i].order = i;
    }

    qsort(a.begin(), a.end(), less<Card>());

    bool is_stable=true;
    for (size_t i=0; i<n-1; ++i)
        if (a[i].rank == a[i+1].rank)
            if (a[i].order > a[i+1].order) {
                is_stable = false;
                break;
            }

    printf("%s\n", is_stable? "Stable":"Not stable");
    for (Card p: a)
        printf("%c %d\n", p.suit, p.rank);

    return 0;
}

Measured memory_bytes: 3960
n = int(input())
max_count = 0
max_elem = 1
for i in range(1, n+1):
    j = i
    j_count = 0
    while j%2 == 0:
        j = j / 2
        j_count = j_count+1
    if max_count < j_count:
        max_count = j_count
        max_elem = str(i)
print(max_elem)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String [] s = new String[n];
		boolean hantei = true;
		for(int i=0;i<n;i++) {
			s[i]=scan.next();
			if(s[i].equals("Y")) {
				hantei = false;
			}
		}
		if(hantei ==true) {
			System.out.println("Three");
		}else {
			System.out.println("Four");
		}
	}

}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;

int main(){
  string S,T; cin>>S>>T;
  int ls = S.size(), lt = T.size();
  vector<vector<int>> dp(ls+1,vector<int>(lt+1,0));
  for(int s = 0; s < ls; s++){
    for(int t = 0; t < lt; t++){
      if(S.at(s)==T.at(t)) dp.at(s+1).at(t+1) = dp.at(s).at(t) + 1;
      else dp.at(s+1).at(t+1) = max(dp.at(s+1).at(t),dp.at(s).at(t+1));
    }
  }
  string res = "";
  int t = lt, s = ls;
  while(s!=0&&t!=0){
    if(dp.at(s).at(t)==dp.at(s-1).at(t))s--;
    else if(dp.at(s).at(t)==dp.at(s).at(t-1))t--;
    else{
      res = S.at(s-1) + res;
      s--;
      t--;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e5+2;
string n;
int k;
int dp[102][2][5];
bool vis[102][2][5];
int fun(int pos,bool same,int oof)
{
	if(pos>=(int)n.size()){
	 if(oof==0) return 1;
	 else return 0;
	}
	if(vis[pos][same][oof])
	{
		return dp[pos][same][oof];
	}
	int ans=0;
	for(int i=0;i<=9;i++)
	{
		if(same&&((i+'0')>n[pos])) continue;
		if((oof-(i!=0?1:0))<0)
		{
			continue;
		}
		ans+=fun(pos+1,same&&((i+'0')==(n[pos])),(oof-(i!=0?1:0)));
	}
	vis[pos][same][oof]=true;
	return dp[pos][same][oof]=ans;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>k;
	cout<<fun(0,true,k);
} 
// I never lose. I either win or I learn

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

int main() {
    int N;
    cin >> N;
    long int ans = 0;
    vector<int> vec(N);
    rep(i, N){
        vec.at(i)=i+1;
    }
    rep(i, N) {
        if(vec.at(i) % 3 == 0 && vec.at(i) % 5 == 0){
        }
        else if(vec.at(i) % 3 == 0 || vec.at(i) % 5 == 0){
        }
        else
            ans+=vec.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 7220
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        v: [usize; n],
    }
    let mut v = v;
    v.sort();
    let v = v.iter().map(|&vi| vi as f64).collect::<Vec<_>>();
    let mut s = (v[0] + v[1]) / 2.0;
    for i in 2..n {
        s = (s + v[i]) / 2.0;
    }
    println!("{}", s);
}


Measured memory_bytes: 4352
#include<cstdio>

using namespace std;

int main(){
    long int n, m;
    scanf("%ld %ld", &n, &m);
    long int ans;
    if (n >= 2 && m >= 2){
        ans = (n - 2) * (m - 2);
        
    } else if (n == 1 && m >= 2){
        ans = m - 2;
    } else if (n >= 2 && m == 1){
        ans = n - 2;
    } else {
        ans = 1;
    }
    printf("%ld\n", ans);
}

Measured memory_bytes: 128