akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    vector<int>v(n); erep(e,v) cin >> e;
    vector<int>maxim = v;
    vector<int>mini = v;
    rep(i,n){
        if(i){
            int ri = n - i - 1;
            cmin(mini[i],mini[i-1]);
            cmax(maxim[ri],maxim[ri+1]);
        }
    }
    int ans = -INF;
    rep(i,n-1) cmax(ans, maxim[i+1] - mini[i]);
    cout << ans << endl;
}





Measured memory_bytes: 7616
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
    double k,i,j,t,c=0;
    cin>>t>>k;
    for(i=0;i<t;i++)
    {
        cin>>j;
        if(j>=k)
            c++;
    }
    cout<<c<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int n;
int a[N], x[N][N], y[N][N];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		for (int j = 1; j <= a[i]; j++) {
			cin >> x[i][j] >> y[i][j];
		}
	}
	int ans = 0;
	for (int mask = (1 << n) - 1; mask >= 0; mask--) {
		bitset<20> b(mask);
		int is_valid = 1;
		for (int i = 1; i <= n; i++) {
			if (b[n - i] == 1) {
				int flag = 1;
				for (int j = 1; j <= a[i]; j++) {
					if (b[n - x[i][j]] != y[i][j]) {
						flag = 0;
						break;
					}
				}
				if (!flag) {
					is_valid = 0;
					break;
				}
			}
		}
		if (is_valid)
			ans = max(ans, (int) b.count());
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    int x = x2 - x1;
    int y = y2 - y1;
    cout << x2 - y << ' ' << y2 + x << ' ' << x1 - y << ' ' << y1 + x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s,t;
    cin>>s>>t;
    vec<vec<bool>> v(26,vec<bool>(26,false));
    rep(i,s.size()) v[s[i]-'a'][t[i]-'a']=true;
    rep(i,26){
        ll sum=0;
        rep(j,26){
            if(v[i][j]==true) sum++;
            if(sum>=2){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    rep(j,26){
        ll sum=0;
        rep(i,26){
            if(v[i][j]==true) sum++;
            if(sum>=2){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 1e5;
ll N, K;
Pii sushi[MAX_N];
int main(){
   cin >> N >> K;
   REP(i, N){
      ll type, taste; cin >> type >> taste;
      sushi[i] = mp(taste, type);
   }
   //sushiをtasteの降順にソート
   sort(sushi, sushi + N, greater<Pii>());

   //優先度付きキュー：tasteの降順で並んでいる
   priority_queue<Pii, vector<Pii>, greater<Pii>> q;
   map<ll, ll> cnt;
   ll base = 0, bonus = 0, total;

   REP(i, K){
      q.push(sushi[i]);
      cnt[sushi[i].second]++;
      base += sushi[i].first;
   }
   bonus = cnt.size();
   total = base + bonus * bonus;

   ll i = K;
   while(!q.empty()){
      Pii s = q.top(); q.pop();
      if(cnt[s.second] == 1) continue;
      cnt[s.second]--;
      base -= s.first;
      while(i < N){
         if(cnt[sushi[i].second] == 0){
            cnt[sushi[i].second]++;
            base += sushi[i].first;
            bonus ++;
            chmax(total, base + bonus * bonus);
            break;
         }
         i++;
      }
   }
   cout << total << endl;




}


Measured memory_bytes: 7280
s = input()
count = 0
a, c, q = 0, 0, 0
n = len(s)
for i in range(n):
    if s[i] == 'C':
        c += 1
    elif s[i] == '?':
        q += 1
    else:
        continue
c = 3 * c + q
p = pow(3, q-3)
for i in range(n):
    if s[i] == 'A':
        a += 3
    elif s[i] == 'C':
        c -= 3
    elif s[i] == 'B':
        count += 3*a*c
    else:
        c -= 1
        count += a*c
        a += 1
print(int(count*p) % 1000000007)

Measured memory_bytes: 3188
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] a) {
        Scanner scan = new Scanner(System.in);
        int stuNum = scan.nextInt();
        Map<Integer, Integer> numMap = new HashMap<>();
        for (int i = 1; i < stuNum + 1; i++) {
            int s = scan.nextInt();
            int dis = stuNum - s;
            numMap.put(stuNum - dis, i);
        }
        for (int j = 1; j < numMap.size() + 1; j++) {
            System.out.printf("%d ", numMap.get(j));
        }
    }
}

Measured memory_bytes: 107756
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		player player1[] = new player[8];
		player player2[] = new player[8];
		player player3[] = new player[8];
        for(int i=0; i<8; i++)player1[i] = new player(sc.nextInt() , sc.nextDouble());
        for(int i=0; i<8; i++)player2[i] = new player(sc.nextInt() , sc.nextDouble());
        for(int i=0; i<8; i++)player3[i] = new player(sc.nextInt() , sc.nextDouble());
        
        Arrays.sort(player1);
        System.out.println(player1[0] + "\n" + player1[1]);
        player1[0].record = 50;
        player1[1].record = 50;
         
        Arrays.sort(player2);
        System.out.println(player2[0] + "\n" + player2[1]);
        player2[0].record = 50;
        player2[1].record = 50;
         
        Arrays.sort(player3);
        System.out.println(player3[0] + "\n" + player3[1]);
        player3[0].record = 50;
        player3[1].record = 50;
        
        Arrays.sort(player1);
        Arrays.sort(player2);
        Arrays.sort(player3);
        player player4[]= new player[6];
        player4[0] = new player(player1[0].playerNumber,player1[0].record);
        player4[1] = new player(player1[1].playerNumber,player1[1].record);
        player4[2] = new player(player2[0].playerNumber,player2[0].record);
        player4[3] = new player(player2[1].playerNumber,player2[1].record);
        player4[4] = new player(player3[0].playerNumber,player3[0].record);
        player4[5] = new player(player3[1].playerNumber,player3[1].record);
        Arrays.sort(player4);
        System.out.println(player4[0] + "\n" + player4[1]);
    }
}
	class player implements Comparable<player>{
		int playerNumber;
	    double record;
	    player(int playerNumber, double record){
	        this.playerNumber = playerNumber;
	        this.record = record;
	    }
	    @Override
	    public String toString(){
	        return  playerNumber + " " + record;
	    }
	    @Override
	    public int compareTo(player o) {
	    	return new Double(record).compareTo(o.record);
	    }
}

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

const int mod = 1e9 + 7;

long long pow_mod(long long n, long long  k, long long m){
  if ( k == 0 ) { return 1; }

  if ( k%2 == 0 ) {
    long long t = pow_mod(n, k/2, m);
    return t*t % m;
  }
  
  return n * pow_mod(n, k-1, mod) % m;
}

long long comb_mod(long long n, long long k, long long m) {
  if ( k == 0 ) { return 1; }

  long long x = 1;
  for ( long long i = 1; i <= k; i++ ) {
    x *= n - k + i;
    x %= m;
  }

  long long y = 1;
  for ( long long i = 1; i <= k; i++ ) {
    y *= i;
    y %= m;
  }

  return x * pow_mod(y, m-2, m) % m;
}

int main() {
  long long n, a, b;
  cin >> n >> a >> b;

  long long ans = pow_mod(2, n, mod) - 1;
  ans = (ans+mod - comb_mod(n, a, mod)) % mod;
  ans = (ans+mod - comb_mod(n, b, mod)) % mod;

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


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <atcoder/lazysegtree>
#include <atcoder/modint>

using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using mint = atcoder::modint998244353;
using F = pair<mint, mint>;
using S = pair<mint, int>;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

int N,Q;
vector<S> A;
inline void input(){
    fast_io();
    cin >> N >> Q;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        A.emplace_back(a,1);
    }
}

S op(S x, S y){ return S{x.first + y.first, x.second + y.second};}
S e(){ return S{0,0}; }
S mapping(F f, S x){ return S{f.first*x.first + f.second*x.second, x.second};}
F composition(F f, F g){ return F{f.first*g.first, f.first*g.second + f.second};}
F id(){ return F{1,0};}

inline int solve(){
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id > lsg(A);
    for (int i = 0; i < Q; i++)
    {
        int type; cin >> type;
        if(type==0){
            int l,r;
            int b,c;
            cin >> l >> r >> b >> c;
            lsg.apply(l,r,F{b,c});
        }
        else{
            int l,r;
            cin >> l >> r;
            cout << lsg.prod(l,r).first.val() << endl;
        }
    }
    return 0;
}   

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


Measured memory_bytes: 19496
#include <iostream>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
  vector<ll> v,w;
  char c;
  ll k,nr=0,nb=0,ng=0,n,sum;
  cin>>n;
  while(scanf("%c",&c)!=EOF){
    if(c=='R'){v.push_back(1);nr++;}
    else if(c=='B'){v.push_back(2);nb++;}
    else if(c=='G'){v.push_back(3);ng++;}
  }
  w=v;
  sum=ng*nb*nr;
  if(sum==0){
    cout<<sum<<endl;
    return 0;
  }
  for(ll i=0;i<n-2;i++){
    for(ll j=i+1;j<n-1;j++){
      k=2*(j+1)-(i+1);
      if(k<=n){
        if(w[k-1]!=w[j]&&w[j]!=w[i]&&w[i]!=w[k-1])sum--;
      }
    }
  }
  if(sum<=0){
    cout<<0<<endl;
    return 0;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main(){
     int n, ans = 0;
     cin >> n;
  
     int data[n+5];
     int fre[2005] = {0};
  
     for(int i = 1; i <= n; i++){
            cin >> data[i];
            fre[data[i]]++;
     }
    
    for(int i = 1; i<= 2000; i++){
        fre[i]+=fre[i-1];
    }
  
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
          int r = data[i] + data[j] - 1;
          int l = max(data[i], data[j]) - min(data[i], data[j]) + 1;
          ans += (fre[r]);
        
          if(l>0){
            ans-=(fre[l-1]);
          }
          if(data[i] <=r  && data[i] >= l){
             ans--;
          }
          if(data[j] <=r  && data[j] >= l){
             ans--;
          }
        }
    }
    ans/=3;
   cout << ans << '\n';
}

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

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

using namespace std;

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

const int inf = 1e7;

int n;
string t;
int q;
string p[10000];
int sa[11][1000000];
int isa[1000000];
int lcp[1 << 21];

int stu(int i, int x, int k, int l, int r){
	if(r <= i || i < l){
		return lcp[k];
	}
	if(i <= l && r <= i + 1){
		return lcp[k] = x;
	}
	int m = (l + r) / 2;
	return lcp[k] = min(
		stu(i, x, 2 * k + 1, l, m),
		stu(i, x, 2 * k + 2, m, r)
	);
}
void stu(int i, int x){
	stu(i, x, 0, 0, n - 1);
}

int rmq(int a, int b, int k, int l, int r){
	if(r <= a || b <= l){
		return inf;
	}
	if(a <= l && r <= b){
		return lcp[k];
	}
	int m = (l + r) / 2;
	return min(
		rmq(a, b, 2 * k + 1, l, m),
		rmq(a, b, 2 * k + 2, m ,r)
	);
}
int rmq(int a, int b){
	return rmq(a, b, 0, 0, n - 1);
}

void pp(){
	string v = t;
	sort(v.begin(), v.end());
	rep(i, n){
		sa[0][i] = lower_bound(v.begin(), v.end(), t[i]) - v.begin();
	}
	for(int i = 1; i <= 10; ++i){
		int k = 1 << i - 1;
		vector<P> s(n);
		rep(j, n){
			s[j] = P(ll(sa[i - 1][j]) << 20 | (j + k < n ? sa[i - 1][j + k] + 1 : 0), j);
		}
		sort(s.begin(), s.end());
		rep(j, n){
			sa[i][s[j].second] = i == 10 || j == 0 || s[j - 1].first < s[j].first ? j : sa[i][s[j - 1].second];
		}
	}

	rep(i, n){
		isa[sa[10][i]] = i;
	}

	int l = 0;
	rep(i, n){
		int r = sa[10][i];
		if(r == n - 1){
			l = 0;
			continue;
		}
		int j = isa[r + 1];
		while(l < 1 << 10 && i + l < n && j + l < n && t[i + l] == t[j + l]){
			++l;
		}
		stu(r, l);
		l = max(l - 1, 0);
	}
}

bool srch(const string& p){
	int m = p.size();

	int h = 0;
	while(isa[0] + h < n && h < m && t[isa[0] + h] == p[h]){
		++h;
	}

	int l = 0;
	int r = n;
	bool b = true;
	while(r - l > 1){
		int k = (l + r) / 2;
		if(b){
			int c = rmq(l, k);
			if(c > h){
				l = k;
			}
			else if(c < h){
				r = k;
				continue;
			}
			else{
				while(isa[k] + h < n && h < m && t[isa[k] + h] == p[h]){
					++h;
				}
				if(isa[k] + h == n){
					l = k;
				}
				else if(h == m){
					return true;
				}
				else{
					if(t[isa[k] + h] < p[h]){
						l = k;
					}
					else{
						r = k;
					}
				}
			}
		}
		else{
			int c = rmq(k, r);
			if(c > h){
				r = k;
			}
			else if(c < h){
				l = k;
				continue;
			}
			else{
				while(isa[k] + h < n && h < m && t[isa[k] + h] == p[h]){
					++h;
				}
				if(isa[k] + h == n){
					l = k;
				}
				else if(h == m){
					return true;
				}
				else{
					if(t[isa[k] + h] < p[h]){
						l = k;
					}
					else{
						r = k;
					}
				}
			}
		}
		b = l == k;
	}
	return isa[l] + m <= n && string(t, isa[l], m) == p;
}

int main(){
	cin >> t >> q;
	n = t.size();
	rep(i, q){
		cin >> p[i];
	}

	pp();

	rep(i, q){
		cout << srch(p[i]) << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
int mod=1000000007;
int main()
{
    int n,m;
    int a[100005]= {0};
    cin>>n>>m;
    int b,c[100005];
    int f=1;
    for(int i=1; i<=m; i++)
    {
        scanf("%d",&b);
        a[b]=1;
        if(a[b-1]==1)
        {
            f=0;
            break;
        }
    }
    if(a[1]==0)
    {
        c[1]=1;
        if(a[2]==0)
            c[2]=2;
        else
            c[2]=0;
    }
    else
    {
        c[1]=0;
        if(a[2]==0)
            c[2]=1;
        else
            c[2]=0;
    }
    for(int i=3; i<=n; i++)
    {
        if(a[i]==0)
            c[i]=(c[i-1]+c[i-2])%mod;
        else
            c[i]=0;
    }
    if(!f)
        cout<<0;
    else
        cout<<c[n];
    return 0;
}


Measured memory_bytes: 1024
S = input()
K = int(input())

s = [v for v in S]

block = []
count = 1

if len(s) == 1:
    if K == 1:
        print(0)
        exit()
    else:
        if K%2 == 1:
            print((K-1)//2)
            exit()
        else:
            print(K//2)
            exit()

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count += 1
        if i+2 == len(s):
            block.append(s[i]*count)
    else:
        block.append(s[i]*count)
        count = 1

z = len(block)
t = 0
d = 0

if not z == 1:
    for j in range(len(block)):
        x = len(block[j])
        if x == 1:
            continue
        else:
            if x%2 == 0:
                t += x//2
            elif x%2 == 1:
                t += x - (x+1)//2
    
    if block[0][0] == block[-1][-1]:
        joint = block[0] + block[-1]
        y = len(joint)
        if y%2 == 1:
            d = 0
        else:
            d = 1
else:
    p = len(block[0])
    if p%2 == 0:
        t = p//2
    else:
        t = (p-1)//2
        if K%2 == 1:
            ans = t + p*(K-1)//2                       
            print(ans)
            exit()
        else:
            ans = p + p*(K-2)//2
            print(ans)
            exit()

ans = t*K + d*(K-1)
print(ans)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace C_Align
{
    public class Program

    {
        public static void Main(string[] args)
        {

            int n = ReadInt();
            List<long> line = new List<long>();
            for (int i = 0 ; i < n ; i++) line.Add(ReadInt());
            line.Sort();

            if(n % 2 == 0)
            {

                List<long> minHalf = new List<long>();
                List<long> maxHalf = new List<long>();

                //数列が偶数
                long res;
                for (int i = 0 ; i < n/2 ; i++)
                {
                    minHalf.Add(line[i]); //小さい順
                    maxHalf.Add(line[n - 1- i]); //大きい順
                }

                res = maxHalf.Sum(x => 2 * x)- minHalf.Sum(x => 2 * x) + minHalf[minHalf.Count - 1] - maxHalf[maxHalf.Count - 1];
                Console.WriteLine(res.ToString());
            }
            else
            {

                List<long> minHalf = new List<long>();
                List<long> maxHalf = new List<long>();

                //数列が奇数
                for (int i = 0 ; i < n / 2 ; i++)
                {
                    minHalf.Add(line[i]); //小さい順
                    maxHalf.Add(line[n - 1 - i]); //大きい順
                }
                minHalf.Add(line[(n - 1) / 2]);
                long res1 = maxHalf.Sum(x => 2 * x) - minHalf.Sum(x => 2 * x) + minHalf[minHalf.Count - 1] + minHalf[minHalf.Count - 2];

                minHalf.Remove(line[(n - 1) / 2]);
                maxHalf.Add(line[(n - 1) / 2]);

                long res2 = maxHalf.Sum(x => 2 * x) - minHalf.Sum(x => 2 * x) - maxHalf[maxHalf.Count - 1] - maxHalf[maxHalf.Count - 2] ;
                Console.WriteLine(Math.Max(res1,res2).ToString());

            }

        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}


Measured memory_bytes: 21468
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL a,b,c;
    cin>>a>>b>>c;
    LL t=c-a-b;
    if(t<=0){
        cout<<"No"<<endl;
    }else{
        if(4*a*b<t*t){
        cout<<"Yes"<<endl;

        }else{
        cout<<"No"<<endl;

        }
    }
}


Measured memory_bytes: 256
import collections

n = int(input())

listAll = []

ans = 0

for i in range(n):
	s = input()

	slist = list(s)

	#print(slist)

	slist.sort()
	#print(slist)
	sString = "".join(slist)
	#print(sString)

	listAll.append(sString)

c = collections.Counter(listAll)
# print(type(c))
for mykey in c.keys():
	# print("きー")
	#print(mykey)
	n = c[mykey]
	ans += n * (n-1) /2


print(int(ans))


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

int main() {
    string s;
    int max = 0;
    int rain = 0;
    cin >> s;

    for(int i=0; i<3; i++)
    {
        if(s[i] == 'R') rain++;
        else rain = 0;
        if(rain > max) max = rain;
    }

    cout << max << endl;

    return 0;
}



Measured memory_bytes: 3620
from collections import defaultdict
import bisect

n, m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(m)]

d = defaultdict(list)
for i in sorted(a):
    d[i[0]].append(i[1])

for x,y in a:
    print(str(x).zfill(6) + str(bisect.bisect_left(d[x], y)+1).zfill(6))

Measured memory_bytes: 82900
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int n;
    scanf("%d",&n);
    int mp[100100]={};
    int tmp;
    while(n--){
        scanf("%d", &tmp);
        mp[tmp]++;
        mp[tmp+2]++;
        mp[tmp+1]++;
    }
    int result=0;
    for(auto &x:mp){
        result=max(result,x);
    }
    cout << result << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin>>N;
    long long arr[N];
    for(int i=0;i<N;i++)
    {
        cin>>arr[i];
    }
    long long ans[N]={0};
    ans[1] = abs(arr[0]-arr[1]);
    for(int i=2;i<N;i++)
    {
        ans[i] = min(ans[i-1] + abs(arr[i]-arr[i-1]),ans[i-2] + abs(arr[i]-arr[i-2]));
    }
    cout<<ans[N-1];
  return 0;
}



Measured memory_bytes: 1792
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mod 1000000007
#define INF 1000000000000000
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	vector<ll> dp(1<<n,INF);
	dp[0]=0;
	for(ll i=0;i<m;i++){
		ll a,b;
		cin>>a>>b;
		ll mask=0;
		for(ll j=0;j<b;j++){
			ll c;
			cin>>c;
			c--;
			mask = (mask|(1<<c));
		}
		for(ll j=0;j<(1<<n);j++){
			if(dp[j]<INF){
				dp[j|mask]=min(dp[j|mask],dp[j]+a);
			}
		}
	}
	if(dp[(1<<n)-1]==INF){
		cout<<-1;
		return 0;
	}
	cout<<dp[(1<<n)-1];
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
using namespace std;

int main()
{
	cout << fixed << setprecision(6);
	int n;
	cin >> n;
	vector<int> als(n);
	for (auto& a : als)cin >> a;

	vector<bool> isVisited(n, false);
	isVisited[0] = true;

	int cnt, pos = 0;
	for (cnt = 1; ; ++cnt) {
		pos = als[pos] - 1;
		if (isVisited[pos]) {
			cnt = -1;
			break;
		}
		if (pos == 1)break;
		isVisited[pos] = true;
	}

	cout << cnt << endl;

	return 0;
}

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

int N, M, X;
vector<int> C(12);
int A[12][12];
int sum;
int ans;
vector<int> p(12);

void dfs(int c, int pay, vector<int>&p)
{
        vector<int> cp(M);
        for (int i = 0; i < M; ++i) cp[i] = p[i];
        for (int i = 0; i < M; ++i) {
                cp[i] += A[c][i];
        }
        bool judge = true;
        for (int i = 0; i < M; ++i) {
                if (cp[i] < X) {
                        judge = false;
                        break;
                }
        }
        pay += C[c];
        if (judge) {
                if (ans == -1) {
                        ans = pay;
                }
                else if (ans > pay) {
                        ans = pay;
                }
                return;
        }

        for (int i = c+1; i < N; ++i) {
                dfs(i, pay, cp);
        }
}

int main()
{

        cin >> N >> M >> X;
        for (int i = 0; i < N; ++i) {
                cin >> C[i];
                for (int j = 0; j < M; ++j) {
                        cin >> A[i][j];
                }
        }
        sum = 0;
        int num = 0;
        ans = -1;
        for (int i = 0;  i < N; ++i) {
                num = 0;
                for (int i = 0; i < M; ++i) {
                        p[i] = 0;
                }
                dfs(i, 0, p);
        }
        cout << ans << endl;



}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 2e6 + 6;
const int mod = (int) 1e9 + 7;

ll f[N], inv[N], finv[N];

void init() {
	f[0] = f[1] = inv[0] = inv[1] = finv[0] = finv[1] = 1;
	for (int i = 2; i < N; i++) {
		f[i] = (f[i - 1] * i) % mod;
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
		finv[i] = (finv[i - 1] * inv[i]) % mod;
	}
}

ll nCr(ll n, ll r) {
	return (f[n] * ((finv[r] * finv[n - r]) % mod)) % mod;
}

ll c(int n, int r) {
	return nCr(n + r + 2, r + 1) - 1;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	init();
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	r1--, c1--;
	ll res = c(r2, c2) - c(r1, c2) - c(r2, c1) + c(r1, c1);
	((res %= mod) += mod) %= mod;
	cout << res << endl;
	return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int per[n];
    int count = 0;
    for(int i = 0; i < n; i++){
        cin >> per[i];
    }
    for(int i = 1; i <= n-2;i++){
        if((per[i] < per[i-1] && per[i] > per[i+1]) || (per[i] > per[i-1] && per[i] < per[i+1])) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    t=s.replace('?',"D")
    print(t)





if __name__ == "__main__":
    main()

Measured memory_bytes: 68920
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }






void solve() {
    ll n,m;
    cin>>n>>m;
    ll a[100010];
    ll s=0;
    rep(i,n){
        cin>>a[i];
        s+=a[i];
    }
    ll cnt=0;
    rep(i,n){
        if((double)a[i]< (double)((double)s/(4.0*(double)m)) ) continue;
        cnt++;
    }
    if(cnt>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}





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


    solve(); 


    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a, b,c;
    string S;
    cin >> S;
    //cin >> a>>b>>c;
    S[3] = '8';
    cout << S << endl;

    return 0;
}


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

typedef long long int ll;

int main(){

int n, value;
vector<int> vec;
cin >> n;


while(n--){

    cin >> value;
    vec.push_back(value);

}

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

    /*
for (auto el : vec)
    cout << el << " ";
cout << endl;
*/
int half = vec.size()/2;
vec[half] - vec[half-1] != 0 ? cout << vec[half] - vec[half - 1] << endl : cout << 0 << endl;


    return 0;
}

Measured memory_bytes: 892
s = gets.chomp
t = gets.chomp
ans = 'UNRESTORABLE'
array = []
(s.size - t.size + 1).times do |i|
	ss = s.slice(i,t.size)
	flag = true
	t.size.times do |j|
		flag = false if ss[j] != "?" && ss[j] != t[j]
	end
	array << i if flag
end

if !array.empty?
	if !array.any?{|a| s.slice(a,t.size) == t}
		s[array[-1],t.size] = t
	end
	s.size.times do |i|
		s[i] = "a" if s[i] == "?"
	end
	ans = s
end

puts ans

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

l = list(" " * 8)

for i in range(N):
	l[i] = list(map(int, input().split()))

import numpy as np
import math

l = np.array(l)

mat = np.zeros([N,N])

for i in range(N):
	for j in range(i, N):
		mat[i,j] = math.sqrt((l[i][0] - l[j][0]) ** 2 + (l[i][1] - l[j][1])**2)

print(np.sum(mat + mat.T) / N)

Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  a -= x;
  b -= x;
  a = abs(a);
  b = abs(b);
  if (a < b)
    cout << 'A' << endl;
  else
    cout << 'B' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

ll cnt = 0;

int arr[1010], dp[1010][1010];

int main()
{
   int t1 = 0;

   int n, x = 0;
   cin >> n;
   int n1 = n;
   while(n1){
         x += n1%10;
         n1 /= 10;
   }
   if(n%x == 0) cout << "Yes";
   else cout << "No";

  // cout << min(n*a, b);


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    string a,b,c;
    cin>>a>>b;
    x=a.size();
    y=b.size();
    if(x==y-1)
    {
        b.pop_back();
        if(b==a)
        {
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 3588
'use strict'
function Main(s) {
  let input = s.trim();
  if(input == "SUN"){
    console.log(7);
  }else if(input == "MON"){
    console.log(6);
  }else if(input == "TUE"){
    console.log(5);
  }else if(input == "WED"){
    console.log(4);
  }else if(input == "THU"){
    console.log(3);
  }else if(input == "FRI"){
    console.log(2);
  }else if(input == "SAT"){
    console.log(1);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21956
#include <stdio.h>

int main(void)
{
	char w[10],text[1001];
	int cnt=0,i;
	scanf("%s",&w);
	while(1){
		scanf("%s",text);
		if(strcmp(text,"END_OF_TEXT")==0) break;
		
		for(i=0;strlen(text)>i;i++){
			if('A'<=text[i]&&'Z'>=text[i]) text[i]+=32;
		}
		if(strcmp(w,text)==0) cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    char a,b;
    while(scanf("%c",&a)!=EOF)
    {
        scanf(" ");
        scanf("%c",&b);
        if (a=='H')
        {
            printf("%c\n",b);
        }
        else
        {
            if (b=='H')
                printf("D\n");
            else
            printf("H\n");
        }
        getchar();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<tuple>
#include<algorithm>
#include<cmath>

#define rep(i,n) for (int i =0; i<(n); ++i)
using namespace std;
int main() {
	int r;
	cin >> r;
	cout << 3 * r*r << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n;
ll a[100010];
int main() {
	scanf("%d",&n);
	int i,j;
	ll x=0;
	for(i=0;i<n;i++)scanf("%lld",a+i),x^=a[i];
	for(i=0;i<n;i++) {
		a[i]|=x;a[i]-=x;
	}
	int cur=0; ll r=0;
	for(j=62;j>=0;j--) {
		for(i=cur;i<n;i++) {
			if(a[i]>>j&1){ 
				swap(a[i],a[cur]);
				break;
			}
		}
		for(i=0;i<n;i++) {
			if(i!=cur&&a[i]>>j&1) a[i]^=a[cur];
		}
		if(a[cur]>>j&1) cur++;
	}
	for(i=0;i<cur;i++)r^=a[i];
	printf("%lld",x+r*2);
	return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,x;
int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;
void init(){//数据读取
	int i,j;
	scanf("%d%d%d",&n,&m,&x);
	for(i=1;i<=n;i++){
		scanf("%d",&c[i]);
		for(j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	}
}
void dfs(int step){
	int i,j,k;
	if(step==len+1){//深搜结束条件
		for(k=1;k<=m;k++)d[k]=0;//d[k]表示被选择的书店，在k列位置上的和
		for(j=1;j<=len;j++)
			for(k=1;k<=m;k++)
				d[k]+=a[b[j]][k];//计算被选择的书店，在k列位置上的和
		for(k=1;k<=m;k++)
			if(d[k]<x)return;//不满足条件
		cost=0;
		for(j=1;j<=len;j++)cost+=c[b[j]];//计算花费
		sum=min(sum,cost);//找最小值
		return ;
	}
	for(i=b[step-1]+1;i<=n;i++)//找组合情况，就让后查找的位置越来越大，请注意i=b[step-1]+1
		b[step]=i,dfs(step+1);
}
int main(){
	init();
	for(len=1;len<=n;len++)//len界定选择的书店的数量
		b[0]=0,dfs(1);
	if(sum==100000000)printf("-1\n");//没找到
	else printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

int a[101][101],d[101],f[101],n,t,color[101];
void dfs_visit(int i){
  int j;
  color[i]=GRAY;
  d[i]=++t;
  for(j=1;j<=n;j++){
    if(a[i][j]==0)continue;
    if(color[j]==WHITE){
      dfs_visit(j);
    }
  }
  color[i]=BLACK;
  f[i]=++t;
}

void dfs(){
  int i;
  t=0;
  for(i=1;i<=n;i++){
    color[i]=WHITE;
  }
  for(i=1;i<=n;i++){
    if(color[i]==WHITE){
      dfs_visit(i);
    }
  }
}

int main(){
  int u,k,l,i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      a[i][j]=0;
      d[i]=-1;
      f[i]=-1;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&l);
      a[u][l]=1;
    }
  }
  dfs();
  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }

  return 0;
}



Measured memory_bytes: 2104
import java.util.*;
public class Main {
	final int INF = 1 << 29;
	int [][] pass;
	boolean [] isused;
	int [] candcost;
	int n, premin;

	//1435 debug
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m) == 0) break;
			pass = new int[n][n];
			isused = new boolean[n];
			candcost = new int[n];
			for(int i = 0;i < n; i++){
				Arrays.fill(pass[i], INF);
			}
			for(int i = 0; i < m; i++){
				int from = sc.nextInt() - 1;
				int to = sc.nextInt() -1;
				int cost = sc.nextInt();
				pass[from][to] = cost;
				pass[to][from] = cost;
			}

			int ans = INF;
			premin = Integer.MIN_VALUE;
			int res = 0;
			while(true){
				res = slimSpan();
				if(res == -1) break;
				ans = Math.min(ans, res);
			}
			System.out.println(ans == INF ? -1 : ans);
		}
	}

	private int slimSpan(){
		Arrays.fill(isused, false);
		Arrays.fill(candcost, INF);
		candcost[0] = 0;
		int max = 0, min = Integer.MAX_VALUE;

		while(true){
			int v = -1;
			for(int i = 0; i < n; i++){
				if(candcost[i] == INF) continue;
				if(! isused[i]){
					if(v == -1 || (candcost[v] > candcost[i]  && premin < candcost[i])){
						v = i;
					}
				}
			}
			if(v == -1) break;
			isused[v] = true;
			if(v != 0){
				max = Math.max(max,candcost[v]);
				min = Math.min(min, candcost[v]);
			}
			//cand cost
			for(int i = 0; i < n; i++){
				if(premin < pass[v][i] && candcost[i] > pass[v][i]){
					candcost[i] = pass[v][i];
				}
			}
		}

		for(int i = 0; i < n; i++){
			if(! isused[i]) return -1;
		}
		premin = min;
		return max - min;
	}

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

Measured memory_bytes: 13000
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut ans = 0;
    for _ in 0..n {
    	let mut x = get!();
        let mut k = 0;
        while x % 2 == 0 {
        	x /= 2;
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352