akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("7 1");
            WillReturn.Add("2");
            WillReturn.Add("5");
            WillReturn.Add("10");
            //8
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2");
            WillReturn.Add("8 20");
            WillReturn.Add("1");
            WillReturn.Add("10");
            //29
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("5");
            WillReturn.Add("30 44");
            WillReturn.Add("26");
            WillReturn.Add("18");
            WillReturn.Add("81");
            WillReturn.Add("18");
            WillReturn.Add("6");
            //56
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(A => int.Parse(A)).ToArray();

        SplitAct(InputList[1]);
        int D = wkArr[0];
        int X = wkArr[1];

        int SumVal = 0;
        foreach (string EachStr in InputList.Skip(2)) {
            int EachA = int.Parse(EachStr);

            for (int I = 1; I <= D; I += EachA) {
                SumVal++;
            }
        }
        Console.WriteLine(SumVal + X);
    }
}


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

int main(){
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int ans = 0;
	
	for(int i = 0; i < n; i++){
		if(i < k)ans += x;
		else ans += y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int maxn =1e6+100;
int n,m,res1,res2;

int a[maxn],b[maxn];
int ans,l,cnt,L,r;
char s[maxn];

queue<int> Q;

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		a[i]=s[i];
	}
	L = 1;
	for(int i=2;i<=n;i++)
	{
		if(a[i]=='1'&&a[i-1]=='0'){
			r=i;
			if(cnt<m){
				cnt++;Q.push(r);
				ans = max(ans,r-L+1);
			}
			else{
				L=Q.front();
				Q.pop();Q.push(r);
				ans = max(ans,r-L+1);
			}
		}
		if(a[i]=='1'&&a[i-1]=='1') ans=max(ans,i-L+1);
	}
	if(a[n]=='1') ans = max(ans,n-L+1);
	else{
		if(cnt<m){
			ans = max(ans,n-L+1);
		}
		else{
			L=Q.front();
			ans=max(ans,n-L+1);
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2560
from collections import Counter
N = int(input())
Ac = Counter(list(map(int, input().split())))
over2 = [ele for ele in Ac.items() if ele[1]>=2]
if len(over2) == 0:
  print(0)
elif len(over2) == 1:
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
else:
  over2.sort(reverse=True)
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
  else:
    print(over2[0][0]*over2[1][0])


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

int main() {
    string w; cin >> w;
    vector<int> ans(26, 0);
    for(int i = 0; i < w.length(); i ++) {
        ans[w[i]-97] ++;
    }
    for(int i = 0; i < 26; i ++) {
        if(ans[i]%2==1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;


int main()
{
	int nCount = 0;
	cin >> nCount;
	int nMax = -1000001, nMin = 1000001;
	long long nSum = 0;
	int nIn = 0;
	while (nCount--)
	{
		cin >> nIn;
		if (nIn>nMax)
		{
			nMax = nIn;
		}
		if (nIn<nMin)
		{
			nMin = nIn;
		}
		nSum += nIn;
	}
	cout << nMin << " " << nMax << " " << nSum << endl;

	//system("pause");
	return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<bool> B(N, false);
    vector<int> A(N);

    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        A.at(i) = a;
    }

    B.at(0) = true;
    bool found = false;
    int count = 0;
    int next = 0;

    while(count <= N) {
        if (B.at(1)) {
            found = true;
            break;
        }
        B.at(next) = false;
        next = A.at(next) - 1;
        B.at(next) = true;
        count++;
    }

    if (found) {
        cout << count << endl;
    } else {
        cout << -1 << endl;
    }

}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

int cnt[2][2000][2000];
int pcnt[2][2001][2001];

int range(int t, int x1, int y1, int x2, int y2) {
    return pcnt[t][x2][y2] - pcnt[t][x1][y2] - pcnt[t][x2][y1] + pcnt[t][x1][y1];
}

int main() {
    FAST_IO();
    int N, K; cin >> N >> K;
    rep(i, N) {
        int x, y; char c; cin >> x >> y >> c;
        if(c == 'W') cnt[0][x%(2*K)][y%(2*K)]++;
        else cnt[1][x%(2*K)][y%(2*K)]++;
    }
    rep(t, 2) repp(x, 1, 2*K) repp(y, 1, 2*K) {
        pcnt[t][x][y] = pcnt[t][x-1][y] + pcnt[t][x][y-1] - pcnt[t][x-1][y-1] + cnt[t][x-1][y-1];
    }
    int ans = 0, q = 0;
    rep(t, 2) rep(x, K) rep(y, K) {
        q = 0;
        q += range(t, 0, 0, x, y);
        q += range(t, x, y, x+K, y+K);
        q += range(t, x+K, y+K, 2*K, 2*K);
        q += range(t, 0, y+K, x, 2*K);
        q += range(t, x+K, 0, 2*K, y);
        q += range(1-t, x, 0, x+K, y);
        q += range(1-t, 0, y, x, y+K);
        q += range(1-t, x+K, y, 2*K, y+K);
        q += range(1-t, x, y+K, x+K, 2*K);
        ans = max(ans, q);
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
	int X, A, B;
	cin >> X >> A >> B;
	
	if( B <= A ){
		cout << "delicious" << endl;
	}else if( B <= A + X ){
		cout << "safe" << endl;
	}else{
		cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 256
import Data.List

minimize :: Int -> Int -> Int
minimize h w = min (minimize' h w) (minimize' w h)
  where minimize' h w = minimum [ diff (w * i) w (h - i)
                                | i <- [1 .. h - 1] ] 
        half a b
          | a `mod` 2 == 0 || b `mod` 2 == 0 =
              let s = a * b `div` 2 in (s, s)
          | a <= b =
              let hb = b `div` 2 in (a * hb, a * (b - hb))
          | otherwise =
              let ha = a `div` 2 in (b * ha, b * (a - ha))
        diff c a b = let (s, l) = half a b
                         [lt, _, gt] = sort [s, l, c]
                       in gt - lt

main :: IO ()
main = do
  [h, w] <- mapM readIO . words =<< getLine
  print $ minimize h w


Measured memory_bytes: 1020
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r;};
struct Node T[MAX];
int n;

void preParse(int u) {
  if(u == NIL)
    return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if(u == NIL)
    return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u) {
  if(u == NIL)
    return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main()
{
  int i, v, l, r, root;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    T[i].p = NIL;
  }

  for(i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)
      T[l].p = v;
    if(r != NIL)
      T[r].p = v;
  }

  for(i = 0; i < n; i++)
    if(T[i].p == NIL)
      root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 1852
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <cstdio>
using namespace std;
int main(void){
	int i,a,b,ans=0;
	cin>>a>>b;
	for(i=a;i<=b;i++){
		if(i/10000==i%10&&i/1000%10==i%100/10)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))
tmp = sum(p[:K]) 
maxsum = tmp
#print(p[:K])
for i in range(1,N-K+1):
  #print(p[i:i+K])
  tmp = tmp - p[i-1] + p[i+K-1]
  maxsum = max(maxsum, tmp)
ans = (maxsum + K) / 2
print(ans)

Measured memory_bytes: 91864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int H,W,N; cin>>H>>W>>N;
  int K=max(H,W);
  cout<<(N+K-1)/K<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int h, w;
vector<string> mp;
int ans = 0;

//inputします
void input() {
    cin >> h >> w;
    mp.resize(h);
    ff(i, 0, h) {
        cin >> mp[i];
    }
}

//ライブラリ置き場


//main
int main() {
    input();
    ff(y, 0, h) {
        ff(x, 0, w) {
            if (mp[y][x] == '#') {
                //cout <<y<<" "<<x<<" "<< "continue" << endl;
                continue;
            }
            vector<vector<int>> dist(h, vector<int>(w, -1));
            queue<pair<int, int>> to_visit;
            dist[y][x] = 0;
            to_visit.push({ y,x });
            while (!to_visit.empty()) {
                pair<int, int> v = to_visit.front();
                to_visit.pop();
                if ( v.second> 0) {
                    if (mp[v.first][v.second-1] == '.' && dist[v.first][v.second - 1] < 0) {
                        to_visit.push({ v.first,v.second - 1 });
                        dist[v.first][v.second - 1] = dist[v.first][v.second] + 1;
                    }
                }
                if (v.second < w - 1) {
                    if (mp[v.first][v.second + 1] == '.' && dist[v.first][v.second + 1] < 0) {
                        to_visit.push({ v.first,v.second + 1 });
                        dist[v.first][v.second + 1] = dist[v.first][v.second] + 1;
                    }
                }
                if (v.first > 0) {
                    if (mp[v.first-1][v.second] == '.' && dist[v.first-1][v.second] < 0) {
                        to_visit.push({ v.first-1,v.second});
                        dist[v.first-1][v.second] = dist[v.first][v.second] + 1;
                    }
                }
                if (v.first < h - 1) {
                    if (mp[v.first + 1][v.second] == '.' && dist[v.first + 1][v.second] < 0) {
                        to_visit.push({ v.first + 1,v.second });
                        dist[v.first + 1][v.second] = dist[v.first][v.second] + 1;
                    }
                }
            }
            int pre = 0;
            ff(i, 0, h) {
                ff(j, 0, w) {
                    pre = max(pre, dist[i][j]);
                    //cout << dist[i][j] << " ";
                }
                //cout << endl;
            }
            ans = max(ans, pre);
        }
    }
    cout << ans << endl;
    return 0; 
}

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

#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 PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	set<string> st;
	int n, m;
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		st.insert(s);
	}
	cin >> m;
	bool opened = false;
	REP(i, m) {
		string t;
		cin >> t;
		if (st.count(t)) {
			if (opened) {
				cout << "Closed by ";
			}
			else {
				cout << "Opened by ";
			}
			opened = !opened;
			cout << t << endl;
		}
		else {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3196
// a code about cooties
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(int)(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(int)(a);i--)
template<typename T> ostream& operator<<(ostream& s, vector<T> t) {rep(i, 0, t.size()) s << (i ? " " : "") << t[i]; return s;}
template<typename T> istream& operator>>(istream& s, vector<T> &t) {rep(i, 0, t.size()) s >> t[i]; return s;}
template<typename T, typename U> ostream& operator<<(ostream& s, pair<T, U> t) {s << "(" << t.first << "," << t.second << ")"; return s;}
template<typename T, typename U> istream& operator>>(istream& s, pair<T, U> &t) {s >> t.first >> t.second; return s;}
typedef long long ll;
const int N = 123;
const ll INF = 1e18;

ll dp[N][N * 3];


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    ll w;
    cin >> n >> w;
    vector<pair<ll, ll>> a(n);
    cin >> a;
    ll w0 = a[0].first;
    //rep(i, 0, N) rep(j, 0, N * 3) dp[i][j] = INF;
    //dp[0][0] = 0;
    ll res = 0;
    rep(i, 0, n) {
        ll weight, value;
        tie(weight, value) = a[i];
        weight -= w0;
        per(inside, 0, N) rep(added, 0, N) {
            ll cw = inside * w0 + added;
            if (cw + weight + w0 <= w) {
                dp[inside + 1][added + weight] =
                    max(dp[inside + 1][added + weight], dp[inside][added] + value);
                res = max(res, dp[inside + 1][added + weight]);
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    ll n,k,a,b;
    cin >> n >> k;
    vector<vector<ll>> g(n);
    vector<bool> done(n,0);
    rep(i,n-1){
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ll ans = k;
    queue<ll> q;
    q.push(0);
    bool out = 0;
    while(!q.empty()){
        ll v;
        v = q.front();
        q.pop();
        done[v] = true;
        ll m = g[v].size();
        if (v == 0){
            if (k-1-m < 0){
                out = 1;
                break;
            }
            (ans *= (fac[k-1]*finv[k-1-m])%MOD)%=MOD;
        }
        else{
            m--;
            if (k-2-m < 0){
                out = 1;
                break;
            }
            (ans *= (fac[k-2]*finv[k-2-m])%MOD)%=MOD;
        }
        for(ll u:g[v]){
            if (done[u]) continue;
            q.push(u);
        }
    }
    if (out) PRINT(0);
    else PRINT(ans);
}




Measured memory_bytes: 9716
def c131
    a, b, c, d = gets.chomp.split(/\s/).map{|x| x.to_i}
    l = c.lcm(d) # 最小公倍数

    e = b/c - a/c + (a%c==0?1:0)
    f = b/d - a/d + (a%d==0?1:0)
    g = b/l - a/l + (a%l==0?1:0)
    puts ((b-a)+1) - (e + f - g)
end

c131

Measured memory_bytes: 2044
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
using namespace std;
//________
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define err(...) fprintf(stderr, __VA_ARGS__ )
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
#define Size 1000111
#define INF  0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define NIL -1
//________


signed main()
{
   FAST();
   string s;
   cin >> s;
   s[0] = '2';
   s[1] = '0';
   s[2] = '1';
   s[3] = '8';
   outl(s);
}



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

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

    int n;
    cin >> n;
    vector<int> cnt(n+1, 0);
    for(int i=1; i<=100; ++i){
        for(int j=1; j<=100; ++j){
            for(int k=1; k<=100; ++k){
                int ans = 0;
                ans += i * i;
                ans += j * j;
                ans += k * k;
                ans += i * j;
                ans += i * k;
                ans += j * k;

                if( ans <= n ){
                    cnt[ans]++;
                }
            }
        }
    }
    for(int i=1; i<=n; ++i){
        cout << cnt[i] << endl;
    }



    return 0;
}

Measured memory_bytes: 3580
//#include <bits/stdc++.h>
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
const int mod = 1000000007;

ll gcd(ll a, ll b){return b ? gcd(b,a%b) : a;};//最大公約数
ll lcm(ll a, ll b){return a*b/gcd(a,b);};//最小公倍数
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
//ll a[100000];
//ll dom[100001];

int main(){
  int a,b;
  cin>>a>>b;
  cout<<lcm(a,b);
   return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s;
  cin>>s;
  string t = "AKIHABARA";
  int j = 0;
  REP(i,t.size()){
    if(j>=s.size() && t[i]!='A'){
      puts("NO");
      return 0;
    }else if(s[j]==t[i]){
      j++;
    }else if(t[i]=='A'){
      //
    }else{
      puts("NO");
      return 0;
    }
  }
  if(j==s.size()){
    puts("YES");
  }else{
    puts("NO");
  }
  return 0;
}


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

using namespace std;

int main()
{
    int N,i,j,k,L[105],sum=0,a;
    cin>>N;
    for(i=1; i<=N; i++)
        cin>>L[i];
    for(i=1; i<=N-2; i++)
        for(j=i+1; j<=N-1; j++)
            for(k=j+1; k<=N; k++)
            {
                a=max(L[i],L[j]);
                a=max(a,L[k]);
                if(L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]&&L[i]+L[j]+L[k]-a>a)
                    sum++;
            }
    cout<<sum<<endl;
    return 0;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, T;
    std::cin >> N >> T;

    vector<pair<int, int>> route;
    REP(i, N) {
        int c, t;
        std::cin >> c >> t;
        if(t <= T) {
            route.emplace_back(c, t);
        }
    }

    if(route.size() == 0) {
        std::cout << "TLE" << std::endl;
    }
    else {
        SORT(route);
        std::cout << route.front().first << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

flag = 1
sorted_index = 0
num_of_sorting = 0
while flag:
  flag = 0
  for i in range(N-1, sorted_index, -1):  # N-1から1まで降順 
    if A[i] < A[i-1]:
      temp = A[i]
      A[i] = A[i-1]
      A[i-1] = temp
      flag = 1
      num_of_sorting += 1
  sorted_index += 1

print(' '.join(map(str, A)))
print(f"{num_of_sorting}")


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

namespace ConsoleApplication1
{
    class Program
    {
        static readonly double best = 22.0;

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                double minV = 1 << 20;
                int minId = 0;

                for (int i = 0; i < n; i++)
                {
                    string[] input = Console.ReadLine().Split(' ');
                    int id = int.Parse(input[0]);
                    double h = double.Parse(input[1]) / 100;
                    double w = double.Parse(input[2]);

                    double bmi = w / Math.Pow(h, 2);

                    double temp = Math.Abs(best - bmi);

                    if (temp < minV)
                    {
                        minV = temp;
                        minId = id;
                    }
                    else if (temp == minV)
                    {
                        minId = Math.Min(minId, id);
                    }
                }
                sb.AppendLine(minId.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9576
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	balls := make(Balls, n)

	for i := 0; i < n; i++ {
		balls[i].x = getNextInt(scanner)
		balls[i].y = getNextInt(scanner)
	}
	sort.Sort(balls)
	dd := make(map[int]map[int]int, 0)
	for i := 0; i < n; i++ {
		for ii := i + 1; ii < n; ii++ {
			dx := balls[ii].x - balls[i].x
			dy := balls[ii].y - balls[i].y
			if _, ok := dd[dx]; ok == false {
				dd[dx] = make(map[int]int, 0)
			}
			if _, ok := dd[dx][dy]; ok == false {
				dd[dx][dy] = 0
			}
			dd[dx][dy]++
		}
	}
	max := 0
	for _, mm := range dd {
		for _, m := range mm {
			if max < m {
				max = m
			}
		}
	}
	fmt.Fprintln(writer, n-max)

	writer.Flush()
}

type Ball struct {
	x int
	y int
}

type Balls []Ball

func (a Balls) Len() int      { return len(a) }
func (a Balls) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Balls) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y < a[j].y
	}
	return a[i].x < a[j].x
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task ""

using namespace std;
typedef long long ll;

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }
    if (fopen(Task".in", "r")){
        freopen(Task".in", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    int n, k; cin >> n; k = 2;
    vector<int> a(n), f(n);
    for (int i=0; i<n; ++i){
        cin >> a[i];
        if (i) f[i] = 2e9 + 5;
        for (int j=i-1; j>=0 && j>=i-k; --j){
            f[i] = min(f[i], f[j] + abs(a[i] - a[j]));
        }
    }
    cout << f[n-1] << '\n';
}


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

int main() {

  string in;

  while( cin >> in ) {

    while( in.size() > 1 ) {

      string o = "";
      for ( int i = 0; i < in.size()-1; i++ ) {
	o += '0' + ( in[i] - '0' + in[i+1] - '0' ) % 10;
      }
      in = o;

    }

    cout << in << endl;

  }

  return 0;

}

Measured memory_bytes: 1184
import sys
sys.setrecursionlimit(100000)

N,M, K = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
CD = [list(map(int,input().split())) for i in range(K)]


#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x]=y

li1 = [i for i in range(N)]
li2 = [i for i in range(N)]

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    # print(str(i)+" ",end="")
    union(min(a-1,b-1),max(a-1,b-1),li1)
# for i in range(K):
#     c = CD[i][0]
#     d = CD[i][1]
#     union(c-1,d-1,li2)

mm = [0 for i in range(max(li1)+1)]
for i in range(N):
    m = root(i,li1)
    mm[m] += 1

# print(li1)
# print(mm)
ans = [mm[li1[i]]-1 for i in range(N)]
# print(ans)

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    ans[a-1] -= 1
    ans[b-1] -= 1


for i in range(K):
    c = CD[i][0]
    d = CD[i][1]
    if find(c-1,d-1,li1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)





Measured memory_bytes: 108752
object Main extends App {
	val n = scala.io.StdIn.readInt
	val a = new Array[String](n)

	for(i<-0 until n){
		a(i) = scala.io.StdIn.readLine.toString
	}

	if(a.toSet.size != n){
		println("No")
	}else{
		var tp = a(0).toList.reverse.head
		var fg = true
		for(i<-1 until n){
			val tq = a(i).toList.head
			if(tp == tq){
				tp = a(i).toList.reverse.head
			}else{
				fg = false
			}
		}

		if(fg){
			println("Yes")
		}else{
			println("No")
		}
	}

}


Measured memory_bytes: 27052
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

class InversionCount {
public:
    InversionCount(vector<ll> target) : target_(target) {}
    ll count(ll left = 0, ll right = -1) {
        if (right < 0) {
            //rはtarget_.size()で初期化
            right = target_.size();
        }
        if (right <= left + 1) {
            return 0;
        }
        ll mid = (left + right) / 2;
        ll result = 0;
        //左半分を数える
        result += count(left, mid);

        //右半分を数える
        result += count(mid, right);

        //左右またぐ数を数える
        result += merge(left, mid, right);

        return result;
    }
private:
    ll merge(ll left, ll mid, ll right) {
        vector<ll> l, r;
        for (ll i = left; i < mid; i++) {
            l.push_back(target_[i]);
        }
        for (ll i = mid; i < right; i++) {
            r.push_back(target_[i]);
        }
        //番兵
        l.push_back(LLONG_MAX);
        r.push_back(LLONG_MAX);

        ll left_index = 0;
        ll right_index = 0;
        ll result = 0;
        for (ll i = left; i < right; i++) {
            if (l[left_index] <= r[right_index]) {
                target_[i] = l[left_index];
                left_index++;
            } else {
                target_[i] = r[right_index];
                right_index++;
                result += ((mid - left) - left_index);
            }
        }
        return result;
    }

    vector<ll> target_;
};

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

    const ll N = S.size();

    vector<ll> num(26, 0);
    for (char c : S) {
        num[c - 'a']++;
    }

    ll odd_num = 0;
    for (ll i = 0; i < 26; i++) {
        if (num[i] % 2 == 1) {
            odd_num++;
        }
    }

    if (odd_num >= 2) {
        cout << -1 << endl;
        return 0;
    }

    //前半に来るものが今まで何個出てきているか
    ll left_num = 0;

    //i番目の文字が最終的に作る回文では何番目に来るか(0-indexed)
    vector<ll> p(N);

    //現在までに各文字が出現した回数
    vector<ll> appear_num(26, 0);

    //各文字がどこへ行くか
    //出現回数が各文字の半分に行くまで積んでいき,
    //半分を超えたものは一つ取り出してそれの反転位置へ
    vector<stack<ll>> stacks(26);

    for (ll i = 0; i < N; i++) {
        if (num[S[i] - 'a'] % 2 == 1) {
            if (++appear_num[S[i] - 'a'] <= num[S[i] - 'a'] / 2) {
                //前半へ
                p[i] = left_num++;
                stacks[S[i] - 'a'].push(p[i]);
            } else if (appear_num[S[i] - 'a'] == num[S[i] - 'a'] / 2 + 1) {
                //中央へ
                p[i] = N / 2;
            } else {
                //後半へ
                ll t = stacks[S[i] - 'a'].top();
                stacks[S[i] - 'a'].pop();
                p[i] = N - 1 - t;
            }
        } else {
            if (++appear_num[S[i] - 'a'] <= num[S[i] - 'a'] / 2) {
                //前半へ
                p[i] = left_num++;
                stacks[S[i] - 'a'].push(p[i]);
            } else {
                //後半へ
                ll t = stacks[S[i] - 'a'].top();
                stacks[S[i] - 'a'].pop();
                p[i] = N - 1 - t;
            }
        }
    }

    InversionCount ic(p);
    cout << ic.count() << endl;
}

Measured memory_bytes: 6504
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const int64_t mod = 1000000007;
const int MAX_N = 100000;

vector<int64_t> fact(MAX_N);
vector<int64_t> inv_fact(MAX_N);
int64_t power(int64_t a, int64_t b) {
  int64_t res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}

int64_t comb(int64_t n, int64_t r) {
  if (n >= r)
    return ((fact[n] * inv_fact[r]) % mod * inv_fact[n - r]) % mod;
  else
    return 0;
}

void gen_fact(int n) {
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) fact[i] = (fact[i - 1] * i) % mod;
}

void gen_inv_fact(int n) {
  inv_fact[n] = power(fact[n], mod - 2);
  for (int i = n - 1; i >= 0; --i) {
    inv_fact[i] = (inv_fact[i + 1] * (i + 1)) % mod;
  }
}

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  rep(i, N) { cin >> A[i]; }
  sort(A.begin(), A.end());

  gen_fact(N);
  gen_inv_fact(N);

  int64_t ans = 0;
  rep(i, N) {
    int64_t add = (A[i] * comb(i, K - 1)) % mod;
    ans = (ans + add) % mod;
    int64_t sub = (A[i] * comb(N - 1 - i, K - 1)) % mod;
    ans = (ans - sub) % mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;



int main(){
  int n,m;
  ll k;
  cin >>n >>m >>k;
  ll a[n],b[m];
  rep(i,n){
    ll g;
    cin >>g;
    if(i>0){a[i]=a[i-1]+g;}else{a[i]=g;}
  }
  rep(i,m){
    ll g;
    cin >>g;
    if(i>0){b[i]=b[i-1]+g;}else{b[i]=g;}
  }
  int ans=0;
  rep(i,n){
    ll q=k-a[i];
    if(q<0)break;
    int qq=upper_bound(b,b+m,q)-b;
    chmax(ans,qq+i+1);
  }
    rep(i,m){
    ll q=k-b[i];
    if(q<0)break;
    int qq=upper_bound(a,a+n,q)-a;
    chmax(ans,qq+i+1);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 6700
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する

vector<int> conv(string s) {
    map<char, int> mp;
    vector<int> ret;
    int cnt = 0;
    for (auto e : s) {
        if (mp.count(e) == 0) {
            mp[e] = cnt++;
        }
        ret.push_back(mp[e]);
    }
    return ret;

}

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

    string s, g;
    cin >> s >> g;
    auto ss = conv(s);
    auto gg = conv(g);
    if (ss == gg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int mo=1000000007;
const int N=2005;
int fac[N*N],inv[N*N];
int n,k,m,f[N][N];
int C(int x,int y){
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main(){
	scanf("%d%d",&n,&k);
	m=n*k; fac[0]=inv[0]=inv[1]=1;
	for (int i=2;i<=m;i++)
		inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo;
	for (int i=1;i<=m;i++)
		fac[i]=1ll*fac[i-1]*i%mo,
		inv[i]=1ll*inv[i-1]*inv[i]%mo;
	if (k==1) return puts("1"),0;
	f[0][0]=1; k-=2;
	for (int i=0;i<=n;i++)
		for (int j=0;j<=i;j++){
			if (i!=j)
				f[i][j+1]=(f[i][j+1]+1ll*C((n-i)+(n-j-1)+(n-j)*k,k)*f[i][j]%mo*(n-j))%mo;
			if (i<n) f[i+1][j]=(f[i+1][j]+f[i][j])%mo;
		}
	printf("%d\n",f[n][n]);
}

Measured memory_bytes: 46464
fun main(args: Array<String>){
    val(n, q) = readLine()!!.split(" ").map(String::toInt)
    val s = readLine()!!
    val cumSum = mutableListOf(0)
    for(i in 1..(n - 1)){
        if(s.substring(i - 1, i + 1) == "AC") cumSum.add(cumSum[i - 1] + 1)
        else cumSum.add(cumSum[i - 1])
    }
    for(i in 1..q){
        val(l, r) = readLine()!!.split(" ").map(String::toInt)
        println(
            when (l) {
                1 -> cumSum[r - 1]
                else -> cumSum[r - 1] - cumSum[l - 1]
            }
        )
    }
}

Measured memory_bytes: 71636
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  int D;
  
  cin >> N >> D;
  
  vector<vector<double>> X(N,vector<double>(D));
  
  for(int i = 0;i < N;++i){
    for(int j = 0;j < D;++j){
      cin >> X[i][j];
    }
  }
  
  int num;
  int num2;
  
  int num3 = 0;
  
  double num4;
  
  int num5 = 0;
    
  for(int i = 0;i < N - 1;++i){
    for(int k = i + 1;k < N;++k){
      for(int j = 0;j < D;++j){
        num = abs(X[i][j] - X[k][j]);
        num2 = num * num;
        num3 = num3 + num2;
      }
      num4 = sqrt((double)num3);
      num3 = 0;
      if(ceil(num4) == floor(num4)){
        num5++;
      }
    }
  }
  
  cout << num5 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const double pi=acos(-1);
int main()
{
	ll sum=0;
	int m,n,x;
	cin>>m>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		sum+=x;
	}
	if(sum>m)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<m-sum<<endl;
	}

	return 0;
} 

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	int len;
	char S[100010], T[10], U[10];
	scanf("%s", &S);

	while (1) {
//		printf("%s\n", S);
		len = strlen(S);
		if (!len) break;
		memset(T, 0, 10);
		memset(U, 0, 10);
		memmove(T, S, 7);
		if (!strcmp(T,"dreamer")) { // dreamerase(d,e,r) or dreamer(d,e)
			memmove(U, S+5, 6);
			if (!strcmp(U,"eraser")) {
				memmove(S, S+11, len-11);
				memset(S+len-11, 0, 11);
			} else if (!strcmp(U,"erasee") || !strcmp(U,"erased")) {
				memmove(S, S+10, len-10);
				memset(S+len-10, 0, 10);
			} else if (!strcmp(U,"ereras") || !strcmp(U,"erdrea")) {
				memmove(S, S+7, len-7);
				memset(S+len-7, 0, 7);
			} else if (!strcmp(U,"er\0")) {
				memmove(S, S+7, len-7);
				memset(S+len-7, 0, 7);
			} else {
				printf("NO\n"); return 0;
			}
		} else if (!strcmp(T,"dreamdr")) { // dreamdream(er)
			memmove(S, S+5, len-5);
			memset(S+len-5, 0, 5);
		} else {
			memset(T, 0, 10);
			memmove(T, S, 6);
			if (!strcmp(T,"eraser")) {
				memmove(S, S+6, len-6);
				memset(S+len-6, 0, 6);				
			} else {
				memset(T, 0, 10);
				memmove(T, S, 5);
				if (!strcmp(T,"dream")) {
					memmove(S, S+5, len-5);
					memset(S+len-5, 0, 5);
				} else if (!strcmp(T,"erase")) {
					memmove(S, S+5, len-5);
					memset(S+len-5, 0, 5);
				} else {
					printf("NO\n");
					return 0;
				}
			}
		}
	}
	
	printf("YES\n");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  int n = (int) s.size();
  if (s == string(n, s[0])) {
    cout << n * k / 2 << '\n';
  } else {
    int ans1 = 0;
    for (int i = 0; i + 1 < n; i++) {
      if (s[i % n] == s[(i + 1) % n]) {
        ++ans1;
        ++i;
      }
    }
    int ans2 = 0;
    for (int i = 0; i+1 < 2*n; i++) {
      if (s[i % n] == s[(i + 1) % n]) {
        ++ans2;
        ++i;
      }
    }
    cout << ans1 + (ans2 - ans1) * (k - 1) << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
s = input()

N = len(s)
a, b = -1, -1
if N == 2:
    if s[0] == s[1]:
        a, b = 1, 2
else:
    for i in range(N - 2):
        if s[i] == s[i + 1] or s[i + 1] == s[i + 2] or s[i + 2] == s[i]:
            a, b = i + 1, i + 3
            break
print(a, b)


Measured memory_bytes: 3188
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static final long MOD = 1000000007;
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		Set<String> S = new HashSet<>();

		for (int i = 0; i < N; i++) {
			S.add(scan.next());
		}

		System.out.println(S.size());
	}
}

Measured memory_bytes: 76844
solve :: [Int] -> Int -> Int -> Int
solve [] _ res = res
solve (x:xs) cnt res = solve xs (cnt + 1) res'
  where res' = if x == cnt
               then res
               else res + 1

main :: IO ()
main = do
  getLine
  input <- map read . words <$> getLine
  putStrLn $ if solve input 1 0 <= 2 then "YES" else "NO"

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

const int N = 55;
int n;
int a[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

    int cnt = 0;
    for (int i = 1; i <= n; i++)
        if (a[i] != i) cnt++;
    
    if (cnt == 2 || cnt == 0) printf("YES");
    else printf("NO");
}

Measured memory_bytes: 256
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define mod 1000000007
#define N 500055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,l[N],r[N],addl,addr,ans,l1,l2,lb,rb;
priority_queue <ll> L;
priority_queue<ll, vector<ll>, greater<ll> > R;
signed main(){
	n=read();
	F(i,1,n){
		l[i]=read();r[i]=read();
		if (i==1){L.push(l[i]);R.push(l[i]);continue;}
		l2=r[i]-l[i];l1=r[i-1]-l[i-1];
		addl-=l2;addr+=l1;
		ll lb=L.top()+addl,rb=R.top()+addr;
		if (l[i]<lb){
			ans+=lb-l[i];
			R.push(lb-addr);
			L.push(l[i]-addl);
			L.push(l[i]-addl);L.pop();
		}
		else if (l[i]>rb){
			ans+=l[i]-rb;
			L.push(rb-addl);
			R.push(l[i]-addr);R.push(l[i]-addr);
			R.pop();
		}
		else{
			L.push(l[i]-addl);
			R.push(l[i]-addr);
		}
	}
	wrn(ans);
	return 0;
}

Measured memory_bytes: 6892
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>

using namespace std;


string w,p;

void f_output(string p){
    int output[101]={0};
    
    stringstream stream;
    stream<<p;
    int x;
    int count=0;
    while(stream>>x){
        output[count]=x;
        count++;
    }
    
    sort(output, output+count);
    cout<<output[0];
    for(int i=1; i<count; i++)cout<<" "<<output[i];
    cout<<endl;
}


int main(){
    map<string, string> book;
    
    while(cin>>w>>p){
        if(book.find(w)==book.end()){
            book[w]=p;
        }else{
            book[w]=book[w]+" "+p;
        }
    }
    
    for (map<string, string>::iterator itr = book.begin(); itr != book.end(); itr++)
	{
		// キーを出力
		cout << itr->first << endl;
		// 値を出力
		f_output(itr->second);
	}
    
}

/*
int main()
{
    
    string w="123 222";
    stringstream stream;
    stream<<w;
    int x;
    while(stream>>x){
        cout<<x<<endl;
    }
    

}
*/

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

int main() {
    string s, t, p;
    int a, b;
    cin >> s >> t >> a >> b >> p;
    if (p == s) a--;
    else if (p == t) b--;
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;


const int maxn = 2e5+10, mod=998244353;
vector<int>t(maxn<<2);
int n,m;
void update(int rt,int l,int r,int pos,int new_val){
	if(l==r){t[rt]=new_val;return;}
	if(pos<=((l+r)>>1))update(rt<<1,l,(l+r)>>1,pos,new_val);
	else update((rt<<1)+1,((l+r)>>1)+1,r,pos,new_val);
	t[rt]=max(t[rt<<1],t[(rt<<1)+1]);
}
int query(int rt,int tl,int tr,int l,int r){
	if(l>r)return 0;
	if(l==tl&&r==tr)return t[rt];
	return max(query(rt<<1,tl,(tl+tr)>>1,l,min(r,(tl+tr)>>1)),query((rt<<1)+1,((tl+tr)>>1)+1,tr,max(l,((tl+tr)>>1)+1),r));
}

int32_t main(){
	IOS
	int n;cin>>n;
	vector<pair<int,int>>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
	}
	sort(a.begin(),a.end());
	vector<int>dp(n+1);
	dp[n]=1;
	for(int i=n-1;i>=0;i--){
		int idx = upper_bound(a.begin(),a.end(),make_pair(a[i].first+a[i].second-1,1000000000000000000ll))-a.begin()-1;
	    idx=max(idx,query(1,0,n-1,i,idx));
		update(1,0,n-1,i,idx);
		
		dp[i]=dp[idx+1];
		dp[i]+=dp[i+1];
		dp[i]%=mod;
	}
	cout<<dp[0];
	
	
}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 14252
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
 
 
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll w,h,x,y;
  cin>>w>>h>>x>>y;
  ld ans = w*h/(ld)2;
  cout(10)<<ans<<" ";
  if(w%2==0 && h%2==0 && w/2==x && h/2==y)cout<<"1"<<endl;
  else cout<<"0"<<endl;
      
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main() {
  int64_t N,ans=0;
  cin>>N;
  vector<int> A(N);
  vector<int> B(N-1);
  for(int i =0;i<N;i++){
    cin>>A[i];
  }
  for(int k =1;k<N;k++){
    if(A[k]<A[k-1]){
      B[k-1]=A[k-1]-A[k];
      A[k]=A[k-1];
      ans+=B[k-1];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4804