akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int magic = 30000000;
int main(){
    int L;
    string u, v, s, t;
    cin >> L;
    cin >> u >> v;
    while(s.size() < magic) s += u;
    while(t.size() < magic) t += v;
    if(s > t) swap(u, v);
    int use = 0;
    for(int e = 1; e <= L; e++){
        int take = L; take -= e * u.size();
        if(take < 0) break;
        if(take % v.size() == 0) use = e;
    }
    string ans;
    for(int e = 0; e < use; e++) ans += u;
    while(ans.size() != L) ans += v;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 112020
n = int(input())
t = list(map(int ,input().split()))
L = list(map(int ,input().split()))

m = sum(t)
d = [0 for _ in range(m + 1)]

v = 0
s = 0
for i in range(n):
    for j in range(t[i]):
        d[s] = v
        v = min(v + 1, L[i])
        s += 1

ans = 0
v = 0
s = m
for i in range(n - 1, -1, -1):
    for j in range(t[i]):
        d[s] = v
        if v == d[s - 1] and v < L[i]:
            ans += 0.25
        v = min(v + 1, L[i], d[s - 1])
        s -= 1

for i in range(1, m + 1):
    if d[i] == d[i - 1]:
        ans += d[i]
    elif d[i] > d[i - 1]:
        ans += d[i] - 0.5
    elif d[i] < d[i - 1]:
        ans += d[i] + 0.5
    #print(i, ans)

print(ans)



Measured memory_bytes: 3188
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    t_hp, t_att, a_hp, a_att = map(int, input().split())

    while True:

        a_hp = a_hp - t_att

        if a_hp <= 0:
            print("Yes")
            exit()

        t_hp = t_hp - a_att

        if t_hp <= 0:
            print("No")
            exit()



if __name__ == "__main__":
    resolve()



Measured memory_bytes: 61712
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,a[SZ],b[SZ],cn[SZ];
pii d[SZ];
ll wo3()
{
	int p=0;
	for(int i=1;i<=n;++i)
		d[++p]=pii(a[i],i),
		d[++p]=pii(b[i],i);
	sort(d+1,d+1+p,greater<pii>());
	int hs=0; ll su=0;
	for(int i=1;i<=n;++i)
		hs-=bool(cn[d[i].se]),
		++cn[d[i].se],
		hs+=bool(cn[d[i].se]),
		su+=d[i].fi;
	if(hs!=n) return su;
	ll aa=0;
	for(int i=1;i<=n;++i)
	{
		int t=(i==n)?(n-1):n;
		aa=max(aa,su+a[d[i].se]+b[d[i].se]
		-d[i].fi-d[t].fi);
	}
	return aa;
}
ll gs(int*t)
{
	ll x=0;
	for(int i=1;i<=n;++i)
		x+=t[i];
	return x;
}
int main()
{
	ll su=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d%d",a+i,b+i),su+=a[i]+b[i];
	cout<<su-max(wo3(),max(gs(a),gs(b)))<<"\n";
}


Measured memory_bytes: 9984
/*input
1 2 2 2 1
2 4
5 1
3
*/
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define trace1(x) cout<<#x<<": "<<x<<endl
#define trace2(x, y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cout<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 
//typedef long long ll;
#define int long long
#define ll long long

 
#define PI 3.141592653589793
#define MOD 1000000007
#define INF 1e15
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; a=a%m; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
/*prime m*/ template<typename T> T modInv(T a, T m){return pow(a,m-2,m);} 

#define MAX 505 
int32_t main() {
	IOS
	int x, y, a, b, c; cin>>x>>y>>a>>b>>c;
	vector<int> A,B,C;
	for(int i = 0; i<a; i++) {int x; cin>>x; A.push_back(x);}
	for(int i = 0; i<b; i++) {int x; cin>>x; B.push_back(x);}
	for(int i = 0; i<c; i++) {int x; cin>>x; C.push_back(x);}

	sort(A.rbegin(), A.rend()); A.push_back(0); A[x] = 0; 
	sort(B.rbegin(), B.rend()); B.push_back(0); B[y] = 0; 
	sort(C.rbegin(), C.rend()); C.push_back(0);

	int i = 0, j = 0, k = 0;
	int ans=0;
	
	while(true){
		while(C[k] >= max(A[i], B[j]) && i+j+k<x+y && k<c) {ans+=C[k]; k++; }
		if(i+j+k == x+y) break;
		if(i<x && A[i]>=B[j]) {ans+=A[i]; i++; }
		else if(j<y && A[i]<=B[j]) {ans+=B[j]; j++;}
		//trace3(i,j,k);
	}
	cout<<ans;





 
return 0;
}
 


Measured memory_bytes: 3316
#include <bits/stdc++.h>
    using namespace std;
     
    int rank[100005] , p[100005];
     
    void makeSet(int x){
    for(int i=1;i<=x;i++){
    p[i]=i;
    rank[i]=0;
    }
    }
     
    int findSet(int x){
    if(x != p[x]){
    p[x] = findSet(p[x]);
    }
    return(p[x]);
    }
     
    void link(int x,int y){
    int X = findSet(x);
    int Y = findSet(y);
    if(rank[X] > rank[Y]){
    p[Y] = X;
    } else {
    p[X] = Y;
    if(rank[X] == rank[Y]){
    rank[Y]++;
    }
    }
    }
     
    signed main(){
    int n , m , x , y , p[100005] , ans=0;
    cin>>n>>m;
     
    makeSet(n);
     
    for(int i=1;i<=n;i++){
    cin>>p[i];
    }
    for(int i=0;i<m;i++){
    cin>>x>>y;
    link(x , y);
    }
     
    for(int i=1;i<=n;i++){
    if(findSet(i) == findSet(p[i])){
    ans++;
    }
    }
     
    cout<<ans<<endl;
    return(0);
    }

Measured memory_bytes: 1408
#include <stdio.h>

int main(void){
	long int a;
	while(1){
		int sum=0;
	scanf("%ld",&a);
	if(a==0)
		break;
	while(a!=1){
		if(a%2==0)
			a/=2;
		else{
			a*=3;
			a++;
		}
		sum++;
	}
	printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010, p = 1e9+7;
ll bin_pow(ll v, ll t) {
	ll res = 1;
	for (;t;t>>=1, v = v * v % p)
		if (t&1)
			res = res * v % p;
	return res;
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (auto &i : a)
		cin >> i;
ll all = 1;
	priority_queue<ll> pos, neg;
	int c0 = 0;
	for (auto i : a) {
		all = all * i % p;
		if (i == 0) {
			++c0;
			continue;
		}
		(i>0?pos:neg).push(abs(i));
	}
	if (k == n) {
		if (all < 0) all += p;
		cout << all << '\n';
		return 0;
	}
	//cerr << c0 << '\n';
	int op = pos.size(), on = neg.size();
	if (c0) if (pos.size() + neg.size() < k || (pos.size()+neg.size()==k && (neg.size()&1)) || (pos.empty() && (k&1))) {
		return cout << 0 << '\n', 0;
	}

	if (pos.empty() && (k&1)) {
		if (c0)
			return cout << 0 << '\n', 0;
		sort(a.begin(), a.end(), greater<>());
		ll res = 1;
		for (int i = 0;i < k;++i)
			res = res * a[i] % p;
		if (res < 0) res += p;
		cout << res << '\n';
		return 0;
	}
//	for (int i = 0;i < n;++i)
//		pos.pb(0), neg.pb(0);

	ll res = 1, si = 1, cnt = 0;
	int i = 0, j = 0;
	int lstp = -1, lstn = -1;
	while (cnt < k) {
		if (pos.empty() || (neg.size() && neg.top() >= pos.top())) {
			res = res * neg.top() % p;
			lstn = neg.top();
			neg.pop();
			si *= -1;
		}
		else {
			res = res * pos.top() % p;
			lstp = pos.top();
			pos.pop();
		}
		++cnt;
	}
	if (res < 0) res += p;
	if (si == -1) {
		ll a, b, c, d;
		a = lstp, b = lstn, c = (pos.size()?pos.top():-1), d = (neg.size()?neg.top():-1);
		cerr << "A B C D " << a << ' ' << b << ' ' << c << ' ' << d << '\n';
		if ((a==-1||d==-1) && (c==-1||b==-1)) ;
		else if (a != -1 && d != -1 && (b==-1||c==-1||(d*b>=a*c))) 
			res = res * bin_pow(a, p-2) % p * d % p;
		else 
			res = res * bin_pow(b, p-2) % p * c % p;

	}
	if (res < 0) res += p;
		cout << res << '\n';
}


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

const int MOD = 1000000007;
long long int n, k, a[5000];

int main(){
  cin >> n >> k;
  rep(i, n){
    cin >> a[i];
  }
  long long int sum = 0;
  rep(i, n){
    long long int fw = 0, bw = 0;
    rep(j, n){
      if(j < i && a[i] < a[j]){
        fw++;
      }
      if(j > i && a[i] < a[j]){
        bw++;
      }
    }
    sum += k * fw;
    sum %= MOD;
    
    long long int tmp = 0;
    tmp = k * (k - 1);
    tmp /= 2;
    tmp %= MOD;
    tmp *= (fw + bw);
    tmp %= MOD;
    sum += tmp;
    sum%= MOD;
  }
  cout << sum << endl; 
  return 0;
}


Measured memory_bytes: 256
import sys
input= sys.stdin.readline
n=int(input())
time=0
tasks=[]
for i in range(n):
  tasks.append(list(map(int,input().split())))
tasks.sort(key=lambda x:x[1])
flag=0
for i in range(n):
  time+=tasks[i][0]
  if time>tasks[i][1]:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")


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

int main(){
vector<long long> V;
string S; cin >> S; int i, j, L=S.size(), b=L-1;
long a=0, c=0, ans=0;
while(a<L&&S[a]=='>'){a++;}
ans+=(a*(a+1))/2; if(a==L){ cout << ans << "\n";return 0; }
while(b>=0&&S[b]=='<'){b--;c++;}
ans+=(c*(c+1))/2; if(c==L){ cout << ans << "\n";return 0; }
i=a;
while(i<=b){
  j=0;
  while(S[i]=='<'){ i++;j++; }
  V.push_back(j); j=0;
  while(S[i]=='>'){ i++;j++; }
  V.push_back(j);
}
int N=V.size();  
for(i=0;i<N;i+=2){ 
if(V[i]<V[i+1]){ ans+=(V[i]*(V[i]-1))/2 + (V[i+1]*(V[i+1]+1))/2; }
else{ ans+=(V[i]*(V[i]+1))/2 + (V[i+1]*(V[i+1]-1))/2; }
}
cout << ans << "\n";
}

Measured memory_bytes: 3068
#include <iostream>

int main(int argc, char *argv[]) {
	int w, h, x, y, r;
	std::cin >> w >> h >> x >> y >> r;

	if (x < r || x > w - r || y < r || y > h - r) {
		std::cout << "No" << std::endl;
	} else {
		std::cout << "Yes" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
g = [0] * 3
for i in range(n):
  if p[i] <= a:
    g[0] += 1
  elif p[i] <= b:
    g[1] += 1
  else:
    g[2] += 1
print(min(g))

Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int num(string SS){
  set<char> X;
  rep(i,SS.size()) X.insert(SS[i]);
  return X.size();
}

int main(){
  int N;
  cin>>N;
  vector< vector<string>> S(12);
  S[0].push_back("a");
  rep(i,N+1){
    rep(j,S[i].size()){
      int Y=num(S[i][j]);
      rep(k,Y+1){
        S[i+1].push_back(S[i][j]+char('a'+k));
      }
    }
  }
  rep(i,S[N-1].size()) cout<<S[N-1][i]<<endl;
}

Measured memory_bytes: 320992
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k:usize = read();
    let s:String = read();
    if k >= s.len() {
        println!("{}", s);
    } else {
        println!("{}...", &s[0..k]);
    }
}


Measured memory_bytes: 2108
import java.io.*;

public class Main{
    public static void main(String []args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            int n =Integer.parseInt(line);
            int m = n*n*n;
            System.out.println(m);
        }
        catch(IOException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24156
package main

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

var (
	BufferSize = 10*10*10*10*10 + 10
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func check() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	s := scanStr(sc)
	k := scanInt(sc)

	c := s[k-1]

	for i := 0; i < n; i++ {
		if s[i] != c {
			fmt.Printf("*")
		} else {
			fmt.Printf("%c", s[i])
		}
	}

	fmt.Printf("\n")

}

func main() {
	check()
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_H = 11234;
const int MAX_N = 1123;

int A[MAX_N];
int B[MAX_N];

const ll INF = 1LL << 61;
ll dp[MAX_H];

int main2() {
  REP(i, MAX_H) dp[i] = INF;

  int H = nextInt();
  int N = nextInt();
  REP(i, N) {
    A[i] = nextInt();
    B[i] = nextInt();
  }

  dp[H] = 0;
  REP(i, N) {
    for (int h = H; h > 0; h--) {
      int nh = max(0, h - A[i]);
      chmin(dp[nh], dp[h] + B[i]);
    }
  }
  ll ans = dp[0];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int max=0,x=0,i;
  char s[100010];
  scanf("%*d %s",s);
  for(i=0;s[i];i++){
    if(s[i]=='I')x++;
    else         x--;
    if(max<x)max=x;
  }
  printf("%d\n",max);
  return 0;
}

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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define let const auto
#define USE_T template <typename T>
#define USE_Ti template <typename T = int>
#define USE_TU template <typename T, typename U>

USE_Ti using duo = std::pair<T, T>;
USE_Ti using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE_Ti inline T in(){T x;std::cin>>x;return x;}
USE_Ti inline vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE_T inline void in(T*x,int n){rep(i,n)x[i]=in<T>();}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

struct Range {
  int l, r, c;
  Range(int l, int r, int c) : l(l), r(r), c(c) {}
};

signed main() {
  while (int N = in()) {
    stack<Range> s;
    rep(i, 1, N + 1) {
      int c = in();
      if (i % 2 != 0) {
        if (not s.empty() and s.top().c == c) {
          s.top().r++;
        } else {
          s.emplace(i, i + 1, c);
        }
      } else {
        if (s.top().c == c) {
          s.top().r++;
        } else {
          int l = s.top().l;
          s.pop();
          if (s.empty()) {
            s.emplace(l, i + 1, c);
          } else {
            s.top().r = i + 1;
          }
        }
      }
    }
    int ans = 0;
    while (not s.empty()) {
      Range r = s.top();
      s.pop();
      if (r.c == 0) { ans += r.r - r.l; }
    }
    cout << ans << endl;
  }
  return 0;
}

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


int main()
{
	int N, count=0;
	string S;
	cin >> N >> S;
	
	rep(i, N-2) {
		if (S.at(i)=='A'&& S.at(i+1) == 'B' && S.at(i+2) == 'C')
		{
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int n,a,b;cin >> n >> a >> b;
    int x[n];
    rep(i,n)cin >> x[i];
    vector<int> dist;
    rep(i,n-1)dist.push_back(x[i+1] - x[i]);
    sort(dist.begin(),dist.end());
    int ans = 0;
    for(auto hoge:dist){
        if(a*hoge <= b)ans+= a*hoge;
        else ans += b;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
N = int(input())
line = []

for i in range(1,N+1):
  if i%15 == 0:
    i = 0
  elif i%3 == 0:
    i = 0
  elif i%5 == 0:
    i = 0
  else:
    i = i
  line.append(i)
ans = sum(line)

print(ans)

Measured memory_bytes: 33720
class UnionFind():
    def __init__(self, num):
        self.parents = [i for i in range(num + 1)]
        self.sizes = [1] * (num + 1)

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            return self.find(self.parents[x])

    def unite(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)

        if root_x == root_y:
            return

        if self.sizes[root_x] < self.sizes[root_y]:
            root_x, root_y = root_y, root_x

        # xがyの親となるように連結する
        self.parents[root_y] = root_x
        self.sizes[root_x] += self.sizes[root_y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def sizeof(self, x):
        return self.sizes[self.find(x)]

if __name__ == "__main__":
    N, M = map(int, input().split())
    bridges = [tuple(map(int, input().split())) for _ in range(M)]

    unionfind = UnionFind(N)
    inconvenience = [0] * M
    inconvenience[M - 1] = N * (N - 1) // 2

    for i, t in enumerate(reversed(bridges), start = 1):
        a, b = t
        if i == M:
            break

        prev = inconvenience[M - i]
        if unionfind.is_same(a, b):
            inconvenience[M - i - 1] = prev
            continue
        n1 = unionfind.sizeof(a)
        n2 = unionfind.sizeof(b)
        inconvenience[M - i - 1] = max(0, prev - n1 * n2)
        unionfind.unite(a, b)

    [print(i) for i in inconvenience]


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

int main(){

    bool puede = false;
    int n = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int time = 0;
        int x = 0, y = 0;
        cin >> time >> x >> y;
        int suma = x+y;
        if(suma <= time)
        {
            if(suma % 2 == 0 && time % 2 == 0 || suma % 2 != 0 && time % 2 != 0)
            {
                puede = true;
            }
        }
        if(!puede)
        {
            cout << "No" << endl;
            return 0;
        }
        puede = false;
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    double a_sum = accumulate(a, a+n, 0LL);
    double ave = a_sum / n;

    double vmin = 1e18;
    ll i_ans = 0;
    rep(i, n){
        double dif = abs(ave - a[i]);
        if(dif < vmin){
            i_ans = i;
            vmin = dif;
        }
    }

    cout << i_ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);

	long a = sca.nextLong();
	long b = sca.nextLong();
	long c = sca.nextLong();
	long sahen = 4 * a * b;
	long uhen = (c - a - b) * (c - a - b);
	if(c-a-b > 0 && sahen < uhen) {
		System.out.println("Yes");
	}
	else {
		System.out.println("No");
	}

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, A, B;

void MAIN() {
    scanf("%d%d%d", &N, &A, &B);
    printf("%d %d\n", min(A, B), max(0, A+B-N));
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 764
macro_rules! read_line_to_tuple {
    ( $( $t:ty ),* ) => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
}

fn main() {
    let n = read_line_to_tuple!(usize);

    let mut ans = 0;
    for a in 1..=n {
        ans += ((n - 1) / a) as i64;
    }
    println!("{}", ans);
}

Measured memory_bytes: 2152
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    from collections import deque
    
    H,W,K=MI()
    x1,y1,x2,y2=MI()
    
    C=[]
    C.append(["@"]*(W+2))
    for _ in range(H):
        c=["@"] + list(input()) + ["@"]
        C.append(c)
    C.append(["@"]*(W+2))
    
    # 各ますにつき4方向分のデータを持つ，コストは（移動回数，今直線で動いた数）でもつ，移動回数がより重要視される
    inf=10**10
    D=[[[(inf,inf)]*4 for _ in range(W+2)]for _ in range(H+2)]#下上右左の4方向
    # D[i][j][k]はi行j列k向き
    
    
    dq=deque()
    for k in range(4):
        D[x1][y1][k]=(0,0)
        dq.append((x1,y1,k,0,0))
    
    dx=[1,-1,0,0]
    dy=[0,0,-1,1]
    
    
    #01BFSでいけそう
    
    while len(dq):
        x,y,d,cnt,k=dq.popleft()
        
        for nd in range(4):
            #方向そのまま
            if nd==d:
                nx=x+dx[nd]
                ny=y+dy[nd]
                nk=(k+1)%K
                ncnt=cnt
                if k+1>=K:
                    ncnt+=1
            #方向転換
            else:
                nk=0
                ncnt=cnt
                if k!=0:
                    ncnt+=1
                nx=x
                ny=y
            if C[nx][ny]==".":
                if D[nx][ny][nd] > (ncnt,nk):#更新する場合だけ
                    D[nx][ny][nd]=(ncnt,nk)
                    if ncnt==cnt:
                        dq.appendleft((nx,ny,nd,ncnt,nk))
                    else:
                        dq.append((nx,ny,nd,ncnt,nk))
                    
    ans=inf
    for d in range(4):
        temp=D[x2][y2][d][0]
        if D[x2][y2][d][1]:
            temp+=1
        ans=min(ans,temp)
        
    if ans>=inf:
        ans=-1
    print(ans)
    
    
    
    # for i in range(1,H+1):
    #     for j in range(1,W+1):
    #         print(D[i][j])
    
    
    
    
    
        
    
                    
            

main()


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            var M = input[1];

            var x = N >= 2 ? N * (N - 1) / 2 : 0;
            var y = M >= 2 ? M * (M - 1) / 2 : 0;

            Console.WriteLine(x + y);
        }
    }
}


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

int main() {
    ld x;
    std::cin >> x;
    pair<ld,ld> now;
    now = {0,0};
    ld d = 0;
    ll cnt = 0;
    while(true){
        cnt++;
        now = {now.first+cos(d),now.second+sin(d)};
        d += 2*M_PI*x/360.0;
        if(abs(now.first)<0.0000000001&&abs(now.second)<0.0000000001){
            std::cout << cnt << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4092
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	var str = lines.shift();
	lines.shift();
	var code;
	while(code = lines.shift()){
		code = code.split(" ");
		var from = +code[1], to = +code[2];
		switch(code[0]){
			case "print":
				console.log(str.slice(from, to+1));
				break;
			case "replace":
				str = str.slice(0, from) + code[3] + str.slice(to+1);
				break;
			case "reverse":
				str = str.slice(0, from) + str.slice(from, to+1).split("").reverse().join("") + str.slice(to+1);
				break;
		}
	}
}

Measured memory_bytes: 16300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	int w, n, a, b;
	vi v;
	cin >> w >> n;
	FOR(i, 1, w+1){
		v.push_back(i);
	}
	REP(i,n){
		scanf("%d,%d",&a, &b);
		swap(v[a-1], v[b-1]);
	}
	REP(i, w){
		cout << v[i] << "\n";
	}
}

Measured memory_bytes: 1252
/*
    AUTHOR : TANMAY SINHA
    INORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb(x) push_back(x)
#define eb(x) emplace_back()
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(j,L,R) for(j=L;j<R;j++)
#define per(i,L,R) for(i=L;i>= R;i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 1e5+10,MAX = 1e6+5;
#define sq(X) ((X)*(X))

int main()
{
    SPEED
    ll n,i,c=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]==c+1)
            c++;
    }
    if(c!=0)
    cout<<n-c<<"\n";
    else
        cout<<"-1\n";
}






Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int x=0,y,z;
	char a[] = {"dream"},b[] = {"erase"}, c[] = {"er"};
	char s[100001];
	scanf("%s",s);
	while (s[x] != '\0')
	{
		if (s[x] == 'd')
		{
			x++;
			for(y=1;y<5;y++,x++)
			{
				if (s[x] != a[y])
				{
					printf("NO");
					return 0;
				}
			}
			if ((s[x] == 'e' && s[x+1] == 'r') && s[x+2] != 'a') x+=2;
		} else if (s[x] == 'e')
		{
			x++;
			for(y=1;y<5;y++,x++)
			{
				if (s[x] != b[y])
				{
					printf("NO");
					return 0;
				}
			}
			if (s[x] == 'r') x++;
		} else
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


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

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> x(M);
	vector<ll> y(M);
	for (int i = 0; i < M; ++i) {
		cin >> x[i] >> y[i];
	}

	vector<ll> cnt(N + 1, 1);
	vector<bool> red(N + 1, false);
	red[1] = true;
	for (int i = 0; i < M; ++i) {
		if (red[x[i]]) { red[y[i]] = true; }

		cnt[x[i]] -= 1;
		cnt[y[i]] += 1;
		if (cnt[x[i]] == 0) {
			red[x[i]] = false;
		}
	}

	ll res = 0;
	for (int i = 1; i <= N; ++i) {
		if (red[i]) { ++res; }
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll x, y;
    cin >> x >> y;
    if(y-2*x>=0&&(y-2*x)%2==0){
        ll kola1 = (y - 2 * x) / 2;
        ll kola2 = x - kola1;
        if(kola1>=0&&kola2>=0){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }
    else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
#include <fstream>

typedef long long int ll;
using namespace std;

int main()
{
    //freopen("06","r",stdin);
    //freopen("06.b","w",stdout);
    int q,h,s,d;
    int n;
    scanf("%d%d%d%d%d",&q,&h,&s,&d,&n);
    int t = min(4*q,min(2*h,s));
    int w = min(8*q,min(4*h,min(2*s,d)));
    ll ans=0;
    ans+=(1LL*(n/2)*w);
    n%=2;
    if(n>0)ans+=t;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  char ch0, ch1, ch2;
  
  scanf("%c%c%c", &ch0, &ch1, &ch2);
  
  if(ch0 == ch1)
    puts("No");
  else if(ch1 == ch2)
    puts("No");
  else if(ch0 == ch2)
    puts("No");
  else 
    puts("Yes");
  
  return 0;
}

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

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

    int a, b, c;
    cin >> a >> b >> c;

    if(a<=c && c<=b) puts("Yes");
    else puts("No");
}

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

using namespace std;

typedef long long int int64;
int main() {
//	ios_base::sync_with_stdio(false);
//	cin.tie(0); cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b || b == c || c == a) {
		if(a == b && b == c) {
			cout << "No\n";
		} else {
			cout << "Yes\n";	
		}
	} else {
		cout << "No\n";	
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int k, s;
  cin >> k >> s;
  int ans=0;
  for(int x=0; x<=k; x++){
    for(int y=0; y<=k; y++){
      int z = s - x - y;
      if(z>=0 && z<=k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const int inf = 1e17;
const double pi = 3.14159265358979;
int t[3005];
signed main() {
	int n, l; cin >> n >> l;
	rep(i, n)cin >> t[i];
	double rx = 0, ry = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int w = t[j] - t[i];
			int p1 = t[i] + t[j], p2 = (p1 + l) % (2 * l);
			if (t[i] <= p2&&p2 <= t[j])swap(p1, p2);
			int k2 = j - i - 1, k1 = n - 2 - k2;
			rx += k1*cos(pi * 2 * p1 / l / 2.0) + k2*cos(pi * 2 * p2 / l / 2.0);
			ry += k1*sin(pi * 2 * p1 / l / 2.0) + k2*sin(pi * 2 * p2 / l / 2.0);
		}
	}
	double d = n*(n - 1)*(n - 2) / 6;
	rx /= d; ry /= d;
	printf("%.13lf %.13lf\n", rx, ry);
}

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

#define rep(loop, N) for (int loop = 0; loop < N; loop++)
using namespace std;

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Harmony(void) {

	int A, B; cin >> A >> B;

	if ((A + B) % 2 == 0)	cout << (A + B) / 2 << endl;
	else					cout << "IMPOSSIBLE" << endl;
	return;
}

void B(void) {

	int N; cin >> N;
	vector<int> p(N); for (int& it : p) cin >> it;

	int counter = 0;
	rep(index, N) if (p[index] != index + 1) counter++;

	cout << (counter <= 2 ? "YES" : "NO") << endl;
	return;
}

int main(void) {

	//A_Harmony();
	B();
	return 0;
}


Measured memory_bytes: 256
import sys
sys.stdin.readline

def main():
    S = input()
    alpha = [chr(i+ord("a")) for i in range(26)]
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            return i+1, i+2
    for i in range(len(S)-2):
        if S[i] == S[i+2]:
            return i+1, i+3
    return -1, -1

if __name__ == "__main__":
    print(*main())

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr << endl
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int x, n;
    cin >> x >> n;
    vector<int> P(n);
    for(auto &p : P) cin >> p;
    int ans = 101;
    for (int i = 101; i >= 0; i--) {
        bool flag = 0;
        rep(j, n) if (i == P[j]) flag = 1;
        if(flag) continue;
        if (abs(i - x) <= abs(ans - x)) ans = i;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3624
#include "bits/stdc++.h"
#include "bitset"


#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define pai pair<int,int> 
#define For(i,a,n) for(i=a;i<n;i++)
#define all(ar) ar.begin(),ar.end() 
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
const ll mod = 1000000007;

ll fac(ll a){
    ll k = 1;
    for(ll n = 1; n<= a; n++){
        k = ((k%mod) * n) % mod;
    }
    return k;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    ll a,b; cin>>a>>b;
    if(abs(a-b) > 1) cout<<0;
    else{
        ll ans = (fac(a) * fac(b)) % mod;
        if(a%2 == b%2) ans = (ans * 2 ) % mod;
        cout<<ans; 
    }
    return 0;
}


Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int kaijou(int n){
    int a=1;
  if(n==0){
    return 1;
  }
    REP(i,n){
        a*=i+1;
    }
    return a;
}
int ncr(int n,int r){
  int a;
  if(n<0||r<0||n<r){
    return 0;
  }
  a=kaijou(n)/kaijou(r)/kaijou(n-r);
  return a;
}
//cout << setprecision(123);
int main(){
  ll N,a=1;
  bool ok=true;
  cin>>N;
  
  vector<ll>v(N);
  REP(i,N)cin>>v[i];
  
  sort(v.begin(),v.end());
  if(N%3!=0&&v[N-1]!=0)ok=false;
  
  for(ll i=1;i>0;i++){
    if(v[N-1]-powl(2,i)<0){
      a=i;
      break;
    }
  }
      
  for(ll i=1;i<=a;i++){
    ll b=0;
    REP(j,N){
      b+=v[j]%2;
      v[j]=v[j]/2;
     }  
  if(b!=N/3*2&&b>0){
    ok=false;
    break;
  }
  }
  
  
  
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int N = 1e5 + 5;
int mx[N], siz[N], n, head[N], tot, ans, mxsiz = 0x3f3f3f3f;
struct node{int to, nex, val;}a[N << 1];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
void add(int x, int y, int z) {a[++ tot].to = y; a[tot].nex = head[x]; head[x] = tot; a[tot].val = z;}
void dfs(int x, int fa)
{
	siz[x] = 1;
	for(int i = head[x]; i; i = a[i].nex)
	{
		int y = a[i].to; if(y == fa) continue;
		dfs(y, x); siz[x] += siz[y];
		mx[x] = max(mx[x], siz[y]);
		ans += 2 * a[i].val * min(siz[y], n - siz[y]);
	}
	mx[x] = max(mx[x], n - siz[x]);
	mxsiz = min(mxsiz, mx[x]);
}
void work()
{
	n = read();
	for(int i = 1, x, y, z; i <= n - 1; i ++)
	{
		x = read(); y = read(); z = read();
		add(x, y, z); add(y, x, z);
	}
	dfs(1, 0); int g1 = 0, g2 = 0;
	for(int i = 1; i <= n; i ++)
	{
		if(mx[i] != mxsiz) continue;
		if(!g1) g1 = i; else g2 = i;
	}
	int em = 0x3f3f3f3f;
	for(int i = head[g1]; i; i = a[i].nex)
	{
		int y = a[i].to;
		if(g2 && y != g2) continue;
		em = min(em, a[i].val);
	}
	cout << ans - em << endl;
}
signed main() {return work(), 0;}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  string s; cin >> s;
  
  const int sheep = 0, wolf = 1;
  vi zoo(n);
  bool possible = false;

  rep(tmp,1<<2) {
    bitset<2> t(tmp);
    rep(i,2) {
      if (t.test(i)) zoo[i] = sheep;
      else zoo[i] = wolf;
    }

    for (int j=1; j<n-1; ++j) {
      if (zoo[j] == sheep) {
        if (s[j] == 'o') zoo[j+1] = zoo[j-1];
        else zoo[j+1] = 1 - zoo[j-1];
      }
      else {
        if (s[j] == 'x') zoo[j+1] = zoo[j-1];
        else zoo[j+1] = 1 - zoo[j-1];
      }
    }

    if (zoo[0] == sheep) {
      if (s[0] == 'o' && zoo[n-1] != zoo[1]) continue;
      if (s[0] == 'x' && zoo[n-1] == zoo[1]) continue;
    }
    else {
      if (s[0] == 'x' && zoo[n-1] != zoo[1]) continue;
      if (s[0] == 'o' && zoo[n-1] == zoo[1]) continue;
    }

    if (zoo[n-1] == sheep) {
      if (s[n-1] == 'o' && zoo[n-2] != zoo[0]) continue;
      if (s[n-1] == 'x' && zoo[n-2] == zoo[0]) continue;
    }
    else {
      if (s[n-1] == 'x' && zoo[n-2] != zoo[0]) continue;
      if (s[n-1] == 'o' && zoo[n-2] == zoo[0]) continue;
    }

    possible = true;
    break;
  }

  if (!possible) {
    cout << -1 << endl;
    return 0;
  }

  rep(i,n) {
    if (zoo[i] == sheep) cout << 'S';
    else cout << 'W';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include <cmath>
#include<cstring>
#include<bits/stdc++.h> 
#define ll long long
#define fo(a,b,c) for(a=b;a<c;a++)
using namespace std;

int main(){
	int n,k,i,sum=0;
	cin >> n >> k;
	int p[n];
	fo(i,0,n){
		cin >> p[i];
	}
	sort(p , p+n);
	fo(i,0,k){
		sum+=p[i];
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	string s, t; cin >> s >> t;
	vector<int> alp(26,0);
	string ss = "";
	int cnt = 1;
	rep(i, 0, s.size() - 1)
	{
		if (alp[s[i] - 'a'] == 0)
		{
			alp[s[i] - 'a'] = cnt;
			ss += cnt + '0';
			++cnt;
		}
		else
		{
			ss += alp[s[i] - 'a'] + '0';
		}
	}
	string tt = "";
	cnt = 1;
	fill(all(alp), 0);
	rep(i, 0, t.size() - 1)
	{
		if (alp[t[i] - 'a'] == 0)
		{
			alp[t[i] - 'a'] = cnt;
			tt += cnt + '0';
			++cnt;
		}
		else
		{
			tt += alp[t[i] - 'a'] + '0';
		}
	}

	if (ss == tt)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>
#include <iomanip>

typedef long long ll;
using namespace std;

int main(){
    int x, a;
    cin >> x >> a;
    if (x>=a) cout << 1;
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 888