akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll tot = 0;
	ll res1 = 0;
	{//i = 0 -> +
		rep(i, n) {
			if (i % 2 == 0) {
				if (tot + a[i] > 0) tot += a[i];
				else {
					res1 += 1 - tot - a[i];
					tot = 1;
				}
			}
			else {
				if (tot + a[i] < 0) tot += a[i];
				else {
					res1 += 1 + tot + a[i];
					tot = -1;
				}
			}
		}
	}
	tot = 0;
	ll res2 = 0;
	{//gyaku
		rep(i, n) {
			if (i % 2 != 0) {
				if (tot + a[i] > 0) tot += a[i];
				else {
					res2 += 1 - tot - a[i];
					tot = 1;
				}
			}
			else {
				if (tot + a[i] < 0) tot += a[i];
				else {
					res2 += 1 + tot + a[i];
					tot = -1;
				}
			}
		}
	}
	ll ans = min(res1, res2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

struct Packet{
    int time,from,to;
    Packet(int time,int from,int to) : time(time),from(from),to(to) {};
};
bool op(Packet left,Packet right){
    return left.time < right.time;
}

int main(){
    while(true){
        int N,M;
        cin >> N >> M;
        if(N == 0 and M == 0) break;
        vector<Packet> packets;
        vector<char> isInfected(N,false);
        isInfected[0] = true;
        for(int i=0;i<M;i++){
            int t,s,d;
            cin >> t >> s >> d;
            s--;d--;
            packets.push_back(Packet(t,s,d));
        }
        sort(all(packets),op);
        for(int i=0;i<M;i++){
            int from = packets[i].from;
            int to = packets[i].to;
            if(isInfected[from]) isInfected[to] = true;
        }
        int cnt = 0;
        for(int i=0;i<N;i++){
            if(isInfected[i]) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

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


int main() {
    int n, a;
    cin >> n >> a;
    while(n >= 500){
        n-=500;
    }
    if(n == 0){
        puts("Yes");
    } else if(a >= n){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, raw_input().split())
S = raw_input()
jp, x = 0, 0

for i in xrange(N):
    if S[i] == 'c':
        print 'No'
    elif jp + x == A+B:
        print 'No'
    elif S[i] == 'b' and x < B:
        x += 1
        print 'Yes'
    elif S[i] == 'a' and x + jp < A+B:
        jp += 1
        print 'Yes'
    else:
        print 'No'

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    vector<vector<bool>> A;
    ll W, H, N;
    ll count = 0;
    cin >> W >> H >> N;
    A.resize(H, vector<bool>(W));
    for(ll i = 0;i < N;i++) {
        ll x, y, a;
        cin >> x >> y >> a;
        if(a == 1) {
            for(ll i = 0;i < x;i++) {
                for(auto &j: A) j[i] = true;
            }
        } else if(a == 2) {
            for(ll i = W - 1;i >= x;i--) {
                for(auto &j: A) j[i] = true;
            }
        } else if(a == 3) {
            for(ll i = H - 1;i >= H - y;i--) {
                for(ll j = 0;j < A[i].size();j++) A[i][j] = true;
            }
        } else {
            for(ll i = 0;i < H - y;i++) {
                for(ll j = 0;j < A[i].size();j++) A[i][j] = true;
            }
        }
    }
    for(auto &i: A) {
        for(auto j: i) {
            if(!j) count++;
        }
    }
    cout << count << endl;
    return 0;
}


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

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

    ll ans = a * c;

    if(ans < a * d){
        ans = a * d;
    }
    if(ans < b * c){
        ans = b * c;
    }
    if(ans < b * d){
        ans = b * d;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a * b > c * d){
		cout << a * b << endl;
	}else{
		cout << c * d << endl;
	}
	return 0;
}

Measured memory_bytes: 256
main :: IO()
main = do
  n <- readLn :: IO Int
  let
    left = (0, 0)
    right = (100, 0)
  outputPoint left
  koch n left right
  outputPoint right


koch :: Int -> (Float, Float) -> (Float, Float) -> IO()
koch 0 _ _ = return ()
koch n left@(x1, y1) right@(x2, y2) = do
  let
    s = ((2 * x1 + x2) / 3, (2 * y1 + y2) / 3)
    t = ((x1 + 2 * x2) / 3, (y1 + 2 * y2) / 3)
    u =
      (
        (fst t - fst s) * (cos $ pi / 3) - (snd t - snd s) * (sin $ pi / 3) + fst s,
        (fst t - fst s) * (sin $ pi / 3) + (snd t - snd s) * (cos $ pi / 3) + snd s
      )
  koch (n - 1) left s
  outputPoint s
  koch (n - 1) s u
  outputPoint u
  koch (n - 1) u t
  outputPoint t
  koch (n - 1) t right

outputPoint :: (Float, Float) -> IO()
outputPoint (x, y) = putStrLn $ (show x) ++ " " ++ (show y)



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

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i = 0; i < h; i++) {
        cin >> a[i];
    }

    vector<bool> row(h, false);
    vector<bool> col(w, false);

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(a[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for(int i = 0; i < h; i++) {
        if(row[i]){
            for(int j = 0; j < w; j++) {
                if(col[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }



    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.PriorityQueue;
import java.util.Comparator;

public class Main {
	class Edge{
		int p, q;
		double cost;
		Edge(int p, int q, double cost){
			this.p = p; this.q = q;
			this.cost = cost;
		}
	}
	int[] par;
//	union-findの木の初期化
	void unionfindInit(int n){
		for(int i = 0;i < n;i++) {
			par[i] = i;
		}
	}
//	木の根を求める
	int unionfindRoot(int x) {
		if(par[x]==x) {
			return x;
		}
		else {
			return par[x] = unionfindRoot(par[x]);
		}
	}
//	xとyが同じ集合に属するか否か
	boolean unionfindSame(int x, int y) {
		return unionfindRoot(x) == unionfindRoot(y);
	}
	
//	xとyの属する集合を併合
	void unionfinUnite(int x, int y) {
		x = unionfindRoot(x);
		y = unionfindRoot(y);
		if (x == y) return;
		par[x]=y;
	}
	void run(){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		par = new int[N+1];
		int M = scan.nextInt();
		int coordinate[][] = new int[N+1][2];
		int p, q;
		double hen1, hen2;
		double[] hypotenuse = new double[M]; //パイル間の距離
		PriorityQueue<Edge> edge = new PriorityQueue<Edge>(new Comparator<Edge>() {
			@Override
			public int compare(Edge e1, Edge e2) {
				if(e2.cost > e1.cost) {
					return 1;
				}
				else if(e2.cost < e1.cost){
					return -1;
				}
				return 0;
			}
		});
		Edge tmp = new Edge(0,0,0);
//		釘の座標情報
		for(int i=1; i< N+1;i++) {
			coordinate[i][0] = scan.nextInt();;
			coordinate[i][1] = scan.nextInt();;
		}
//		フェンスの情報
		unionfindInit(N+1);
		for(int i=0; i < M; i++) {
			p = scan.nextInt();
			q = scan.nextInt();
			hen1 = Math.abs(coordinate[p][0] - coordinate[q][0]);
			hen2 = Math.abs(coordinate[p][1] - coordinate[q][1]);
			hypotenuse[i] = Math.sqrt(hen1*hen1+hen2*hen2);
			edge.offer(new Edge(p, q, hypotenuse[i]));
		}
//		System.out.println("mainasu: " + mainasu_sum);
		double sum=0;
		for(int i = 0; i < M; i++) {
			tmp = edge.poll();
			if(!unionfindSame(tmp.p, tmp.q)) unionfinUnite(tmp.p, tmp.q);
			else {
				sum += tmp.cost;
//				System.out.println("tmp: " + tmp.cost);
			}
		}
		System.out.println(sum);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 68376
from collections import deque
n = int(input())
S = deque()
for i in range(n):
    l = input().split()
    if l[0] == "insert":
        S.appendleft(l[1])
    elif l[0] == "deleteFirst":
        S.popleft()
    elif l[0] == "deleteLast":
        S.pop()
    elif l[0] == "delete":
        try:
            S.remove(l[1])
        except:
            pass
print(*S)



Measured memory_bytes: 69740
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner input = new Scanner(System.in);
    int n, i;
    int pn, num;

    while (true){
      int m, p;
      m = p = 0;
      n = input.nextInt();
      if (n == 0) break;
      for (i = 0; i < n; i++){
        pn = input.nextInt();
        num = input.nextInt() + input.nextInt();
        
        if (num > m){
          m = num;
          p = pn;
        }
      }
      System.out.println(p + " " + m);
    }
  }
}

Measured memory_bytes: 161388
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N >> M;
	vector<vector<bool>>flag(N + 1,vector<bool>(N+1,false));
	vector<int>edge;
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		edge.push_back(L);
		edge.push_back(R);
		flag[L][R] = true;
		flag[R][L] = true;
	}
	long long int ans = 0;
	K = edge.size() / 2;
	for (int i = 0; i < K; i++) {
		L = edge[i * 2];
		R = edge[i * 2 + 1];
		flag[L][R] = false;
		flag[R][L] = false;
		vector<int>dis(N + 1, INT_MAX);
		dis[1] = 0;
		queue<int>Q;
		Q.push(1);
		while (!Q.empty()) {
			int cn = Q.front();
			int c = dis[cn];
			Q.pop();
			for (int j = 1; j <= N; j++) {
				if (flag[cn][j]) {
					if (dis[j] > c + 1) {
						dis[j] = c + 1;
						Q.push(j);
					}
				}
			}
		}
		for (int i = 1; i <= N; i++) {
			if (dis[i] == INT_MAX) {
				ans++;
				break;
			}
		}
		flag[L][R] = true;
		flag[R][L] = true;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cctype>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  int cnt = 0;
  while (true) {
    for (auto& a : v) {
      if (a % 2 == 0) {
        a /= 2;
      } else {
        cout << cnt << endl;
        return 0;
      }
    }
    cnt++;
  }
}


Measured memory_bytes: 256
def fanction(n):
    listIn = []
    tmp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if tmp % i == 0:
            cnt_in = 0
            while tmp % i ==0:
                cnt_in += 1
                tmp //= i
            listIn.append([i, cnt_in])

    if tmp != 1:
        listIn.append([tmp, 1])

    return listIn
    
N = int(input())

arr = fanction(N)

tmp = 1
count = 0
for a, b in arr:
    while 'true':
        if b >= tmp:
            b -= tmp
            count += 1
            tmp += 1
        else:
            tmp = 1
            break

print(count)

Measured memory_bytes: 9480
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a, b;

signed main() {
	cin >> n >> a >> b;
	if ((b - a) % 2) {
		cout << min(a + (b - a - 1) / 2, (n - b + 1) + (n - (a + n - b + 1)) / 2) << endl;
	}
	else cout << (b - a) / 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
    char w[11]={0,},t[1001]={0,},eot[]="END_OF_TEXT";
    int count=0,tsize,i;
    scanf("%s", &w);
    while(1){
		scanf("%s", &t);
		if(strcmp(t,eot)==0) break;
		tsize=strlen(t);
		for(i=0;i<tsize;i++){
			if(65<=t[i] && t[i]<=90) t[i]+=32;
		}
		if(strcmp(t,w)==0) count++;
	}
    printf("%d\n",count);
    return 0;   
}

Measured memory_bytes: 548
#include <iostream>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <vector>;
using namespace std;

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

	vector<long long >p(n);
	vector<long long >m(n);

	for (int i = 0;i < n;i++) {
		int x, y;
		cin >> x >> y;
		p[i] = x + y;
		m[i] = x - y;
	}
	sort(p.begin(), p.end());
	sort(m.begin(), m.end());

	long long a = max(p[n - 1] - p[0], m[n - 1]-m[0]);

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
int main() {
	ll N;
	cin >> N;
	for (ll h = 1; h <= 3500; h ++)
		for (ll n = 1; n <= 3500; n ++)
			if (4 * h * n - n * N - h * N > 0) 
				if (h * n * N % (4 * h * n - n * N - h * N) == 0) {
					ll w = h * n * N / (4 * h * n - n * N - h * N);
					if (w > 3500 || w < 0) continue;
					cout << h << " " << n << " " << w << endl;
					return 0;
				}
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def inv_mod(a, N):
    """
    Fermatの小定理より(Nが素数のときしか使えない)
    aの逆元 ax = 1 (mod N)を満たすx = a^(N-2) mod Nを返す。
    O(log N)
    """

    def bpm(x, y, N):
        """
         Bisection power method : 二分累乗法
         O(log y)でx^(y) mod N を求める。
        """
        ans = 1
        x %= MOD
        digit = int((math.log(y, 2) // 1 + 1))  # yの２進数表示の桁数
        for i in range(digit):
            if (y >> i) & 1 == 1:
                ans *= x
                ans %= MOD
            x **= 2
            x %= MOD
        return ans

    return bpm(a, N - 2, N)


def bpm(x, y, N):
    """
     Bisection power method : 二分累乗法
     O(log y)でx^(y) mod N を求める。
    """
    ans = 1
    x %= MOD
    digit = int((math.log(y, 2) // 1 + 1))  # yの２進数表示の桁数
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


n, a, b = map(int, input().split())

nCa = 1
nCb = 1

inv_list = [1]  # 0で割るというのは定義されないので無視。
for i in range(max(a, b)):
    inv_list.append(int(MOD - inv_list[(MOD % (i + 2)) - 1] * (MOD // (i + 2)) % MOD))

for i in range(a):
    nCa *= inv_list[i]
    nCa %= MOD
    nCa *= n - i
    nCa %= MOD

for i in range(b):
    nCb *= inv_list[i]
    nCb %= MOD
    nCb *= n - i
    nCb %= MOD

print((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)


Measured memory_bytes: 13116
def gen_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    return divisors


N = int(input())

divisors = gen_divisors(N)
divisors.remove(1)
ans = sum([d-1 for d in divisors if N//(d-1) == N%(d-1)])

print(ans)


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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10E9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)
#define PI 3.141592653589793

template<class T> bool minn(T &a ,T b){ return (a > b ? (a = b , true) : false); };
template<class T> bool maxn(T &a ,T b){ return (a < b ? (a = b , true) : false); };

                                     
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

  long r; cin >> r;
  cout << (3 * r * r) << endl;
                                             
#ifdef LOCAL_DEFINE 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

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

using namespace std;

void solve(){
    int n,k;
    while(cin>>n>>k){
        if(k==1) cout<<0<<endl;
        else cout<<n-k<<endl;
    }
}

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




Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,m,n;
    char a[100000] ,b[100000];
    scanf("%d ",&n);
    scanf("%s",a);
    scanf(" %s",b);
    for(i=0;i<n;i++)
    {
        printf("%c%c",a[i],b[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		HashSet<Integer> scores = new HashSet<Integer>();
		for(;;) {
			String[] str = sc.next().split(",");
			int a = Integer.parseInt(str[0]), b = Integer.parseInt(str[1]);
			if( (a|b) == 0 ) break;
			map.put(a, b);
			scores.add(b);
		}
		int[] ans = new int[scores.size()];
		int i=0;
		for(int a: scores) ans[i++] = a;
		sort(ans);
		while(sc.hasNext()) {
			int q = sc.nextInt();
			System.out.println( (ans.length - binarySearch(ans, map.get(q))) );
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 11000
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

 string S,T;
 cin >> S >> T;
 cout << T << S;










	return 0;

}



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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, A, B, C, D;
    std::cin >> N >> A >> B >> C >> D;
    A--; B--; C--; D--;

    string S;
    std::cin >> S;

    vector<int> table(N, 0);
    for(int i = 1; i < N; i++) {
        table[i] = (S[i] == '#' && S[i - 1] == '#') ?
            table[i - 1] + 1 : table[i - 1];
    }

    string ans = "Yes";
    if(table[A] != table[max(C, D)]) {
        ans = "No";
    }
    else if(D < C) {
        bool ok = false;
        for(int i = B - 1; i <= D - 1; i++) {
            if(i + 2    <  N   &&
               S[i]     == '.' &&
               S[i + 1] == '.' &&
               S[i + 2] == '.') {
                ok = true;
                break;
            }
        }
        if(!ok) {
            ans = "No";
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1360
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int& a, int b) { if (a < b) { a = b; return true; } else return false; }

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

	if (s.size() % 2 == 0) {
		for (int i = 0; i < s.size(); i += 2) {
			if (s[i] != 'h' || s[i + 1] != 'i') {
				cout << "No" << endl;
				return 0;
			}
	  }
	}
	else {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
using namespace std;
int usi[213456];
string uiop[213456];
signed main() {
	int n, m, k = 0, a = 1, ans = 0; string s, t; cin >> n >> m;
	while (n >= a) {
		a *= m;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
ll n;
cin >> n;
ll ans = 100000000000000000;
for (ll i = 1;i*i <= n;i++) {
  ll k;
  if (n % i == 0) {
    k = n/i;
    ans = min(ans,i+k-2);
  }
}
cout << ans << endl;


return 0;
}



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

using namespace std;

const int N = 5000;
char a[N + 3];
char ans[N + 3][N + 3];
char mnc;
int n, m, num;

bool cmp(int x, int y) {
    for (int i = 1; i <= n; ++i) {
        if (ans[x][i] < ans[y][i]) return true;
        if (ans[x][i] > ans[y][i]) return false;
    }
    return false;
}

int main() {
    scanf("%d %d", &n, &m);
    scanf("%s", a + 1);
    mnc = 'z';
    for (int i = 1; i <= n; ++i) {
        mnc = min(mnc, a[i]);
    }
    if (m >= 14) {
        for (int i = 1; i <= n; ++i) {
            printf("%c", mnc);
        }
        return 0;
    }
    int len = 0, mxl = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[i] != mnc) len = 0;
        else len++;
        if (len > mxl) {
            mxl = len;
        }
    }
    len = 0;
    num = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[i] != mnc) len = 0;
        else len++;
        if (i == n) {
            num++;
            int tmp = min(n, len* (1 << m));
            for (int j = 1; j <= tmp; ++j) {
                ans[num][j] = mnc;
            }
            for (int j = tmp + 1, k = n - len; j <= n; ++j, k--) {
                ans[num][j] = a[k];
            }
        }
        if (len == mxl) {
            num++;
            int tmp = min(n, len * (1 << m - 1));
            for (int j = 1; j <= tmp; ++j) {
                ans[num][j] = mnc;
            }
            for (int j = tmp + 1, k = i + 1; j <= n; ++j, ++k) {
                ans[num][j] = a[k <= n ? k : 2 * n + 1 - k];
            }
        }
    }

    int fans = 1;
    for (int i = 1; i <= num; ++i) {
        if (cmp(i, fans)) {
            fans = i;
        }
    }
    for (int j = 1; j <= n; ++j) {
        printf("%c", ans[fans][j]);
    }
    return 0;
} 

Measured memory_bytes: 8448
#include <iostream>

using namespace std;

int amida[11];
int n, m, correct, d;

void init()
{
    for (int i = 1; i <= n; i++)
           amida[i] = i;
}

int main()
{
    while (cin >> n, n) {
        string inp[31];

        cin >> m >> correct >> d;
         for (int i = 0; i < d; i++)
            cin >> inp[i];
         init();

        for (int i = 0; i < d; i++) {
            for (int j = 0; j < inp[i].size(); j++)
                if (inp[i][j] == '1')
                    swap(amida[j + 1], amida[j + 2]);
        }

        if (amida[correct] == m)
            cout << 0 << endl;
        else {
            bool flag = false;
            int ans = amida[correct];

            init();
            for (int i = 0; i < d; i++) {
                for (int j = 0; j < inp[i].size(); j++)
                    if (inp[i][j] == '1')
                        swap(amida[j + 1], amida[j + 2]);

                for (int j = 1; j < n; j++) {
                    if ((amida[j] == m && amida[j + 1] == ans)
                        || (amida[j] == ans && amida[j + 1] == m)) {

                        if (inp[i][j - 1] == '1' || inp[i][j] == '1')
                            continue;
                        else if (j > 1 && inp[i][j - 2] == '1')
                            continue;
                        flag = true;
                        cout << i + 1 << " " << j << endl;

                        break;
                    }
                }
                if (flag)
                    break;
            }
            if (!flag)
                cout << 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1208
N = int(input())
K = int(input())
L = len(str(N))

suu = []
for i in range(L):
    suu.append(int(str(N)[i]))

DP_1 =[[0 for k in range(L+2)] for i in range(L+1)]
DP_2 =[[0 for k in range(L+2)] for i in range(L+1)]
DP_2[0][0] = 1
for i in range(L):
    for k in range(L+1):
        DP_1[i+1][k] = DP_1[i][k] + DP_1[i][k-1] * 9 
        if suu[i]:
            DP_1[i+1][k] += DP_2[i][k] + DP_2[i][k-1] * max(suu[i] - 1, 0)
            DP_2[i+1][k] = DP_2[i][k-1]
        else:
            DP_2[i+1][k] = DP_2[i][k]
print(DP_1[L][K]+ DP_2[L][K])

Measured memory_bytes: 3440
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
 
void solve()
{
    int n; cin>>n;
    multiset<int> s;
    rep(i,0,n)
    {
        int x; cin>>x;
        multiset<int>::iterator it = s.lower_bound(x);
        if(it == s.begin())
        {
            s.insert(x);
            continue;
        }
        it--;
        s.erase(it);
        s.insert(x);
    }
    cout<<(int)s.size();
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), m = fs.nextInt();
		int s[] = new int[n];
		Arrays.fill(s, -1);
		
		for(int i=0;i<m;i++) {
			int d = fs.nextInt()-1;
			int c = fs.nextInt();
			if(s[d]==-1) {
				s[d] = c;
			}
			else if(s[d]!=c) {
				System.out.println(-1);
				return;
			}
		}
		
		if(n>=2&&s[0]==0) {
			System.out.println(-1);
			return;
		}
		
		for(int i=0;i<n;i++) {
			if(s[i] == -1) {
				if(n>=2&&i==0)s[i]=1;
				else s[i] = 0;
			}
		}
		
		String ans = "";
		for(int i=0;i<n;i++) {
			ans += s[i];
		}
		System.out.println(ans);
		
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	string s;
	// nyuryoku
	cin >> s;
	int y = (s[0]-'0')*1000 + (s[1] - '0')*100 + (s[2] - '0')*10 + (s[3] - '0');
	int m = (s[5] - '0')*10 + (s[6]- '0');
	int d = (s[8] - '0')*10 + (s[9] - '0');
 	// keisan
 	if(y < 2019){
 		cout << "Heisei" << endl;
 	}else if(y > 2019){
 		cout << "TBD" << endl;
 	}else if(m > 4){
 		cout << "TBD" << endl;
 	}else{
 		cout << "Heisei" << endl;
 	}
	// syutsuryoku
}

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

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3632
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))


Measured memory_bytes: 20572
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n;
	while (cin >> n,n) {
		int Sum = 0;
		int Max = -1;
		int Min = 1001;
		for (int i = 0; i < n; i++) {
			int a; cin >> a;
			Sum += a; Max = max(Max, a); Min = min(Min, a);
		}
		Sum -= Max + Min;
		cout << Sum / (n - 2) << endl;
	}
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
//void swap(ll a,ll b){
//	ll d;
//	d=a;
//	a=b;
//	b=d;
//	return;
//}
ll mypow(ll x,int m){
	if(m==0)return 1;
	if(m%2==0){
		int x2=mypow(x,m/2);
		return x2*x2;
	}else{
		int x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
//    	cout<<b<<endl;
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int h,w,k;
char str[302][302];
int m[303]={};
int ans[303];
int ksi=1;
int main() {
	cin>>h>>w>>k;
	rep(i,0,h){
		rep(j,0,w){
			cin>>str[i][j];
			if(str[i][j]=='#'){
				m[i]++;
				ans[i]=ksi;
				ksi++;
			}
		}
	}
	int g=1,x=1;
	int now[303];
	rep(i,0,h){
//		cout<<m[i]<<endl;
		if(m[i]==0){
			x++;
			continue;
		}
		rep(j,0,w){
			now[j]=g;
			if(ans[i]!=g&&str[i][j]=='#'){
				g++;
			}
		}
		rep(l,0,x){
			rep(j,0,w-1){
				cout<<now[j]<<" ";
			}
			cout<<now[w-1]<<endl;
		}
		g++;
		x=1;
	}
	rep(l,0,x-1){
		rep(j,0,w-1){
			cout<<now[j]<<" ";
		}
		cout<<now[w-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 896
def YesNo(b):
    print("Yes" if b else "No")


def solve(l, t0, t):
    s = {t0}
    for v in l:
        s, ps = set(), s
        for a in ps:
            s.add(a+v)
            s.add(a-v)
    return t in s


s = input()
x, y = map(int, input().split())

f = s.split('T')
x0 = len(f[0])
xl = [len(v) for v in f[2::2]]
yl = [len(v) for v in f[1::2]]

YesNo(solve(xl, x0, x) and solve(yl, 0, y))

Measured memory_bytes: 81156
class HitBlow
  def self.check(a, b)
    hits = [a, b].transpose.select { |x, y| x == y }.flatten.uniq
    blows = a & b - hits
    [hits.size, blows.size]
  end
end

STDIN.read.split("\n").each_slice(2) do |a, b|
  result = HitBlow.check(a.split.map(&:to_i), b.split.map(&:to_i))
  printf "%s %s\n", result[0], result[1]
end

Measured memory_bytes: 8636
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
long long dp[51][51][2510];
using namespace std;
int main(void){
    int N,A;
    cin>>N>>A;
    int x[50];
    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    dp[0][0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<2500;k++){
                if(dp[i][j][k]){
                    dp[i+1][j][k]+=dp[i][j][k];
                    dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
                }
            }
        }
    }
    long long ans=0;
    for(int i=1;i<=N;i++){
        ans+=dp[N][i][i*A];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 48256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

int main(){
  int a,b;
  cin>>a>>b;
  int c=0;
  for(int i = a; i <= b; i++){
    int s1 = i%10;
    int s10 = (i%100-s1)/10;
    int s10000 = i/10000;
    int s1000 = (i-s10000*10000)/1000;
    if(s1==s10000&&s10==s1000){
      c++;
    }
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
    s <- getLine
    putStrLn $ map swapCase s

swapCase :: Char -> Char
swapCase c
  | isLower c = toUpper c
  | isUpper c = toLower c
  | otherwise = c



Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

int main() {
  string s;
  int n;
  ll ans = 0;
  vector<int> r, g, b;
  cin >> n >> s;
  rep(i, n) {
    if (s.at(i) == 'R') {
      r.push_back(i);
    }
    if (s.at(i) == 'G') {
      g.push_back(i);
    }
    if (s.at(i) == 'B') {
      b.push_back(i);
    }
  }
  for (int i = 0; i < r.size(); i++) {
    for (int j = 0; j < g.size(); j++) {
      int x, y;
      x = min(r.at(i), g.at(j));
      y = max(r.at(i), g.at(j));
      int p = 2 * x - y;
      int q = (x + y) / 2;
      int r = 2 * y - x;
      if (p >= 0 && p < s.size() && p < x && s.at(p) == 'B') ans++;
      if (q < s.size() && (x + y) % 2 == 0 && q > x && q < y && s.at(q) == 'B')
        ans++;
      if (r < s.size() && y < r && s.at(r) == 'B') {
        ans++;
      }
    }
  }
  cout << r.size() * g.size() * b.size() - ans << endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m,k;
vl a;

vl dp;

int main(){
	cin>>n>>m>>k;
	a=dp=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	dp=a;
	for(int i=1;i<k;i++){
		deque<int> q;
		vl DP(n);
		for(int j=0;j<n;j++){
			if(j>=i) DP[j]=dp[q.front()]+a[j]*(i+1);
			while(!q.empty()&&dp[q.back()]<=dp[j]) q.pop_back();
			q.push_back(j);
			if(!q.empty()&&q.front()==j-m) q.pop_front();
		}
		dp=DP;
	}
	ll res=-1;
	for(int i=0;i<n;i++) res=max(res,dp[i]);
	cout<<res<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S;
	cin >> S;
	string ans = "Yes";
	int N = (int)S.length();
	for(int i=0;i<N / 2;i++){
		if(S[i] != S[N - 1 - i])ans = "No";
	}
	string a = S.substr(0, (N - 1) / 2);
	string b = S.substr((N + 3) / 2 - 1);
	int Na = (int)a.length();
	for(int i=0;i<Na / 2;i++){
		if(a[i] != a[Na - 1 - i])ans = "No";
	}
	int Nb = (int)b.length();
	for(int i=0;i<Nb / 2;i++){
		if(b[i] != b[Nb - 1 - i])ans = "No";
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}



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

  ll h,w;
  std::cin>>h>>w;

  ll dif=MOD;

  std::vector<ll> temp(3);

  if(h>=3){
  rep(i,0,3)temp[i]=h/3;
  rep(i,0,h%3)temp[i]++;
  chmin(dif,(temp[0]-temp[2])*w);
  }

  if(w>=3){
  rep(i,0,3)temp[i]=w/3;
  rep(i,0,w%3)temp[i]++;
  chmin(dif,(temp[0]-temp[2])*h);
  }

  rep(i,1,h){
    temp[0]=i*w;
    temp[1]=(w/2)*(h-i);temp[2]=(w/2+(w%2))*(h-i);
    std::sort(all(temp));
    chmin(dif,temp[2]-temp[0]);
  }

  rep(i,1,w){
    temp[0]=i*h;
    temp[1]=(h/2)*(w-i);temp[2]=(h/2+(h%2))*(w-i);
    std::sort(all(temp));
    chmin(dif,temp[2]-temp[0]);
  }
  
  std::cout<<dif;

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll ans = 0;

    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0)
            continue;
        ans += i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 1e5 + 10 , mod = 1e9 + 7 ; 

int n , m , f [ N ] ;

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m ;
	if ( abs ( n - m ) > 1 )
		return cout << 0 , 0 ;
	f [ 0 ] = 1 ;
	for ( int i = 1 ; i < N ; i++ )
		( f [ i ] = f [ i - 1 ] * i ) %= mod ;
	int ans = 0 ;
	if ( n == m ) {
		ans = f [ n ] * f [ m ] * 2 ;
		ans %= mod ; 
	}
	else {
		ans = f [ n ] * f [ m ] % mod ; 
	}
	cout << ans << '\n' ; 
}


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

using namespace std;

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

	vector<int> m(n);
	for (int i = 0; i < n; i++) {
		cin >> m[i];
	}

	int min = m[0];
	for (auto d : m) {
		if (d < min) { min = d; }
		x -= d;
	}

	

	cout << n + (int)(x / min) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  double d = log2(n);
  int ans = d;
  ans = pow(2, ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

// int prime[1000001];
// vector<ll> primes;

// void soe() {
//     int i,j;
//     for(i=2;i<1000001;i++) prime[i] = 1;
//     for(i=2;i<=sqrt(1000001);i++) {
//         if(prime[i] == 1) {
//             for(j=i*i;j<1000001;j+=i) {
//                 prime[j] = 0;
//             }
//         }
//     }
//     for(i=2;i<1000001;i++) {
//         if(prime[i]) primes.pb(i);
//     }
// }

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

    int n,i=0;
    cin >> n;
    string a,b;
    cin >> a >> b;
    while(a[i]) {
        cout << a[i] << b[i];
        i++;
    }
    cout << "\n";
    return 0;
}




Measured memory_bytes: 256
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:continue
        for j in range(i * 2, n + 1, i):is_prime[j] = False
    return is_prime

def main():
    q=int(input())
    is_prime = primes(10**5+1)
    a = [0 for i in range(10**5+1)]
    for i in range(3,10**5+1):
        if is_prime[i] and is_prime[(i+1)//2]:a[i]+=1
    for i in range(3,10**5+1):a[i]+=a[i-1]
    for i in range(q):
        l,r=map(int,input().split())
        print(a[r]-a[l-1])

main()

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

#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ll long long

int main() {
    int n;
    cin >> n;
    int d[n];
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }

    std::vector<int> v;
    for (int i = 0; i < n-1; ++i) {
        for (int j = i+1; j < n; ++j) {
            v.push_back(d[i]*d[j]);
        }
    }
    cout << accumulate(v.begin(),  v.end(), 0) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

D.sort()

chouten = {}
for i in D:
    if i not in chouten:
        chouten[i] = 0
    chouten[i] += 1

# print(chouten)

if 0 not in chouten or chouten[0] != 1:
    print(0)
    exit()

kosuu = 1
# for k, v in chouten.items():
#     if k == 0:
#         continue
#     if k == 1:
#     kosuu = kosuu**v

for i in range(len(chouten)):
    if i not in chouten:
        print(0)
        exit()
    if i == 0:
        continue
    elif i == 1:
        continue
        kosuu = chouten[i]
    else:
        kosuu *= chouten[i - 1]**chouten[i]
        kosuu = kosuu % 998244353

print(kosuu)

Measured memory_bytes: 62508