akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll l, r, ans = inf;
	cin >> l >> r;
	ll al = l % 2019;
	ll ar = r % 2019;
	if (al > ar)cout << 0 << endl;
	else if ((r - l) >= 2019)cout << 0 << endl;
	else {
		for (ll i = l; i <= r - 1; i++) {
			for (ll j = i + 1; j <= r; j++) {
				ans = min((i * j) % 2019, ans);
			}
		}
		cout << ans << endl;
	}
	ggr
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    if(n>=m) cout << 0 << endl; 
    else{
        sort(a.begin(),a.end());
        vector<pair<int,int>> b(m-1);
        rep(i,m-1){
            b[i] = make_pair(a[i+1] - a[i], i);
        }
        sort(b.begin(),b.end(),greater<pair<int,int>>());
        // rep(i,m-1){
        //     cout << b[i].first << " " << b[i].second << endl;
        // }
        vector<int> c(n+1);
        c[0] = -1;
        c[n] = m-1;
        rep(i,n-1){
            c[i+1] = b[i].second;
        }
        sort(c.begin(),c.end());
        // cout << c.size() << endl;
        // rep(i,n+1){
        //     cout << c[i] << endl;
        // }
        ll cnt = 0;
        rep(i,n){
            cnt += a[c[i+1]]-a[c[i]+1];
        }
        cout << cnt << endl;
    }


    return 0;
}

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

using namespace std;




int main(){
    long long N;
    long ans=0;
    string S;
    double Q;

    cin>>S;

    vector<bool> bb(S.size());

    bool check=true;

    while(check){
        bool tes=false; 
        for(long i=1;i<S.size();++i){
            if(S[i]=='0'&&S[i-1]=='1'||S[i]=='1'&&S[i-1]=='0'){
                tes=true;
                ans++;
                S.erase(S.begin()+i-1);
                S.erase(S.begin()+i-1);
                i=max((long)(i-2),0L);
            }
        }

        if(!tes)check=false;
    }


    cout<<ans*2<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<n;++i)
#define ll long long

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

string today;

int main () {
  cin >> today;

  vector<string> v = {"Sunny", "Cloudy", "Rainy"};

  if (today == v[0]) {
    cout << v[1] << "\n";
  } else if (today == v[1]) {
    cout << v[2] << "\n";
  } else {
    cout << v[0] << "\n";
  }
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    if(s[n - 1] != '0' || s[0] != '1') {
        cout << -1 << endl;
        return;
    }
    for(int i = 0; i < n-2-i; ++i) {
        if(s[i] != s[n-2-i]) {
            cout << -1 << endl;
            return;
        }
    }
    int root = 1, now = 2;
    for(int i = 0; i < n-1; ++i) {
        cout << root << ' ' << now << endl;
        if(s[i] == '1') root = now;
        ++now;
    }
    return;
}

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

Measured memory_bytes: 3816
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define INF 1000000001
#define MOD 1000000007

using namespace std;



int main() {
	int n, cmin =INF , cmax = -INF;
	cin >> n;
	REP(i, n) {
		int a;
		cin >> a;
		if(i!=0){
			if (a - cmin > cmax) {
				cmax = a - cmin;
			}
		}
		if (cmin > a) {
			cmin = a;
		}
		
	}
	cout << cmax << endl;
	return 0;
}

Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Aoj.ALDS.Chapter11A
{
    class DirectedGraph
    {
        // Map[s][t]??¨??¨??????????????? s -> t????????° Map[s][t] >= 1 ??¨?????????
        private int[][] Map;

        public DirectedGraph(int vertexNum)
        {
            Map = new int[vertexNum + 1][];
            for (int i = 0; i <= vertexNum; i++)
            {
                Map[i] = new int[vertexNum + 1];
            }

            for (int i = 0; i <= vertexNum; i++)
            {
                for (int j = 0; j <= vertexNum; j++)
                {
                    Map[i][j] = 0;
                }
            }
        }

        public void Connect(int from, int to)
        {
            if (OutOfRange(from) || OutOfRange(to))
                throw new ArgumentException("");
            Map[from][to] = 1;
        }

        public int Connected(int from, int to)
        {
            if (OutOfRange(from) || OutOfRange(to))
                throw new ArgumentException("");
            return Map[from][to];
        }

        private bool OutOfRange(int index)
        {
            return index < 0 || index > Map.Count();
        }
    }
    class Program
    {
        public static void Solve()
        {
            int n = int.Parse(Console.ReadLine());

            var graph = new DirectedGraph(n);

            for (int i = 0; i < n; i++)
            {
                int[] inputs = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var from = inputs[0];
                foreach (var to in inputs.Skip(2).ToArray())
                {
                    graph.Connect(from, to);
                }
            }

            var tmp = new string[n];
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    tmp[j - 1] = graph.Connected(i, j).ToString();
                }
                Console.WriteLine(string.Join(" ", tmp));
            }
        }


        public static void Main()
        {
            // Console.SetIn(new System.IO.StreamReader("Aoj/AlgorithmsAndDataStructures/Input/11_Graph_A_01.txt"));
            // var sw = new Stopwatch();
            // sw.Start();

            Solve();

            // Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
        }
    }
}

Measured memory_bytes: 9828
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    int result = 0;
    for (int i=0; i<k; i++) {
        result += v[i];
    }
    cout << result << endl;
}

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

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

  for (int i = 0; i < S.size() - 1; i++) {
    if (S.at(i) == S.at(i + 1)) {
      printf("Bad");
      return 0;
    }
  }

  printf("Good");
  return 0;
}


Measured memory_bytes: 256
x = [int(input()) for _ in range(5)]

m = sorted([xx for xx in x if xx % 10], key=lambda y: y %
           10) + [xx for xx in x if xx % 10 == 0]

n = [(10 - mm % 10) for mm in m if mm % 10]

print(sum(m) + sum(n[1:]))

Measured memory_bytes: 3060
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

int main(){

    

    string S;
    
    cin >> K;
    cin >> S;
    if(S.length()<=K){
        cout << S << endl;
    }else{
        cout << S.substr(0,K) << "..."  << endl; 
    }
    
    

}

Measured memory_bytes: 3624
sub f{my($m,$n)=@_;return ($m<$n)?$m:$n;}
$n=<>;
@h=glob<>;
@dp;$#dp=$n;
$dp[0]=0;
$dp[1]=abs($h[1]-$h[0]);
for(my$i=2;$i<$n;$i++){
    $dp[$i]=&f( $dp[$i-1]+abs($h[$i]-$h[$i-1]),
                $dp[$i-2]+abs($h[$i]-$h[$i-2])); 
}
print $dp[$n-1];

Measured memory_bytes: 26496
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int n; cin >> n;
    int m=1;
    while(m*m <= n) m++;
    m--;
    cout << m*m << endl;
    return 0;
}

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

int main(){
    int x;
    ll ans = 0;
    cin >> x;
    rep(i, 50){
        rep(j, 10){
            if (ll(pow(i,j+2)) <= ll(x)) ans = max(ll(pow(i,j+2)), ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<cmath>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i32 d,n;
cin >> d >> n;
if(d == 0){
    if(n == 100)cout << 101 << endl;
    else cout << n << endl;
}else{
    i64 k = pow(100,d);
    if(n != 100)
    cout << k * n << endl;
    else
        cout << k * n + k << endl;
}
}

Measured memory_bytes: 3832
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int ABC[3];
int countEven;
bool even[3] = {false, false, false};
bool check() {
	if(ABC[0] == ABC[1] && ABC[1] == ABC[2]) return true;
	return false;
}

void setEven() {
	countEven = 0;
	for(int i = 0; i < 3; i++) {
		if(ABC[i] % 2 == 0) {
			countEven++;
			even[i] = true;
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	for(int i = 0; i < 3; i++) cin >> ABC[i];
	asort(ABC, 3);
	setEven();
	int ans = 0;
	while(!check()) {
		if(countEven == 0) {
			ABC[0] += 2;
		} else if(countEven == 1) {
			for(int i = 0; i < 3; i++) {
				if(!even[i]) ABC[i]++;
			}
		} else if(countEven == 2) {
			for(int i = 0; i < 3; i++) {
				if(even[i]) ABC[i]++;
			}
		} else if(countEven == 3) {
			ABC[0] += 2;
		}
		asort(ABC, 3);
		setEven();
		ans++;
	}
	cout << ans << endl;
}


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

using namespace std;

int main()
{
	int a; int b; char op;
	while (true)
	{
		cin >> a >> op >> b;
		if (op == '+'){
			cout << a + b << endl;
		}
		if (op == '-'){
			cout << a - b << endl;
		}
		if (op == '*'){
			cout << a * b << endl;
		}
		if (op == '/'){
			cout << a / b << endl;
		}
		if (op == '?')
			break;
	}

	return 0;

}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(void){

    double N,T,A,ans=0,tmp1,tmp2,tmp3,min=9999999999;
    
    cin >> N >> T >> A;
    

     REP(i,N){

        cin >> tmp1;

        tmp2 = T - 0.006*tmp1;    
        
        tmp3 = A-tmp2;
        if(tmp3 < 0)  tmp3 *= -1;
 
        if(min > tmp3){
            min = tmp3;
            ans= i+1;
        }  
    }

    cout << ans << endl;
   
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    int H,W,A,B; cin >> H >> W >> A >> B;
    int s[1010][1010];
    for (int i = 0; i < B; i++){
        for (int j = 0; j < W; j++){
            if (j < A) s[i][j] = 0;
            else s[i][j] = 1;
        }
    }
    for (int i = B; i < H; i++){
        for (int j = 0; j < W; j++){
            if (j < A) s[i][j] = 1;
            else s[i][j] = 0;
        }
    }
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << s[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 5120
// AOJ ITP1_11_B Dice II
// 2018.4.29 bal4u
  
#include <stdio.h>
  
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];
  
int main()
{
    int i, j;
    int a[7], b[7], dice[7];
  
    for (i = 1; i <= 6; i++) scanf("%d", assign+i);
    for (i = 1; i <= 6; i++) scanf("%d", a+i);
    for (j = 0; j < 24; j++) {
        for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
        for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
        for (i = 1; ; i++) {
            if (i > 6) { puts("Yes"); return 0; }
            if (a[i] != b[i]) break;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 2148
#include <stdio.h>
 
int main(void){
  int N;
  char C[3];
  int A = 0;
  int W = 0;
  int T = 0;
  int R = 0;
  scanf("%d",&N);
  
  for(int i = 0; i < N; i++){
    scanf("%s",C);
    if(strcmp(C,"AC")==0){
      A++;
    }else if(strcmp(C,"WA")==0){
      W++;
    }else if(strcmp(C,"TLE")==0){
      T++;
    }else if(strcmp(C,"RE")==0){
      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);
  
  return 0;
}

Measured memory_bytes: 1736
#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

typedef long long ll;

using namespace std;
int main(){
	ll d,g;
	cin >> d >> g;
	vector<ll> p(d), c(d);
	for(int i=0; i<d; ++i) cin >> p[i] >> c[i];
	
	ll tt = accumulate(p.begin(),p.end(),1);
	vector<ll> ret(tt,0);
	auto sb = ret;
	for (auto i=0; i<d; ++i){
		for(auto j=1; j<=p[i]; ++j){
			auto pt = (i+1)*j*100;
			if (j==p[i]) pt += c[i];
			for (auto k=0; k<tt; ++k){
				if (j>k) continue;
				sb[k] = max(ret[k-j]+pt,ret[k]);
				if (sb[k]>=g) break;
			} 
		}
		ret = sb;
	}
	for (auto it = ret.begin(); it!=ret.end(); ++it){
		if (*it>=g){
			cout << it - ret.begin() << endl;
			break;
		}	
	}
	return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

int N,D,ans=0;

int main(){
    cin>>N>>D;
    int X[N][D];
    rep(i,N){
        rep(j,D){
            cin>>X[i][j];
        }
    }
    rep(i,N){
        repi(j,i+1,N){
            int sum=0;
            rep(k,D)sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            if(sum==int(sqrt(sum))*int(sqrt(sum)))ans++;

        }
    }
    out(ans);
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define rfo(i,n) for(int i=n-1;i>=0;i--)
#define Fo(i,q,n) for(int i=q;i<n;i++)
#define rFo(i,q,n) for(int i=n-1;i>=q;i--)
#define fO(i,n,k) for(int i=0;i<n;i+=k)
#define FO(i,q,n,k) for(int i=q;i<n;i+=k)
#define zero(a,n) memset(a,0,sizeof(a[0])*n)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
const int MOD=1000000007;
void print(){cout <<endl;}
template <typename T, typename... Types> 
void print(T var1, Types... var2){cout << var1 << " " ;print(var2...) ;}
//ceil of a/b
template <typename T>
T fceil(T a,T b){return (T)(a+b-1)/b;}
template <typename T>
void printvec(vector<T> v){ for(int i=0;i<(int)v.size();i++){ cout<<v[i]<<" ";} cout<<endl;}
template <typename T>
void printarr(T a[],int n){ for(int i=0;i<n;i++){ cout<<a[i]<<" ";} cout<<endl;}
//const int N=2e5;
//int arr[N+1];

 
int main(){
	string s,t;
	cin>>s;
	cin>>t;
	int n = s.size();
	int m=t.size();
	int maxm=0;
	fo(i,n-m+1){
		int cnt=0;
		fo(j,m){
			if(s[i+j]==t[j]){cnt++;}	
		}
		maxm = max(maxm,cnt);	
	}
	cout<< m-maxm<<endl;
	return 0;
}






/*NOTE: Take MOD after sorting and not before sorting!*/


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<vector>
#define N 10000

using namespace std;

int rank[N];
int root[N];

int find(int x) {
	if (x == root[x]) {
		return x;
	}
	else {
		return root[x] = find(root[x]);
	}
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);

	if (x == y) {
		return;
	}

	if (rank[x] > rank[y]) {
		root[y] = x;
	}
	else if(rank[x] < rank[y]) {
		root[x] = y;
	}
	else {
		root[y] = x;
		rank[x] += 1;
	}
}

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

int main() {

	int n, q;

	cin >> n >> q;

	int com, x, y;
	

	for (int i = 0; i < n; i++) {
		rank[i] = 0;
		root[i] = i;
	}

	//int a, b;
	for (int i = 0; i < q; i++) {
		cin >> com;
		cin >> x >> y;

		if (com == 0) {
			if (same(x, y)) {
				continue;
			}

			unite(x, y);
		}
		else {
			if (same(x, y)) {
				cout << '1' << endl;
			}
			else {
				cout << '0' << endl;
			}
		}

	}
	return 0;
}




Measured memory_bytes: 3172
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int intpow(int a, int n) {
	// a^nのint ver
	rep(i, n - 1)
		a *= a;
	return a;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1)) % mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n, int k) {
	//nのk桁目
	rep(i, k - 1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (C <= A + B + 1)
		cout << B + C;
	else
		cout << 2 * B + A + 1;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin >> n;
    while(n>0){
        n -= 1000;
    }
    out(abs(n));
}

Measured memory_bytes: 3616
N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
line1 = [0]*C
line2 = [0]*C
line0 = [0]*C
for i in range(N):
  c = list(map(int, input().split()))
  for j in range(N):
    if (i+j)%3 == 0:
      line0[c[j]-1] +=+1
    if (i+j)%3 == 1:
      line1[c[j]-1] +=+1
    if (i+j)%3 == 2:
      line2[c[j]-1] +=+1
ans = float("inf")
#line0をi+1に、1をj+1に, 2をk+1にそろえよう
#print(line0,line1,line2)
for i in range(C):
  for j in range(C):
    if j !=i :
      for k in range(C):
        if k !=i and k!=j: 
#          print(i,j,k)
          curr = 0
          for l in range(C):
            curr += line0[l]*D[l][i]
            curr += line1[l]*D[l][j]
            curr += line2[l]*D[l][k]
#          print(curr)
          ans = min(ans, curr)
print(ans)

Measured memory_bytes: 47452
#include <iostream>
using namespace std;
int main(){
  char str[100] = {0};
  cin >> str;
  if(str[0] == 'S' && str[1] == 'A' && str[2] == 'T'){
    cout << "1" << endl;
  }else if(str[0] == 'F' && str[1] == 'R' && str[2] == 'I'){
    cout << "2" << endl;
  }else if(str[0] == 'T' && str[1] == 'H' && str[2] == 'U'){
    cout << "3" << endl;
  }else if(str[0] == 'W' && str[1] == 'E' && str[2] == 'D'){
    cout << "4" << endl;
  }else if(str[0] == 'T' && str[1] == 'U' && str[2] == 'E'){
    cout << "5" << endl;
  }else if(str[0] == 'M' && str[1] == 'O' && str[2] == 'N'){
    cout << "6" << endl;
  }else if(str[0] == 'S' && str[1] == 'U' && str[2] == 'N'){
    cout << "7" << endl;
  }
  return 0;
}

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

int main() {
    int A;
    unsigned long int B, N;
    unsigned long int x;
    cin >> A >> B >> N;
    if (N < B) {
        x = N;
    } else {
        x = B - 1;
    }
    unsigned long long int res;
    res = A * x / B - A * (x / B);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    int N, M; cin >> N >> M;
    vector<int> G(N+2, 0);
    for (int i = 0; i < M; ++i) {
        int l, r; cin >> l >> r; r++;
        G[l]++;
        G[r]--;
    }

    for (int i = 1; i <= N; ++i) G[i+1] += G[i];
    int res = 0;
    for (int i = 1; i <= N; ++i) if (G[i] == M) ++res;
    cout << res << endl;
}

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

int main() {
  int N;
  cin >> N;
  int a = N%10;
  if(a == 3){
  	cout << "bon" << endl;
  }
  else if(a == 1 || a == 6 || a == 8 || a == 0){
  	cout << "pon" << endl;
  }
  else cout << "hon" << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

const int mod = 1000000007;
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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint p(int n, int k)
    {
        return fact[n] * ifact[n - k];
    }
} c(1000005);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    vector<vector<mint>> dp(N + 10, vector<mint>(N + 10, 0));
    dp[A - 1][0] = 1;

    for (int i = A; i <= B; i++)
    {
        for (int j = 0; j <= N; j++)
        {
            // i人グループが0個
            dp[i][j] += dp[i - 1][j];
            int n = N - j;
            mint pw = c.fact[i].pow(C);
            for (int k = C; k <= D && i * k <= n; k++)
            {
                mint res = c(n, i * k) * c.fact[i * k] / pw / c.fact[k];
                pw *= c.fact[i];
                dp[i][j + i * k] += dp[i - 1][j] * res;
            }
        }
    }
    cout << dp[B][N] << endl;
    return 0;
}

Measured memory_bytes: 26980
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

void test() {
	int a,b,c,d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int m = a<b ? (a+b)/(a+1) : (a+b)/(b+1);
	int pl=0, ph=min((a+m-1)/m,b)+1;
	while (pl+1 < ph) {
		int pm=(pl+ph)/2;
		if (a-pm*m >= (b-pm+m-1)/m) pl=pm;
		else ph=pm;
	}
	int p=pl, q=max(0, (b-p)/m - ((b-p)%m ? 0 : 1)), w=a-p*m-q, u=b-p-q*m;
	//printf("m=%d, p=%d, q=%d, w=%d, u=%d\n",m,p,q,w,u);
	assert(w>=0);
	assert(w<=m);
	assert(u>=0);
	assert(u<=m);
	
	c--;
	d -= c;
	int pp=min(p,c/(m+1));
	c -= pp*(m+1);
	p -= pp;
	while (p>0) {
		if (c+d <= m) {
			for (int i=0; i<d; i++) printf("A");
			printf("\n");
			return;
		}
		for (int i=c; i<m; i++) {
			printf("A");
			d--;
		}
		printf("B");
		d--;
		c = 0;
		p--;
	}
	int ww = min(w, c);
	w -= ww;
	c -= ww;
	while (w > 0 && d > 0) {
		printf("A");
		w--;
		d--;
	}
	int uu = min(u, c);
	u -= uu;
	c -= uu;
	while (u > 0 && d > 0) {
		printf("B");
		u--;
		d--;
	}
	int qq=min(q,c/(m+1));
	c -= qq*(m+1);
	q -= qq;
	while (q>0) {
		if (c+d <= m+1) {
			if (c==0 && d>0) {
				printf("A");
				d--;
			}
			for (int i=0; i<d; i++) printf("B");
			printf("\n");
			return;
		}
		if (c==0 && d>0) {
			printf("A");
			d--;
		}
		for (int i=max(c,1); i<m+1; i++) {
			printf("B");
			d--;
		}
		c = 0;
		q--;
	}
	printf("\n");
}

int main() {
	int ttn;
	scanf("%d", &ttn);
	while (ttn--) test();
	return 0;
}


Measured memory_bytes: 384
import numpy as np

N, D=map(int, input().split())
a=np.zeros((N, D))
for i in range(N):
  a[i, :]=list(map(int, input().split()))
  
counter=0
for i in range(N-1):
  for j in range(i+1, N):
    temp=pow(np.sum((a[i]-a[j])**2), 1/2)
    if temp-int(temp)==0:
      counter+=1
      
print(int(counter))

Measured memory_bytes: 12508
#include<stdio.h>

int main(void){
  int a;
  int b;
  int c;
  
  scanf("%d", &a);
   scanf("%d", &b);
   scanf("%d", &c);
  
  if(a == b && b == c){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}



int ap[1001];

void solve()
{
	int x,n;
	cin>>x>>n;
	rep(i,1,n+1)
	{
		int ai;
		cin>>ai;
		ap[ai]=1;
	}
	int l=x,r=x;
	while(1)
	{
		if(!ap[l])
		{
			cout<<l<<endl;
			return ;
		}
		if(!ap[r])
		{
			cout<<r<<endl;
			return ;
		}
		l--;
		r++;
	}
}

int main()       
{
	fastio
	ll t=1;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

// modを取らないnCkの計算
// 全体としてはオーバーフローしないはずでも、先に分子だけ計算したときに
// オーバーフローする可能性があることに注意                                                                                            
long long NCK[54][54];
void init(int n=54)	{
  for (int i=0; i<n; i++) {
    for (int j=0; j<=i; j++) {
      if (j==0 || j==i) {
        NCK[i][j] = 1;
      } else {
        // パスカルの三角形の性質 nCk = (n-1)C(k-1) + (n-1)Ck を利用
        NCK[i][j] = NCK[i-1][j-1] + NCK[i-1][j];
      }
    }
  }
  return;
}

struct edge {
  int cost;
  int x1;
  int y1;
  int x2;
  int y2;
};


struct data {
  int v;
  int min;
  int p;
};

// vector sort用
bool MySort (const data &p1, const data &p2){
  return p1.min < p2.min;
}

// priority_queue 用
class CompareFirst {
public:
  bool operator()(data n1, data n2) {
    return n1.min < n2.min;
  }
};


int main() {
  std::string s;
  std::cin >> s;
  int n = s.length();
  std::vector<int > digit(n);
  for (int i=0; i<n; i++) {
    digit[i] = s[i];
  }
  int count = 1;
  int prev = digit[0];
  int K = n;
  for (int i=1; i<n; i++) {
    if (digit[i]!=prev) {
      K = std::min(K, std::max(i, n-i));
      count = 0;
    } else {
      count++;
    }
    prev = s[i];
  }
  std::cout << K << std::endl;
}

Measured memory_bytes: 3484
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数

int main() {
  int N, K, Q;
  ci(N, K, Q);
  ve<int> A(Q), B(N, K - Q);
  rep(i, Q){
    ci(A.at(i));
    B.at(A.at(i) - 1)++;
  }
  rep(i, N){
    if(B.at(i) > 0){
     co("Yes");
    }
    else{
     co("No");
    }
  }
}

Measured memory_bytes: 1536
K = int(input())
if K % 2 == 0:
    print(-1)
else:
    mod = K
    t = 0
    for _ in range(K+1):
        t *= 10
        t += 7
        if t % mod == 0:
            print(_+1)
            exit(0)
        else:
            t %= mod
    print(-1)


Measured memory_bytes: 8964
#include<bits/stdc++.h>
#define ll long long

const int N = 200010;

std::pair <int, int> p[N];
int sufmax[N], sufmin[N];
int n;

ll calc(){
	int max = 0, max1 = 0, min = INT_MAX, min1 = INT_MAX;
	for (int i = 0; i < n; ++ i){
		max = std::max(max, p[i].first);
		max1 = std::max(max1, p[i].second);
		min = std::min(min, p[i].first);
		min1 = std::min(min1, p[i].second);
	}
	return 1ll * (max - min) * (max1 - min1);
}

int main(){
//	freopen("data.txt", "r", stdin);
//	freopen("E.txt", "w", stdout);
	scanf("%d", &n);
	int max = 0, min = INT_MAX, sit1, sit2;
	for (int i = 0; i < n; ++ i){
		scanf("%d%d", &p[i].second, &p[i].first);
		if (p[i].first > p[i].second){
			std::swap(p[i].first, p[i].second);
		}
	}
	if (n == 1){
		return printf("0\n"), 0;
	}
	ll ans = calc();
	std::sort(p, p + n);
	for (int i = 0; i < n; ++ i){
	//	printf("%d %d\n", p[i].first, p[i].second);
	}
	sufmin[n] = INT_MAX;
	for (int i = n - 1; i >= 0; -- i){
		sufmax[i] = std::max(sufmax[i + 1], p[i].first);
		sufmin[i] = std::min(sufmin[i + 1], p[i].first);
	}
	int nowmax = 0, nowmin = INT_MAX;
	for (int i = 0; i < n; ++ i){
		int x = std::max(nowmax, sufmax[i]), y = std::min(nowmin, sufmin[i]);
		int _x = std::max(std::max(nowmax, p[i].second), sufmax[i + 1]), _y = std::min(std::min(nowmin, p[i].second), sufmin[i + 1]);
		if (!i || _x - _y <= x - y){
			std::swap(p[i].first, p[i].second);
		}
		else{
		//	break;
		}
		nowmax = std::max(nowmax, p[i].first);
		nowmin = std::min(nowmin, p[i].first);
	}
	return printf("%lld\n", std::min(calc(), ans)), 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <math.h>
 
using namespace std;
int main() {
	unsigned long long x, y;
	cin >> x >> y;
 
	int count = 1;
	while (x<=y)
	{
		x *= 2;
		count++;
	}
	cout << count-1 << endl;
	return 0;
}

Measured memory_bytes: 384
use List::Util qw/sum/;
<>;
my @a1 = split(' ', <>);
my @a2 = split(' ', <>);

my $sum = sum ($a1[0], @a2[0..$#a1]);
my $max = $sum;

for my $i (1..$#a1) {
  $sum = $sum + $a1[$i] - $a2[$i-1];
  $max = $sum > $max ? $sum : $max;
}

print $max;

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

ll maxSubarrayXOR(vector<ll> set, int n) 
{ 
    // Initialize index of 
    // chosen elements 
    int index = 0; 
  
    // Traverse through all 
    // bits of integer  
    // starting from the most 
    // significant bit (MSB) 
    for (int i = 60; i >= 0; i--) 
    { 
        // Initialize index of 
        // maximum element and 
        // the maximum element 
        int maxInd = index; 
        ll maxEle = LLONG_MIN; 
        for (int j = index; j < n; j++) 
        { 
            // If i'th bit of set[j] 
            // is set and set[j] is  
            // greater than max so far. 
            if ( (set[j] & (1LL << i)) != 0  
                     && set[j] > maxEle ) 
                maxEle = set[j], maxInd = j; 
        } 
  
        // If there was no  
        // element with i'th 
        // bit set, move to 
        // smaller i 
        if (maxEle == LLONG_MIN) 
        continue; 
  
        // Put maximum element 
        // with i'th bit set  
        // at index 'index' 
        swap(set[index], set[maxInd]); 
  
        // Update maxInd and  
        // increment index 
        maxInd = index; 
  
        // Do XOR of set[maxIndex] 
        // with all numbers having 
        // i'th bit as set. 
        for (int j=0; j<n; j++) 
        { 
            // XOR set[maxInd] those 
            // numbers which have the 
            // i'th bit set 
            if (j != maxInd && 
               (set[j] & (1LL << i)) != 0) 
                set[j] = set[j] ^ set[maxInd]; 
        } 
  
        // Increment index of 
        // chosen elements 
        index++; 
    } 
  
    // Final result is  
    // XOR of all elements 
    ll res = 0; 
    for (int i = 0; i < n; i++) 
        res ^= set[i]; 
    return res; 
} 

int main(){
    int n; scanf("%d",&n);
    vector<ll> a(n);
    rep(i,0,n)scanf("%lld",&a[i]);
    ll s=0;
    rep(i,0,n)s^=a[i];
    ll ans=s;
    rep(i,0,n)a[i]&=(~s);
    ll add=maxSubarrayXOR(a,n);
    ans+=add*2LL;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.buffer.readline

a,b,c,d = map(int,input().split())

p = [a,b]
if a <= 0 <= b:
    p.append(0)
q = [c,d]
if c <= 0 <= d:
    q.append(0)

res = a*c
for x in p:
    for y in q:
        res = max(res,x*y)

print(res)

Measured memory_bytes: 61804
package main
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sort"
)

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var sc = newScanner()

func main() {
	n := scanInt()
	a := scanInts(n)
	a1 := make([]int, n)
	a2 := make([]int, n)
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		a1[i] = -a[i] + i + 1
		a2[i] = a[i] + i + 1
		m[a2[i]]++
	}
	sort.Ints(a1)

	var ans int
	for i := 0; i < n; i++ {
		ans += m[a1[i]]
	}
	fmt.Println(ans)
}

Measured memory_bytes: 17696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int n; cin >> n;
    vector<int> v(n+1, 0);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0) ++v[i];
        }
    }

    int rtn = 0;
    for (int i = 1; i <= n; ++i)
        if (i % 2 != 0 && v[i] == 8) ++rtn;

    cout << rtn << endl;
}


Measured memory_bytes: 3632