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

int N;
string S, T;

void solve() {
	cin >> S >> T;
	N = sz(S);
	rep(i, 0, N) {
		bool ok = true;
		rep(j, 0, N) {
			if(S[(j + i) % N] != T[j]) {
				ok = false;
				break;
			}
		}
		if(ok) {
			cout << "Yes\n";
			return;
		}
	}
	cout << "No\n";
}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
constexpr double eps = 1e-6;
constexpr ll LINF = 100200300400500600ll;
constexpr int INF = 2*((1<<30)-1)+1;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {-1,0,1,0};
constexpr int mod = 1000000007;
#define Yes(ifeq) cout<<(( ifeq )? "Yes":"No")<<endl;

void Main(){
  int a,b;
  cin>>a>>b;
  if(a<=b){
    cout<<"unsafe"<<endl;
  }else{
    cout<<"safe"<<endl;
  }
  
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  int ans = 0;
  bool flag = true;
  while (true) {
    rep(i, N) {
      if (A[i] % 2 != 0) {
        flag = false;
      }
    }
    if (flag) {
      rep(i, N) {
        A[i] /= 2;
      }
      ans++;
    }
    else {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

n = input()
a = list(map(int, input().split()))
sum_a = 1

if 0 in a:
    print(0)
    sys.exit()

for e in a:
    sum_a *= e
    if sum_a > 1e18:
        print(-1)
        sys.exit()

if sum_a > 1e18:
    sum_a = -1

print(sum_a)

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

int main(){
	int D,G; cin>>D>>G;
	vector<int> P(D), C(D);
	rep(i, D) cin>>P[i]>>C[i];

	int ans = INT_MAX;
	for(int bin=1; bin<(1<<D); ++bin){ // max<2^10=1024

		int cnt = 0, tot = 0;
		rep(j, D) // max=10
			if(bin & 1<<j){
				cnt += P[j]; // count
				tot += P[j]*(j+1)*100 + C[j]; // total
			}
		if(tot < G) continue;

		ans = min(ans, cnt);
		rep(j, D)
			if(bin & 1<<j){
				int now_cnt = cnt;
				int now_tot = tot - C[j];
				rep(k, P[j]-1){ // max=100, delete p-1 times
					now_cnt--;
					now_tot -= (j+1)*100;
					if(now_tot >= G) ans = min(ans, now_cnt);
				}
			}

	}
	cout<< ans <<endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    

    string s, t;
    cin >> s >> t;
    
    map<char, vector<int>> m;
    for (int i = 0; i < s.size(); ++i)
    {
        m[s[i]].push_back(i);
    }
    for (int i = 0; i < 26; ++i)
    {
        char c = 'a' + i;
        sort(m[c].begin(), m[c].end());
    }
    long long now = -1;
    long long ret = 0;
    for (int i = 0; i < t.size(); ++i)
    {
        if (m[t[i]].size() == 0)
        {
            cout << -1 << endl;
            return 0;
        }
        auto itr = lower_bound(m[t[i]].begin(), m[t[i]].end(), now + 1);
        int nextposind = itr - m[t[i]].begin();
        if (itr == m[t[i]].end())
        {
            nextposind = 0;
        }
        int nextpos = m[t[i]][nextposind];
        if (nextpos <= now)
        {
            ret += 1;
        }
        now = nextpos;
    }
    
    cout << (long long)s.size() * ret + now + 1ll << endl;
    
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cctype>
#include <iomanip>
#include <limits>
#include <bitset>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef unsigned long long int ull;
const ll mod = 1000000007;
const ll linf = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = (m); i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<>()
#define SUM(a) accumulate((a).begin(), (a).end(), 0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
template <typename T>
int len(T tmp)
{
	int res = 0;
	while (tmp > 0)
	{
		res++;
		tmp /= 10;
	}
	return res;
}
template <typename T>
T gcd(T a, T b)
{
	T t;
	while (b != 0)
	{
		t = a % b;
		a = b;
		b = t;
	}
	return a;
}
template <typename T>
T recfact(T start, T n)
{
	T i;
	if (n <= 16)
	{
		T r = start;
		for (i = start + 1; i < start + n; i++)
			r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
template <typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
template <typename T>
T fct(T n)
{
	return recfact<T>(1, n);
}
template <typename T>
T ncm(T n, T m)
{
	if (n < m)
		return 0;
	T x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr)
{
	if (firstItr < 0 || secondItr > int(str.size() - 1))
		return str;
	while (firstItr < secondItr)
	{
		swap(str[firstItr], str[secondItr]);
		firstItr++;
		secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str)
{
	int itr = 0;
	std::string res;
	while (itr < int(str.size()))
	{
		char tmp = str[itr++];
		int length = 1;
		while (itr < int(str.size()) && str[itr] == tmp)
		{
			++itr;
			++length;
		}
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
str split(str str, size_t first_itr, size_t second_itr)
{
	string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++)
	{
		tmp.push_back(str.at(i));
	}
	return tmp;
}

int main(void)
{
	int k;
	cin >> k;
	if (k < 10)
	{
		cout << k << endl;
		return 0;
	}
	queue<ll> q;
	for (int i = 1; i < 10; i++)
	{
		q.push(i);
	}
	for (int i = 9;;)
	{
		ll tmp = q.front();
		q.pop();
		ll x;
		if (tmp % 10)
		{
			x = tmp * 10 + tmp % 10 - 1;
			q.push(x);
			i++;
			if (i == k)
				break;
		}
		x = tmp * 10 + tmp % 10;
		q.push(x);
		i++;
		if (i == k)
			break;
		if (tmp % 10 != 9)
		{
			x = tmp * 10 + tmp % 10 + 1;
			q.push(x);
			i++;
			if (i == k)
				break;
		}
	}
	cout << q.back() << endl;
	return 0;
}

Measured memory_bytes: 768
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc145
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_abc145B();
        }

        public static void solve_abc145B()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string s = Console.ReadLine();

            if (n % 2 != 0)
            {
                Console.WriteLine("No");
            }
            else
            {
                bool ok = true;
                for (int i = 0; i < n / 2; i++)
                {
                    if (s[i] != s[i + n / 2])
                    {
                        ok = false;
                        break;
                    }
                }

                if (ok)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }

        public static void solve_abc145A()
        {
            int r = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine(r * r);
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  long sum = 0;
  for (int i = 1; i <= N; i++){
    if (i % 3 != 0 && i % 5 != 0){
      sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"


signed main() {
      int N, K, ans = 0;
      cin >> N >> K;
      vector<int> V(N);
      for (int i = 0; i < N; i++) cin >> V[i];
      for (int i = 1; i <= min(K, N); i++) {
            for (int A = 0; A <= i; A++) {
                  for (int B = 0; B <= i - A; B++) {
                        priority_queue<int, vector<int>, greater<int>> temp;
                        int point = 0;
                        for (int j = 0; j < A; j++) {
                              temp.push(V[j]);
                              point += V[j];
                        }
                        for (int j = 0; j < B; j++) {
                              temp.push(V[N - j - 1]);
                              point += V[N - j - 1];
                        }
                        for (int j = 0; j < K - A - B; j++) {
                              if (!temp.empty() && temp.top() < 0) {
                                    point -= temp.top();
                                    temp.pop();
                              } else break;
                        }
                        ans = max(ans, point);
                  }
            }
      }
      cout << ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	bool changed = true;
	int orgLen = s.length();
	while (true) {
		if (changed == false || s.length() == 0)
			break;
		changed = false;
		for (int i = 0; i < (s.length() - 1); i++) {
			if ((s[i] == '0' && s[i + 1] == '1') ||
				(s[i] == '1' && s[i + 1] == '0')) {
				s.erase(i, 2);
				i -= 2;
				changed = true;
			}
		}
	}
	cout << (orgLen - s.length());
	return 0;
}

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

string a,b,c;

int main() {
    cin>>a>>b>>c;
    a[0] = a[0] - 'a'+'A';
    b[0] = b[0] - 'a'+'A';
    c[0] = c[0] - 'a'+'A';
    cout<<a[0]<<b[0]<<c[0];
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  while(n!=0||x!=0){
    int i,j,k;
    int o=0;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	for(k=j+1;k<=n;k++){
	  if(i+j+k==x) o++;
	}
      }
    }

    cout << o << endl;

    cin >> n >> x;
  }


  return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];
        public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            HashMap<String,Integer> kuji = new HashMap<String,Integer>();
            for(int i = 0;i < n;i++){
                String key = sc.next();
                kuji.put(key, 1);
            }
            System.out.println(kuji.size());
    }
    
}


Measured memory_bytes: 77940
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v) {std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

#define EPS 1e-8
#define EQ(a, b) (abs((a)-(b)) < EPS)

inline int signum(double x) { return (abs(x) < EPS) ? 0 : (x > 0) ? 1 : -1; }

typedef complex<double> P;

double dot(P a, P b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

double cross(P a, P b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

int ccw(P a, P b, P c) {
    b -= a;
    c -= a;
    int sign = signum(cross(b, c));
    if (sign != 0) return sign;
    if (signum(dot(b, c)) == -1) return -2;
    if (abs(b) < abs(c)) return 2;
    return 0;
}

double dis_p_li(P a, P b, P c) {
    b -= a;
    c -= a;
    return abs(cross(b, c)) / abs(b);
}

double dis_p_li_ss(P a, P b, P c) {
    P x1 = b - a;
    P y1 = c - a;
    P x2 = a - b;
    P y2 = c - b;
    if (signum(dot(x1, y1)) < 0) return abs(y1);
    if (signum(dot(x2, y2)) < 0) return abs(y2);
    return dis_p_li(a, b, c);
}

bool is_intersected_li_ss(P a1, P a2, P b1, P b2) {
    return (ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0) &&
           (ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0);
}

double dis_li_s_li_s(P a1, P a2, P b1, P b2) {
    if (is_intersected_li_ss(a1, a2, b1, b2)) return 0.0;
    return min({
                       dis_p_li_ss(a1, a2, b1),
                       dis_p_li_ss(a1, a2, b2),
                       dis_p_li_ss(b1, b2, a1),
                       dis_p_li_ss(b1, b2, a2)
               });
}

int main() {

    int Q;
    cin >> Q;

    while (Q--) {

        vector<P> p(4);
        for (int i = 0; i < 4; i++) {
            double x, y;
            cin >> x >> y;
            p[i] = P(x, y);
        }
        double ans = dis_li_s_li_s(p[0], p[1], p[2], p[3]);
        cout << fixed << setprecision(10) << ans << endl;
    }

}















































Measured memory_bytes: 3352
n,k=open(0)
k=int(k)
d=[1]+[0]*7
for n in map(int,n[:-1]):
  p=[0]*8
  for i in range(n):
    if i<1:
      for j in range(4):
        p[j+4]+=d[j]
    else:
      for j in range(3):
        p[j+5]+=d[j]
  for i in range(10):
    if i<1:
      for j in range(4):
        p[j+4]+=d[j+4]
    else:
      for j in range(3):
        p[j+5]+=d[j+4]
  if n<1:
    for i in range(4):
      p[i]+=d[i]
  else:
    for i in range(3):
      p[i+1]+=d[i]
  d=p
print(sum(d[k::4]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define mod 1000000007
#define P(a,b) pair<a,b>
#define CIN(V,s,n) for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}

using namespace std;
bool sortBylen(string &a,string &b)
{
    if(a.size()>b.size())
        return true;
    else if(a.size()==b.size())
    {
        if(a>b)
        {
            return true;
        }
        else
            false;
    }
    else
        return false;
}



dl Coin(vector<vector<vector<dl> > > &DP,ll a1,ll a2,ll a3,dl n)
{
    if(a1+a2+a3 == 0)
        return 0;
    if(DP[a1][a2][a3]!=-1.0)
        return DP[a1][a2][a3];
    dl ans = n;
    if(a1>0)ans += Coin(DP,a1-1,a2,a3,n)*a1;
    if(a2>0)ans += Coin(DP,a1+1,a2-1,a3,n)*a2;
    if(a3>0)ans += Coin(DP,a1,a2+1,a3-1,n)*a3;
    ans = ans*(1.0/(a1+a2+a3));

    return DP[a1][a2][a3] = ans;

}

int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll n,W,i,j,k=2,l1,l2,m;
    ll a1=0,a2=0,a3=0;
    ll r,c;
    cin >> n;

    for(i=0;i<n;i++)
    {
        cin >> W;
        if(W==1)
            a1++;
        else if(W==2)
            a2++;
        else
            a3++;
    }
    vector<vector<vector<dl> > > DP(n+1,vector<vector<dl> > (n+1,vector<dl>(n+1,-1)));

    Coin(DP,a1,a2,a3,n);

    cout << fixed << setprecision(11);
    cout << DP[a1][a2][a3];

}
	return 0;
}


Measured memory_bytes: 219008
#include<iostream>
#include<string>
#include<vector>
#define M 1000000007
using namespace std;
vector<bool> nature(1000,true);
void make(int n){
	nature[0]=nature[1]=false;
	for(int i=2;i<=n;i++){
	if(nature[i]){
int k=2*i;
while(k<=1000){
nature[k]=false;
k+=i;
}
	}
	}
}

int main(void){
	int n;
	cin>>n;
	make(n);
	long long int sum=1;
for(int i=2;i<=n;i++){
	if(nature[i]){
		int t=0,k=i;
while(n>=k){
t+=n/k;
	k*=i;
}
sum*=t+1;
sum%=M;
	}
}
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int r,g,b;
    cin>>r>>g>>b;

    r=r*100;
    g=g*10;
    int ans=r+g+b;

    if(ans%4==0){
        cout<<"YES"<<endl;
    }else{

    cout<<"NO"<<endl;
    }

    return 0;
}


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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;

/*
f(n) = f(n-1) + f(n-3); n >= 6
f(3) = 1;	
f(4) = 1;
f(5) = 1;
*/

int main() {
	fast;
	cin.tie(0);
	lld n;
	cin >> n;
	int a, b, c, d;
	a = 0, b = 0, c = 1;
	
	if (n == 1) cout << 0 << endl;
	else if (n == 2) cout << 0 << endl;
	else if (n == 3) cout << 1 << endl;
	else {
		for (int i = 4; i <= n; i++) {
			d = c + a;
			d %= MOD;
			a = b;
			b = c;
			c = d;
		}
		
		cout << d << endl;
	}
}


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

class UnionFind {
private:
  vector<int> data;

  bool isSame(int x, int y) { return find(x) == find(y); }

  bool doUnite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y)
      return (false);
    if (data[x] > data[y])
      swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int getFind(int k) {
    if (data[k] < 0)
      return (k);
    return (data[k] = find(data[k]));
  }

  int getSize(int k) { return (-data[find(k)]); }

public:
  UnionFind(int N) { data.resize(N, -1); }

  int same(int x, int y) { return isSame(x, y); }
  bool unite(int x, int y) { return doUnite(x, y); }
  int find(int k) { return getFind(k); }
  int size(int k) { return getSize(k); }
};

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

  vector<set<int>> dame(N);
  UnionFind uf(N);

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    dame[A].insert(B);
    dame[B].insert(A);
    uf.unite(A, B);
  }

  for (int i = 0; i < K; i++) {
    int C, D;
    cin >> C >> D;
    C--, D--;
    if (!uf.same(C, D)) {
      continue;
    }
    dame[C].insert(D);
    dame[D].insert(C);
  }

  for (int i = 0; i < N; i++) {
    if (i != 0) {
      cout << " ";
    }
    cout << uf.size(i) - dame[i].size() - 1;
  }

  cout << endl;
  return 0;
}

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

int main() {
  int n;

  cin >> n;

  vector<int> h(n), ans(n);

  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  ans[1] = abs(h[0] - h[1]);
  for (int i = 2; i < n; i++) {
    if (abs(h[i] - h[i - 1]) + ans[i - 1] < abs(h[i] - h[i - 2]) + ans[i - 2])
      ans[i] = abs(h[i] - h[i - 1]) + ans[i - 1];
    else
      ans[i] = abs(h[i] - h[i - 2]) + ans[i - 2];
  }

  cout << ans[n - 1];

  return 0;
}

Measured memory_bytes: 1024
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

struct node {
	int d, lch, rch;
	node() { lch = rch = d = -1; }
	node(int d) :d(d) { lch = rch = -1; }
};
vector<node> v;

LL n, l, ans;
string s[100010];

LL calc(LL num) {
	int ret = 0;
	while (num % 2 == 0) {
		ret++;
		num /= 2;
	}
	return pow(2, ret);
}

int main() {
	cin >> n >> l;
	REP(i, n) cin >> s[i];

	v.emplace_back(node(0));
	REP(i, n) {
		int now = 0;
		REP(j, s[i].size()) {
			if (s[i][j] == '0') {
				if (v[now].lch != -1) now = v[now].lch;
				else {
					v[now].lch = v.size();
					v.emplace_back(node(v[now].d + 1));
					now = v[now].lch;
				}
			}
			else {
				if (v[now].rch != -1) now = v[now].rch;
				else {
					v[now].rch = v.size();
					v.emplace_back(node(v[now].d + 1));
					now = v[now].rch;
				}
			}
		}
	}

	LL ret = 0;
	for (auto i : v) {
		if (i.lch == -1 && i.rch == -1) continue;
		if (i.lch == -1 || i.rch == -1) ret ^= calc(l - i.d);
	}

	if (ret) cout << "Alice" << endl;
	else cout << "Bob" << endl;
}

Measured memory_bytes: 2872
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <string>
#include <numeric>
#include <algorithm>

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

int n, m, count;
std::vector<std::pair<int,int>> data;
std::set<long long int> friends;

void f(int k) {
    if (count >= 2) return;

    for (auto d:data) {
        if(d.first == k) {
            int t = d.second;
            friends.insert(t);
            count++;
            f(t);
            count--;
        }else if(d.second == k && d.first != 1){
            int t=d.first;
            friends.insert(t);
            count++;
            f(t);
            count--;
        }
    }
}

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

    std::vector<int> result;

    for (;;) {
        std::cin >> n >> m;
        if (n == 0 && m == 0) break;
        data.resize(m);
        rep(i, m) std::cin >> data.at(i).first >> data.at(i).second;
        count = 0;

        f(1);

        result.push_back(friends.size());
        data.clear(); data.shrink_to_fit();
        friends.clear();
    }

    for (auto r : result) std::cout << r << "\n";
    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;cin >> a >> b;
	cout << (b-a)*(b-a-1)/2-a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
typedef struct{
    ll S;
    ll T;
    ll X;
} P;

bool comp(P p1, P p2){
    return p1.X > p2.X;
}
// const int INF = INT_MAX;
struct LazySegmentTree {
private:
    int n;
    vector<int> node, lazy;
    vector<bool> lazyFlag;
 
public:
    LazySegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, INF);
        lazyFlag.resize(2*n-1, false);
 
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
 
    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }
 
    void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }
 
    int find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return INF;
        if(a <= l && r <= b) return node[k];
        int vl = find(a, b, 2*k+1, l, (l+r)/2);
        int vr = find(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,Q;
    cin >> N >> Q;
    ll S[200010], T[200010], X[200010];
    ll D[200010];
    rep(i,0,N){
        cin >> S[i] >> T[i] >> X[i];
        T[i]--;
    }
    rep(i,0,Q){
        cin >> D[i];
    }
    ll pos[200010];
    memset(pos, -1, sizeof(pos));
    vector<P> lp;
    rep(i,0,N){
        P tmp = {S[i], T[i], X[i]};
        lp.push_back(tmp);
    }
    sort(lp.begin(), lp.end(), comp);
    LazySegmentTree seg( vector<int>(Q, INF) );
    rep(i,0,N){
        ll s = lp[i].S;
        ll t = lp[i].T;
        ll x = lp[i].X;
        if(s < x) s = x;
        if(t < x) t = x;
        ll ss = max(0LL, s - x);
        ll tt = max(0LL, t - x);
        ll p1 = lower_bound(D, D+Q, ss) - D;
        ll p2 = upper_bound(D, D+Q, tt) - D;
        seg.update(p1,p2,x);
    }
    // seg.update(0,N,1);


    rep(i,0,Q){
        ll v = seg.find(i,i+1);
        if(v == INF){
            print(-1);
        }else{
            print(v);
        }
    }

    
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;


template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

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


Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n,x,y=map(int,input().split())

d=deque()
for i in range(n):
    tmp=[0]*n
    tmp[i]=1
    d.append([[i],tmp])
# print(d)

x,y=x-1,y-1
for i in range(n-1):
    ans=0
    for j in range(n):
        now,itta=d.popleft()
        tugi=[]
        for k in now:
            if k==n-1:
                if itta[k-1]==0:
                    itta[k-1]=1
                    tugi.append(k-1)
                if y==k and itta[x]==0:
                    itta[x]=1
                    tugi.append(x)
            elif k==0:
                if itta[k+1]==0:
                    itta[k+1]=1
                    tugi.append(k+1)
                if x==k and itta[y]==0:
                    itta[y]=1
                    tugi.append(y)
            else:
                if itta[k-1]==0:
                    itta[k-1]=1
                    tugi.append(k-1)
                if y==k and itta[x]==0:
                    itta[x]=1
                    tugi.append(x)
                if itta[k+1]==0:
                    itta[k+1]=1
                    tugi.append(k+1)
                if x==k and itta[y]==0:
                    itta[y]=1
                    tugi.append(y)
        ans+=len(tugi)
        d.append([tugi,itta])
        # print(tugi)
        # print(itta)
    print(ans//2)
    ans=0

Measured memory_bytes: 123508
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
    #define debug(x) cerr<<#x<<":"<<x<<endl
    const int maxn=(int)1e6+5;
    typedef long long ll;
    const ll MOD=1e9+7;
    inline ll qpow(ll a, ll b) {return b? ((b&1)? a*qpow(a*a%MOD,b>>1)%MOD: qpow(a*a%MOD,b>>1))%MOD: 1;}
    inline ll gcd(ll a, ll b) {return b? gcd(b, a%b): a;}
    inline ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
    ll a[maxn];
    int main(){
        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        ll n,m;
        cin>>n>>m;
        rep(i,1,n){
            cin>>a[i];
            a[i]/=2;
        }
        ll l1=1,l2=1,flag=1;
        rep(i,1,n){
            l1=lcm(l1,a[i]);
            l2=lcm(l2,a[i]*2);
            
            if(l1>m){flag=0;break;}
        }
        rep(i,1,n)if(l1/a[i]%2==0){ printf("0\n"); return 0;}
        cout<<(flag?(m/l1-m/l2):0)<<endl;
    }
    /* 
    2 50
    6 10
    */

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)
	H := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &H[i])
	}

	var currentMoveCount, maxMoveCount int
	for i := 0; i < N-1; i++ {
		if H[i] >= H[i+1] {
			currentMoveCount++
		} else {
			maxMoveCount = int(math.Max(float64(currentMoveCount), float64(maxMoveCount)))
			currentMoveCount = 0
		}
	}

	maxMoveCount = int(math.Max(float64(currentMoveCount), float64(maxMoveCount)))
	fmt.Println(maxMoveCount)
}


Measured memory_bytes: 5504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int p = Integer.parseInt(str[1]);

		int sum = a * 3 + p;

		System.out.println(sum / 2);
	}
}


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

string r(string a){
	reverse(a.begin(),a.end());
	return a;
}
int main(){
	int T; cin >> T;
	while(T--){
		string s; cin >> s;
		set<string> c;
		for(int i = 1 ; i < s.size() ; i++){
			string a = s.substr(0,i) , b = s.substr(i);
			c.insert(a+b);
			c.insert(b+a);
			c.insert(r(a)+r(b));
			c.insert(r(b)+r(a));
			c.insert(a+r(b));
			c.insert(b+r(a));
			c.insert(r(a)+b);
			c.insert(r(b)+a);
		}
		cout << c.size() << endl;
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll A[100000],B[100000],D[100000];
vector<ll> ps,ns;
ll N;

int main()
{
  cin>>N;
  ll ans;
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>B[i];
  rep(i,N){
    D[i]=A[i]-B[i];
    if(D[i]>0){
      ps.pb(-D[i]);
    }
    else if (D[i]<0) ns.pb(-D[i]);
  }
  ll s;
  ans = ns.size();
  rep(i,ns.size()) s+=ns[i];
  //cout<<s<<endl;
  sort(ps.begin(),ps.end());
  rep(i,ps.size()){
    if(s<=0) break;
    ans++;
    s+=ps[i];
  }
  if(s>0) puts("-1");
  else cout<<ans<<endl;
}


Measured memory_bytes: 3572
// Create your own template by modifying this file!
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <deque>
#include <stack>
#include <functional>
#define SZ(X) ((int)(X).size())
#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 FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x;  }
void _R(int &x) { scanf("%d", &x);  }
void _R(int64_t &x) { scanf("%lld", &x);  }
void _R(double &x) { scanf("%lf", &x);  }
void _R(char &x) { scanf(" %c", &x);  }
void _R(char *x) { scanf("%s", x);  }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...);  }
template<class T> void _W(const T &x) { cout << x;  }
void _W(const int &x) { printf("%d", x);  }
void _W(const int64_t &x) { printf("%lld", x);  }
void _W(const double &x) { printf("%.16f", x);  }
void _W(const char &x) { putchar(x);  }
void _W(const char *x) { printf("%s", x);  }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' ');  }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);  }
#ifdef DEBUG
 #define debug(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define debug(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;

char S[1005], T[1005];

void solve() {
    R(S, T);
    int N = LEN(S), M = LEN(T);
    int ans = MOD;
    REP(i, N - M + 1) {
        int cnt = 0;
        REP(j, M) {
            if (T[j] != S[i+j]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    W(ans);
}

int main() {
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long k,n,i,j,x;
int main(){
	k=read();
	if(k==1){
		pus(1,2);
		pus(1,2);
		return 0;
	}
	n=(((k+3)>>2)<<1);
	pus(n,2);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++){
			x=(i&1?0:n)+1+(i+j)%n;
			pus(x>k?x-n:x,j==n?2:1);
		}
    return 0;
}

Measured memory_bytes: 1152
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a; cin>>a;
    ll m[a];
    for(int q=0; q<a; q++) cin>>m[q];
    sort(m, m+a);
    ll o = 0+m[a-1];
    for(int q=2, i = a-2; q<a; q++){
        o += m[i];
        if(q%2==1) i--;
    }
    cout<<o;
}

Measured memory_bytes: 5192
import sys
input = sys.stdin.readline
 
def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))
 
def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a
 
def lcm(a: int, b: int):
	return a * b // gcd(a, b)
 
def main():
	#n=int(input())
	#vA=linput()
	a,b,c = linput()
	
	res = 0
	
	x = (a%2)*b*c
	y = (b%2)*c*a
	z = (c%2)*a*b
	
	res = min(x,y,z)
	
	#sT = "No Yes".split()
	#print(sT[res])
	print(res)
 
if __name__ == "__main__":
	main()

Measured memory_bytes: 9104
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);

#define debug(x) (#x " : " + to_string(x))
#define debug_cout(x) (cout << #x << " : " <<  to_string(x) << endl)
#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(ll i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair((a), (b));
using namespace std;
using ll = long long;
//#define int long long
template<class T> bool chmax(T& a, T& b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T& b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 2e9;

/*****/

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

	int ret = 0;
	ret += N / (D * 2 + 1);
	//debug_cout(ret);

	N %= (D * 2 + 1);
	if (N > 0)
		ret++;
	//debug_cout(N);
	//debug_cout(ret);

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    int n; cin>>n;
    bool flag = true;
    ll ans=1;
    ll arr[n]; 
    F {
        cin>>arr[i];
        if(arr[i] == 0) flag = false;
    }
    if(flag == false) cout<<0;
    else {
        F {
            if(arr[i] > 1000000000000000000/ans) {
                cout<<-1;
                return 0;
            }
            ans *= arr[i];
            
        }
        cout<<ans;
    } 

    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
void addmod(int &a, ll b){a=(a+b); if(a>=MODV)a-=MODV;}
void mulmod(int &a, ll b){a=(a*b)%MODV;}
template<class T>bool domin(T &a, const T &b){return a>b?a=b,1:0;}
template<class T>bool domax(T &a, const T &b){return a<b?a=b,1:0;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf("%lld",&a);return a;}

int main() {
  int n=gi(), m=gi();
  vector<bool> rc(n+1,false);
  int ans=0;
  for(int i=0;i<m;i++){
    int a=gi(), b=gi();
    if(a>b)swap(a,b);
    if(a==1){
      if(rc[b])ans=1;
      rc[b]=true;
    }
    if(b==n){
      if(rc[a])ans=1;
      rc[a]=true;
    }
  }
  if(ans==1)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;

  return 0;
}

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

using std::vector;
using std::pair;
using Pair = pair<uint32_t, uint32_t>;

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  uint32_t N{}, M{};
  std::cin >> N >> M;

  vector<Pair> city(M);
  std::for_each(city.begin(), city.end(), [](auto& p){ std::cin >> p.first >> p.second; --p.first; });

  vector<vector<Pair>> state(N);
  for(uint32_t index = 0; index < city.size(); ++index)
  {
    auto& p = city[index];
    state[p.first].push_back( { p.second, index } );
  }

  std::for_each(state.begin(), state.end(), [](auto& list){ std::sort( list.begin(), list.end(), std::less<Pair>()); });

  vector<Pair> res(M);
  for(uint32_t state_i = 0; state_i < state.size(); ++state_i)
  {
    for(uint32_t x_i = 0; x_i < state[state_i].size(); ++x_i)
    {
      auto city_i = state[state_i][x_i].second;
      res[city_i] = { state_i + 1, x_i + 1};
    }
  }

  std::for_each(res.cbegin(), res.cend(), [](auto& ans){
  std::cout << std::setw(6) << std::setfill('0') << ans.first << std::setw(6) << std::setfill('0') << ans.second << '\n';
  });
  std::cout << std::flush;

  return 0;
}

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

int main() {
  int N,M,i,a,b;
  cin >> N >> M;
  vector<int> count(N,0);
  for(i=0;i<M;++i){
    cin >> a >> b;
    count.at(a-1)++;
    count.at(b-1)++;
  }
  for(i=0;i<N;++i)
    cout << count.at(i) << endl;
}


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

int main() {
	string s;cin>>s;
	char n='A';
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]<=n)ans++;
		n=s[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3224