akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  cin>>a>>b;
  vector<int> c(a);
  rep(i,a)
    cin>>c[i];
  int d=0;
  rep(i,a){
  d+=min(c[i],abs(b-c[i]))*2;
  }
  out(d);
}

Measured memory_bytes: 3804
from collections import Counter
S=input()
T=input()
s=list(S)
t=list(T)
a=Counter(s)
b=Counter(t)
c=a.most_common()
d=b.most_common()
flag=True
for i in range(min(len(d),len(c))):
    if d[i][1]==1 and c[i][1]==1:
        break
    if d[i][1]>=2 and flag:
        e=[]
        for j in range(len(s)):
            if t[j]==d[i][0]:
                e.append(s[j])
        for j in range(len(e)-1):
            if e[j]!=e[j+1]:
                flag=False
                break
    if c[i][1]>=2 and flag:
        f=[]
        for j in range(len(s)):
            if s[j]==c[i][0]:
                f.append(t[j])
        for j in range(len(f)-1):
            if f[j]!=f[j+1]:
                flag=False
                break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 8752
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll N, M;
	cin >> N >> M;
	vector<vector<ll>> tasks(M+1);
	rep(i,0,N) {
		ll A, B;
		cin >> A >> B;
		if (M-A >= 0) {
			tasks[M-A].push_back(B);
		}
	}
	priority_queue<ll> queue;
	ll score = 0;
	rrep(d,M+1,0) {
		for (ll task : tasks[d]) {
			queue.push(task);
		}
		if (!queue.empty()) {
			score += queue.top();
			queue.pop();
		}
	}
	cout << score << endl;
}


Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

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

int main() {
    
    ll N;
    cin >> N;

    string S;
    cin >> S;

    ll r = 0;
    ll g = 0;
    ll b = 0;

    rep(i, N) {
        if (S[i] == 'R') { r++; }
        if (S[i] == 'B') { b++; }
        if (S[i] == 'G') { g++; }
    }
    
    ll ans = r * g * b;

    rep(i, N) {
        for (ll c = 1; i + 2 * c < N; c++) {
            ll j = i + c;
            ll k = i + 2*c;
            if (S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) { ans--; }
        }
    }

    cout << ans;
    system("PAUSE");
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int.Parse(Console.ReadLine());
            int[] s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int mid = Partition(s, 0, s.Length-1);

            StringBuilder sb = new StringBuilder();
            for(int i=0;i<s.Length;++i)
            {
                if (i == mid)
                {
                    sb.Append("[" + s[i] + "]");
                }
                else
                {
                    sb.Append(s[i]);
                }
                if(i != s.Length - 1) { sb.Append(" "); }
            }
            Console.WriteLine(sb.ToString());
        }
        static int Partition(int[] a, int p, int r)
        {
            int x = a[r];
            int i = p - 1;
            for(int j=p;j<r;++j)
            {
                if( a[j] <= x)
                {
                    i = i + 1;
                    int tmp = a[i];
                    a[i] = a[j];
                    a[j] = tmp;
                }


            }
            int tmp2 = a[i + 1];
            a[i + 1] = a[r];
            a[r] = tmp2;
            return i + 1;
        }
        
    }

}



Measured memory_bytes: 19500
#include<stdio.h>
int main(){
	int a,b,d;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
	if(op=='+'){
		d=a+b;
		printf("%d\n",d);}
	else if(op=='-'){
		d=a-b;
		printf("%d\n",d);}
	else if(op=='*'){
		d=a*b;
		printf("%d\n",d);}
	else if(op=='/'){
		d=a/b;
		printf("%d\n",d);}
	else if(op=='?'){
		break;}
	}
return 0;
}

Measured memory_bytes: 2684
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string a,b;
	string x[100];
	while(cin>>a>>b)
	{
		int len=a.size();
		for(int i=0;i<len;i++)
		{
			x[i]=a.substr(i)+a.substr(0,i); 
		}
		for(int i=0;i<len;i++)
		{
			if(x[i]==b)
			{
				cout<<"Yes"<<endl;
				break;
			}
			if(i==len-1)
			cout<<"No"<<endl;
		}
	}
	return 0;
}

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

int main (void){
  long int n;
  cin >> n;
  vector<long int> c(n,0);
  for(int i = 0;i < n;i++){
    cin >> c[i];
  }

  vector<long int> dp(n,100000000);

    dp[0] = 0;
    dp[1] = abs(c[1] - c[0]);
    for(int i = 2;i < n;i++){
      if(dp[i-1] + abs(c[i-1] - c[i]) < dp[i-2] + abs(c[i-2] - c[i])){
        dp[i] = dp[i-1] + abs(c[i-1] - c[i]);
      }else{
        dp[i] = dp[i-2] + abs(c[i-2] - c[i]);
      }
    }

    cout << dp[n-1] << endl;
    return 0;

}


Measured memory_bytes: 4756
#include <stdio.h>
#include <string.h>

int main(void) {
  char w[11];
  scanf("%s", w);
  
  int cnt=0;
  for ( ; ; ) {
    char str[1001];
    scanf("%s", str);

    if (strcmp(str, "END_OF_TEXT")==0) break;

    for (int i=0; str[i]!='\0'; i++) {
      if (str[i]>='A' && str[i]<='Z') str[i]+=32;
    }

    if (strcmp(str, w)==0) cnt++;
  }
  
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n; cin >> n;
    ll ans = 0;
    vector<ll> cnt(n+1);
    rep(i, n+1) cnt[i] = 2;
    cnt[1] = 1;
    for(ll i = 2; i <= n; i++){
        for(ll j = 2*i; j <= n; j += i){
            cnt[j]++;
        }
    }
    FOR(i,1,n+1){
        ans += (ll)i * cnt[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 81224
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt()

  if (k == 0) {
    println(n.toLong * n)
  } else {
    var ans = 0L
    for (b <- k+1 to n) {
      ans += ((n - k + 1) / b) * (b-k)
      ans += ((n - k + 1) % b).min(b-k)
    }
    println(ans)
  }
}


Measured memory_bytes: 55404
#include <iostream>

using namespace std;

int main(void){
  string a,b;
  cin >> a >> b;
  if(a.length()>b.length()) cout << "GREATER" << endl;
  else if(a.length()<b.length()) cout << "LESS" << endl;
  else if(a<b) cout << "LESS" << endl;
  else if(a>b) cout << "GREATER" << endl;
  else cout << "EQUAL" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define vpll vector <pll>
#define pb push_back

int main()
{
   int s,w;
   cin>>s>>w;
   if(w>=s)
    cout<<"unsafe";
   else
   {
    cout<<"safe";
   }
    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, M;
  cin>>N>>M;
  vector<vector<int> > edge(N);
  int A, B;
  for(int i=0;i<M;++i) {
    cin>>A>>B;
    A--;
    B--;
    edge[A].push_back(B);
    edge[B].push_back(A);
  }
  map<int, int> amap;
  for(int i=0;i<N;++i) amap[i] = -1;
  queue<pair<int, int> > que;
  pair<int, int> state;
  que.push(mp(0, 0));
  bool nibu = true;
  int node, parity;
  while(!que.empty()) {
    state = que.front();que.pop();
    node = state.fi;
    parity = state.se;
    if(amap[node]>-1) {
      if(amap[node]!=parity) nibu = false;
      continue;
    }
    amap[node] = parity;
    for(int i=0;i<edge[node].size();++i) {
      if(amap[edge[node][i]]>-1) {
        if(amap[edge[node][i]]!=(parity^1)) nibu = false;
        continue;
      }
      que.push(mp(edge[node][i], parity^1));
    }
  }
  if(!nibu) {
    cout<<N*(N-1)/2-M<<endl;
    return 0;
  }
  ll one=0, zero=0;
  for(int i=0;i<N;++i) {
    if(amap[i]==0) zero++;
    else one++;
  }
  cout<<one*zero-M<<endl;
}



Measured memory_bytes: 13440
/* Coached by rainboy */
#include <stdio.h>

#define N 100000

int main() {
	static char s[N + 1];
	static int dp[N], aa[N];
	int n, q, i;

	scanf("%d%d%s", &n, &q, s);
	for (i = 1; i < n; i++)
		aa[i] = (s[i - 1] == 'A' && s[i] == 'C');
	dp[0] = aa[0];
	for (i = 1; i < n; i++)
		dp[i] = dp[i - 1] + aa[i];
	while (q--) {
		int l, r;

		scanf("%d%d", &l, &r), l--, r--;
		printf("%d\n", dp[r] - dp[l]);
	}
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef long long int num;

const num NMAX = 2e5;
const num MODULO = 1e5;

num position[NMAX];

num absnum(num x) {
  return (x > 0 ? x : -x);
}

int main () {
  num n, m;
  cin >> n >> m;
  num sum = 0;
  for (int i = 1; i <= n - 1; i++) {
    int s;
    cin >> s;
    sum += s;
    position[i + 1] = sum;
  }

  num ans = 0, current = 1;
  REP(i, m) {
    int a;
    cin >> a;
    ans += absnum(position[current + a] - position[current]);
    current += a;
  }

  cout << ans % MODULO << endl;
}

Measured memory_bytes: 1944
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
//#include <map>
#include <set>
#define INF (1000000000)
#define MOD (1000000007)
#define K (2)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;
typedef pair<int, int> PII;


char map[200][200];
const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};

int main()
{
	int num;
	scanf("%d", &num);
	for (int ca = 0; ca < num; ca++){
		for (int i = 0; i < 200; i++){
			strcpy(map[i], "");
		}
		
		int n;
		scanf("%d", &n);
		
		for (int i = 0; i < n + K + K; i++){
			for (int j = 0; j < n + K + K; j++){
				if (!i || !j || i == n + K + K - 1 || j == n + K + K - 1){
					map[i][j] = '#';
				}
				else {
					map[i][j] = ' ';
				}
			}
		}
		
		int y = n - 1 + K;
		int x = K;
		int d = 0;
		int nodraw = 0;
		while (true){
			int b = (d + 2) % 4;
			int r = (d + 1) % 4;
			if (map[y + dy[b]][x + dx[b]] != '#' || map[y + dy[r]][x + dx[r]] != '#'){
				map[y][x] = '#';
			}
			else {
				break;
			}
						
			if (map[y + dy[d] * 2][x + dx[d] * 2] == '#'){
				d = (d + 1) % 4;
				if (++nodraw == 4){
					break;
				}
			}
			else {
				y += dy[d];
				x += dx[d];
				nodraw = 0;
			}
		}
		
		if (ca) puts("");
		for (int i = 2; i < n + K; i++){
			printf("%.*s\n", n, &map[i][2]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1236
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int x,y;
    cin >> x >> y;
    int ans = 0;
    if(x < 4)
    {
        ans += (4 - x) * 100000;
    }
    if(y < 4)
    {
        ans += (4 - y) * 100000;
    }
    if(x == 1 && y == 1)
    {
        ans += 400000;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define inf 0x7fffffff
#define mkp make_pair
#define maxn 100205
typedef unsigned int U;
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const  double eps = 1e-8;
const double pi = acos(-1);
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
int n,m,d1,d2;
int ok[400005],num[605][605];
void pre(){
	for(int i=1;i*i<=200000;i++)
		ok[i*i]=i;
}
int col[2][4000005];
vector<pair<int,int> > Q[2];
bool in(int x,int y){
	if(x<0) return 0;
	if(x>=2*n) return 0;
	if(y<0) return 0;
	if(y>=2*n) return 0;
	return 1;
}
void dfs(pair<int,int> x,int u,int opt){
	int i,v;
	int X=x.first,Y=x.second;
	for(i=0;i<Q[opt].size();i++){
		int xx=X+Q[opt][i].first,yy=Y+Q[opt][i].second;
		if(!in(xx,yy)) continue;
		v=num[xx][yy];
		if(col[opt][v]) continue;
		col[opt][v]=col[opt][u]%2+1;
		dfs({xx,yy},v,opt);
	}
}
int sum(int x,int y){
	int i,j,cnt=0;
	for(i=0;i<2*n;i++)
		for(j=0;j<2*n;j++)
			if(col[0][num[i][j]]==x&&col[1][num[i][j]]==y) cnt++;
	return cnt;
}
void print(int x,int y){
	int cnt=0,i,j;
	for(i=0;i<2*n;i++)
		for(j=0;j<2*n;j++){
			if(col[0][num[i][j]]==x&&col[1][num[i][j]]==y) printf("%d %d\n",i,j),cnt++;
			if(cnt>=n*n) return ;
	}
	return ;
}
int main(){
	int i,j,u,v,e,w;
	//freopen("a.out","r",stdin);
	//freopen("a.ans","w",stdout);
	n=read(),d1=read(),d2=read();
	int cnt=0;
	for(i=0;i<2*n;i++)
		for(j=0;j<2*n;j++)
			num[i][j]=++cnt;
	pre();
	for(i=0;i*i<=d1;i++){
		if(!ok[d1-i*i]&&(d1-i*i)!=0) continue;
		Q[0].push_back({i,ok[d1-i*i]});
		Q[0].push_back({-i,ok[d1-i*i]});
		Q[0].push_back({i,-ok[d1-i*i]});
		Q[0].push_back({-i,-ok[d1-i*i]});
	}
	for(i=0;i*i<=d2;i++){
		if(!ok[d2-i*i]&&(d2-i*i)!=0) continue;
		Q[1].push_back({i,ok[d2-i*i]});
		Q[1].push_back({-i,ok[d2-i*i]});
		Q[1].push_back({i,-ok[d2-i*i]});
		Q[1].push_back({-i,-ok[d2-i*i]});
	}
	for(i=0;i<2*n;i++){
		for(j=0;j<2*n;j++){
			if(!col[0][num[i][j]]) col[0][num[i][j]]=1,dfs({i,j},num[i][j],0);
			if(!col[1][num[i][j]]) col[1][num[i][j]]=1,dfs({i,j},num[i][j],1);
		}
	}
	for(i=1;i<=2;i++)
		for(j=1;j<=2;j++){
			if(sum(i,j)>=n*n) {print(i,j);return 0;}
		}
	return 0;
}
/*
8
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
*/

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

using namespace std;

int main()
{
    int a[100];
    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=n-1;i>n-1-k;i--)
        sum+=a[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll X;
  cin>>X;
  ll ans = X/11*2;
  X %= 11;
  if(0<X && X<=6) ans++;
  else if(6<X) ans += 2;
  cout<<ans<<endl;
}



Measured memory_bytes: 3536
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
a.insert(0,0)
a.append(0)
cost = 0
for i in range(1,n+2):
        cost += abs(a[i]-a[i-1])

for i in range(1,n+1):
        print(cost-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]))

Measured memory_bytes: 21120
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;

ll N;
ll A[100000], B[100000];
ll sum[100000];

int main(){
    cin>>N;
    rep(i,N){
        cin>>A[i]>>B[i];
        sum[i]=A[i]+B[i];
    }

    ll ans=0;
    rep(i,N) ans-=B[i];

    sort(sum,sum+N,greater<>());

    for(int i=0;i<N;i+=2) ans+=sum[i];

    cout<<ans<<endl;
}

Measured memory_bytes: 2560
Q, H, S, D = map(int, input().split(" "))
N = int(input())
H = min(H, 2*Q)
S = min(S, 2*H, 4*Q)
D = min(D, 2*S, 4*H, 8*Q)

ans = (N // 2)*D + (N % 2)*S
print(ans)


Measured memory_bytes: 3060
N,K=map(int,input().split())
A=list(map(int,input().split()))
MOD=10**9+7
ans=0
C=[0 for _ in range(max(A)+1)]
for i in range(N-1):
    for j in range(i+1,N):
        a=A[j]-A[i]
        if a<0:
            #ans+=1
            C[A[i]]+=1
D=[0 for i in range(max(A)+1)]
for i in range(N):
    for j in range(N):
        if i==j:
            continue
        a=A[i]-A[j]
        if a>0:
            D[A[i]]+=1

for i in range(len(C)):
    a=K*C[i]%MOD
    ans+=a
k=(K*(K-1))//2
k=k%MOD
for i in range(len(D)):
    b=k*D[i]%MOD
    ans+=b
print(ans%MOD)

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

int pos = 0;

int read(string s){
	int tmp = 0;
	while(s[pos] == ' ') pos++;
	while(s[pos] != ' '){
		tmp = tmp * 10 + s[pos++] - '0';
	}
	return tmp;
}

int main(){
	string s;
	while(getline(cin,s)){
		pos = 0;
		int one = 0,sum = 0;
		if(s == "0") break;
		s += " ";
		for(int i = 0;pos < s.length() - 1;i++){
			int num = read(s);
			if(num == 1) one++;
			if(num >= 10) num = 10;
			sum += num;
		}
		while(sum <= 11 && one){
			one--;
			sum += 10;
		}
		if(sum > 21) cout << 0 << endl;
		else cout << sum << endl;
	}
}

Measured memory_bytes: 3144
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#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 <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=pow(10,18);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const ll dx[4]={0,0,1,-1};
const ll dy[4]={-1,1,0,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n,m;cin>>n>>m;
  vector<bool>isOK(n,false);
  vector<ll>count(n,1);
  isOK[0]=true;
  rep(i,m){
    ll x,y;cin>>x>>y;
    x--;y--;
    if(isOK[x]){
      isOK[y]=true;
    }
    if(count[x]==1)isOK[x]=false;
    count[x]--;
    count[y]++;
  }
  ll ans=0;
  rep(i,n){
    if(isOK[i]&&count[i]>0)ans++;
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed;
  return solve();
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Union Find tree
//-------------------------------------------------
class UnionFind
{
private:
    ::std::vector<int> par;
    ::std::vector<int> rank;
public:
    UnionFind(int n):par(n), rank(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        if (rank[rx]>rank[ry]){
            par[ry] = rx;
        }else{
            par[rx] = ry;
            if (rx==ry) rank[ry]++;
        }
    }
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi x(n),y(n);
    UnionFind uf(n);
    rep(i,n) cin>>x[i]>>y[i];
    vector<vi> X(101010), Y(101010);
    rep(i,n){
        X[x[i]].pb(i);
        Y[y[i]].pb(i);
    }
    rep(i,101010){
        for(auto e:X[i]) uf.unite(e,X[i][0]);
        for(auto e:Y[i]) uf.unite(e,Y[i][0]);
    }
    map<int,vi> c;
    rep(i,n){
        int r = uf.root(i);
        c[r].pb(i);
    }
    ll ans=0;
    for(auto &e:c){
        set<int> xs,ys;
        for(auto v:e.se){
            xs.ins(x[v]);
            ys.ins(y[v]);
        }
        ans += (ll)(xs.size())*ys.size();
    }
    ans-=n;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 14840
import sys
input = sys.stdin.readline
import numpy as np

N = int(input())
X = np.array(input().split(), dtype = np.int64)
L = int(input())

U = N.bit_length()
# 各ホテルから、2^n回でどこまで行けるか
next_x = []
next_x.append(np.searchsorted(X, X+L, side = 'right') - 1)
for i in range(U):
    next_x.append(next_x[i][next_x[i]])

def days(a,b):
    a -= 1
    b -= 1
    if b < a:
        a,b = b,a
    # 到着できない範囲で最大限進む
    result = 0
    for n in range(U,-1,-1):
        c = next_x[n][a]
        if c < b:
            a = c
            result += 1 << n
    return result + 1

Q = int(input())
for _ in range(Q):
    a,b = map(int,input().split())
    print(days(a,b))

Measured memory_bytes: 30084
N = int(input())
ans = ''

for i in range(1, 100):
  if N <= 26**i:
    N = N - 1
    for j in range(i):
      ans += chr(ord('a')+ N % 26)
      N = N // 26
    break
  else:
    N = N - 26**i
    
print(ans[::-1])


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

using namespace std;

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

    int n;
    cin >> n;
    set<string> dic;
    while (n--) {
        string comm, c;
        cin >> comm >> c;
        if (comm == "insert") {
            dic.insert(c);
        } else if (comm == "find") {
            cout << (dic.find(c) != dic.end() ? "yes" : "no") << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 29068
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B =sc.nextLong();
        long C =sc.nextLong();
        long D =sc.nextLong();
        long num1,num2,num3,num4,num5,num6,opt;
        long cd = C*D/gcd(C,D);
        num1 = B/C;
        num2 = B/D;
        num3 = B/cd;
        num4 = (A-1)/C;
        num5 = (A-1)/D;
        num6 = (A-1)/cd;
        opt = (B-A+1)-(num1+num2-num3-(num4+num5-num6));
        System.out.println(opt);
    }
    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 23764
import math
S = input()#文字列を読み込む
T = input()#文字列を読み込む
min0 = len(T)#minの最悪な値


for j in range(0, len(S) - len(T)+1):
    count = 0
    for i in range(len(T)):
        if T[i] != S[j+i]:
            count += 1
    min0 = min(min0,count)

print(min0)


Measured memory_bytes: 9112
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
	ll n, m;

	cin >> n >> m;

	if (n >= 3 && m >= 3) {
		cout << (n - 2) * (m - 2) NL;
	} else if (n == 2 || m == 2) {
		cout << 0 NL;
	} else if (n == 1 && m == 1) {
		cout << 1 NL;
	} else if (n == 1 || m == 1) {
		cout << max(n, m) - 2 NL;
	}


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028841971693993
#define mod 1000000007
#define MOD mod
#define sec setprecision
#define RAND_MAX 0x7fffffff
using namespace std;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long 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;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a)%mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	string p = "";
	rip(i,  n) {
		p.push_back(s[i]);
		p.push_back(t[i]);
	}
	cout << p << endl;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (s.size() <= n) {
    n = s.size();
  }
  for (int i=0; i<n; i++) {
    cout << s.at(i);
  }
  if (s.size() > n) {
    cout << "...";
  }
  cout << endl;
}

Measured memory_bytes: 3628
def main():
    K = int(input())
    from math import gcd
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            g = gcd(i, j)
            for k in range(1, K+1):
                ans += gcd(g, k)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69852
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int A, B, M;
    cin >> A >> B >> M;

    vector<int> a(A);
    for (int i = 0; i < A; i++)cin >> a[i];

    vector<int> b(B);
    for (int i = 0; i < B; i++)cin >> b[i];

    int minA = *min_element(a.begin(), a.end());
    int minB = *min_element(b.begin(), b.end());

    int ans=minA+minB;

    for(int i=0;i<M;i++){
        int x,y,z;
        cin>>x>>y>>z;
        x--;
        y--;
        ans=min(ans,a[x]+b[y]-z);

    }

    cout<<ans<<endl;
}



Measured memory_bytes: 1024
#pragma warning(disable  4996)
#define _CRT_SECURE_NO_WARNINGS
//#include<bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include<cstring>
#include<map>
#include<set>
#include<string>
#include <climits>
#include <vector>
#include<stack>
#include<bitset>
#include<unordered_map>
#include<queue>
#include<deque>
#include<iomanip>
#define pb push_back
#define endl '\n';
#define sz(s) int(s.size())
#define Ceil(x,y)  ((x+y-1)/y)
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define I64 int
typedef long long ll;
typedef unsigned long long ull;
typedef double dl;
const ll mod = ll(1e9 + 7);
const double PI = acos(-1.0);
const int N = (int)1e7 + 1;
using namespace std;

void Selim()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int dx[4] = { 0, -1, 0, 1 };
int dy[4] = { -1, 0, 1, 0 };
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll LCM(ll a, ll b) { return a / gcd(a, b)*b; }
//ll fact(long long  n) { return !n ? 1 : n * fact(n - 1); }
//transform(s.begin(), s.end(), s.begin(), ::tolower);
//palindrom if(s==string(s.rbegin(),s.rend()));
//memset(arr,0,sizeof arr)

/*
*********************************************************************************************

If you want something you've never had, you must be willing to do something you've never done

*********************************************************************************************
*/

int main()
{
	Selim();

	ll n, ans = 1;
	cin >> n;
	vector<ll>v(n);
	for (int i = 0; i < n; i++){
		cin >> v[i];
	}
	sort(all(v));
	for (int i = 0; i < n; i++){
		if (v[i]>0 && ans>ll(1e18) / v[i])return cout <<-1, 0;
		ans *= v[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3988
#include<stdio.h>
int main(){
  int n, i;
  double x[10], sum = 0.0;
  char u[10][4];
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%lf %s", &x[i], &u[i]);
  for(i = 0; i < n; ++i){
    if(u[i][0] == 'J'){
      sum += x[i];
    }else{
      sum += (x[i] * 380000.0);
    }
  }
  printf("%f\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib> 
#include <ctime>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main() {
	string s;
	cin >> s;
	int i, j, ret = 0;
	for (i = 0, j = s.size() - 1; i < j; i++, j--) {
		if (s[i] != s[j]) ret++;
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = [1]
c = 1
for i in range(n):
    ans.append(a[ans[i] - 1])
b = ans.index(ans[n])
if k < b:
    for l in range(k):
        c = a[c - 1]
else:
    for l in range((k-b)%(n-b)+b):
        c = a[c - 1]
print(c)


Measured memory_bytes: 32360
#include <stdio.h>

int main(){
    char outputG[5] = "Good";
    char outputB[5] = "Bad";
    char c[4];
    int i, flag=0;
    for(i=0; i<4; i++){
        scanf("%c", &c[i]);
    }
    for(i=1; i<4; i++){
        if(c[i-1] == c[i]){
            flag =1;
        }
    }
    if(flag ==1){
        printf("%s\n", outputB);
    }else{
        printf("%s\n", outputG);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  long a, b, c, ans = 0;

  if(scanf("%ld %ld %ld", &a, &b, &c) == 1);

  if(b >= c) {
    ans = c * 2;
    b = b - c;
    if(b > 0) {
      ans += b;
    }
  } else {
    ans = b * 2;
    c = c - b;
    while(c > 0 && a >= 0) {
      c--;
      a--;
      ans++;
    }
  }

  printf("%ld", ans);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define P pair<int,int>
const LL inf = 0x3f3f3f3f;
const LL mod = 1e9+7;
const LL N = 1e5+10;
template <typename tp> inline void read(tp &x)
{
	x=0;char c=getchar();int f=0;
	for(;c>'9'||c<'0';f|=(c=='-'),c=getchar());
	for(;c<='9'&&c>='0';x=(x<<3)+(x<<1)+c-'0',c=getchar());
	if(f) x=-x;
}
char s[10000];
int num[1000];
int main()
{
	scanf("%s",s);
	int len=strlen(s);	
	for(int i=0;i<len;i++)
		num[s[i]]++;
	if((num['S']==0||num['N']==0)&&num['N']+num['S']>0) return 0*puts("No");
	if((num['E']==0||num['W']==0)&&num['E']+num['W']>0) return 0*puts("No");
	puts("Yes");	
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
char s[100005];
int main(){
    scanf("%s", s+1);
    int n = strlen(s+1);
    for(int i=1;i<=n;i++){
        if(i >= 2){
            if(s[i] == s[i-1]){
                printf("%d %d\n", i-1, i);
                return 0;
            }
        }
        if(i >= 3){
            if(s[i] == s[i-1] || s[i] == s[i-2] || s[i-1] == s[i-2]){
                printf("%d %d\n", i-2, i);
                return 0;
            }
        }
    }
    printf("-1 -1\n");
}

Measured memory_bytes: 3888
#include <stdio.h>

int main(){
  int n;
  int buf[20];
  int i;
  int count=0;
  scanf("%d",&n);
  //printf("n=%d\n",n);
  for(i=0;i<n;i++){
    scanf("%d",&buf[i]);
  }
  for(i=0;i<n-2;i++){
    if(((buf[i]<buf[i+1]) && (buf[i+1]<buf[i+2])) || ((buf[i]>buf[i+1]) && (buf[i+1]>buf[i+2]))){
      count++;
    }
  }
  /*
  printf("%d\n",buf[0]);
  printf("%d\n",buf[1]);
  printf("%d\n",buf[2]);
  */
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <stack>
#include <vector>

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

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

signed main() {
  int N = rint();
  int Q = rint();
  vector<int> es[N];
  int xs[N] = {0};
  dotimes(i, N - 1) {
    int a = rint() - 1;
    int b = rint() - 1;
    es[a].emplace_back(b);
    es[b].emplace_back(a);
  }
  dotimes(i, Q) {
    int p = rint() - 1;
    int x = rint();
    xs[p] += x;
  }
  bool visited[N] = {0};
  stack<int> s;
  visited[0] = true;
  s.push(0);
  while (!s.empty()) {
    int a = s.top();
    s.pop();
    for (int b : es[a]) {
      if (visited[b])
        continue;
      visited[b] = true;
      xs[b] += xs[a];
      s.push(b);
    }
  }
  printf("%lld", xs[0]);
  dotimes(i, N - 1)
    printf(" %lld", xs[i+1]);
  puts("");
  return 0;
}


Measured memory_bytes: 18032
#include<stdio.h> 
main(void)
{
 int i,x,y;
 	for(i=1;;i++){
		 scanf("%d %d",&x,&y);
 		if(x==0 && y==0)break;
 		if(x>y)printf("%d %d\n",y,x);
 		else printf("%d %d\n",x,y);
 		}
 return 0;
 } 


Measured memory_bytes: 1976
(let* ((n (read))
    (a (make-array n))
    (b (make-array (- n 1)))
    (s 0))
    (loop for i below (- n 1) do
        (setf (aref b i) (read))
    )

    (loop for i below (- n 1) do
        (progn
            (if (or (zerop i) (< (aref b i) (aref b (- i 1))))
                (setf (aref a i) (aref b i))
            )
            (setf (aref a (+ i 1)) (aref b i))
        )
    )
    (format t "~D~%" 
        (loop for i below n sum (aref a i))
    )
)

Measured memory_bytes: 24520
x,n = map(int, input().split())
p = map(int, input().split())

if(n):
    l = [0 for _ in range(102)]
    for i in p:
        l[i] = 1

    for i in range(101):
        if(l[x-i] == 0):
            ans = x-i
            break
        if(l[x+i] == 0):
            ans = x+i
            break
    print(ans)
else:
    print(x)


Measured memory_bytes: 9060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	int n;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0 << endl;
	}
	else {
		int i;
		int mul = 10;
		int ans = 0;
		while (mul <= n) {
			ans += n / mul;
			mul *= 5;
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
//be name khoda
//Pedram Sadeghian
// :)
#include <bits/stdc++.h>
using namespace std;

const int maxN = 1e5;
int nam[maxN][3], ans, n, m, k1, k2, k3;
pair <int, pair <int, int> > P[maxN];
bool issame(int a, int b){
	return nam[a][0] == nam[b][0];
}
void merrge(int a, int b){
	if (nam[a][2] < nam[b][2])
		swap(a, b);
	int S = nam[a][2] + nam[b][2], k = a;
	bool plp = 1;
	while (k != a || plp){
		plp = 0;
		nam[k][2] = S;
		nam[k][0] = nam[b][0];
		k = nam[k][1];
	}
	k = b; plp = 1;
	while (k != b || plp){
		plp = 0;
		nam[k][2] = S;
		k = nam[k][1];
	}
	S = nam[a][1];
	nam[a][1] = nam[b][1];
	nam[b][1] = S;
	return ;
}
int main(){
	//ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 0 ; i < m ; i++){
		cin >> k1 >> k2 >> P[i].first;
		P[i].second.first = k1;
		P[i].second.second = k2;
	}
	sort(P, P + m);
	for (int i = 0 ; i < n ; i++){
		nam[i][0] = i + 1;
		nam[i][1] = i;
		nam[i][2] = 1;
	}
	for (int i = 0 ; i < m ; i++){
		if (not issame(P[i].second.first, P[i].second.second)){
			ans += P[i].first;
			merrge(P[i].second.first, P[i].second.second);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, res; cin >> N;
  res = 0;
  RNG(i, 1, N+1) if ((i % 3) && (i % 5)) res += i;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int dm[] = {-1, 0, 1, 0}, dn[] = {0, -1, 0, 1};
int h, w, count;
vector< vector<int> > field;

bool valid(int m, int n) {
    return 0 <= m && m < h && 0 <= n && n < w && field[m][n] == 1;
}

void dfs(int m, int n) {
    field[m][n] = 0;
    count++;

    for(int i = 0; i < 4; i++) {
        if(valid(m + dm[i], n + dn[i])) {
            dfs(m + dm[i], n + dn[i]);
        }
    }
}

int main() {
    while(1) {
        cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }

        field.resize(h);
        int m, n;
        for (int i = 0; i < h; i++) {
            string input;
            cin >> input;

            field[i].resize(w);

            for (int j = 0; j < w; j++) {
                if(input[j] == '@') {
                    m = i;
                    n = j;
                }
                if(input[j] == '#') {
                    field[i][j] = 0;
                } else {
                    field[i][j] = 1;
                }
            }
        }

        count = 0;
        dfs(m, n);

        cout << count << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
    int N;
    int ac = 0, wa = 0, tle = 0, re = 0;

    cin >> N;

    rep(i, N)
    {
        string s;
        cin >> s;

        if (s == "AC")
            ac++;
        if (s == "WA")
            wa++;
        if (s == "TLE")
            tle++;
        if (s == "RE")
            re++;
    }

    cout << "AC x " << ac << endl
         << "WA x " << wa << endl
         << "TLE x " << tle << endl
         << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 3624
N = int(input())
H = list(map(int,input().split()))
hmax = H[0]
flag = 0
for i in range(1,N):
    hmax = max(hmax,H[i])
    if hmax-H[i]>=2:
        flag = 1
        break
if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 63984
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort(reverse=True)

high = 10**18+1
low = -1

while high-low>1:
    res = k
    mid = (low+high)//2
    for i in range(n):
        res -= max(0, a[i]-(mid//b[i]))
    if res < 0: low = mid
    else: high = mid
print(high)

Measured memory_bytes: 113748