akhauriyash/Code-Regression huggingface dataset:
a,b,m = map(int,input().split())        
a1 = list(map(int,input().split()))
b1 = list(map(int,input().split()))
ab = []
for _ in range(m):
    t = list(map(int,input().split()))
    ab.append(t)

ans = min(a1)+min(b1)

for i in ab:
    #print(a1[i[0]-1]+b1[i[1]-1]-i[2])
    ans = min(ans, a1[i[0]-1]+b1[i[1]-1]-i[2])
print(ans)

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


int main() {
  long d;
  cin>>d;
  vector<long>c(26);
  rep(i,26){
    cin>>c.at(i);
  }
  vector<vector<long>>s(d,vector<long>(26));
  rep(i,d){
    rep(j,26){
      cin>>s[i][j];
    }
  }
  rep(i,d){
    long ans=0;
    rep(j,26){
      if(s[i][ans]<s[i][j]){
        ans=j;
      }
    }
    cout<<ans+1<<endl;
  }
  
}




Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define mod 1000000007
#define int long long
using namespace std;
const int N=1e5+100;
int n,k,u[N],v[N],p[N],w,sum[N];
int m_pow(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) ans=(ans*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return ans;
}
int g(int x)
{
	int ans=0;
	for (int l=1,r;l<=x;l=r+1)
	{
		r=min(x,x/(x/l));
		int ret=(sum[r]-sum[l-1]+mod)%mod;
		ret=(ret*m_pow(x/l,n));
		ans=(ans+ret)%mod;
	}
	return ans;
}
signed main()
{
	scanf("%lld%lld",&n,&k);
	u[1]=1;
	for (int i=2;i<=k;i++)
	{
		if (v[i]==0)
		{
			v[i]=p[++w]=i;
			u[i]=-1;
		}
		for (int j=1;j<=w;j++)
		{
			if (p[j]>v[i] || p[j]>k/i) break;
			v[p[j]*i]=p[j];
			if (i%p[j]==0) u[p[j]*i]=0;
			else u[p[j]*i]=u[i]*(-1);
		}
	}
	for (int i=1;i<=k;i++) sum[i]=(sum[i-1]+u[i]+mod)%mod;
	int ans=0;
	for (int i=1;i<=k;i++)
	  ans=(ans+(i*g(k/i))%mod)%mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 6208
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

vector<ll> v[28];
vector<ll> v2;

int dp[100001]={};
int num[100001]={};
const ll INF=1000000000000000001;
int main() {

	int n,m;
	cin>>n>>m;
	for(int i=1;i<n+1;++i)num[i]=1;
	dp[1]=1;
	int x1,y1;
	for(int i=0;i<m;++i){
		cin>>x1>>y1;
		if(dp[x1]>0)dp[y1]++;
		num[x1]--;
		num[y1]++;
		if(num[x1]==0)dp[x1]=0;
	}
	int total=0;
	for(int i=1;i<n+1;++i){
		if(dp[i]>0)total++;
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<limits>
#include<numeric>

using namespace std;

int main() {

	int n;
	while (cin >> n, n != 0) {
		vector<int> data(n);
		for (int& temp : data) {
			cin >> temp;
		}

		int sum_max = numeric_limits<int>::min();
		for (int i = 0; i < n; ++i) {
			int sum = 0;
			auto it2 = i;
			for (int j = i; j < n; ++j) {
				sum = sum + data[j];

				if (sum_max < sum) {
					sum_max = sum;
				}
			}
		}
		cout << sum_max << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
#include <stdlib.h>

#include <queue>

using namespace std;

typedef struct State_Def {
	int y;
	int x;
} S;

const int INF = 1e+8;
int h, w, n;
int x[4] = {1, 0, -1, 0};
int y[4] = {0, 1, 0, -1};
char **data;
int **dist;
int *fX;
int *fY;

int bfs(int sI, int sJ, int gI, int gJ)
{
	int res = INF;
	int i, j;
	queue<S> q;

	S s = {sI, sJ};	
	q.push(s);	

	for (i=0; i<h; i++)
		for (j=0; j<w; j++)
			dist[i][j] = INF;
	dist[sI][sJ] = 0;

	while (q.size()) {
		S t = q.front();
		q.pop();

		if (t.x == gJ && t.y == gI) break;

		for (i=0; i<4; i++) {
			int nx = t.x + x[i];
			int ny = t.y + y[i];

			if (0<=nx && nx<w && 0<=ny && ny<h && data[ny][nx] != 'X' && dist[ny][nx] == INF) {
				dist[ny][nx] = dist[t.y][t.x] + 1;
				S u = {ny, nx};
				q.push(u);
			}
		}
	}

	return dist[gI][gJ];
}

int main()
{
	int i, j;
	int sI, sJ;	
	int res;

	scanf("%d%d%d ", &h, &w, &n);
	data = (char **)calloc(h, sizeof(char *));;
	for (i=0; i<h; i++)
		data[i] = (char *)calloc(w, sizeof(char));

	fX = (int *)calloc(n, sizeof(int));;
	fY = (int *)calloc(n, sizeof(int));;

	for (i=0; i<h; i++) {
		for (j=0; j<w; j++)
			scanf("%c ", &(data[i][j]));
	}

	for (i=0; i<h; i++) {
		for (j=0; j<w; j++) {
			if (data[i][j] == 'S') {
				sI = i;
				sJ = j;
			} else if (0 < data[i][j] - '0' && data[i][j] - '0' <= n) {
				fX[ (int)(data[i][j] - '0') - 1 ] = j;  	
				fY[ (int)(data[i][j] - '0') - 1 ] = i;  	
			}
		}
	}

	dist = (int **)calloc(h, sizeof(int *));;
	for (i=0; i<h; i++) 
		dist[i] = (int *)calloc(w, sizeof(int));

	res = bfs(sI, sJ, fY[0], fX[0]);
	for (i=1; i<n; i++) 
		res += bfs(fY[i-1], fX[i-1], fY[i], fX[i]);

	printf("%d\n", res);

	for (i=0; i<h; i++)
		free(data[i]);
	free(data);

	for (i=0; i<h; i++)
		free(dist[i]);
	free(dist);

	free(fX);
	free(fY);

	return 0;
}

Measured memory_bytes: 5756
#include<stdio.h>

#define MAX 500001

int h;

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
}

int maxHeapify(int *A, int i){
  int l,r,largest,buf;
  l = left(i);
  r = right(i);

  if((l <= h) && (A[l] > A[i]))
    largest = l;
  else
    largest = i;
  
  if((r <= h) && (A[r] > A[largest]))
    largest = r;

  if(largest != i){
    buf = A[largest];
    A[largest] = A[i];
    A[i] = buf;
    maxHeapify(A,largest);
  }
    
}

void buildMaxHeap(int *A){
  int i;

  for(i = h / 2; i >= 1; i--)
    maxHeapify(A,i);
}

int main(){
  int i,c[MAX];

  scanf("%d",&h);
  for(i = 1; i <= h; i++){
    scanf("%d",&c[i]);
  }

  buildMaxHeap(c);

  for(i = 1; i <= h; i++)
    printf(" %d",c[i]);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);
ll H,W;
vector<vector<ll>> c(10,vector<ll>(10));
vector<vector<ll>> A;

int main() {
    cin >> H >> W;
    A.assign(H,vector<ll>(W));
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> A[i][j];
        }
    }
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int l=0;l<10;l++){
                c[j][l]=min(c[j][l],c[j][i]+c[i][l]);
            }
        }
    }

    ll ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(A[i][j]!=-1){
                ans+=c[A[i][j]][1];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
from itertools import combinations
N, K = map(int, input().split())
xy = [tuple(map(int, input().split())) for i in range(N)]

ans = float("inf")
for p1, p2 in combinations(xy, 2):
    x1 = p1[0]
    x2 = p2[0]
    if x2 < x1:
        x1, x2 = x2, x1
        #x2 > x1
    for p3, p4 in combinations(xy, 2):
        y1 = p3[1]
        y2 = p4[1]
        if y2 < y1:
            y1, y2 = y2, y1
        # y2 >= y1
        count = 0
        for x, y in xy:
            if x >= x1 and x <= x2 and y >= y1 and y <= y2:
                count += 1

        if count >= K:
            ans = min(ans, (x2-x1)*(y2-y1))


print(ans)


Measured memory_bytes: 50652
#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0;char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,a[100005],mx=0;
int main(){
	n=read();
	for (int i=1;i<=n;++i){
		a[i]=read();
		mx=max(mx,a[i]);
	}
	for (int i=1;i<=n;++i) if (mx-a[i]>1){
		puts("No");
		return 0;
	}
	int c=0;
	for (int i=1;i<=n;++i) if (a[i]<mx) ++c;
	if (!c){
		if (mx==n-1){
			puts("Yes");
			return 0;
		}
	}
	if (c>=mx){
		puts("No");
		return 0;
	}
	if (n-c<(mx-c)*2){
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        
        
        void solve()
        {
        	 	int n;
			  cin >> n;
			  string s;
			  cin >> s;
			  int cnt1 = 0,cnt2 = 0;
			  loop(i,n){
			    if(s[i]=='R')
			      cnt1++;
			    else
			      cnt2++;
			  }
			  int ans = min(cnt1,cnt2),t = 0;
			  loop(i,cnt1){
			    if(s[i] == 'R'){
			       t --;
			    }
			  }
			  cout << min(ans,cnt1+t);
		}
        signed main()
        {
        	solve();
		}

Measured memory_bytes: 3748
#include<stdio.h>
int max2(int a, int b){return a<b?b:a;}
int a, b, c, max, ans;
int k;
int main(){
  scanf("%d%d%d%d", &a, &b, &c, &k);
  ans = a+b+c;
  max = max2(a, max2(b, c));
  ans -= max;
  ans += max<<k;
  printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    int m;
    cin>>m;
    ll ans=0;
    ll t=0;
    ll num=0;
    rep(i,m){
        ll d,c;
        cin>>d>>c;
        ans+=(d*c+t)/9;
        t=(d*c+t)%9;

        num+=c;
        ans+=num-1;
        num=(num>0)?1:0;
    }
    fin(ans-(t==0));
}

Measured memory_bytes: 256
import heapq
n,k = map(int,input().split())
d = {}
z = []
for i in range(n):
    a,b = map(int,input().split())
    z.append([a,b])
    d[a] = 0
for i in range(len(z)):
    d[z[i][0]]+=z[i][1]
c = sorted(d.keys())
l=0
for i in range(len(c)):
    if(k<=0):
        print(c[i-1])
        l+=1
        break
    k-=d[c[i]]
if(l!=1):
    print(c[-1])


Measured memory_bytes: 25644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int r = 0; r < N/R + 1; r++) {
    for (int g = 0; g < N/G + 1; g++) {
      if ((N - R*r - G*g) % B == 0 && r*R + g*G <= N) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

ll MA = pow(10,6)+10;

int main() {
  ll N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i]; sort(A,A+N);
  ll count[MA] = {}; rep(i,N) count[A[i]]++;
  vector<bool> can(MA, true);
  ll result = 0;
  rep(i,N) {
    if (!can[A[i]]) continue;
    for (int x=A[i]; x<MA; x+=A[i]) can[x] = false;
    if (count[A[i]]==1) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 13120
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = float('inf')

def dfs(cur, a, b, c):
  if cur == N:
    return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF
  res0 = dfs(cur + 1, a, b, c)
  res1 = dfs(cur + 1, a + l[cur], b, c) + 10
  res2 = dfs(cur + 1, a, b + l[cur], c) + 10
  res3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(res0, res1, res2, res3)

print(dfs(0, 0, 0, 0))

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

using ll = long long;
using P = pair<int, int>;
#define reps(i,n) for (int i=1; i<=n; i++)
#define zarray(x,n) x[n+1]; reps(i,n) {x[i]=0;} 
#define zarray2(x,n,m) x[n+1][m+1]; reps(i,n) { reps(j,m) {x[i][j]=0;}}

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

    string ans = (s == "ABC") ? "ARC" : "ABC";
    cout << ans << endl;
}


Measured memory_bytes: 3616
readDouble :: String -> Double
readDouble = read
x ? (a,b) = if x then a else b

main = do
    s <- map readDouble.words<$>getContents
    putStr ((show$solve s) ++ " " ++ (show$solve2 s))

solve :: [Double] -> Double
solve (w:h:_) = w*h/2

solve2 :: [Double] ->  Int
solve2 [w,h,x,y] = (w `isHalved` x && h `isHalved` y)?(1,0)

a `isHalved` b = a == b * 2


Measured memory_bytes: 508
#include <iostream>

using namespace std;

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

    int ans = (int) S.size();
    for (int i = 0; i < S.size() - 1; ++i) {
        if (S[i] != S[i + 1]) {
            ans = min(ans, max((int) S.size() - i - 1, i + 1));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll l,r;
	cin>>l>>r;
	ll L=sqrt(l);
	ll R=sqrt(r);
	ll ans=1;
	map<ll,ll>a;
	for(ll i=2;i<=L;i++){
		if(l%i==0){
			a[i]++;
		}
		while(l%i==0){
			l/=i;
		}
	}
	if(l!=1){
		a[l]++;
	}
	for(ll i=2;i<=R;i++){
		if(r%i==0){
			a[i]++;
		}
		while(r%i==0){
			r/=i;
		}
	}
	if(r!=1){
		a[r]++;
	}
	for(auto i=a.begin();i!=a.end();i++){
		ll val=i->second;
		if(val==2){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int main(){
	int n,m;	cin>>n>>m;

	bool flag=false;
	for(int x=0; x<=n; x++){
		for(int y=0;x+y<=n;y++){
			int z=n-(x+y);

			int now=x*10000 + y*5000 + z*1000;

			if(x+y+z==n && now==m){
				printf("%d %d %d\n",x,y,z);
				flag=true;
				break;
			}

		}
		if(flag) break;
	}

	if(flag==false) printf("-1 -1 -1\n");

	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N := sc.Next()
	if strings.Contains(N, "9") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    string t, s;
    cin >> s >> t;
    out(t + s);
}


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

int main(){
  int n,at=0,bt=0,a[102];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=n-1;i>=0;i-=2){
    at+=a[i];
  }
  for(int i=n-2;i>=0;i-=2){
    bt+=a[i];
  }
  cout<<at-bt<<endl;
}


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

typedef long long int llint;

int main()
{
  int n, t;
  cin>> n >> t;

  int c[101];
  int ti[101];

  int ans = 10000000;
  
  for(int i = 0; i < n; i++) {
    cin>> c[i] >> ti[i];

    if(t >= ti[i]) {
      ans = min(ans, c[i]);
    }
  }

  if(ans == 10000000) cout<< "TLE" <<endl;
  else cout<< ans <<endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))
s_1 = 0
s_2 = 0
ans = 100

for i in range(1, n):
    s_1 = sum(w[:i])
    s_2 = sum(w[i:])
    if(ans > abs(s_1 - s_2)):
        ans = abs(s_1 - s_2)
print(ans)

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

int main(){
  int n,i,j,a,b;
  char op[8]={},str[1001]={},p[1001]={};

  scanf("%s", str);
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s %d %d",op,&a,&b);
    if(strcmp(op,"print")==0){
      for(j=a;j<=b;j++){
        printf("%c", str[j]);
      }
      printf("\n");
    }
    else if(strcmp(op,"reverse")==0){
      for(j=a;j<=b;j++){
        p[b-j]=str[j];
      }
      for(j=a;j<=b;j++){
        str[j]=p[j-a];
      }
    }
    else if(strcmp(op,"replace")==0){
      scanf("%s",p);
      for(j=a;j<=b;j++){
        str[j]=p[j-a];
      }
    }
  }

  return 0;
}



Measured memory_bytes: 2112
n=int(input())

l=([False]*53)

for i in range(n):
    pic,ran=input().split()
    ran=int(ran)

    if pic=='S':
        a=ran
        l[a]=True
    elif pic=='H':
        a=13+ran
        l[a]=True
    elif pic=='C':
        a=26+ran
        l[a]=True
    else :
        a=39+ran
        l[a]=True

for k in range(1,53):
    if l[k]==False:
        if k<14:
            print("S",k)
        elif k<27:
            print("H",k-13)
        elif k<40:
            print("C",k-26)
        else:
            print("D",k-39)



Measured memory_bytes: 5608
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    N, A, B = MI()
    diff = abs(A - B)

    if diff % 2 == 0:
        print(diff // 2)
    else:
        ans = 0
        minp = min(A, B)
        maxp = max(A, B)
        # print(N - maxp + 1, maxp, minp)
        if N - maxp + 1 > minp:
            ans += minp - 1
            B -= minp - 1
            B -= 1
            ans += 1
            A = 1
            # print(ans, A, B)
            if B == 1:
                print(ans)
            else:
                ans += abs(B - A) // 2
                print(ans)
        else:
            ans += N - maxp
            A += N - maxp
            A += 1
            ans += 1
            B = N
            # print(ans, A, B)
            if A == N:
                print(ans)
            else:
                ans += abs(B - A) // 2
                print(ans)
        # # print(minp, maxp, N - maxp)
        # else:
        #     print(max(A, B) - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 66028
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
 
int main()
{
    int a, b, c, d;
  
 // 整数の入力
    scanf("%d %d %d %d", &a, &b, &c, &d);
 // printf("%d\n",N);

    if((a + b) > (c + d))
    printf("Left\n");
    else if((a + b) == (c + d))
    printf("Balanced\n");
    else
    printf("Right\n");
    return 0;
}


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

int main()
{
	char ch, ch2;
	
	while(1)
	{
		scanf("%c", &ch);
		
		if(islower(ch)){
			ch2 = toupper(ch);
			cout << ch2;
		}else{
			ch2 = tolower(ch);
			cout << ch2;
		}
		
		if(ch == '\n'){
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3104
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll x, y; cin >> x >> y;
	ll res = 0;
	if (y < x)
	{
		if (y < 0 && x < 0)res = abs(y) - abs(x) + 2;
		if (y < 0 && 0 <= x)res = abs(abs(y) - abs(x)) + 1;
		if (y == 0)res = x + 1;
		if (0 < y)res = x - y + 2;
	}
	else
	{
		if (x*y < 0)res = abs(abs(y) - abs(x)) + 1;
		else res = y - x;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int h, m, s;
  scanf("%d", &s);
  h = s / 3600;  //s?§????60*60??§?????????????°???°??????????????¨???????????????
  m = (s % 3600) /60 ; //s?§????60*60??§?????£??????????????????m??¨s???????¨????????§????60??§???????????????m????????????
  s = s % 60 ; //s?§????60??§?????£??????????????????60???????°??????????

  printf("%d:%d:%d\n", h,m,s);

  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
using Pc=pair<char,char>;
ll dp[300][200000];
int main() {
   int n,x;
   cin>>n>>x;
   vector<ll> a(n);
   for(int i=0;i<n;i++)cin>>a[i];
   sort(all(a));
for(int i=0;i<=x;i++){
    dp[0][i]=i;
}
   for(int i=0;i<n;i++){
   for(int j=0;j<=x;j++){
             (dp[i+1][j]+=dp[i][j%a[i]])%=mod;
             (dp[i+1][j]+=dp[i][j]*i)%=mod;
         }
     }
   cout<<dp[n][x]<<endl;
}

Measured memory_bytes: 312832
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007
#define N 2000007
ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
vector<vector<ll>> adj;
vector<ll> he,v,visited;
ll dfs(ll src) {
    visited[src]=1;
    v[src]=he[src];
    for(auto itr: adj[src]) {
        if(!visited[itr]) {
            v[src]=max(v[src],dfs(itr));
        }
    }
    return v[src];
}
ll cnt=0;
void bfs(ll src,ll n) {
    queue<ll> q;
    q.push(src);
    visited[src]=1;
    while(!q.empty()) {
        ll p=q.front();
        q.pop();
        int flag=0;
        for(auto itr: adj[p]) {
            if(he[itr]>=he[p]) {
                flag=1;
                break;
            }
        }
        for(auto itr: adj[p]) {
            if(!visited[itr]) {
                visited[itr]=1;
                q.push(itr);
            }
        }
        if(flag==0) cnt++;
    }
}
void solve() {
    ll n,m,a,b;
    cin>>n>>m;
    cnt=0;
    v= vector<ll>(n);
    visited = vector<ll>(n);
    he = vector<ll>(n);
    adj = vector<vector<ll>>(n);
    for(int i=0;i<n;i++) cin>>he[i];
    for(int i=0;i<m;i++) {
        cin>>a>>b;
        a--;
        b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    // dfs(0);
    for(int i=0;i<n;i++) 
    if(!visited[i])
    bfs(i,n);
    cout<<cnt;
}   


int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<endl;
    }
    return 0; 

}


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

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  
  //長さMの配列を作る。要素を０で初期化する。
  vector<int> B(M,0);
  for (int i=0;i<M;i++) cin >> B[i];
  
  //N*Mの配列を作る。
  //Aは、vector<int>の長さNの配列
  //これを、vector<int>(M)で初期化
  vector<vector <int>> A(N,vector<int>(M));
  for (int i=0;i<N;i++){
    for (int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  
  int ans=0;
  for (int i=0;i<N;i++){
    int sum=0;
    for (int j=0;j<M;j++){
        sum+=A[i][j]*B[j];
    }
    sum+=C;
    if (sum>0) ans++;
  }
  cout << ans << endl;
}
      


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

int main(){

  int n, num;
  string s;
  list<int> v;

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> s;
    if(s[0] == 'i'){
      cin >> num;
      v.push_front(num);
    }else if(s[6] == 'F'){
      v.pop_front();
    }else if(s[6] == 'L'){
      v.pop_back();
    }else if(s[0] == 'd'){
      cin >> num;
      for(list<int>::iterator it = v.begin(); it != v.end(); it++){
        if(*it == num){
          v.erase(it);
          break;
        }
      }
    }
  }
  int flag = 0;
  for(list<int>::iterator it = v.begin(); it != v.end(); it++){
    if(flag++) cout << " ";
    cout << *it;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 34368
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cstdio>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int a;
  cin >> a;
  if (a%2 == 0){
    cout << a;
  } else {
    cout << a*2;
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
    N = parseInt(readline())
    D = []
    streak = 0
    for i in 1:N
        D1, D2 = parseMap(split(readline()))
        if D1 == D2
            streak += 1
        else
            streak = 0
        end
        if streak == 3
            return "Yes"
        end
    end
    return "No"
end


println(main())

Measured memory_bytes: 161964
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 305;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

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

// ---- コーディングはここから！ ('-')7
ld dp[N][N][N];
void solve(){
	lli n; cin>>n; vl h(4,0);
	fore(i,0,n){int a; cin>>a; h[a]++;}
	ld tot=1.0*n;
	fore(i,0,N)fore(j,0,N)fore(k,0,N)dp[i][j][k]=-1;
	auto f=[&](auto f, int a, int b, int c)->ld{
			if(a<0 or b<0 or c<0)return 0;
			if(a+b+c==0)return 0;
			if(dp[a][b][c]>-.05)return dp[a][b][c];
			ld res = 1 + f(f,a-1,b,c) * a/tot +
			f(f,a+1,b-1,c) * b/tot +
			f(f,a,b+1,c-1) * c/tot;
			ld x = (tot-a-b-c)/tot;
			res/=(1-x);
			return dp[a][b][c]=res;
	};
	cout<<fixed<<setprecision(10)<<f(f,h[1],h[2],h[3])<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 447284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(ll i=0; i<n; i++)
#define loopo(i,n) for(ll i=0; i<n; i++)
using namespace std;


int main(){
    fast;
    
    int n;cin>>n;
    
    set<string> p;
    
    loop(n){
        string s;cin>>s;
        p.insert(s);
    }
    
    cout<<p.size()<<endl;
    
    
    return 0;
}



Measured memory_bytes: 19244
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

N,A = map(int,input().split())
X = sorted(map(int,input().split()))
Y = []
for x in X:
    Y.append(abs(A-x))
ans = max(Y)
for y in Y:
    ans = gcd(y,ans)
print(ans)

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

int main() {

  string S;  
  cin >> S;
  
  if (S == "hi" ) {
    cout << "Yes" << endl;
  }
  
  else if (S == "hihi" ) {
    cout << "Yes" << endl;
  }
  
  else if (S == "hihihi" ){
    cout << "Yes" << endl;
  }
  
    
  else if (S == "hihihihi" ){
    cout << "Yes" << endl;
  }

    
  else if (S == "hihihihihi" ) {
    cout << "Yes" << endl;
  }

  else {
  cout << "No" << endl;
  }

}
      

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DIncenters {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, l; cin >> n >> l;
      vector<int> t(n);
      rep(i, n) {
        cin >> t[i];
      }

      double sumx = 0;
      double sumy = 0;

      rep(i, n) {
        for(int j=i+1; j<n; j++) {
          double k = (t[i]+t[j])/2.0;
          auto x = cos(2*PI*k/l);
          auto y = sin(2*PI*k/l);
          //debug(i, j, x, y);
          auto neg = j-i-1;
          auto pos = n-2-neg;
          //debug(pos, neg);
          sumx += x*(pos-neg);
          sumy += y*(pos-neg);
        }
      }

      ll d = ((ll)n)*(n-1)*(n-2)/6;

      cout << setprecision(15) << fixed;
      cout << sumx/d << ' ' << sumy/d << endl;
    }
};

signed main() {
  DIncenters solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
int N, M;
int alpha[100010][26];
std::string S;
int main() {
	std::cin >> S;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == S[i + 1]) {
			std::cout << i + 1 << " " << i + 2 << std::endl;
			return 0;
		}
	}
	for (int i = 0; i < S.size() - 2; i++) {
		if (S[i] == S[i + 2]) {
			std::cout << i + 1 << " " << i + 3 << std::endl;
			return 0;
		}
	}
	std::cout << -1 << " " << -1 << std::endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    char x;
    cin >> x;
    int m=n;
    for (int i=0; i<m-1; i++)
    {
        char y;
        cin >> y;
        if (x==y) 
        {
            n--;
        }
        else
            x = y;
    }
    cout << n;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int i = s % 100;
        int k = s / 100;
        if (1 <= i && i <= 12 && 1 <= k && k <= 12)
            System.out.println("AMBIGUOUS");
        else if (1 <= i && i <= 12)
            System.out.println("YYMM");
        else if (1 <= k && k <= 12)
            System.out.println("MMYY");
        else
            System.out.println("NA");
    }
}


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

int main(){

  long long int a,n;

  while(cin >> n){

    for(int i=1;i<=n;i++){
      if(i == 1) a = 2;
      else a += i;
    }

    if(n == 0) cout << 0 << endl;
    else cout << a << endl;
  }
}

Measured memory_bytes: 1156
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }
    let &ans = [a * c, a * d, b * c, b * d].iter().max().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 2096
A,B,C,D=input().split()
A=int(A)
B=int(B)
C=int(C)
D=int(D)

sumL=A+B
sumR=C+D


if sumL>sumR:
    print('Left')
elif sumL<sumR:
    print('Right')
else:
    print('Balanced')

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

int main(){
	int n;
	cin>>n;
	map<int,int> mp;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		mp[a]++;
	}
	bool ans=true;
	if(mp.size()==3){
		for(auto p:mp){
			if(p.second*3!=n){
				ans=false;
			}
		}
		int a=mp.begin()->first;
		int b=next(mp.begin())->first;
		int c=next(mp.begin(),2)->first;
		if((a^b)!=c){
			ans=false;
		}
	}
	else if(mp.size()==2){
		int a=mp.begin()->second;
		int b=next(mp.begin())->second;
		int c=mp.begin()->first;
		int d=next(mp.begin())->first;
		if((a+a!=b||c!=0)&&(a!=b+b||d!=0)){
			ans=false;
		}
	}
	else if(mp.size()==1){
		int a=mp.begin()->first;
		if(a!=0){
			ans=false;
		}
	}
	else{
		ans=false;
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int ans=0;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<=n;i++)
	{
		if(i*2+(n-i)*4==m)
		{
			ans=1;
		}
	}
	if(ans==0) cout<<"No";
	else cout<<"Yes";
 } 

Measured memory_bytes: 3620
a, b, c = map(int, input().split())
if a%2 == 0 and a == b and c == b:
    print(-1)
else:
    ans = 0
    while a%2 == b%2 == c%2 ==0:
        ans += 1
        a,b,c=(b+c)/2,(c+a)/2,(a+b)/2
    print(ans)

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

int main()
{
	long long int A,B,C;
	scanf("%lld %lld %lld",&A,&B,&C);
	if(A%2==0 || B%2==0 || C%2==0)
		printf("0\n");
	else if(max(max(A,B),C)==A)
		printf("%lld\n", B*C);
	else if(max(max(A,B),C)==B)
		printf("%lld\n", A*C);
	else if(max(max(A,B),C)==C)
		printf("%lld\n", B*A);
}

Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn func(a: &Vec<usize>) -> i64 {
    let n = a.len() - 1;
    let mut ans = 0;
    for i in (0..n).rev() {
        if a[i+1] == a[i] + 1 {
            continue;
        } else if a[i] <= i && a[i] + 1 > a[i+1] {
            ans += a[i] as i64;
        } else {
            return -1;
        }
    }
    ans
}


fn main() {
    let n: usize = read_line().trim().parse().unwrap();
    let mut a = Vec::with_capacity(n+1);
    for i in 0..n {
        let x: usize = read_line().trim().parse().unwrap();
        a.push(x);
    }
    a.push(0);
    println!("{}", func(&a));
}


Measured memory_bytes: 6396
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var list = new List<int>();
        for (int i = 0; i < inp[0]; i++) list.Add(int.Parse(Console.ReadLine()));
        list = list.OrderBy(f => f).ToList();
        int bus = 1;
        int first = list[0];
        int ans = 0;
        for (int i = 1; i < inp[0]; i++)
        {
            if (first + inp[2] < list[i] || bus == inp[1])
            {
                bus = 1;
                first = list[i];
                ans++;
            }
            else bus++;
        }
        Console.WriteLine(ans + 1);
    }
}

Measured memory_bytes: 18524
# ABC062
# https://atcoder.jp/contests/abc062/tasks/arc074_b

# 方針
# 数列のなかで左から1個目のものをx=1とする(1<=x<=3N)
# このとき点P(x=p,N<=p<=2N)をおき、pを動かして考える

# A = (a1,a2,a3..apの中から大きいものN個の和)
# B = (a(p+1),a(p+2)..a(3n)の中から小さいものN個の和) とすると
# 求めたいのは A-B
# pを動かしてA-Bの最大値を求めればそれが答えになる

# 愚直に実装するとO(N^2)であるためTLE

# プライオリティキューを用いることによりO(N)で実装できる
# pがインクリメントされる毎に
# A -> 一番小さい値をpop
# B -> 一番大きい値をpop すれば良い

from heapq import heappush,heappop

N=int(input())
*a,=map(int,input().split())
a=[0]+a

A,B=0,0
As,Bs=[None]*(3*N+1),[None]*(3*N+1)
l,r=[],[]

for p in range(1,N+1):
    heappush(l,a[p])
A=sum(l)
As[N]=A
for p in range(N+1,2*N+1):
    heappush(l,a[p])
    b=heappop(l)
    A=A+a[p]-b
    As[p]=A

for p in range(2*N+1,3*N+1)[::-1]:
    heappush(r,-a[p])
B=-sum(r)
Bs[2*N+1]=B
for p in range(N+1,2*N+1)[::-1]:
    heappush(r,-a[p])
    b=heappop(r)
    B=B+a[p]+b
    Bs[p]=B
    
ans=max(As[p]-Bs[p+1] for p in range(N,2*N+1))
print(ans)

Measured memory_bytes: 123040
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;


int main()
{
    int64_t N, M;
    std::cin >> N >> M;

    std::map<int64_t, std::vector<int64_t>> mat;

    for (size_t i = 0; i < M; ++i) {
        int64_t a, b;
        std::cin >> a >> b;
        mat[a].push_back(b);
        mat[b].push_back(a);
    }

    auto v = mat[1];
    if (std::find(v.begin(), v.end(), N) != v.end()) {
        std::cout << "POSSIBLE" << std::endl;
        return 0;
    }
    for (auto d: v) {
        auto vv = mat[d];
        if (std::find(vv.begin(), vv.end(), N) != vv.end()) {
            std::cout << "POSSIBLE" << std::endl;
            return 0;
        }
    }
    std::cout << "IMPOSSIBLE" << std::endl;
    return 0;
}


Measured memory_bytes: 24424
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    A, B = MAP()
    X = [A + B, A * B, A - B]
    print(max(X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int x3,y3,x4,y4;
    int defx=x2-x1;
    int defy=y2-y1;
    x3=x2-defy;
    y3=y2+defx;
    x4=x3-defx;
    y4=y3-defy;
    
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,K;
    cin >> N >> K;
    map<ll,ll> mp;
    vector<ll> v;
    rep(i,N){
        ll a,b;
        cin >> a >> b;
        if(mp.count(a)){
            mp[a] += b;
        }else{
            mp.emplace(a,b);
            v.push_back(a);
        }
    }
    sort(v.begin(),v.end());
    ll M = v.size();
    ll out = 0;
    ll sum = 0;
    rep(i,M){
        sum += mp[v[i]];
        if(sum>=K){
            out = v[i];
            break;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 4728