akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(ALL(a));
    reverse(ALL(a));
    ll ans = 0;
    vll seat(n, 0);
    int idx = 0;
    for (int i = 0; i < (n + 1) / 2; i++) {
        if (i > 0) ans += seat[idx - 2];
        seat[idx] = a[i];
        idx += 2;
    }

    idx = 1;
    // DEBUG_VLL(seat)
    for (int i = (n + 1) / 2; i < n; i++) {
        ans += min(seat[idx - 1], seat[(idx + 1) % n]);
        idx += 2;
    }
    cout << ans << '\n';
    return 0;
}


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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)1e6 + 123, mod = (int)1e9 + 7, inf = (int)1e9;
const ll INF = 1e18;
int n, m;
ll ans = INF;
string s, t;

bool check(ll x){
	ll a = x / n;
	ll b = x / m;
	ll lca = a * b / __gcd(a, b);
	a = lca / a;
	b = lca / b;
	for(ll i = 0; i * a < n; i++)
		if(s[i * a] != t[i * b])
			return 0;
	ans = min(ans, x);
	return 1;
}


int main(){
	cin >> n >> m;
	cin >> s >> t;
	for(ll i = 1; i <= m; i++)
		if(n * i % m == 0 && check(n * i))
			cout << n * i, exit(0);
	cout << -1;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0) cout<<1<<endl;
  if(b==0) cout<<2<<endl;
  if(c==0) cout<<3<<endl;
  if(d==0) cout<<4<<endl;
  if(e==0) cout<<5<<endl;
}

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

int main() {
  string S;
  int Q;
  cin >> S >> Q;

  deque<char> dq(S.size());
  for(int i=0; i<S.size(); i++){
    dq[i] = S[i];
  }

  bool flag = false;
  for(int i=0; i<Q; i++){
    int T;
    cin >> T;
    if(T == 1){
      flag = !flag;
    }else{
      int F;
      char C;
      cin >> F >> C;
      if(F==1){
        if(!flag){
          dq.push_front(C);
        }else{
          dq.push_back(C);
        }
      }else{
        if(!flag){
          dq.push_back(C);
        }else{
          dq.push_front(C);
        }
      }
    }
  }

  string ans = "";
  if(flag){
    for(int i=dq.size()-1; i>=0; i--){
      ans += dq[i];
    }
  }else{
    for(int i=0; i<dq.size(); i++){
      ans += dq[i];
    }
  }

  cout << ans << endl;
}

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

int main() {
	char left[15] = {'q', 'a', 'z', 'w', 's', 'x', 'e', 'd', 'c', 'r', 
					'f', 'v', 't', 'g', 'b'};
	char right[11] = {'y', 'h', 'n', 'u', 'j', 'm', 'i', 'k', 'o', 'l', 'p'};
	while (true) {
		string s;
		cin >> s;
		if (s[0] == '#') return 0;
		int t[s.size()] = {0};
		for (int i = 0; i < 11; i++) {
			if (s[0] == right[i]) {
				t[0] = 1;
				break;
			}
		}
		
		for (int i = 1; i < s.size(); i++) {
			for (int j = 0; j < 11; j++) {
				if (s[i] == right[j]) {
					t[i] = 1;
					break;
				}
			}
		}
		
		int count = 0;
		for (int i = 0; i < s.size() - 1; i++)
			if (t[i] != t[i+1]) count++;
		cout << count << endl;
	}
}

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

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

int dp[3001][3001];

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

    int n, t; cin >> n >> t;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) cin >> p[i].first >> p[i].second;

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            if (j >= p[i].first)  dp[i + 1][j] = max(dp[i][j], dp[i][j - p[i].first] + p[i].second);
            else dp[i + 1][j] = dp[i][j];
        }
        dp[i + 1][t] = max(dp[i][t], dp[i][t - 1] + p[i].second);
    }
    cout << dp[n][t] << endl;
    return 0;
}


Measured memory_bytes: 35456
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[200005];
void init(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
    }
    long long ans=0,nw=0;
    int l=1,r=1;
    while(r<=n){
        while((!(nw&a[r]))&&r<=n){
            nw|=a[r++];
            ans+=(r-l);
        }
        nw^=a[l++];
    }
    printf("%lld",ans);
}
int main(){
    init();
    return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    int ans = S.size();
    string s[2];
    for(int c=0;c<26;c++){
        int cur = 0;
        s[cur] = S;
        char cc = 'a' + c;
        while(set<char>(s[cur].begin(), s[cur].end()).size() != 1){
            int next = cur ^ 1;
            s[next] = string(s[cur].size()-1, '.');
            for(int i=0;i<s[next].size();i++){
                if(s[cur][i] == cc || s[cur][i+1] == cc){
                    s[next][i] = cc;
                }else{
                    s[next][i] = s[cur][i];
                }
            }
            cur = next;
        }
        ans = min(ans, int(S.size() - s[cur].size()));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define int   long long  int
#define double  long double
#define rp(i,a,b)  for (int i = a; i <= b; i++)
#define hi ios_base :: sync_with_stdio(false); cin.tie(0);cout.tie(0);
int i,j,k;
main()
{
    int r,g,b,k;cin>>r>>g>>b>>k;
    int c=0;
    while(1)
    {
        if(g>r) break;
        g=g*2;
        c++;
    }
   // cout<<c<<endl;
    while(1)
    {
        if(b>g) break;
        b=b*2;
        c++;
    }
   // cout<<c<<endl;
    if(c<=k)cout<<"Yes"<<endl;else cout<<"No"<<endl;
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) {  a = b;  return true;  } return false; }


int main() {
  ll n,k; cin >> n >> k;
  vector<double> p(n);
  rep(i,n){
    double c; cin >> c;
    p[i] = (c+1)/2;
  }
  
  vector<double> sum(n+1,0);
  rep(i,n)  sum[i+1] += sum[i] + p[i];
  //累積和
  
  double ans = 0;
  for(ll i=k; i<n+1; i++) 
    ans = max(ans, sum[i]-sum[i-k]);
  
  printf("%.16f", ans);
}

Measured memory_bytes: 6464
using System;
using System.Linq;

namespace AtCoderTutorial
{
    public class AtCoder176
    {
        public static void Main(string[] args)
        {
//            long[] inputs = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray();
            char[] N = Console.ReadLine().ToCharArray();
            int total = 0;

            for (int i = 0; i < N.Length; i++)
            {
                total += int.Parse(N[i].ToString());
            }


            if (total % 9 == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

#define l long 
using namespace std;

l solve(int idx , vector<int>&v , vector<l>&dp , int n ,int k)
{
    if(idx == n)
      return 0;
    
    if(dp[idx] != -1)
     return dp[idx];


    l omin = 1e12;


    for(int i = 1 ; i <= k && i + idx <= n ; i++)
    {
        l my = solve(idx + i , v , dp , n ,k) + abs(v[idx] - v[idx + i]);

        if(my < omin)
           omin = my;
    }
    dp[idx] = omin;

    return omin;
}
int main() {
    

    int n,k;
    cin>>n>>k;

    vector<int>v(n) ;

    for(int i = 0 ;i<n ;i++)
      cin>>v[i];

   
   vector<l>dp(n+1 , -1);

   l ans = solve( 0 , v , dp , n - 1 , k);

   cout<<ans<<endl;
}   


Measured memory_bytes: 13828
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, m;
string s;
int a[114514];
signed main() {
	cin >> n >> m >> s;
	REP(i, s.size()) {
		a[i] += a[i - 1];
		if (s[i - 1] == 'A'&&s[i] == 'C') {
			a[i]++;
		}
	}
	rep(i, m) {
		int l, r; cin >> l >> r;
		if (l == 1)cout << a[r - 1] << endl;
		else cout << a[r - 1] - a[l - 1] << endl;
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	//sv();
	string s;
    ll n,i,j,ans=0;
    cin>>s;
    n= s.size();
    for(i=1;i<n;i++){
        if(s[i]==s[i-1]){
            ans++;
            if(s[i]=='0')
            s[i]='1';
            else
            {
                s[i]='0';
            }
            
        }
    }
    cout<<ans;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n, m, q;
    cin >> n >> m >> q;

    vector<vector<ll>> count(n, vector<ll>(n, 0));
    for(int i = 0; i < m; ++i){
        ll l, r;
        cin >> l >> r;
        count.at(l - 1).at(r - 1)++;
    }

    for(int l = 0; l < n; ++l){
        for(int r = 0; r < n; ++r){
            if(l > 0){
                count.at(l).at(r) += count.at(l - 1).at(r);
            }
            if(r > 0){
                count.at(l).at(r) += count.at(l).at(r - 1);
            }
            if(l > 0 && r > 0){
                count.at(l).at(r) -= count.at(l - 1).at(r - 1);
            }
        }
    }

    vector<pair<ll, ll>> query(q);
    for(int i = 0; i < q; ++i){
        ll ql, qr;
        cin >> ql >> qr;
        query.at(i).first = ql - 1;
        query.at(i).second = qr - 1;
    }

    for(int i = 0; i < q; ++i){
        const ll ql = query.at(i).first;
        const ll qr = query.at(i).second;
        ll ans = count.at(qr).at(qr);
        if(ql > 0){
            ans -= count.at(ql - 1).at(qr);
            ans -= count.at(qr).at(ql - 1);
            ans += count.at(ql - 1).at(ql - 1);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4480
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  int p[n+1];
  for(int i=1;i<n+1;i++){
    cin >> p[i];
  }
  int x[m],y[m];
  for(int i=0;i<m;i++){
    cin >> x[i] >> y[i];
  }
  vector<int> adj[n+1];
  for(int i=0;i<m;i++){
    adj[x[i]].push_back(y[i]);
    adj[y[i]].push_back(x[i]);
  }
  int color[n+1];
  for(int i=1;i<n+1;i++){
    color[i] = 0;
  }
  int c = 0;
  for(int i=1;i<n+1;i++){
    if(color[i] != 0) continue;
    c += 1;
    queue<int> q;
    q.push(i);
    color[i] = c;
    int temp;
    while(!q.empty()){
      temp = q.front();
      q.pop();
      for(int j=0;j<adj[temp].size();j++){
        if(color[adj[temp][j]] != 0) continue;
        color[adj[temp][j]] = c;
        q.push(adj[temp][j]);
      }
    }
  }
  vector<int> group[c+1];
  vector<int> value[c+1];
  for(int i=1;i<n+1;i++){
    group[color[i]].push_back(i);
    value[color[i]].push_back(p[i]);
  }
  for(int i=1;i<c+1;i++){
    sort(group[i].begin(),group[i].end());
    sort(value[i].begin(),value[i].end());
  }
  int ans = 0;
  int r;
  for(int i=1;i<c+1;i++){
    r = 0;
    for(int l=0;l<group[i].size();l++){
      while(r < group[i].size()){
        if(group[i][l] < value[i][r]){
          break;
        }
        if(group[i][l] == value[i][r]){
          ans += 1;
          break;
        }
        r += 1;
      }
      //r -= 1;

    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int nm = 0;
    int flag = 1;
    for(int i = 0; i < s.size()/2; i++){
        if(s.at(i) == s.at(s.size()-1-i)){
            nm++;
        } else {
            flag = 0;
        }
    }
    int end = (s.size()-3)/2;
    for(int i = 0; i < s.size()/4; i++){
        if(s.at(i) == s.at(end-i)){
            nm++;
        } else {
            flag = 0;
        }
    }
    int start = (s.size()+1)/2;
    for(int i = 0; i < s.size()/4; i++){
        if(s.at(start+i) == s.at(s.size()-1-i)){
            nm++;
        } else {
            flag = 0;
        }
    }
    if(flag == 0){
        cout << "No";
    } else {
        cout << "Yes";
    }
}

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

int main(){
  int n, flag = 0;
  char s;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%c", &s);
    if(s == 'Y') flag = 1;
  }
  if(flag) printf("%s","Four");
  else printf("%s","Three");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

// 抽象化したセグメント木
template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;

    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }

    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }

    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }

    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }

    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};

ll h[200010],a[200010];

int main() {

    int n;cin>>n;
    SegTree<ll> dp(n+1,[](ll a,ll b){return max(a,b);},0);

    rep(i,n) cin>>h[i];
    rep(i,n) cin>>a[i];

    ll ans=0;

    rep(i,n) {
        ll ma = dp.get(0,h[i]);
        if (dp.get(h[i],h[i]+1)<ma+a[i]) {
            dp.update(h[i],ma+a[i]);
            ans = max(ans,ma+a[i]);
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 7424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        
        int seikai = 0;
        String Sichimojime = S.substring(0, 1);
        String Snimojime = S.substring(1, 2);
        String Ssanmojime = S.substring(2, 3);
        
        String Tichimojime = T.substring(0, 1);
        String Tnimojime = T.substring(1, 2);
        String Tsanmojime = T.substring(2, 3);
        
        if(Sichimojime.equals(Tichimojime)) {
        	seikai++;
        }
        if(Snimojime.equals(Tnimojime)) {
        	seikai++;
        }
        if(Ssanmojime.equals(Tsanmojime)) {
        	seikai++;
        }

        System.out.println(seikai);

	}

}

Measured memory_bytes: 21972
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int N = 2019;

            int l = cin.ReadInt;
            int r = cin.ReadInt;

            if (r - l >= N)
            {
                Console.WriteLine(0);
                return;
            }


            int ans = N;
            for (int i = l; i <= r - 1; i++)
            {
                for (int j = i + 1; j <= r; j++)
                {
                    int val = (i % N) * (j % N);
                    val %= N;
                    if (val < ans)
                    {
                        ans = val;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }

    class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
int n, m, x;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n >> m >> x;
	int cost1 = 0, cost2 = 0;
	rep(i, 0, m) {
		int ai; cin >> ai;
		cost1 += ai < x;
		cost2 += ai > x;
	}
	cout << min(cost1, cost2);
	return 0;
}

Measured memory_bytes: 256
/* 
STATUS :> 
PROBLEM LINK:>	https://atcoder.jp/contests/abc175/tasks/abc175_a
LINKDIN PROFILE :>	linkedin.com/in/dheerajpoonia29/
*/

// #include "macro.h"
// #include "../../macro.h"


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


void inline cp();

int main(){
	cp();
	int t=1;	
	//cin>>t;
	while(t--){
		string s;
		cin>>s;
		if(s=="SSS")
			cout<<0;
		else if(s=="RRR")
			cout<<3;
		else if(s=="RSR" || s=="SRS")
			cout<<1;
		else if(s=="SRR" || s=="RRS")
			cout<<2;
		else if(s=="SSR" || s=="RSS")
			cout<<1;
		else
			cout<<0;
	}
	return 0;
}

void inline cp(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE	
	freopen("../../input.txt", "r", stdin);
	freopen("../../output.txt", "w", stdout);
#endif 
}

Measured memory_bytes: 3548
#include <cstdio>
#include <vector>
using namespace std;

#define INF 0x33433433

struct Edge {
    int len;
    int to;
};

int n;
int m;
int state;
int ans;
int deg[15];
int rev[16];
int dp[1 << 16];
int mincost[15][15];
vector<struct Edge> es[15];
vector<int> vs;

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

    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            mincost[i][j] = INF;
            if (i == j) mincost[i][j] = 0;
        }
    }

    for (int i=0; i<m; i++) {
        int s, t, l;

        scanf("%d%d%d", &s, &t, &l);
        ans += l;
        mincost[s][t] = min(mincost[s][t], l);
        mincost[t][s] = min(mincost[t][s], l);
        deg[s]++;
        deg[t]++;
    }

    for (int k=0; k<n; k++) {
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                mincost[i][j] = min(mincost[i][j], mincost[i][k]+mincost[k][j]);
            }
        }
    }

    for (int i=0; i<n; i++) {
        if (deg[i]%2 == 1) {
            rev[i] = vs.size();
            vs.push_back(i);
        }

        for (int j=i-1; j>=0; j--) {
            if (deg[i]%2 == 1 && deg[j]%2 == 1) {
                struct Edge e;

                e.len = mincost[i][j];
                e.to = rev[j];
                es[rev[i]].push_back(e);
                e.to = rev[i];
                es[rev[j]].push_back(e);
            }
        }
    }
/*
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            printf("%d ", mincost[i][j]);
        }
        puts("");
    }
*/
    state = 1 << vs.size();
    fill(dp, dp+state, INF);
    dp[0] = 0;
    for (int i=0; i<state; i++) {
        for (int j=0; j<vs.size(); j++) {
            int v = j;
            for (int k=0; k<es[v].size(); k++) {
                int u = es[v][k].to;
                int len = es[v][k].len;

                //printf("::: %d %d %d\n", state, v, u);
                if (((i >> v) & 1) == 1) continue;
                if (((i >> u) & 1) == 1) continue;

                //printf(":: %d %d\n", v, u);
                dp[i | (1 << v) | (1 << u)] = min(dp[i | (1 << v) | (1 << u)], dp[i]+len);
                //dp[i] = min(dp[i], dp[i & ~(1 << v) & ~(1 << u)] + len);
            }
        }
    }
/*
    for (int i=0; i<state; i++) {
        printf("%d: %d\n", i, dp[i]);
    }
*/
    printf("%d\n", ans + dp[state-1]);
}

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

struct Node
{
    int key;
    struct Node * left;
    struct Node * right;
    Node(int key_) : key(key_), left(nullptr), right(nullptr) {};
};

struct BinarySearchTree
{
    int n_node;
    Node * root;
    
    // Constructor
    BinarySearchTree(): n_node(0), root(nullptr) {};
    
    // Insert
    void insert(int key){
        Node * z = new Node{key};
        Node * y = nullptr;
        Node * x = root;
        while (x != nullptr){
            y = x;
            if (key < x->key){
                x = x->left;
            }else{
                x = x->right;
            }
        }
        if (y == nullptr){
            root = z;
        }else if (key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
        ++n_node;
    }
    
    // print
    void print(){
        _inorder_walk(root);
        cout << endl;
        _preorder_walk(root);
        cout << endl;
    }
    
    //inorder walk
    void _inorder_walk(Node * node){
        if (node == nullptr) return;
        _inorder_walk(node->left);
        cout << ' ' << node->key;
        _inorder_walk(node->right);        
    }
    
    //preorder walk
    void _preorder_walk(Node * node){
        if (node == nullptr) return;
        cout << ' ' << node->key;
        _preorder_walk(node->left);
        _preorder_walk(node->right);
    }
    
    
};

int main()
{
    ios::sync_with_stdio(false);
    int m = 0;
    cin >> m;
    
    BinarySearchTree bst;
    string command;
    int key;
    for (int i = 0; i != m; ++i){
        cin >> command;
        if (command[0] == 'i'){
            cin >> key;
            bst.insert(key);
        }else if (command[0] == 'p'){
            bst.print();
        }else{
            cout << "unexpected command! " << command << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 18712
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef set <string>sst;
typedef set <long long>sl;
typedef queue <long long>que;
typedef vector <long long>vec;
typedef unsigned long long ull;
typedef map <long long,long long>mll;
typedef pair <long long,long long>pll;
typedef vector <pair<long long,long long> >vpl;
typedef pair <long long, unsigned long long > pul;
ll n,z,x,c;
int main()
{
    cin>>z>>x;
    cout<<z/__gcd(z,x)*x<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<LL> a(n);
    rep(i, n) cin >> a[i];

    int cnt4 = 0, cnt2 = 0, cnt = 0;
    for (auto &x: a) {
        if (x % 4 == 0) ++cnt4;
        else if (x % 2 == 0) ++cnt2;
        else ++cnt;
    }

    if ((cnt2 == 0 and cnt4 + 1 >= cnt) or cnt4 >= cnt) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 1024
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.Vector;

 class Main {

    static final int M = 100;

    static int dp[][][]= new int[M][M][2];

    static int K;
    static Vector<Integer> num;
    
    static int countInRangeUtil(int pos, int cnt, int tight )
    {
        // Last position
        if (pos == num.size()) {

            if (cnt == K)
                return 1;
            return 0;
        }

        if (dp[pos][cnt][tight] != -1)
            return dp[pos][cnt][tight];

        int ans = 0;
        
        int limit = (tight!=0 ? 9 : num.get(pos));

        for (int dig = 0; dig <= limit; dig++) {
            int currCnt = cnt;

            // If the current digit is nonzero
            // increment currCnt
            if (dig != 0)
                currCnt++;

            int currTight = tight;

            // At this position, number becomes
            // smaller
            if (dig < num.get(pos))
                currTight = 1;

            // Next recursive call
            ans += countInRangeUtil(pos + 1, currCnt, currTight);
        }
        return dp[pos][cnt][tight] = ans;
    }
    
    static int countInRange(Vector<Integer> num)
    {

        for(int i=0;i<M;i++)
            for(int j=0;j<M;j++)
                for(int k=0;k<2;k++)
                    dp[i][j][k]=-1;
        return countInRangeUtil(0, 0, 0);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s=in.next();
        K=in.nextInt();
        num=new Vector<>();
        for(int i=0;i<s.length();i++){
            num.add(s.charAt(i)-'0');
        }
        int x=countInRange(num);
        System.out.println(x);
    }
}


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

int main() { /* ここに書く */
  string A,B,C;
  int a,b;
  cin>>A>>B>>a>>b>>C;
  
  if(A==C){
    a--;}
  else{
    b--;}
  
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

//------------------------------------------------------

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

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

    rep(i, n - 1) {
        int a;
        cin >> a;
        g = gcd(g, a);
    }
    cout << g << endl;
    return 0;
}

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

int main(){
  long long L, R;
  cin >> L >> R;
  
  if(R - L >= 2019){
    cout << 0 << endl;
  }else{
    long long min = 2019;
    for(int i = L; i <= R; i++){
      for(int j = i + 1; j <= R; j++){
        if( ((i%2019) * (j%2019)) % 2019 < min){
          min = ((i%2019) * (j%2019)) % 2019;
        }
      }
    }
    cout << min << endl;
  }
  
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int a, b, c, A[100], B[100], C[100][100];
int ans = 0;
string s, t, r;


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

if(a<=8&&b<=8) cout << "Yay!" << endl;
else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int a,w,t,r,N,i;
    char S[100000][3] = {0};
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%s",S[i]);
    }
    for(i=0;i<N;i++){
        if(S[i][0] == 'A')
            a++;
        if(S[i][0] == 'W')
            w++;
        if(S[i][0] == 'T')
            t++;
        if(S[i][0] == 'R')
            r++;
    }
    printf("AC x %d\n", a);
    printf("WA x %d\n", w);
    printf("TLE x %d\n", t);
    printf("RE x %d\n", r);
}

Measured memory_bytes: 2028
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, cc;
  cin >> n >> cc;
  vector<VI> d(cc, VI(cc));
  REP(i, 0, cc) REP(j, 0, cc) cin >> d[i][j];
  vector<VI> c(n, VI(n));
  REP(i, 0, n) REP(j, 0, n) {
    cin >> c[i][j];
    c[i][j]--;
  }
  ll mi = 1e16;
  vector<VI> homo(3, VI(cc, 0));
  REP(i, 0, n) {
    REP(j, 0, n) {
      homo[(i + j) % 3][c[i][j]] += 1;
    }
  }
  REP(i, 0, cc) {
    REP(j, 0, cc) {
      if (i == j) continue;
      REP(k, 0, cc) {
        if (i == k || j == k) continue;
        int sapiens[3] = {i, j, k};
        ll cost = 0;
        REP(q, 0, 3) {
          REP(u, 0, cc) {
            cost += (ll) homo[q][u] * (ll) d[u][sapiens[q]];
          }
        }
        mi = min(mi, cost);
      }
    }
  }
  cout << mi << endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(i%2==1&&x%2==1){
			sum++;
		}
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int N;
    cin >> N;
    int a[2][100];
    for(int i = 0; i < 2; ++i) for(int j = 0; j < N; ++j) cin >> a[i][j];

    int memo[2][100];
    memo[0][0] = a[0][0];
    memo[1][0] = a[1][0] + a[0][0];
    for(int j = 1; j < N; ++j){
        for(int i = 0; i < 2; ++i){
            if(i == 0)
                memo[0][j] = memo[0][j-1] + a[0][j];
            else
                memo[1][j] = max(memo[0][j], memo[1][j-1]) + a[1][j];
        }
    }
    cout << memo[1][N-1] << endl;

    return 0;
}


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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 301;

string a[MAX];

int n;
int ans;

int const MOD1 = 1e9 + 9;
int const MOD2 = 1e9 + 7;
int const P = 41;

ull hr[MAX][MAX];
ull hc[MAX][MAX];

int add(int a, int b, int MOD) {
	return (a + b) % MOD;
}

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

void solve() {
	fi(0, n - 1) {
		fj(0, n - 1) {
			a[i][j] -= 'a';
		}
	}
	//row
	fi(0, n - 1) {
		fj(0, n - 1) {
			ull h1 = 0;
			ull h2 = 0;
			fo(0, n - 1) {
				int x = (j + o) % n;
				h1 = mult(h1, P, MOD1);
				h1 = add(h1, a[i][x], MOD1);
				h2 = mult(h2, P, MOD2);
				h2 = add(h2, a[i][x], MOD2);
			}
			hr[i][j] = h1 * MOD2 + h2;
		}
	}	
	//col
	fi(0, n - 1) {
		fj(0, n - 1) {
			ull h1 = 0;
			ull h2 = 0;
			fo(0, n - 1) {
				int x = (j + o) % n;
				h1 = mult(h1, P, MOD1);
				h1 = add(h1, a[x][i], MOD1);
				h2 = mult(h2, P, MOD2);
				h2 = add(h2, a[x][i], MOD2);
			}
			hc[i][j] = h1 * MOD2 + h2;
		}
	}
	fi(0, n - 1) {
		fj(0, n - 1) {
			bool f = true;
			fo(0, n - 1) {
				int x1 = o;
				int y1 = 0;
				int x2 = 0;
				int y2 = o;
				x1 = (x1 + i) % n;
				y1 = (y1 + j) % n;
				x2 = (x2 + i) % n;
				y2 = (y2 + j) % n;
				if (hr[x1][y1] != hc[y2][x2]) {
					f = false;
				}
			}
			if (f) { 
				ans++;
				err("i = %d j = %d\n", i, j);
			}
		}
	}
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin >> n;
	fi(0, n - 1) {
		cin >> a[i];
	}
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std; 
const long long int MOD = 1000000007; 
long long int N, M, K, H, W, L, R; int main() {	ios::sync_with_stdio(false);	cin.tie(0); 	cin >> H >> W;	vector<string>r(H);	vector<string>c(W);	for (int i = 0; i < H; i++) {		cin >> r[i];	}	for (int i = 0; i < H; i++) {		for (int j = 0; j < W; j++) {			c[j].push_back(r[i][j]);		}	}	for (int i = 0; i < H; i++) {		sort(r[i].begin(), r[i].end());	}	for (int i = 0; i < W; i++) {		sort(c[i].begin(), c[i].end());	} 	int rood = 0;	vector<int>ro(13);	for (int i = 0; i < H; i++) {		int cnt = 0;		for (int j = 0; j < H; j++) {			if (r[i] == r[j]) {				cnt++;			}		}		ro[cnt]++;	}	int cood = 0;	vector<int>co(13);	for (int i = 0; i < W; i++) {		int cnt = 0;		for (int j = 0; j < W; j++) {			if (c[i] == c[j]) {				cnt++;			}		}		co[cnt]++;	}	for (int i = 1; i <= 11; i += 2) {		rood += ro[i] / i;	}	for (int i = 1; i <= 11; i += 2) {		cood += co[i] / i;	}	if ((H & 1) < rood || (W & 1) < cood) {		cout << "NO\n";		return 0;	}	if ((!(H & 1) && rood) || (!(W & 1) && cood)) {		cout << "NO\n";		return 0;	}	if (H >= 7 && H < 9 && W >= 7 && W < 9 && ro[H] && co[W]) {		cout << "NO\n";		return 0;	}	cout << "YES\n";	return 0;}
                

                
            


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

int main () {
  int N, M, p;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i = 0; i < 2 * M; i++) {
    cin >> p;
    vec.at(p - 1)++;
  }
  for (int i = 0; i < N; i++){
    cout << vec.at(i) <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int a,b;
  	cin>>a>>b;
  	if(a%3==0||b%3==0||(a+b)%3==0) cout<<"Possible"<<endl;
  	else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n;cin>>n;
  int ans=0;
  int now=0;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(a==ans+1)ans++;
  }
  if(ans==0)cout<<-1<<endl;
  else cout<<n-ans<<endl;
}


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

int main() { 
    int ans = 0;
    string s;
    cin >> s;
    for(int i = 1; i < s.size(); ++i) {
        if(s[i-1] != s[i]) {
            ans++;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 512
#include <iostream>
#include <queue>

using namespace std;

typedef pair<int, int> P;

int main() {
	int seki[17] = {0};
	int mati[100];
	queue<P> q;
	bool hantei2 = false;
	for (int i = 0; ; i++) {
		if (i % 5 == 0) {
			if (i/5 >= 100) {
				hantei2 = true;
			} else if ((i/5) % 5 == 1) {
				q.push(P(5, i/5));
			} else {
				q.push(P(2, i/5));
			}
		}
		for (int j = 0; j < 17; j++) {
			if (seki[j] == i) {
				seki[j] = 0;
			}
		}
		while (!q.empty()) {
			P p = q.front();
			bool hantei = false;
			for (int j = 0; j < 17; j++) {
				if (j+p.first-1 >= 17) {
					break;
				}
				int counter = 0;
				for (int k = 0; k < p.first; k++) {
					counter += seki[j+k];
				}
				if (counter == 0) {
					for (int k = 0; k < p.first; k++) {
						seki[j+k] = i+17*(p.second%2)+3*(p.second%3)+19;
					}
					mati[p.second] = i-(p.second*5);
					hantei = true;
					break;
				}
			}
			if (hantei) {
				q.pop();
			} else {
				break;
			}
		}
		if (hantei2 && q.empty()) {
			int counter = 0;
			for (int j = 0; j < 17; j++) {
				counter += seki[j];
			}
			if (counter == 0) {
				break;
			}
		}
	}
	int n;
	while (cin >> n) {
		cout << mati[n] << endl;
	}
	return 0;
}

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

int main() {
	int n;
	while (scanf("%d", &n), n) {
		map<string, int>mp;
		string s; int Max = 0;
		int d = 0;
		for (int i = 1; i <= n; i++) {
			string c; cin >> c;
			mp[c]++;
			if (mp[c] > Max) { s = c; Max = mp[c]; }
			int sec = 0;
			for (auto p : mp) {
				if (p.first != s&&sec < p.second)sec = p.second;
			}
			if (sec + n - i < Max && !d)d = i;
		}
		if (!d)puts("TIE");
		else cout << s << ' ' << d << endl;
	}
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200000];
int acopy[200000];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		acopy[i] = a[i];
	}
	sort(acopy, acopy + n);
	int front = acopy[n / 2], back = acopy[n / 2 - 1];
	for (int i = 0; i < n; i++) {
		if (a[i] < front)cout << front << endl;
		else cout << back << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main(void)
{
    int s, t, d;
    cin >> d >> t >> s;
    if (d <= t * s)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,x,m; cin >> n >> x >> m;
    vector<ll> v;
    map<ll,ll> mp;

    ll cnt = 0;
    while(mp.count(x) == 0){
        v.pb(x);
        mp[x] = cnt;
        cnt++;
        x = (x*x) % m;
    }
    ll start = mp[x];
    ll T = cnt - start;

    if(n <= start){
        ll ans = 0;
        rep(i,0,n) ans += v[i];
        cout << ans << enld;
        return 0;
    }

    ll sumT = 0;
    rep(i,0,T) sumT += v[start+i];

    ll ans = 0;
    rep(i,0,start) ans += v[i];
    n -= start;

    ans += n/T * sumT;

    n %= T;

    rep(i,0,n) ans += v[start+i];

    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 6684
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

s = int(input())
A = [0]*2001
for i in range(3, s+1):
    A[i] = 1

for i in range(3, s + 1):
    for j in range(3, i-2):
        A[i] = (A[i] + A[j]) % MOD

print(A[s])


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

int main(void){
    int n;
    cin>>n;
    int x = 0;
    bool ng = false;
    rep(i,n){
        string s;
        cin>>s;
        if(s == "A") x++;
        else x--;
        if(x < 0) ng = true;
    }
    cout<<((!ng && x == 0) ? "YES" : "NO")<<endl;
    return 0;
}



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

int main()
{
	int N, M;
	cin >> N >> M;

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

	for(int m=0; m<M; m++){
		int s, c;
		cin >> s >> c;
		if(d[s-1] != -1 && d[s-1] != c){
			cout << "-1";
			return 0;
		} else {
			d[s-1] = c;
		}
	}

	if(d[0]==0){
		if(N==1){
			cout << 0;
			return 0;
		} else {
			cout << "-1";
			return 0;
		}
	} else if(d[0]==-1){
		if(N==1){
			cout << 0;
			return 0;
		} else {
			cout << 1;
		}
	} else {
		cout << d[0];
	}

	for(int n=1; n<N; n++){
		if(d[n] != -1){
			cout << d[n];
		} else {
			cout << 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, K = rl()

num = []
while N > 0:
	num.append(N % K)
	N = N // K
print(len(num))


Measured memory_bytes: 38256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
int a[205];
int main(){
	int n;
	scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int ans=0;
	while(1){
		bool f=0;
		for(register int i=1;i<=n;i++){
			if(a[i]%2!=0){
				f=1;break;
			}
			else a[i]/=2;
		}
		if(f) break;
		else ans++;
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 256