akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

long long int after_length(const int level) {
	if (level == 0) return 0;
	else return 2 * after_length(level - 1) + 3;
}
int main() {
	int l, n; std::cin >> l >> n;
	std::string snake; std::cin >> snake;
	int count = 0;
	for (auto i = 1; i < snake.size(); ++i) {
		if (snake[i] == 'o' && snake[i - 1] == 'o')++count;
	}
	std::cout << l + after_length(n) * count << '\n';
}


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

using namespace std;

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

    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N-1; i++) cin >> C[i];

    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += B[A[i]-1];
        if (A[i] == (A[i-1] + 1)) sum += C[A[i-1]-1];
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm> // sort

using namespace std;

int main(){
    int A,B,K;

    cin >> A >> B >> K;

    vector<int> v(B);
    

    //両方で割れたら格納
    for(int i = 1; i <= B; i++)
    {
        if( A % i == 0 && B % i == 0)v.push_back(i);
    }

    sort(v.begin(),v.end(),greater<int>());

    int res;

    res = v[K-1];
    cout << res << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
typedef unsigned long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
int main() {
    ll n, k, a, count;
    ll kount[100001], b[100001], c[100001];
    bool is[100001];
    count = 0;
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> a;
        if (!is[a]) {
            kount[a] = 1;
            is[a] = true;
        } else {
            kount[a]++;
        }
        count += a;
    }
    cin >> k;
    rep(i, k) cin >> b[i] >> c[i];
    for (ll i = 0; i < k; i++) {
        count += (c[i] - b[i]) * kount[b[i]];
        if (is[c[i]]) {
            kount[c[i]] += kount[b[i]];
        } else {
            is[c[i]] = true;
            kount[c[i]] = kount[b[i]];
        }
        kount[b[i]] = 0;
        cout << count << endl;
    }
}


Measured memory_bytes: 6000
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;

    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner(Stream source)
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    private Scanner Cin;
    private int N, M;
    private string[] A, B;

    private void Scan()
    {
        Cin = new Scanner(Console.OpenStandardInput());
        N = Cin.NextInt();
        M = Cin.NextInt();
        A = new string[N];
        B = new string[M];
        for (int i = 0; i < N; i++)
        {
            A[i] = Cin.Next();
        }
        for (int i = 0; i < M; i++)
        {
            B[i] = Cin.Next();
        }
    }

    public void Solve()
    {
        Scan();
        int cnt = 0;
        int loop = N - M + 1;
        for (int i = 0; i < loop; i++)
        {
            for (int j = 0; j < loop; j++)
            {
                if (Equal(i, j))
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }
        Console.WriteLine("No");
    }

    private bool Equal(int y,int x)
    {
        for (int i = 0; i < M; i++)
        {
            for (int j = 0; j < M; j++)
            {
                if (B[i][j] != A[i + y][j + x]) return false;
            }
        }
        return true;
    }
}






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

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

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

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

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


//ここから編集する

ll histogram_max_square(vector<ll> h) {

    h.push_back(0);
    using P = pair<ll, int>;
    stack<P> st;

    ll maxv = 0;

    for (int i = 0; i < h.size(); ++i) {
        if (st.empty()) {
            st.push(P(h[i], i));
            continue;
        }
        if (st.top().first < h[i]) {
            st.emplace(h[i], i);
            continue;
        }
        if (st.top().first > h[i]) {
            int target = i;
            while (true) {
                if (st.empty() || st.top().first < h[i]) {
                    break;
                }
                ll tmp = (i - st.top().second + 1) * (st.top().first + 1);
                if (st.top().first) chmax(maxv, tmp);
                target = st.top().second;
                st.pop();
            }
            st.emplace(h[i], target);
        }
    }
    return maxv;
}


bool check(string a, string b) {
    if (a[0] == b[0] && a[1] == b[1]) return true;
    return a[0] != b[0] && a[1] != b[1];
}

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

    int H, W;
    cin >> H >> W;

    vector<string> vs(H);
    vector<vector<ll> > rect(H, vector<ll>(W));
    rep(i, 0, H) {
        cin >> vs[i];
    }

    for (int i = 1; i < H; ++i) {
        for (int j = 1; j < W; ++j) {
            string a = vs[i - 1].substr(j - 1, 2);
            string b = vs[i].substr(j - 1, 2);
            if (check(a, b)) {
                rect[i][j] = 1;
            }
        }
    }


    for (int i = 1; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (rect[i][j] == 1) rect[i][j] += rect[i - 1][j];
        }
    }

    ll ans = max(H, W);

    for (int i = 1; i < H; ++i) {
        ll tmp = histogram_max_square(rect[i]);
//        if (ans < tmp) {
//            cerr << "update to :" << tmp << ",i : " << i << endl;
//        }
        chmax(ans, tmp);
    }

//    for (int i = 0; i < W; ++i) {
//        cerr << rect[1][i];
//    }
//    cerr << endl;

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 37888
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define REP(I,N) for(int I=0;I<N;++I)
#define REPP(I,A,B) for(int I=A;I<B;++I)
#define RI(X) scanf("%d",&X)
#define RII(X,Y) scanf("%d%d",&X,&Y)
#define RIII(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define DRI(X) int X;scanf("%d",&X)
#define DRII(X,Y) int X,Y;scanf("%d%d",&X,&Y)
#define DRIII(X,Y,Z) int X,Y,Z;scanf("%d%d%d",&X,&Y,&Z)
#define MS0(X) memset(X,0,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define RS(X) scanf("%s",X);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;

const LL MAXN=1000000;
const LL MOD=1e9+7;
LL f[MAXN];

int main(){
	f[0]=1;
	REPP(i,1,MAXN){
		f[i]=(f[i-1]*i)%MOD;
	}
	DRII(n,m);
	if(abs(n-m)>1){
		puts("0");return 0;
	}
	LL ans=(f[n]*f[m])%MOD;
	if(n==m)ans=(ans*2)%MOD;
	printf("%lld",ans);
}


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

using namespace std;

int main() {
	
	int N; cin >> N;
	pair<int, int> t[N]; // t for Task
	// cin >> t[0].second >> t[0].first; // {deadline, time}

	for (int i = 0; i < N; i++) {
		cin >> t[i].second >> t[i].first; // We put deadline into pair.first so that we can sort by it
	}
	sort(t, t+N); // Sort by deadline

	int sum = 0;
	int possible = true;
	for (int i = 0; i < N; i++) {
		sum += t[i].second;
		if (t[i].first < sum) possible = false;
		// cout << t[i].first << ' ' << sum << endl;
	}
	cout << (possible ? "Yes" : "No"); // Look at this one-line conditional
	return 0;
}

Measured memory_bytes: 5192
function main() {
  var
  line, a, b;
  for (;;) {
    n = parseInt(input.shift(), 10);
    if (n === 0) break;
    console.log(n.toString(8).split('').map(function (c) {
      return '01235789'.charAt(+c);
    }).join(''));
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 20140
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		InputReader in = new InputReader(System.in);
		int n = in.readInt();  
		long arr[] = new long[87]; 
		arr[0] = 2; 
		arr[1] = 1;
		for(int i = 2; i<=n; i++) {
			arr[i] = arr[i-2] + arr[i-1]; 
		}
		System.out.println(arr[n]);
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


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

int main() {
	string S;
	cin >> S;
	int Qnum;
	cin >> Qnum;
	int Tcount = 0;
	string mae;
	string ushiro;
	for (int i = 0; i < Qnum; i++) {
		int T;
		cin >> T;
		if (T == 1) Tcount++;
		else {
			int F;
			char C;
			cin >> F >> C;
			if ((F + Tcount) % 2 == 1) mae += C;
			else ushiro += C;
		}
	}
	reverse(mae.begin(), mae.end());
	if (Tcount % 2 == 1) {
		mae += S;
		mae += ushiro;
		reverse(mae.begin(), mae.end());
		cout << mae;
	}
	else {
		cout << mae << S << ushiro;
	}
}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

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

    for(int i = 0; i < t.length(); i++) {
        if(t[i] == '?') {
            t[i] = 'D';
        }
    }

    cout << t << endl;

    return 0;
}

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

int main(void) {
  int K, A, B;
  K = A = B = 0;
  int hoge = 0;
  int h = 0;

  cin >> K >> A >> B;

  for (; A <= B; A++) {
    if (0 == A % K) {
      hoge++;
      break;
    }
  }

  if (1 == hoge) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector <int> V;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=200000;
static const int NMAX=50;
static const int MMAX=50;
int n,a;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(i%2)dq.push_back(a);
        else dq.push_front(a);
    }
    
    if(n%2){
        for(auto it=dq.begin();it!=dq.end();it++)
            cout<<(it==dq.begin()?"":" ")<<*it;
    }else{
        for(auto it=dq.end()-1;it>=dq.begin();it--)
        cout<<(it==dq.end()-1?"":" ")<<*it;
    }
    cout<<"\n";
    
    
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <vector>
#include <set>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

int main(int argc, char* argv[])
{
	int			nLine;
	int			nColumn;
	char		chWord;
	int			nCount			= 0;

	cin >> nLine >> nColumn;

	for (int i = 1; i<= nLine; i++)
	{
		for (int j = 1; j <= nColumn; j++)
		{
			cin >> chWord;

			if (chWord == '#')
			{
				nCount++;
			}
		}
	}

	if (nCount != nLine + nColumn - 1)
	{
		cout << "Impossible" << endl;
	}
	else
	{
		cout << "Possible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		String ans = "Sunny";
		if (S.equals("Sunny")) {
			ans = "Cloudy";
		} else if (S.equals("Cloudy")) {
			ans = "Rainy";
		}
		System.out.println(ans);
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 3;
    if (a == b){
        ans --;
    }
    if (b == c){
        ans --;
    }
    if (c == a){
        ans --;
    }
    if (a == b && b == c){
        ans ++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if ((i + j) % 2 == 0)cout << "#";
				else cout << ".";
				if (j == W - 1)cout << endl;
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    int t1, t2;
    cin >> t1 >> t2;
    long long a1, a2;
    long long b1, b2;
    cin >> a1 >> a2 >> b1 >> b2;
    if (a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2){
        cout << "infinity" << endl;
        return 0;
    }
    if (a1 < b1){
        swap(a1, b1);
        swap(a2, b2);
    }
    if ((a1 * t1 + a2 * t2) > (b1 * t1 + b2 * t2)){
        cout << 0 << endl;
        return 0;
    }
    long long dis = abs((a1 * t1 + a2 * t2) - (b1 * t1 + b2 * t2));
    long long ok = 0;
    long long ng = 1e18;
    while (abs(ok - ng) > 1){
        long long mid = (ok + ng) / 2;
        if (log10(dis) + log10(mid) >= 18) {
            ng = mid;
            continue;
        }
        if (dis * mid > (a1 - b1) * t1) ng = mid;
        else ok = mid;
    }
    if (dis * ok == (a1 - b1) * t1) cout << ok * 2 << endl;
    else cout << ok * 2 + 1 << endl;
}

Measured memory_bytes: 512
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
int lev[300], n;
char g[300][300];
int bfs(int u)
{
    mem(lev,0);
    lev[u] = 1;
    queue<int> q;
    q.push(u);
    int d = 1;
    while(!q.empty()){
        u = q.front(); q.pop();
        f0(v,n) if(u!=v && g[u][v]=='1' && !lev[v])
        {
            lev[v] = lev[u]+1;
            d = max(lev[v], d);
            q.push(v);
        }
    }
    return d;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n;
    f0(i,n)
    {
        cin>>g[i];
    }
    int k  = 0;
    f0(i,n) k = max(k,bfs(i));
    //f0(i,n) cout << lev[i] << " ";
    f0(i,n) f0(j,n) if(i!=j)
    {
        if(g[i][j]=='1' && abs(lev[i] - lev[j])!=1){
            cout << "-1";
            return 0;
        }
    }
    cout << k;
    return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
B - Frog 2
https://atcoder.jp/contests/dp/tasks/dp_b
AC
"""
import sys
from sys import stdin


def solve(ashiba, N, K):
    dp = [float('inf')] * N
    dp[0] = 0
    for i in range(1, len(ashiba)):
        paths = [dp[j]+abs(ashiba[j]-ashiba[i]) for j in range(max(0, i-K), i)]
        dp[i] = min(paths)
    return dp[-1]


def main(args):
    N, K = map(int, input().split())
    ashiba = [int(i) for i in input().split()]
    ans = solve(ashiba, N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 55392
#include"bits/stdc++.h"
using namespace std;
int v[10000];
int main(){
	int T;
	cin>>T;
	double a,b,flag=0;
	double ans=99999999;
	cin>>a>>b;
	for(int i=1;i<=T;i++){
		scanf("%d",&v[i]);
		if(ans>=abs(b-(a-v[i]*0.006))){
			flag=i;
			ans=abs(b-(a-v[i]*0.006));
		}
	}
	cout<<flag<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
template <class X> void print(X x) { cout << x << endl; }
#define in(A, n)                                                                                                       \
    rep(i, n) {                                                                                                        \
        cin >> f;                                                                                                      \
        A.push_back(f);                                                                                                \
    }

void print(vl x) {
    for(ll i : x) {
        cout << i << " ";
    }
    cout << endl;
}
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v, m;
ll codeforces = 1;
string S, T;
vector<vl> g(MAX_N);
vl A, B;
void input() { cin >> n >> x >> m; }
void solve() {
    vl syuki(m, 0);
    while(syuki[x] == 0) {
        A.pb(x);
        syuki[x]++;
        x = (x * x) % m;
    }

    rep(i, A.size()) {
        if(A[i] == x) {
            a = i;
            break;
        }
    }

    // print(A);
    // print(a);
    if(n < a) {
        rep(i, n) { ans += A[i]; }
        print(ans);
    } else {
        rep(i, a) { ans += A[i]; }
        n -= a;
        k = n / (A.size() - a);
        t = n % (A.size() - a);
        rep(i, A.size() - a) { p += A[i + a]; }
        ans += p * k;
        rep(i, t) { ans += A[i + a]; }
        print(ans);
    }
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    while(codeforces--) {
        solve();
    }
}

Measured memory_bytes: 16276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int M = 1000000000;
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    ll N, K, S;
    cin >> N >> K >> S;
    vll l(K + 1), r(K + 1), A(N);
    ll c = 0;
    if (N == K)
    {
        rep(i, N)
        {
            A[i] = S;
        }
    }
    else if (S != 1)
    {
        rep(i, N)
        {
            if (c < K)
            {
                if (i % 2 == 0)
                {

                    A[i] = 1;
                    if (i != 0)
                        c++;
                }
                else
                {
                    A[i] = S - 1;

                    c++;
                }
            }
            else
            {
                if (S != M and S != M - 1)
                    A[i] = M;
                else
                {
                    A[i] = 2;
                }
            }
        }
    }
    else if (S == 1)
    {
        rep(i, N)
        {
            if (i < K)
                A[i] = 1;
            else
            {
                A[i] = 2;
            }
        }
    }

    rep(i, N)
    {
        cout << A[i] << endl;
    }
    return 0;
}

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

int main() {
    double a, b, x; cin >> a >> b >> x;
    double h = x / (a*a);
    double theta;
    if (b <= 2 * h) {
        // 台形
        theta = atan(2 * b / a - (2*x) / (a*a*a));
    } else {
        // 三角形
        theta = atan((a*b*b) / (2*x));
    }
    cout << setprecision(10) << (180.0 * theta) / M_PI << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().ToCharArray();
        if (s.Length % 2 == 1)
        {
            Console.WriteLine("No");
            return;
        }
        for (var i = 0; s.Length > i; i+=2)
        {
            if (s[i] != 'h' || s[i + 1] != 'i')
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 13140
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

b = S()
if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "G":
    print("C")
else:
    print("G")

Measured memory_bytes: 3564
#include <bits/stdc++.h>
// #include <atcoder/all>

using std::cin;
using std::cout;
using std::vector;
// using namespace atcoder;
typedef long long ll;

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << std::endl;
#else
#define DEBUG(x)
#endif

#define ALL(obj) (obj).begin(), (obj).end()
#define BIT(n) (1LL << (n))

const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    // write code below
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 0; i < n + 1; i++)
    {
        a[i] = 0;
    }
    a[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        if (i - 3 >= 0)
            a[i] = a[i - 1] + a[i - 3];
        a[i] %= MOD;
    }
    cout << a[n] << std::endl;

    // write code above
    return 0;
}


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

using namespace std;
#define pb push_back

typedef long long ll;

int n;
const int maxn = 1e5+5;
ll MOD = 1e9+7;
vector<int> G[maxn];
ll dp[2][maxn];

ll dfs(bool c, int u, int p) //
{
  if(dp[c][u] != -1ll) return dp[c][u];
  ll ret = 1ll;
  for(auto v: G[u])if(v!=p)
  {
    if(c) ret = (ret*dfs(0, v, u))%MOD;
    else ret = (ret*(dfs(0, v, u)+dfs(1, v, u)))%MOD; //care overflow
  }
  return dp[c][u] = ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n;
  int tu, tv;
  for(int i = 0; i < n-1; i++)
  {
    cin >> tu >> tv;
    G[tu].pb(tv);
    G[tv].pb(tu);
  }
  G[0].pb(1);
  memset(dp, -1ll, sizeof(dp));
  cout << dfs(0, 0, -1) << endl; //color not black in psuedo root nxt to node 1

  return 0;
}


Measured memory_bytes: 15616
let () = Scanf.scanf "%d\n" @@ fun n ->
  let vs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun v -> v in
  let cs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun c -> c in
  Printf.printf "%d\n" @@ Array.fold_left ( + ) 0 @@ Array.init n @@ fun i -> max 0 @@ vs.(i) - cs.(i)


Measured memory_bytes: 384
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    string s;
    cin >> s;
    if (s.find('A') != string::npos && s.find('B') != string::npos)
        print("Yes");
    else
        print("No");

    return 0;
}



Measured memory_bytes: 256
N = int(input())
S1 = input()
S2 = input()
mod = 1000000007
j = 0
if S1[0] == S2[0]:
    ans = 3
else:
    ans = 6
while 1:
    if S1[j] == S2[j]:
        j += 1
        if j >= N:
            break
        ans = (ans*2)%mod
    else:
        j += 2
        if j >= N:
            break
        if S1[j] != S2[j]:
            ans = (ans*3)%mod
print(ans)

Measured memory_bytes: 3064
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

N, X, T = map(int, input().split())

val = N // X
if N % X == 0:
    print(val * T)
else:
    print((val + 1) * T)


Measured memory_bytes: 65260
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	if(a==1||b==1){
		cout<<abs(max(a,b)-2)<<endl;
	}
	else cout<<(a-2)*(b-2)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
string s,c;
int main(){
	cin>>s>>c;
	int lens=s.size(),lenc=c.size();
	int len=max(lens,lenc);
	for(int i=0;i<len;i++)
		if(i<lens&&i<lenc)printf("%c%c",s[i],c[i]);
		else if(i<lens)printf("%c",s[i]);
		else printf("%c",c[i]);
	puts("");
	return 0;
}

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

int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double da = h/6.0 + m*2.0/(60.0*12.0);
    double db = m / 30.0;
    double dd = abs(da-db);
    // cout << da  << " " << db << " " << dd << endl;
    cout << fixed << setprecision(10) << sqrt((double)a*a + (double)b*b - 2.0 * (double)a*(double)b*cos(dd*PI)) << endl;
    return 0;
}

Measured memory_bytes: 4192
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>
#include <vector>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)

const int INF = 1e9;

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int a[n][m];
    int b[m];
    int res[n];
    REP(i, n)
        REP(j, m)
            cin >> a[i][j];
    REP(i, m)
        cin >> b[i];
    REP(i, n){
        res[i] = 0;
        REP(j, m)
            res[i] += (a[i][j] * b[j]);
        }

    REP(i, n)
        cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[101010];
ll b[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
string s[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
ll sr,sc;
int main() {
    cin>>N;
    ll acount=0;
    ll bcount=0;
    ll bacount=0;
    rep(i,0,N){
        cin>>s[i];
        if(s[i][0]=='B' && s[i][s[i].size()-1]=='A'){
            bacount++;
        }else if(s[i][0]=='B'){
            bcount++;
        }else if(s[i][s[i].size()-1]=='A'){
            acount++;
        }
        rep(j,0,s[i].size()){
            
            if(j==0)continue;
            if(s[i][j-1]=='A' && s[i][j]=='B'){
                ans++;
            }
        }
    }
    if(bacount>0){
        ans+=bacount-1;
        if(acount!=0 ||bcount!=0)ans++;
    }
    cout<<ans+min(acount,bcount)<<endl;
    cerr<<acount<<" "<<bcount<<endl;
	return 0;
}


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



int main() {
  int n, q;
  cin >> n >> q;
  vector<ll> a(n);
  rep(i, n){
    cin >> a[i];
  }
  rep(i,q){
    ll x;
    cin >> x;
    ll ans = 0;
    ll sum = 0;
    int right = 0;
    for (int left = 0; left < n; left++){
      while(right < n &&sum + a[right] <= x){
        sum += a[right];
        right++;
      }
      ans += right - left;
      if(right == left)right++;
      else sum -= a[left];
    }
    cout << ans << endl;
  }
}


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

const int N = 1e5 + 10;

int n, a[N];

inline int read() {
    int x = 0, k = 1; char c = getchar();
    for (; c < 48 || c > 57; c = getchar()) k ^= (c == '-');
    for (; c >= 48 && c <= 57; c = getchar()) x = x * 10 + (c ^ 48);
    return k ? x : -x;
}

inline bool cmp(int x, int y) {
    return x > y;
}

int main() {
    n = read();
    for (int i = 1; i <= n; i++)
        a[i] = read();
    std::sort(a + 1, a + 1 + n, cmp);
    
    int t = 1;
    for (; t < n && t < a[t + 1]; t++);
    int w = n + 1;
    for (; w > 1 && a[w - 1] < t; w--);
    w = w - 1;
    if ((a[t] - t) % 2 == 1 || ((w >= t) && (a[w] >= t) && (w - t) % 2 == 1))
        puts("First");
    else
        puts("Second");
    return 0;
}

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

int main()
{
	int a, b;
	int sum = 0;
	cin >> a >> b;

	if (a > b)
	{
		sum += a;
		--a;
	}
	else
	{
		sum += b;
		--b;
	}

	if (a > b)
	{
		sum += a;
		--a;
	}
	else
	{
		sum += b;
		--b;
	}

	cout << sum;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 1e6 + 10;
int pre[N], n, sub[N];
char s[N], t[N];

bool chkpre(int x) {
    return x % (x - pre[x]) > 0 || !pre[x];
}

bool chksub(int x) {
    return x % (x - sub[x]) > 0 || !sub[x];
}

void getfail(char *s, int *nxt) {
    nxt[0] = nxt[1] = 0;
    int j = 0;
    rep(i, 1, n - 1) {
        while(j && s[i] != s[j]) j = nxt[j];
        nxt[i + 1] = (s[i] == s[j] ? ++j : 0);
    }
}

int main() {
    scanf("%s", s);
    n = strlen(s);
    rep(i, 0, n - 1) t[i] = s[n - i - 1];
    t[n] = '\0';

    getfail(s, pre), getfail(t, sub);
    
    int flag = chkpre(n) ? 1 : 2;
    bool f = 1;
    rep(i, 1, n - 1) if (s[i] != s[i - 1]) { f = 0; break; }
    if (f) flag = n;
    printf("%d\n", flag);
    if (flag != 2) { puts("1"); return 0; }

    int ans = 0;
    rep(i, 0, n - 1) {
        int x = n - i - 1;
        if (chkpre(i + 1) && chksub(x)) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define F first
#define S second
#define pb push_back
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vLL vector<LL>
#define vpint vector<pair<int, int>>
#define vpLL vector<pair<LL, LL>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(n) \
    for (int i = 0; i < n; i++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long LU;
const LL mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define fi first
#define se second 
signed main(){
  int h,w,k,ans=0,b,p,sum=0;
  string c[10],s[10];
  cin>>h>>w>>k;
  for(int i=0;i<h;i++){
    cin>>c[i];
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(c[i][j]=='#') sum++;
    }
  }
  for(int i=0;i<(1<<h);i++){
    b=0;
    for(int j=0;j<h;j++){
      s[j]=c[j];
    }
    
    for(int j=0;j<h;j++){
      if(i&(1<<j)){
	for(int k=0;k<w;k++){
	  if(s[j][k]=='#') b++,s[j][k]='.';
	}
      }
    }
    for(int j=0;j<(1<<w);j++){
      p=0;
      for(int k=0;k<w;k++){
	if(j&(1<<k)){
	  for(int l=0;l<h;l++){
	    if(s[l][k]=='#') p++;
	  }
	}
      }
      //cout<<sum<<" "<<b<<" "<<p<<" "<<sum-b-p<<"\n";
      if(sum-b-p==k){
	ans++;
      }
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 3628
using System;
 
class Program
{
    static void Main(string[] arg)
    {
        int N = int.Parse(Console.ReadLine());
        string[] tmp = Console.ReadLine().Split(' ');
        ulong[] num = new ulong[N];

        for (int i = 0; i < N; i++)
        {
            num[i] = ulong.Parse(tmp[i]);
            if (num[i] == 0)
            {
                Console.WriteLine("0");
                return;
            }
        }

        ulong ret = 1;

        try
        {
            checked
            {
                for (int i = 0; i < N; i++)
                {
                    ret *= num[i];
                }
            }
        }
        catch (OverflowException ex)
        {
            Console.WriteLine("-1");
            return;
        }

        if (ret > (ulong)Math.Pow(10, 18))
        {
            Console.WriteLine("-1");
            return;
        }
        else
        {
            Console.WriteLine(ret);
        }

        return;
    }
}

Measured memory_bytes: 41896
#include <bits/stdc++.h>
 
using namespace std;
 
typedef int in;
#define int long long
 
in main() {
    int n;
    cin >> n;
    vector<pair<int,int> > v;
    for(int i = 0 ; i < n ; i ++){
        int a;
        cin >> a;
        v.push_back({a,i + 1});
    }
    sort(v.begin(),v.end());
    for(int i = 0 ; i < n ; i ++){
        if(i){
            cout << " ";
        }
        cout << v[i].second;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2544
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N, A, B;
	cin >> N >> A >> B;
 
	// 解法
	if (N==1) printf("Hello World\n");
	else printf("%lld\n", A+B);
}
 


Measured memory_bytes: 256