akhauriyash/Code-Regression huggingface dataset:
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 6e2 + 5;
const size_t M = N * N;

double f[N], g[N][N];
int e[M][2];
vector<int> graph[N];

int main() {
    int n = read(), m = read();
    for (int i = 0; i < m; ++i) {
        int &u = e[i][0] = read();
        int &v = e[i][1] = read();
        graph[u].emplace_back(v);
    }
    for (int i = n - 1; i >= 1; --i) {
        double mul = (double) 1 / graph[i].size();
        for (int j : graph[i]) {
            for (int k = 0; k <= n; ++k) {
                g[i][k] += g[j][k] * mul;
            }
        }
        f[i] = g[i][0] += 1;
        g[i][i] = 1;
    }
    double ans = f[1];
    for (int i = 0; i < m; ++i) {
        int u = e[i][0], v = e[i][1];
        if (graph[u].size() == 1) continue;
        double mul = (double) 1 / (graph[u].size() - 1);
        double cur = f[1] - f[u] * g[1][u];
        double nf = 1;
        for (int w : graph[u]) {
            if (w == v) continue;
            nf += mul * f[w];
        }
        cur += nf * g[1][u];
        if (cur < ans) ans = cur;
    }
    printf("%.19f\n", ans);
    return 0;
}


Measured memory_bytes: 7040
#include<cstdio>

using namespace std;

int main(){
//     int a = 2;
//     int b = 2;
//     int c = a ^ b;
//     printf("%d\n", c);

    long int n;
    scanf("%ld", &n);
    long int a[n];
    for(int i = 0; i < n; i++){
        scanf("%ld", &a[i]);
    }
    long int l = 0, r = 0;
    long int sm = a[0];
    long int ans = 1;
    while(r < n - 1){
        int x = sm ^ a[r+1];
        if(sm + a[r+1] == x){
            r++;
            sm = x;
            ans += r - l + 1;
        }else if(l < r){
            sm -= a[l];
            l++;
        }else{
            r++;
            l++;
            sm = a[r];
            ans++;
        }
        // printf("%d %d\n", l, r);
        // printf("%d\n", ans);
    }
    printf("%ld\n", ans);
    
}

Measured memory_bytes: 1664
#include <stdio.h>

int main()
{
    int a,i,sum[30]={};
    char c;
    
    while(scanf("%c",&c) != EOF){
        if('a'<=c && c<='z'){
            a=c-'a';
            sum[a]++;
        }else if('A'<=c && c<='Z'){
            a=c-'A';
            sum[a]++;
        }
    }

    for(i=0;i<26;i++)
    printf("%c : %d\n",i+'a',sum[i]);

    return 0;
}


Measured memory_bytes: 2068
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;

	//うーん
	ll u_n = ((tmp & ma0) ^ ma0);
	if (!u_n) {
		ci += 8;
		while (*ci++ >= '0');
		return 1000000000;
	}
	int dig = 68 - __builtin_ctzll(u_n);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (72 - dig >> 3);
	return tmp;
}

int B[200000];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();

	ll kotae = 0;
	rep(i, N) {
		int a = getint();
		if (i + a < N) B[i + a]++;
		if (i - a >= 0) kotae += B[i - a];
	}
	printf("%lld", kotae);

	Would you please return 0;
}

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

using namespace std;

const int maxn = 100010;
const int maxm = 200010;

int l[maxn], e, ok = 0;
int n, m;
int vis[maxn], col[maxn];
int cnt = 0, cnt_b = 0, cnt1 = 0, c = 0;

struct Edge {
	int v, x;
} E[maxm<<1];

inline void addEdge(int u, int v) {
	E[e].v = v; E[e].x = l[u]; l[u] = e++;
}

void dfs(int u) {
	vis[u] = 1; ++ c;
	for (int p = l[u]; p >= 0; p = E[p].x) {
		int v = E[p].v;
		if (!vis[v]) {
			col[v] = (col[u] ^ 1);
			dfs(v);
		} else if (col[v] != (col[u] ^ 1)) ok = 0;
	}
}

int main() {
	memset(l, -1, sizeof(l));
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		addEdge(u, v);
		addEdge(v, u);
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			ok = 1;
			c = 0;
			dfs(i);
			if (c == 1) {
				++ cnt1;
				continue;
			}
			++ cnt;
			if (ok) cnt_b ++;
		}
	}
	printf("%lld\n", 1LL*cnt*cnt + 1LL*cnt_b*cnt_b + 1LL*n*n - 1LL*(n-cnt1)*(n-cnt1));
	return 0;
}

Measured memory_bytes: 6400
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

// main function
int main()
{
	ll K = 0;
	ll ans = 0;
	vector<ll> A(3);

	cin >> A[0] >> A[1] >> A[2];
	cin >> K;

	sort(A.begin(), A.end());

	ans = pow(2.0, K) * A[2] + A[1] + A[0];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read


s = input()

MOD = 2019
d = [0]*MOD
d[0] = 1
r = 0
t = 1
for i in reversed(s):
    r += int(i)*t
    r %= MOD
    t *= 10
    t %= MOD
    d[r] += 1
    
print(sum(i*(i-1)//2 for i in d))

    




Measured memory_bytes: 68032
from heapq import heappush, heappop
import sys
input = sys.stdin.readline


# def dijkstra(graph: list, node: int, start: int) -> list:
#     # graph[node] = [(cost, to)]
#     INF = float('inf')
#     dist = [INF] * node
#
#     dist[start] = 0
#     heap = [(0, start)]
#     while heap:
#         cost, thisNode = heappop(heap)
#         for NextCost, NextNode in graph[thisNode]:
#             dist_cand = dist[thisNode] + NextCost
#             if dist_cand < dist[NextNode]:
#                 dist[NextNode] = dist_cand
#                 heappush(heap, (dist[NextNode], NextNode))
#     return dist
#     # dist = [costs to nodes]
def dijkstra(graph: list, n: int, v_s: int, INF: int = float('inf')) -> list:
    # graph[v_from] = [(cost, v_to), ...]
    dist = [INF] * n

    dist[v_s] = 0
    heap = [(0, v_s)]  # heap = [(dist[v], v), ...]
    while heap:
        _, v_from = heappop(heap)
        for cost, v_to in graph[v_from]:
            dist_cand = dist[v_from] + cost
            if dist_cand < dist[v_to]:
                dist[v_to] = dist_cand
                heappush(heap, (dist[v_to], v_to))
    return dist
    # dist = [costs to nodes]


n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    l, r, c = map(int, input().split())
    l -= 1
    r -= 1
    edge[l].append((c, r))
for i in range(1, n):
    edge[i].append((0, i - 1))

dist = dijkstra(edge, n, 0)
ans = dist[-1] if dist[-1] != float("inf") else -1

print(ans)


Measured memory_bytes: 43792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    private static final int ANTENNA_COUNT = 5;

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] antennas = new int[ANTENNA_COUNT];
            for (int i = 0; i < ANTENNA_COUNT; ++i) {
                antennas[i] = Integer.parseInt(reader.readLine());
            }
            int maxDistance = Integer.parseInt(reader.readLine());
            test(antennas, maxDistance);
        }
    }

    public static void test(int[] antennas, int maxDistance) {
        int offset = 0;
        for (int a = 0; a < ANTENNA_COUNT; ++a) {
            ++offset;
            for (int b = offset; b < ANTENNA_COUNT; ++b) {
                int distance = antennas[b] - antennas[a];
                if (distance > maxDistance) {
                    System.out.println(":(");
                    return;
                }
            }
        }
        System.out.println("Yay!");
    }

}


Measured memory_bytes: 21204
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
      EXPLAINATION BELOW->
      Same as editorial ,main to uderstand no restriction on visiting again the visisted nodes
      Best TC
      5 4
      1 2,1 3,2 4, 2 5
      answer 1 2 3 4 5
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
   int a,b,c;cin>>a>>b>>c;
   if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=c))cout<<"Yes\n";
   else cout<<"No\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    priority_queue<pair<ll, ll>> pq;
    for(int i = 0; i < N; i++) {
        ll t, d;
        cin >> t >> d;
        pq.push({d, t - 1});
    }
    ll ans = 0;
    ll cnt[N] = {0};
    ll kinds = 0;
    priority_queue<ll> Q;
    for(int i = 0; i < K; i++) {
        auto dt = pq.top();
        pq.pop();
        cnt[dt.second]++;
        if(cnt[dt.second] > 1)
            Q.push(-dt.first);
        else
            kinds++;
        ans += dt.first;
    }
    ans += kinds * kinds;
    // debug(ans);
    ll a = ans;
    while(!pq.empty() && !Q.empty()) {
        auto dt = pq.top();
        pq.pop();
        if(cnt[dt.second] > 0)
            continue;
        cnt[dt.second]++;
        kinds++;
        a += dt.first + 2 * kinds - 1 + Q.top();
        Q.pop();
        ans = max(ans, a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3440
from collections import deque
def main():
    S = input()
    Q = int(input())
    ans = deque(S)
    switch = "F"
    count = 0

    for q in range(Q):
        T, *arg = input().split()
        T = int(T)

        if T == 1:
            count += 1
            if switch == "F":
                switch = "R"
            elif switch == "R":
                switch = "F"
        else:
            if switch == "F":
                if int(arg[0]) == 1:
                    ans.appendleft(arg[1])
                else:
                    ans.append(arg[1])
            else:
                if int(arg[0]) == 1:
                    ans.append(arg[1])
                else:
                    ans.appendleft(arg[1])

    if count % 2 == 0:
        print("".join(ans))
    else:
        ans.reverse()
        print("".join(ans))
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 8812
n, m = gets.strip.split(' ').map(&:to_i)

dist = Array.new(n+1) { [10**12]*(n+1) }

(1..n).each do |i|
  dist[i][i]=0
end

abc = readlines.map {|line| line.strip.split.map(&:to_i) }

abc.each do |a, b, c|
  dist[a][b] = c
  dist[b][a] = c
end

# ここまで隣接行列の初期化処理
# dist[a][b]には頂点a,b間の辺のコストを入れておく
# dist[a][a]には0、辺が存在しない場合には 10**12 (INFINITY) を入れておく

# warshall floyd
(1..n).each do |via|    # 経由する頂点
  (1..n).each do |from| # 始点
    (1..n).each do |to| # 終点
      dist[to][from] = dist[from][to] = [dist[from][to], dist[from][via] + dist[via][to]].min
    end
  end
end
 
result = 0
abc.each do |a, b, c|
  # 2つの頂点を結ぶ辺が最短でなければいずれの最短経路からも利用されることはない
  result += 1 if dist[a][b] < c
end
 
puts result


Measured memory_bytes: 2172
#!/usr/bin/ruby
class Integer;def infinite?;false end end
n,ma,mb=gets.split.map(&:to_i)
a,b,c=$<.map{|e|e.split.map(&:to_i)}.transpose
amax=a.max
bmax=b.max
dp=(n+1).times.map{(n*amax+1).times.map{[Float::INFINITY]*(n*bmax+1)}}
dp[0][0][0]=0
n.times{|i|
	0.upto(n*amax){|ca|
		0.upto(n*bmax){|cb|
			next if dp[i][ca][cb].infinite?
			dp[i+1][ca][cb]=[dp[i+1][ca][cb],dp[i][ca][cb]].min
			dp[i+1][ca+a[i]][cb+b[i]]=[dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]].min
		}
	}
}
r=Float::INFINITY
1.upto(n*amax){|ca|
	1.upto(n*bmax){|cb|
		r=[r,dp[n][ca][cb]].min if ca*mb==cb*ma
	}
}
p r.infinite? ? -1 : r

Measured memory_bytes: 55292
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct B {
	int val;
	int weight;
};

ll solve(int weight[], int val[], int n, int w) {
	ll dp[n + 1][w + 1];
	memset(dp, 0, sizeof dp);
	for (int row = n - 1; row >= 0; row--) {
		for (int col = 1; col <= w; col++) {
			ll e = dp[row + 1][col];
			ll i = 0;
			if (col >= weight[row]) {
				i = val[row] + dp[row + 1][col - weight[row]];
			}
			dp[row][col] = max(e, i);
		}
	}
	return dp[0][w];
}





int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif
	int n, w;
	cin >> n >> w;
	int weight[100];
	int val[100];
	for (int i = 0; i < n; i++) {
		cin >> weight[i];
		cin >> val[i];
	}
	cout << solve(weight, val, n, w);
	return 0;
}

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

int main () {
  long long N , A ,B ;
  cin >> N >> A >> B ;
  string S ;
  cin >> S ;
  int pre[2] ={} ;
  for(int i = 0 ; i < N ; i++ ){
    if(S[i]=='c') cout << "No" << endl ;
    if(S[i]=='a') {
      if(pre[0] <A + B){
        cout << "Yes" << endl ;
        pre[0]++ ;
      } else {
        cout << "No" << endl ;
      }
    }
    if(S[i]=='b'){
      if(pre[0]<A+B && pre[1]<B) {
        cout << "Yes" << endl ;
        pre[0]++ ;
        pre[1]++ ;
      } else {
        cout << "No" << endl ;
      }
    }
  }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  char t=s[s.size()-1];
  if(s[s.size()-1]=='3') cout<<"bon";
  else if(t=='0'||t=='1'||t=='6'||t=='8') cout<<"pon";
  else cout<<"hon";
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>

using namespace std;

struct UnionFind{
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  bool unionSet(int x, int y){
    x = root(x); y = root(y);
    if(x != y){
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y){
    return root(x) == root(y);
  }
  int root(int x){    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x){
    return -data[root(x)];
  }
};

int main()
{
  int N, M;
  cin >> N >> M;

  int p[N];
  for(int i = 0; i < N; ++i) cin >> p[i];
  
  UnionFind uf(N);
  
  int x, y;
  for(int i = 0; i < M; ++i){
    cin >> x >> y;
    uf.unionSet(x-1,y-1);
  }

  int ans {0};
  for(int i = 0; i < N; ++i) if(uf.findSet(i,p[i]-1)) ++ans;
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
int main()
{
    int a,b,c;
    mp.clear();
    cin>>a>>b>>c;
    mp[a]++;
    mp[b]++;
    mp[c]++;
    for(int i=-102;i<102;i++)
        if(mp[i]==1)
    {
        cout<<i<<endl;
        break;
    }
    return 0;
}

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

if n >= 400 and n <= 599:
    print(8)
elif n >= 600 and n <= 799:
    print(7)
elif n >= 800 and n <= 999:
    print(6)
elif n >= 1000 and n <= 1199:
    print(5)
elif n >= 1200 and n <= 1399:
    print(4)
elif n >= 1400 and n <= 1599:
    print(3)
elif n >= 1600 and n <= 1799:
    print(2)
elif n >= 1800 and n <= 1999:
    print(1)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    int P[N]; REP(i,N) cin >> P[i];
    int mn[N]; mn[0] = P[0];
    REP(i,N-1){
        mn[i+1] = min(P[i+1], mn[i]);
    }
    int ans = 0;
    REP(i,N) if(mn[i] == P[i]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
def main():
    from collections import Counter
    from itertools import combinations

    n, *s = map(lambda x: str(x)[0], open(0).read().split())
    c = Counter(s)

    m = [c.get(x) if c.get(x) != None else 0 for x in ["M", "A", "R", "C", "H"]]
    ans = sum(i * j * k for i, j, k in combinations(m, 3))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11412
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	string s;
	cin >> s;
	for ( int i = 0 ; i < s.length() ; i++ ) {
		if ( s[i] == s[i+1] ) {
			cout << i + 1 << ' ' << i + 2;
			return 0;
		}
		else if ( s[i] == s[i+2] ) {
			cout << i + 1 << ' ' << i + 3;
			return 0;
		}
	}
	cout << -1 << ' ' << -1;
}

Measured memory_bytes: 512
from collections import defaultdict
N = int(input())
A = [int(x) for x in input().split()]
p = 10 ** 9 + 7
C = defaultdict(int)
mod = 1 - N % 2
for a in A:
  if a % 2 != mod:
    print(0)
    break
  elif a >= N:
    print(0)
    break
  else:
    C[a] += 1
    if a and C[a] > 2:
      print(0)
      break
    elif a == 0 and C[a] > 1:
      print(0)
      break
else:
  print(2 ** (N // 2) % p)

Measured memory_bytes: 14820
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)

def main():
    S = input()
    Q = int(input())
    d = deque(list(S))
    rev = False

    def insert(x,f):
        g = f == "2" # append
        if rev:
            g = not g

        if g:
            d.append(x)
        else:
            d.appendleft(x)


    for q in range(Q):
        inp = input()
        if inp == "1":
            rev = not rev
        else:
            _,F,C = inp.split()
            insert(C,F)


    if rev:
        d.reverse()

    print("".join(d))



if __name__ == "__main__":
  main()

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

int main() {
  int N,M,A;
  cin >> N;
  M = (N/1000) + 1;
  A = (M * 1000) - N;
  if (A == 1000) {
    cout << 0 <<endl;
  }
  else {
    cout << A << endl;
  }
}


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

using namespace std;

string a;

int main() {
	getline(cin, a);
	for(int i = 0; i < a.size(); ++i) {
		if(a[i] == 'C') 
		for(int j = i; j < a.size(); ++j) {
			if(a[j] == 'F'){
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int a[N], dp[N];

signed main(){
    IOS;
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 2; i <= k; i++)
        dp[i] = abs(a[i] - a[1]);
    for (int i = k+1; i <= n; i++) {
        dp[i] = inf;
        for (int j = i-k; j < i; j++) {
            dp[i] = min(dp[i], dp[j] + abs(a[i]-a[j]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}

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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

using pint = pair<int,int>;
int main () {
    int N, M, K;
    cin >> N >> M >> K;
    vector<set<int> > dame(N);
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        dame[a].insert(b);
        dame[b].insert(a);
        uf.merge(a, b);
    }
    for (int i = 0; i < K; ++i) {
        int c, d; cin >> c >> d; --c, --d;
        if (!uf.issame(c, d)) continue;
        dame[c].insert(d);
        dame[d].insert(c);
    }

    for (int i = 0; i < N; ++i) {
        int mem = uf.size(i) - 1; // 同じ連結成分の「自分以外」の人数
        mem -= dame[i].size(); // その中ですでに友達かブロック関係の人数
        cout << mem << " ";
    }
    cout << endl;
}

Measured memory_bytes: 24704
<?php
fscanf(STDIN, '%d %d', $n, $k);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$minus = $zero = $plus = [];
for ($i = 0; $i < $n; $i++) {
    if ($a[$i] < 0) {
        $minus[] = -$a[$i];
    } elseif ($a[$i] === 0) {
        $zero[] = 0;
    } else {
        $plus[] = $a[$i];
    }
}

sort($plus);
sort($minus);

$cnt_plus = count($plus);
$cnt_zero = count($zero);
$cnt_minus = count($minus);

// プラスになるものの組み合わせ
$kumi_plus = $cnt_plus * ($cnt_plus - 1) / 2 + $cnt_minus * ($cnt_minus - 1) / 2;
// 0になるものの組み合わせ
$kumi_zero = $cnt_zero * ($n - $cnt_zero) + $cnt_zero * ($cnt_zero - 1) / 2;
// マイナスになるものの組み合わせ
$kumi_minus = $cnt_minus * $cnt_plus;

// 二分探索
$left = -10 ** 18 - 1;
$right = 10 ** 18 + 1;
while ($right - $left > 1) {
    $mid = intdiv($left + $right, 2);
    if (cnt($mid) < $k) $left = $mid;
    else $right = $mid;
}
echo $left;

// $x未満になるものの組み合わせの数を返す
function cnt($x)
{
    global $minus, $plus, $cnt_minus, $cnt_plus, $kumi_minus, $kumi_zero, $kumi_plus;

    if (!$x) { // 0の場合はマイナスになる組み合わせの数を返す
        return $kumi_minus;
    }

    if ($x > 0) {
        $res = $kumi_minus + $kumi_zero;

        // しゃくとり プラスxプラス
        $j = $cnt_plus - 1;
        for ($i = 0; $i < $cnt_plus; $i++) {
            for ($j = $j; $j > $i; $j--) {
                if ($plus[$i] * $plus[$j] < $x) {
                    $res += $j - $i;
                    break;
                }
            }
        }

        // しゃくとり マイナスxマイナス
        $j = $cnt_minus - 1;
        for ($i = 0; $i < $cnt_minus; $i++) {
            for ($j = $j; $j > $i; $j--) {
                if ($minus[$i] * $minus[$j] < $x) {
                    $res += $j - $i;
                    break;
                }
            }
        }

        return $res;
    }

    if ($x < 0) {
        $res = 0;

        // しゃくとり マイナスxプラス
        $j = 0;
        for ($i = $cnt_minus - 1; $i >= 0; $i--) {
            for ($j = $j; $j < $cnt_plus; $j++) {
                if (-$minus[$i] * $plus[$j] < $x) {
                    $res += $cnt_plus - $j;
                    break;
                }
            }
        }

        return $res;
    }
}

Measured memory_bytes: 29172
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 25) {
            System.out.println("Christmas");
        } else if (n == 24) {
            System.out.println("Christmas Eve");
        }  else if (n == 23) {
            System.out.println("Christmas Eve Eve");
        } else {
            System.out.println("Christmas Eve Eve Eve");
        }




    }

}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl;
#define mod 1000000007
#define pb push_back
#define endl '\n'

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

	string a,b;
	cin>>a>>b;

	int ac,bc;
	cin>>ac>>bc;

	string l;
	cin>>l;

	if(l==a) ac--;
	else bc--;

	cout<<ac<<" "<<bc<<endl;

	
	
	
	



}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a, b, c;
  int k;
  cin >> a >> b >> c >> k;

  int b_flag = true;
  for(int i=0; i<k; i++){
    if(a < b){
      b_flag = false;
    }
    if(b_flag) b *= 2;
    else c *= 2;
  }

  if(a < b && b < c){
    cout << "Yes" << '\n';
  }else{
    cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 3128
s=input()
t=input()
dict_s = {}
dict_t = {}
ans = 0

for i in range(len(s)):
    s1 = s[i]
    if s1 in dict_s.keys():
        dict_s[s1] += 1
    else:
        dict_s[s1] = 1

for i in range(len(t)):
    t1 = t[i]
    if t1 in dict_t.keys():
        dict_t[t1] += 1
    else:
        dict_t[t1] = 1

for i in range(len(s)):
    if dict_s[s[i]] != dict_t[t[i]]:
        ans = 1
        break

print("Yes" if ans==0 else "No")


Measured memory_bytes: 3632
#include <string>
#include <iostream>
using namespace std;
int n, a, c; string s;
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a), s += (char)(a + 48);
	while(s.find(to_string(c++)) != string::npos) ;
	printf("%d\n", --c);
	return 0;
}

Measured memory_bytes: 3332
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main() {
	long long  n;
	cin>>n;
	long long ans=1,t=1,p=1;
	if(n==1)
    {
        cout<<0;
        return 0;
    }
	//ans=n%mod*(n-1)%mod;
	ans=1;
	;

	//cout<<ans;
	while(n)
    {

        ans=(ans%mod*10)%mod;
        t=(t%mod*9)%mod;
        p=(p%mod*8)%mod;
        //cout<<ans;
        n--;
    }
   // ans

 cout<<(ans-t+mod-t+mod+p)%mod;

}


Measured memory_bytes: 3624
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define lu unsigned long long int
#define pi pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for (ll i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define be begin
#define sz(a) (ll)(a.size())
#define INF 1e18
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

// ll gcd(ll a, ll b){
// 	return b == 0 ? a : gcd(b, a % b);
// }

// ll mod = 1e9+7;

// ll mult(ll x, ll y){
//     ll rem=1;
//     while(y){
//         if(y&1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y>>=1;
//     }
//     return rem;
// }


void solve(ll T){
	string s;
	cin>>s;
	ll n=s.length();
	ll ans = 0;
	for(ll i=0;i<n;i++){
		ans+=s[i]-'0';
	}
	if(ans%9==0){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// std::cout << std::unitbuf;
	ll T=1;
	// cin>>T;
	for(ll t=1;t<=T;t++){
		solve(t);
	}
	return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;


int main(){
    int n;
    cin>>n;
    ll x;
    cin>>x;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    ll ans=0;
    for(int i=0;i<n-1;i++){
        ll s=a[i]+a[i+1];
        if(s>x){
            ll d=s-x;
            if(d>a[i+1]){
                ans+=a[i+1];
                a[i+1]=0;
            }else{
                ans+=d;
                a[i+1]-=d;
            }
        }
    }
    if(a[0]>x) ans+=a[0]-x;
    cout<<ans<<endl;
}

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

using namespace std;
const int N = 200000;

int n, k, x;
int a[N];

double Calc(int i) {return a[i + k - 1] - a[i - 1];}

int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1;i <= n; ++i) {
		scanf("%d", &a[i]);
	}
	for(int i = 1;i <= n - k; ++i) 
		if(a[i] < a[i + k])
			puts("Yes");
		else 
			puts("No");
	return 0;
}

Measured memory_bytes: 4536
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

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 ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
class Edge{
public:
//int s;
int t;
long long len;
};
class Node{
    public:
    int num;//node番号
    long long dist;//startからの距離
    vector<Edge> edge;//自分から生えている辺
    bool comp;//dijkstra中で到達しているかどうか
    void in_edge(Edge &edge_in){
        edge.push_back(edge_in);
    }  
};
bool operator >(const Node& a,const Node &r){
  return a.dist > r.dist;
}
void dijkstra(vector<Node> &node,int s,int n){
    //n個のノードでできたグラフのsからtまでの最短距離を計算する
    //この時各要素のdistの値はsからの最短距離となる
    for(int i=1;i<=n;i++){
        //初期化
        node[i].dist=inf;
        node[i].num=i;
        node[i].comp=true;
    }
    node[s].dist=0;
    priority_queue<Node,vector<Node>,greater<Node>> que;
    que.push(node[s]);
    while(!que.empty()){
        Node buf;
        buf=que.top();//
        que.pop();
        int k=buf.num;
        if(node[k].comp){
            node[k].comp=false;
            int edge_num=buf.edge.size();
            for(int i=0;i<edge_num;i++){
                int buf_t=node[k].edge[i].t;
                int buf_len=node[k].edge[i].len;
                if(node[buf_t].dist>node[k].dist+buf_len){
                node[buf_t].dist=node[k].dist+buf_len;
                que.push(node[buf_t]);
                }
            }
        }
    }
}
signed main(){
  int n;int u,v;cin>>n>>u>>v;
  vector<Node> node(n+1);
  rep(i,n-1){
    int a,b;cin>>a>>b;
    Edge edge;
    edge.len=1;
    edge.t=b;
    node[a].in_edge(edge);
    edge.t=a;
    node[b].in_edge(edge);
  }
  vector<Node> T(node);
  dijkstra(T,u,n);
  dijkstra(node,v,n);
  vector<Node> q;
  int res=0;
  rep1(i,n){
    if(T[i].dist<node[i].dist&&T[i].edge.size()==1){
      res=max(res,node[T[i].edge[0].t].dist);
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 28204
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#include <numeric>
using namespace std;

int main()
{
    int num;
    cin >> num;
    long long ans = 0;
    for(int i=1;i<=num;i++){
        for(int j=1;j<=num;j++){
            for(int k=1;k<=num;k++){
                ans += gcd(gcd(i,j),k);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int ui32;
const long long INFLL = 1e18;

using namespace std;

const int MAXN = 200000;

int a[MAXN + 1], b[MAXN + 1];

void add(int x, multiset<int> &s1, multiset<int> &s2) {
    s2.insert(x);
    while (s1.size() < s2.size() - 1) {
        auto it = s2.begin();
        s1.insert(*it);
        s2.erase(it);
    }
}

void del(int x, multiset<int> &s1, multiset<int> &s2) {
    if (s2.find(x) != s2.end()) {
        s2.erase(s2.find(x));
    } else {
        s1.erase(s1.find(x));
    }
    while (s1.size() > s2.size()) {
        auto it = s1.end();
        --it;
        s2.insert(*it);
        s1.erase(it);
    }
    while (s1.size() + 1 < s2.size()) {
        auto it = s2.begin();
        s1.insert(*it);
        s2.erase(it);
    }
}

int get(multiset<int> &s1, multiset<int> &s2) {
    return *s2.begin();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("input.txt", "w", stdout);

    int n;
    cin >> n;
    multiset<int> s1, s2;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        add(a[i], s1, s2);
    }
    for (int i = 0; i < n; i++) {
        del(b[i], s1, s2);
        cout << get(s1, s2) << "\n";
        add(b[i], s1, s2);
    }
    return 0;
}

Measured memory_bytes: 14516
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    string s;cin>>s;
    int n=s.size();
    int dp[n][2];
    rep(i,0,n){
        dp[i][0]=-1000000000;
        dp[i][1]=-1000000000;
    }
    dp[0][0]=1;
    dp[1][1]=1;
    rep(i,0,n){
        if(dp[i][0]>=0){
            if(i<n-1&&s[i+1]!=s[i]){
                dp[i+1][0]=max(dp[i+1][0],dp[i][0]+1);
            }
            if(i<n-2)dp[i+2][1]=max(dp[i+2][1],dp[i][0]+1);
        }
        if(dp[i][1]>=0){
            
            if(i<n-1)dp[i+1][0]=max(dp[i+1][0],dp[i][1]+1);
        }
    }
    cout<<max(dp[n-1][0],dp[n-1][1])<<endl;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n,c; cin >> n >> c;
    vector<vector<int>> d(c);
    rep(i,c){
        rep(j,c){
            int D; cin >> D;
            d[i].push_back(D);
        }
    }
    vector<vector<int>> C(n);
    rep(i,n)rep(j,n){
        int x; cin >> x;
        x--;
        C[i].push_back(x);
    }
    vector<int> team0,team1,team2;
    rep(i,n)rep(j,n){
        if((i+j)%3 == 0) team0.push_back(C[i][j]);
        if((i+j)%3 == 1) team1.push_back(C[i][j]);
        if((i+j)%3 == 2) team2.push_back(C[i][j]);
    }
    vector<vector<int>> table(3);
    rep(i,c){
        int sum0 = 0,sum1 = 0,sum2 = 0;
        for(int x : team0) sum0 += d[x][i];
        for(int x : team1) sum1 += d[x][i];
        for(int x : team2) sum2 += d[x][i];
        table[0].push_back(sum0);
        table[1].push_back(sum1);
        table[2].push_back(sum2);
    }
    int ans = 1e9;
    rep(i,c)rep(j,c)rep(k,c){
        if(i == j || j == k || k == i) continue;
        ans = min(ans,table[0][i]+table[1][j]+table[2][k]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5516
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = 1e18;
const int N = 20;
map<ll, ll> fr;

void solve(int t)
{
	ll n;
	cin >> n;
	ll a[n + 1];
	ll cn = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (a[i] % 2 == 1 and i % 2 == 1) cn++;
	}
	cout << cn << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);



	int t = 1;
	//cin >> t;

	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
int n;
vector<int> G[MAXN];
int dep[MAXN];
int ans;
void dfs(int v,int p,int d)
{
    ans=max(ans,d);
    dep[v]=d;
    for(auto to:G[v]) 
    {
        if(to==p) continue;
        dfs(to,v,d+1);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v); G[v].push_back(u);
    }
    dfs(1,0,0);
    int root=1;
    for(int i=1;i<=n;i++) if(dep[i]>dep[root]) root=i;
    dfs(root,0,0);
    if(ans%3==1) puts("Second"); else puts("First");
}


Measured memory_bytes: 21376
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
s = input().rstrip()[::-1]

ans = []

left, right = 0, 0 + m

while True:
    if right >= n:
        ans.append(n - left)
        break
    for i in range(right, left, -1):
        flag = 1
        if s[i] == "0":
            ans.append(i - left)
            flag = 0
            break
    if flag:
        print(-1)
        sys.exit()
    else:
        left = i
        right = left + m

print(*ans[::-1])
        
        


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string s;cin >> s;
  if(s[0]==s[1] and s[1]==s[2])cout << "Yes";
  else if(s[2]==s[3] and s[1]==s[2])cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e18
#define EPS 1e-9
#define int long long
int fun(int wts[], int vals[], int n, int w){
    int sum_of_vals = 0LL;
    for(int i = 1; i <= n; i++){
        sum_of_vals += vals[i];
    }
    int dp[n+1][sum_of_vals+1];
    /*dp[i][j] = minimum total wt that makes value j considering the 1st i items*/

    
    for(int j = 0; j <= sum_of_vals; j++) dp[0][j] = INF;
    dp[0][0] = 0LL;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= sum_of_vals; j++){
            if(j < vals[i]) dp[i][j] = dp[i-1][j];
            else dp[i][j] = min(dp[i-1][j], dp[i-1][j-vals[i]] + wts[i]);
        }
    }
    int maxi = 0LL;
    for(int j = 0; j <= sum_of_vals; j++){
        //cout << dp[n][j] << " ";
        if(dp[n][j] <= w){
            maxi = j;
        }
    }
    return maxi;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int T=1;
	//cin >> T;
	FOR1(i, T)
	{
		//cout << "Case #" << i << ": ";
       int n, w;
       cin >> n >> w;
       int vals[n+1], wts[n+1];
       FOR1(i, n){
           cin >> wts[i] >> vals[i];
       }
       cout << fun(wts, vals, n, w);
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;


int main() {
	int A,B,C,D;
  	cin >> A >> B >> C >> D;
	cout << max(A*B,C*D) << endl;
}

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

int main(){
	string s;  cin >> s;
	int len = s.size();
	vector<int> t(len+1, 0);
	for(int i=0; i<len; i++)
		if(s[i] == '<')
			t[i+1] = t[i] + 1;
	for(int i=len-1; i>=0; i--)
		if(s[i] == '>')
			t[i] = max(t[i], t[i+1] + 1);
	long ans = 0;
	for(int i=0; i<=len; i++)
		ans += (long)t[i];
	
	cout << ans << endl;
	return 0;
}

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

char chars[10][3] = {
  {'M', 'A', 'R'},
  {'M', 'A', 'C'},
  {'M', 'A', 'H'},
  {'M', 'R', 'C'},
  {'M', 'R', 'H'},
  {'M', 'C', 'H'},
  {'A', 'R', 'C'},
  {'A', 'R', 'H'},
  {'A', 'R', 'H'},
  {'R', 'C', 'H'},
};

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

  vector<ll> a(5, 0);
  rep(i,0,N-1) {
    string s;
    cin >> s;
    switch (s[0])
    {
    case 'M':
      a[0]++;
      break;    
    case 'A':
      a[1]++;
      break;    
    case 'R':
      a[2]++;
      break;    
    case 'C':
      a[3]++;
      break;    
    case 'H':
      a[4]++;
      break;
    default:
      break; 
    }
  }

  ll ans = 0;
  for (int i = 0; i < 3; ++i)
    for (int j = i + 1; j < 4; ++j)
      for (int k = j + 1; k < 5; ++k)
        ans = ans + a[i] * a[j] * a[k];

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define LL long long
using namespace std;
int n,m,s[101][101],p[101],ans;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		cin>>s[i][0];
		for(int j=1;j<=s[i][0];j++) cin>>s[i][j],s[i][j]--;
	}
	for(int i=1;i<=m;i++) cin>>p[i];
	for(int i=0;i<=pow(2,n)-1;i++)
	{
		int sum=0;
		for(int j=1;j<=m;j++)
		{
			int tot=0;
			for(int k=1;k<=s[j][0];k++)
			{
				if(i&1<<s[j][k]) tot++;
			}
			if(tot%2==p[j]) sum++;
		}
		if(sum==m) ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256