akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
typedef tuple<int, int, int> tiii;

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int m, t, p, r;
		cin >> m >> t >> p >> r;
		if(m == 0 && t == 0 && p == 0 && r == 0){ break; }
		vector<vector<int>> wrong_count(t, vector<int>(p));
		vector<tiii> order(t);
		for(int i = 0; i < t; ++i){ order[i] = tiii(0, 0, -(i + 1)); }
		for(int i = 0; i < r; ++i){
			int mi, ti, pi, ji;
			cin >> mi >> ti >> pi >> ji;
			--ti; --pi;
			if(wrong_count[ti][pi] < 0){ continue; }
			if(ji == 0){
				--get<0>(order[ti]);
				get<1>(order[ti]) += mi + wrong_count[ti][pi] * 20;
				wrong_count[ti][pi] = -1;
			}else{
				++wrong_count[ti][pi];
			}
		}
		sort(order.begin(), order.end());
		for(int i = 0; i < t; ++i){
			if(i > 0){
				const int j = i - 1;
				if(get<0>(order[j]) == get<0>(order[i]) && get<1>(order[j]) == get<1>(order[i])){
					cout << "=";
				}else{
					cout << ",";
				}
			}
			cout << -get<2>(order[i]);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int n;


bool bfs(int x, int y){
    if (4 * x + 7 * y == n){
        return true;
    }else if (4 * x + 7 * y > n){
        return false;
    }

    if (bfs(x + 1, y)) return true;
    if (bfs(x, y + 1)) return true;
    
    return false;
}

int main(){
    cin >> n;
    if (bfs(0, 0)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

}


Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    A, B = map(int, input().split())
    ret = -1
    for x in range(1, 10000//8+1):
        if int(x*0.08) == A and int(x*0.10) == B:
            ret = x
            break

    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n, q = gets.split.map(&:to_i)


g = Array.new(n+1){[]}
(n-1).times do
  a,b = gets.split.map{ |i| i.to_i }# 0-indexedに変更
  g[a].push(b)
  g[b].push(a)
end

points = Array.new(n+1,0)
q.times do |i|
  node,x = gets.split.map(&:to_i)
  points[node] += x
end

que = [1] # BFS, 木の根である頂点0から足す
used = Array.new(n,false)
while v = que.shift # 破壊的メソッド。空配列は変更が行わずnilを返す
  used[v] = true #
  g[v].each do |w|
    used[w] ? next : que.push(w)
    points[w] += points[v]
  end
end

puts points.drop(1).join(' ')

Measured memory_bytes: 27388
#include<stdio.h>
char S[999],v[999];main(){
	int T,C,i;
	for(;fgets(S,999,stdin),S[2];puts(T?"no":"yes")){
		for(T=C=i=0;i<strlen(S);i++)
		switch(S[i]){
			case '(': v[C++]=1;break;
			case '[': v[C++]=2;break;
			case ')': if(!C||v[--C]!=1)goto F;break;
			case ']': if(!C||v[--C]!=2)goto F;break;
		}
		if(!C)continue;
		F:T=1;
	}
exit(0);}

Measured memory_bytes: 0
N=int(input())
A=[int(i) for i in input().split()]
a=sum(A)//2#sumx
P=[0]*(N+1)
Q=[0]*(N+1)
for i in range(1,N+1):
    if i%2==1:
        P[i]+=P[i-1]+A[i-1]
    else:
        P[i] += P[i - 1]
T=[0]*N
T[0]=P[-1]-a
for i in range(1,N):
    T[i]=A[i-1]-T[i-1]
for t in T:
    print(2*t,end=' ')

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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin();
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin();
#define ct(i) cout<< i << "\n";
# define M_PIl          3.141592653589793238462643383279502884L 
#define mod 1000000007
#define M 100005


void answer(){
    ll n,ans=0,a,b;
    cin>>n;
    cout<<2*n*M_PIl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();

    return 0;
}

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

bool judge(string stc, int begin, int end){
    bool ok = true;
    for(int i=begin; i<end+1; i++){
        if(stc.at(i) != stc.at(end-i)){
            ok = false;
        }
    }
    return ok;
}

int main(){
    string kaibun;
    
    cin >> kaibun;
    int n = kaibun.size();
    int mid = n/2;
    

    if(judge(kaibun, 0, mid-1) && judge(kaibun,mid+1, n-1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main(){
  int n,x,y;cin>>n>>x>>y;
  map<int,int> mp;
  
  for(int i=1;i<=n-1;i++){
    for(int j=i+1;j<=n;j++){
      mp[min(j-i,abs(i-x)+1+abs(j-y))]++;
    }
  }

  for(int i=1;i<n;i++){
    cout<<mp[i]<<endl;
  }
}

Measured memory_bytes: 384
function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  let ary = args[1].split(' ').map(n => parseInt(n, 10));
  let max;
  let total = 0;
  
  ary.sort((a, b) => { return b - a });
  
  for (let i = 0; i < ary.length; i++) {
    if (i === 0) { 
      max = ary[0];
    } else {
      total += ary[i];
    }
  }
  
  (max < total) ? console.log('Yes') : console.log('No');
  
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29556
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define loop(i, a, b) for(li i=a; i<=b; i++)
#define stuff ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long li;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<li, li> lii;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ii> vii;
typedef vector<lii> vlii;
li mod = 1e9+7;
li expo(li base, li exponent)
{
	li ans=1;
	while(exponent)
	{
		if(exponent&1) ans = (ans*base)%mod;
		base = (base*base)%mod;
		exponent >>= 1;
	}
	return ans;
}
li gcd(li x, li y)
{
	if(y==0) return x;
	return gcd(y, x%y);
}


typedef tree<li, null_type, less<li>,
rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
	stuff;
	// #ifndef ONLINE_JUDGE 
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// freopen("error.txt", "w", stderr);
	// #endif

	li n, k;
	cin >> n >> k;
	vector<li> ar(n+1, 0);
	ar[0] = 0;
	for(li i=1; i<=n; i++)
	{
		ar[i] += ar[i-1]+i;
		// cout << i << " " << ar[i] <<endl;
	}
	// for(auto x : ar)
	// {
	// 	cout << x << " ";
	// }
	// cout << endl;
	li lo, hi, ans=0;
	for(int i=k; i<=n; i++)
	{
		lo = ar[i-1];
		hi = ar[n]-ar[n-i];
		// cout << i << " " << lo << " l " << hi << endl;
		ans = (ans+(hi-lo+1))%mod;
	}
	ans++;
	cout << ans;
	return 0;
}


Measured memory_bytes: 4780
#include <stdio.h>

int main(void)
{
	int n, no, b, c, a, i, j;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		no = 0;
		b = 0;
		c = 0;
		for (j = 0; j < 10; j++){
			scanf("%d", &a);
			if (b < a) b = a;
			else if (c < a) c = a;
			else no++;
		}
		if (no == 0) printf("YES\n");
		else printf("NO\n");
	}

	return (0);
}

Measured memory_bytes: 580
from collections import deque

H, W = map(int, input().split())
maze = [list(input()) for i in range(H)]
XY = [(-1, 0), (1, 0), (0, 1), (0, -1)]

t_max = 0
for i in range(H):
    for j in range(W):
        step = [[0]*W for _ in range(H)]
        visited = [[False]*W for _ in range(H)]
        queue = deque([(i, j)])
        while queue:
            x, y = queue.popleft()
            if maze[x][y] == "#":
                continue
            if visited[x][y]:
                continue
            for dx, dy in XY:
                nx = x + dx
                ny = y + dy
                if 0 <= nx <= H-1 and 0 <= ny <= W-1:
                    step[nx][ny] = step[x][y] + 1
                    queue.append((nx, ny))
                    t_max = max(t_max, step[nx][ny])
            visited[x][y] = True

print(t_max-1)





Measured memory_bytes: 9324
n, k = map(int, input().split())
arr = []
for i in range(n):
  c = i + 1
  p = 1 / n
  while 1 <=  c <= k - 1:
    c *= 2
    p *= 0.5
  arr.append(p)
ans = sum(arr)
print(ans)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

int main() {
    int h,w;
    cin>>h>>w;
    ll c[10][10];
    rep(i,10){
        rep(j,10){
            cin>>c[i][j];
        }
    }
    vll d(10,0);
    rep(i,h){
        rep(j,w){
            int a;
            cin>>a;
            if (a!=-1){
                d[a]+=1;
            }
        }
    }
    vll cost(10,1000000);
    vi v{0,2,3,4,5,6,7,8,9};
    for (int i=0;i<40320*9;i++){
        for (int j=0;j<9;j++){
            int num=v[j];
            ll cost1=0;
            for (int k=j;k<8;k++){
                cost1+=c[v[k]][v[k+1]];
            }
            cost1+=c[v[8]][1];
            cost[num]=min(cost[num],cost1);
        }
        next_permutation(all(v));
    }
    ll ans=0;
    for (int i=0;i<10;i++){
        if (i==1)continue;
        //cout<<i<<" "<<cost[i]<<" "<<d[i]<<endl;
        ans+=cost[i]*d[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	r := nextInt()
	ans := 3 * r * r
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<queue>
using namespace std;
int main () {
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>>tr(N + 1);
  for (int i = 0; i < N - 1; i ++) {
    int a, b;
    cin >> a >> b;
    tr[a].push_back(b);
    tr[b].push_back(a);
  }
  vector<int>par(N + 1, -1);
  par[1] = 0;
  queue<int>que;
  que.push(1);
  vector<long long>ans(N + 1, 0);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int i = 0; i < (int)tr[u].size(); i ++) {
      int v = tr[u][i];
      if (par[v] == -1) {
        par[v] = u;
        que.push(v);
      }
    }
  }
  for (int i = 0; i < Q; i ++) {
    int p;
    long long x;
    cin >> p >> x;
    ans[p] += x;
  }
  queue<int>q_;
  q_.push(1);
  while (!q_.empty()) {
    int u = q_.front();
    q_.pop();
    ans[u] += ans[par[u]];
    for (int i = 0; i < (int)tr[u].size(); i ++) {
      int v = tr[u][i];
      if (v != par[u]) q_.push(v);
    }
  }
  for (int i = 1; i <= N; i ++) cout << ans[i] << endl;
}

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

int N;
int arr[100000];
long long area;

int main(){
  cin >> N;
  long long first,second;
  for (int i=0;i<N;i++){
    cin >> arr[i];
  }
  sort(arr,arr+N);
  for (int i=N-1;i>0;i--){
     if (arr[i]==arr[i-1]){
        if (first==0){
          first = arr[i];
          i -= 1;
        }
        else if(second==0){
          second = arr[i];
          break;
        }
     }
  }
  area = first*second;
  cout << area;
  return 0;
}
       

Measured memory_bytes: 640
<?php
 	fscanf(STDIN,"%d",$n);
 	$pairs = array();
  	for($i=1; $i<=1000000; $i++){
  		if($n%$i==0){
          if($n/$i<$i){
            break;
          }
          $pairs[] = [$n/$i,$i];
        }
  	 }
	
	$sum=0;
	$min = 10**12;
	foreach($pairs as $pair){
      $sum+=$pair[0]-1;
      $sum+=$pair[1]-1;
      $min = min($sum,$min);
      $sum = 0;
    }

	echo $min."\n";


  


Measured memory_bytes: 4728
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

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

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> M >> K;
	vector<long long int>by(N*M + 1, 1);
	vector<long long int>rev(N*M + 1, 1);
	long long int ans = 0;
	for (int i = 1; i <= N * M; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	for (int i = 0; i < N; i++) {
		long long int box = 1LL * i * (i + 1) / 2;
		box *= M;
		box %= MOD;
		box *= M;
		box %= MOD;
		box *= by[N*M - 2];
		box %= MOD;
		box *= rev[K - 2];
		box %= MOD;
		box *= rev[N*M - K];
		box %= MOD;
		ans += box;
		ans %= MOD;
	}
	for (int i = 0; i < M; i++) {
		long long int box = 1LL * i * (i + 1) / 2;
		box *= N;
		box %= MOD;
		box *= N;
		box %= MOD;
		box *= by[N*M - 2];
		box %= MOD;
		box *= rev[K - 2];
		box %= MOD;
		box *= rev[N*M - K];
		box %= MOD;
		ans += box;
		ans %= MOD;
	}
	ans %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

// UnionFind
class UnionFind {
private:
    vector<int> par;
public:
    UnionFind(int n) {
        par.resize(n, -1);
    }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (size(rx) < size(ry)) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int n, m; cin >> n >> m;
    if (m + 1 < n - n / 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    else if (n - 1 == m) {
        cout << 0 << endl;
        return 0;
    }
    vector<pair<int,int>> a(n);
    UnionFind uni(n);
    REP(i, n) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    REP(i, m) {
        int x, y; cin >> x >> y;
        uni.unite(x, y);
    }
    vector<bool> b(n, false);
    ll ans = 0;
    int cnt = n - m - 2;
    REP(i, n) {
        if (b[uni.root(a[i].second)]) {
            if (cnt > 0) {
                cnt--;
                ans += a[i].first;
            }
        }
        else {
            b[uni.root(a[i].second)] = true;
            ans += a[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
const int NMAX=100666; //LOL
using namespace std;
const int INF=1000000007;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;

string s;

void solve()
{
    cin>>s;
    bool q=0;
    bool l=0;

    for(int i=0; i<s.size(); ++i)
    {
        if(i<= s.size() -5 && s[i]=='e' && s[i+1] =='r' && s[i+2]=='a' && s[i+3]=='s' && s[i+4]=='e')
        {
            i+=4;
            l=0;
            q=1;

           continue; 
        }
        if(i<= s.size() -5 && s[i]=='d' && s[i+1] =='r' && s[i+2]=='e' && s[i+3]=='a' && s[i+4]=='m')
        {
            q=0;
            l=1;
            i+=4;
           continue; 
        }
             
        if(q && s[i]=='r')
        {
            q=0;
            continue;
        }
        if(l && i<=s.size()-2 && s[i]=='e' && s[i+1]=='r')
        {
            l=0;
            i++;
           continue; 
        }

        cout<<"NO";
        return;
    }
    cout<<"YES";
}

int main()
{
   
   
    solve();
    cout<<"\n";
 
    return 0;
}


Measured memory_bytes: 512
/*Count Balls*/

#include <bits/stdc++.h>

using namespace std;

int main(){
    
    long long blue;
    long long red;
    long long times;
    long long suma;
    long long mod;
    
    cin >> times >> blue >> red;
    
    suma =  blue + red;
    mod = times % suma;
    
    suma = times / suma;
    suma = suma * blue;
    
    if(mod >= blue)
       suma += blue;
    else
       suma += mod;
    
    cout << suma;
        
    return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
arr = list(input().split())
ans = 0
for i in range(N,10**7):
    flg = True
    s = str(i)
    for k in s:
        if str(k) in arr:
            flg = False
            break
    if flg:
        print(i)
        exit()

Measured memory_bytes: 3060
def main():
    N = int(input())
    a = list(map(int, input().split()))
    Q = int(input())
    maxa = max(a)
    x = [0] * ((10**5)+1)
    ans = 0
    for i in range(0, N):
        e = a[i]
        x[e] += 1
        ans += e
    for j in range(Q):
        b, c = list(map(int, input().split()))
        ans += (c - b) * x[b]
        x[c] += x[b]
        x[b] = 0
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20748
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

 int N;
 cin >> N;

 vector<long long> A(N);
 long long sum = 0;
 for(int i = 0;i < N;i++) {
   cin >> A.at(i);
   sum += A.at(i);
 }

 long long b = 0,ans = 1LL<<60;
 for(int i = 0;i < N;i++) {
   b += A.at(i);
   sum -= A.at(i);
   ans = min(ans,abs(sum-b));
 }

 cout << ans << endl;

}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int a[200000], b[200000], cnt;
int n, left[2], right[2], mid;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  sort(a, a + n);
  sort(b, b + n);
  if (n % 2) {
    cout << b[n / 2] - a[n / 2] + 1 << endl;
  } else {
    cout << b[(n - 1) / 2] + b[(n - 1) / 2 + 1] -
                (a[(n - 1) / 2] + a[(n - 1) / 2 + 1]) + 1
         << endl;
  }
}

Measured memory_bytes: 5204
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() { 
    int n;cin >> n;
    int ans = 1;
    rep(i, 3) ans*=n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3560
S = input()

ans=0
res=0
for i in range(0, len(S)):
    if(S[i]=='A' or  S[i]=='C' or S[i]=='G' or S[i]=='T'):
        res+=1
    else:
        ans = max(res, ans)
        res = 0

ans = max(res, ans)
print(ans)

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


auto solve(long long a, long long b, long long c){
    return min(min(a + b, a + c), b + c);
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    auto result = solve(a, b, c);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
x,n=map(int,input().split())
if n>0:
    p=list(map(int,input().split()))
    p=set(p)
    mini=10**10
    ans=0
    for i in range(102):
        if i not in p:
            if abs(i-x)<mini:
                mini=abs(i-x)
                ans=i
    print(ans)
else:
    print(x)

Measured memory_bytes: 9192
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,f[N][2],sum[N];
ll ans;
char s[N];

int main() { 
	scanf("%s", s+1);
	n = strlen(s+1);
	int cnt = 0;
	REP(i,1,n) if (s[i]=='1') ans+=(++cnt+1)/2;
	PER(i,1,n) {
		f[i][0]=f[i+1][0];
		f[i][1]=f[i+1][1];
		sum[i]=sum[i+1];
		if (s[i]=='1') ++f[i][i&1],++sum[i];
	}
	int pos = 1;
	while (s[pos]=='1') ++pos;
	if (pos>n) return printf("%lld\n",ans),0;
	cnt = 0;
	--pos;
	REP(i,1,pos) cnt += i&1;
	int now = 1;
	REP(i,pos+1,n) {
		int j = i;
		while (j<n&&s[j+1]=='0') ++j;
		ans += (j-i+1ll)*cnt;
		if (j==n) break;
		int k = j+1;
		while (k<n&&s[k+1]=='1') ++k;
		if ((k-j)%2&&pos%2) {
			REP(t,i,j-1) {
				ans += f[t][now];
				now ^= 1;
			}
			if (pos%2) ans += (sum[j]+1)/2;
			else ans += sum[j]/2;
			++pos;
		}
		else {
			REP(t,i,j) {
				ans += f[t][now];
				now ^= 1;
			}
		}
		REP(t,1,k-j) cnt += (pos+t)&1;
		pos += k-j;
		i = k;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=1e8;
    int z;
    for(int i=0;i<s.size()-2;i++){
    int a=(s.at(i)-'0')*100;
    int b=(s.at(i+1)-'0')*10;
    int c=(s.at(i+2)-'0');
    int x=a+b+c;
    ans=min(abs(x-753),ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    int n, k;
    cin >> n >> k;
    
    vector<int> v[n];
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a].eb(b);
        v[b].eb(a);
    }
    
    ll ans = 1;
    int reached[100001] = {0};
    int par[100001];
    rep(i, 100001) par[i] = -1;
    
    queue<pair<pii, int> > q;
    q.push({{0, -1}, 1});
    
    while (!q.empty()) {
        int now = q.front().F.F;
        int bef = q.front().F.S;
        int eda = q.front().S; // 何番目の枝か
        q.pop();
        
        reached[now] = 1;
        if (bef == -1) { // root
            ans *= k;
        } else {
            int cnt = k;
            cnt--; // 親の分
            if (par[par[now]] != -1) cnt--; // 距離2の, 親の親
            cnt -= eda - 1;
            // cout << "cnt " << cnt << " " << eda << endl;
            (ans *= cnt) %= inf;
        }
        
        {
            int cnt = 0;
            rep(i, sz(v[now])) {
                int nxt = v[now][i];
                if (nxt == bef) continue;
                if (reached[nxt]) continue;
                cnt++;
                par[nxt] = now;
                q.push({{nxt, now}, cnt});
            }
        }
        
        // cout << ans << endl;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 8056
// Problem: https://atcoder.jp/contests/abc160/tasks/abc160_c
// Type: Math

#include <bits/stdc++.h>

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;

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

	int k, n;
	cin >> k >> n;
	
	vector<int> m(n);
	for (auto &e : m) {
		cin >> e;
	}

	int max_segment = 0;
	for (int i = 1; i < m.size(); ++i) {
		max_segment = max(max_segment, m[i] - m[i - 1]);
	}
	max_segment = max(max_segment, m[0] + (k - m[m.size() - 1]));
	cout << k - max_segment;

	return 0;
}


Measured memory_bytes: 1024
import math
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
ans = 0
cal = 0
for i in range(n):
  for j in range(i+1, n):
    for k in range(d):
      de = abs(x[i][k] - x[j][k])
      cal += de**2
    if math.sqrt(cal)%1==0:
      ans += 1
    cal = 0
print(ans)

Measured memory_bytes: 9152
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
	int n;
	cin>>n;
	double t, a;
	cin>>t>>a;
	double mn=1e9; int ans=-1;
	for(int i=1; i<=n; i++){
		double h;
		cin>>h;
		if(mn>abs(t-h*0.006-a)){
			mn=abs(t-h*0.006-a);
			ans=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	var N = parseInt(input[0], 10);
	var n = N / 2
	var S = input[1]
	if (N % 2 !== 0) {
	  console.log('No');
	} else {
	  var str = [];
    for (var i = 0; i < S.length / n; i++) {
      str.push(S.substr(i * n, n));
  }
	 // console.log(str);
	  if (str[0] === str[1]){
	    console.log('Yes');
	  } else {
	    console.log('No')
	  }
	}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int R, C;
char g[500][501];
vector<int> rowHasAt[500];
int main()
{
	scanf("%d", &R);
	C = R;
	bool f = false;
	for (int i = 0; i < R; ++i) {
		scanf("%s", g[i]);
		for (int j = 0; j < C; ++j) {
			if (g[i][j] == '#') {
				rowHasAt[j].push_back(i);
				f = true;
			}
		}
	}
	if (!f) {
		puts("-1");
		return 0;
	}
	int mnCost = 1e9, at = -1;
	bool need = false;
	for (int i = 0; i < R; ++i) {
		int cur = 0;
		bool curNeed = false;
		for(int j=0;j<C;++j)
			if (g[i][j] == '.') {
				if (rowHasAt[i].empty()) {
					curNeed = true;
				}
				++cur;
			}
		if(curNeed)
			++cur;
		if (mnCost>cur) {
			mnCost = cur;
			at = i;
			need = curNeed;
		}
	}
	if (mnCost > 1e8) {
		puts("-1");
		return 0;
	}
	if (need) {
		for(int i=0;i<R;++i)
			for(int j=0;j<C;++j)
				if (g[i][j] == '#') {
					string tmp = "";
					for (int x = 0; x < C; ++x)
						tmp += g[i][x];
					for (int x = 0; x < C; ++x) {
						g[x][at] = tmp[x];
						if (tmp[x] == '#')
							rowHasAt[at].push_back(x);
					}
					i = j = R;
				}
	}
	for (int it = 0; it<2; ++it)
		for (int i = 0; i < C; ++i) {
			if (g[at][i] == '.' && (it || i != at)) {
				int r = rowHasAt[at][0];
				string tmp = "";
				for (int x = 0; x < C; ++x)
					tmp += g[r][x];
				for (int x = 0; x < C; ++x)
					g[x][i] = tmp[x];
			}
		}
	for (int i = 0; i < C; ++i) {
		assert(g[at][i] == '#');
		for(int j=0;j<R;++j)
			if (g[j][i] == '.') {
				++mnCost;
				break;
			}
	}
	printf("%d\n", mnCost);
	return 0;
}

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

int main(){
    int n;
    double m,sum=0;
    cin >> n;
    cin >> m;
    int count = 0;
    int a[n];
    bool can = false;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    rep(i,n){
        if(a[i] >= sum / (4 * m))count++;
        if(count == m){
            can = true;
            break;
        }
    }
    if(can){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    numbers = []
    for i in range(n):
        numbers.append(len(set(map(int, input().split()))))
    row3 = [numbers[i:i+3] for i in range(n - 2)]
    if([1,1,1] in row3):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

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

void swap(int *a, int *b) {
  int temp = *a;
  *a = *b;
  *b = temp;
}

int main() {
  int n;  cin >> n;
  
  int card[n];
  for (int i = 0; i < n; i++) 
    cin >> card[i];
  
  int max;
  for (int i = 0; i < n; i++) {
    max = i;
    for (int j = i + 1; j < n; j++) {
      if (card[max] < card[j])
        max = j;
    }
    swap(card[i], card[max]);
  }
  
  int alice = 0, bob = 0;
  for (int i = 0; i < n; i += 2) {
    alice += card[i];
    if (i + 1 < n)
      bob += card[i + 1];
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

set<long long> s, t;

long long mn(long long x, int wh, int p){
    if(wh == -1){
        return min(mn(x, 1, -1), mn(x, 2, -1));
    }
    else if(wh == 1){
        auto k = s.lower_bound(x);
        if(k == s.end()){
            k--;
            long long l = x - *k;
            if(p == 2) return l;
            return l + mn(*k, 2, 1);
        }
        else if(k == s.begin()){
            long long r = *k - x;
            if(p == 2) return r;
            return r + mn(*k, 2, 1);
        }
        else{
            long long r = *k - x;
            auto k1 = k;
            k1--;
            long long l = x - *k1;
            if(p == 2) return min(l, r);
            return min(l + mn(*k1, 2, 1), r + mn(*k, 2, 1));
        }
    }
    else{
        auto k = t.lower_bound(x);
        if(k == t.end()){
            k--;
            long long l = x - *k;
            if(p == 1) return l;
            return l + mn(*k, 1, 2);
        }
        else if(k == t.begin()){
            long long r = *k - x;
            if(p == 1) return r;
            return r + mn(*k, 1, 2);
        }
        else{
            long long r = *k - x;
            auto k1 = k;
            k1--;
            long long l = x - *k1; 
            if(p == 1) return min(l, r);
            return min(l + mn(*k1, 1, 2), r + mn(*k, 1, 2));
        }
    }
}


int main(){
    long long a, b, q, x, s1, t1;
    cin >> a >> b >> q;
    for(int i = 0; i < a; ++i){
        cin >> s1;
        s.insert(s1);
    }
    for(int i = 0; i < b; ++i){
        cin >> t1;
        t.insert(t1);
    }
    for(int i = 0; i < q; ++i){
        cin >> x;
        cout << mn(x, -1, -1) << endl;

    }
}


Measured memory_bytes: 12544
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
-- import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import GHC.Magic (oneShot)


main :: IO ()
main = do
  n <- read <$> getLine
  ls <- VU.unfoldrN n (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  print $ binSearch 0 n ls

{-# INLINE binSearch #-}
binSearch :: Int -> Int -> VU.Vector Int -> Int
binSearch ng ok !ls | ok - ng <= 1 = ok
binSearch ng ok !ls =
  if isPossibleWith mid ls then
    binSearch ng mid ls
  else
    binSearch mid ok ls
  where
    mid = (ng + ok) `shiftR` 1

{-# INLINE isPossibleWith #-}
isPossibleWith :: Int -> VU.Vector Int -> Bool
isPossibleWith 1 !ls = VU.and $ VU.zipWith (<) ls (VU.tail ls)
isPossibleWith numChars !ls
  = VU.foldr loop (\ !len_ !chars_ -> True) ls 0 Nil
  where
    {-# INLINE loop #-}
    loop = \ !reqLen cont -> oneShot $ \ !wordLen !chars ->
      if reqLen > wordLen
      then cont reqLen chars
      else countUpCps (cont reqLen) numChars (cutOff chars reqLen) (reqLen-1) 

data List = Nil | Snoc !List {-# UNPACK #-} !Int {-# UNPACK #-} !Int
 deriving Show

{-# INLINE countUpCps #-}
countUpCps :: (List -> Bool) -> Int -> List -> Int -> Bool
countUpCps cont !numChars = go
  where
    go !xs !ind | ind < 0 = False
    go (Snoc xs i e) ind
      | i == ind = if | e < numChars - 1 -> cont $! Snoc xs i (e+1)
                      | otherwise        -> go xs (ind-1)
    go xs ind = cont $! Snoc xs ind 1

{-# INLINE cutOff #-}
cutOff :: List -> Int -> List
cutOff !xs !till = go xs
  where
    go (Snoc xs i e) | i >= till = go xs
    go xs = xs

Measured memory_bytes: 7036
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static final int INF = Integer.MAX_VALUE;
  static Node[] nodes;

  public static void main(String[] args) {
    boolean result = solve();
    if (result) {
      System.out.println("Yes");
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < nodes.length; i++) {
        sb.append(nodes[i].v + "\n");
      }
      System.out.print(sb);
    } else {
      System.out.println("No");
    }
  }

  static boolean solve() {
    int N = sc.nextInt();
    nodes = new Node[N];
    for (int i = 0; i < N; i++) {
      nodes[i] = new Node(i);
    }
    for (int i = 0; i < N - 1; i++) {
      int A = Integer.parseInt(sc.next()) - 1;
      int B = Integer.parseInt(sc.next()) - 1;
      nodes[A].next.add(nodes[B]);
      nodes[B].next.add(nodes[A]);
    }
    int K = sc.nextInt();
    for (int i = 0; i < K; i++) {
      int V = Integer.parseInt(sc.next()) - 1;
      int P = Integer.parseInt(sc.next());
      nodes[V].v = nodes[V].min = nodes[V].max = P;
    }
    Node[] order = new Node[N];
    order[0] = nodes[0];
    nodes[0].parent = -1;
    for (int i = 0, pos = 1; i < N; i++) {
      for (Node c : order[i].next) {
        if (c.parent != INF) continue;
        c.parent = order[i].id;
        c.depth = order[i].depth + 1;
        order[pos++] = c;
      }
    }
    int parity = -1;
    for (int i = 0; i < N; i++) {
      if (order[i].v == INF) continue;
      int p = (order[i].v ^ order[i].depth) & 1;
      if (parity == -1) {
        parity = p;
      } else if (parity != p) {
        return false;
      }
    }
    for (int i = N - 1; i >= 0; i--) {
      for (Node c : order[i].next) {
        if (c.id == order[i].parent) continue;
        order[i].min = Math.max(order[i].min, c.min - 1);
        order[i].max = Math.min(order[i].max, c.max + 1);
      }
      if (order[i].min > order[i].max) return false;
    }
    for (int i = 1; i < N; i++) {
      order[i].min = Math.max(order[i].min, nodes[order[i].parent].min - 1);
      order[i].max = Math.min(order[i].max, nodes[order[i].parent].max + 1);
      if (order[i].min > order[i].max) return false;
    }
    order[0].v = order[0].min;
    for (int i = 1; i < N; i++) {
      int pv = nodes[order[i].parent].v;
      if (order[i].min <= pv - 1 && pv - 1 <= order[i].max) {
        order[i].v = pv - 1;
      } else {
        order[i].v = pv + 1;
      }
    }
    return true;
  }


  static class Node {
    int id, depth, parent = INF, v = INF, min = -INF / 2, max = INF / 2;
    ArrayList<Node> next = new ArrayList<>();

    public Node(int id) {
      this.id = id;
    }
  }
}


Measured memory_bytes: 92992
<?php

$input = trim(fgets(STDIN));
if ($input === '5 7 5') {
    echo "YES\n";
} elseif ($input === '5 5 7') {
    echo "YES\n";
} elseif ($input === '7 5 5') {
    echo "YES\n";
} else echo "NO\n";


Measured memory_bytes: 16128
def base(x,p):
    if int(x/p) >= 1:
        return base(int(x/p),p)+str(x%p)
    return str(x%p)
n = int(input())
c = 10**9
for i in range(n+1):
  c = min(c,sum(list(map(int,(base(i,6)+base(n-i,9))))))
print(c)

Measured memory_bytes: 3060
import sys
n, a, b = map(int, input().split())
turn = 'Al'
while(True):
  if (turn == 'Al'): #Alice's Turn
    if ((a == 1) & (b == 2)):
      print('Borys')
      sys.exit()
    elif (b - a == 1):
      a -= 1
    else:
      a += 1
    turn = 'Bo'
  else:
    if ((a == n - 1) & (b == n)):
      print('Alice')
      sys.exit()
    elif (b - a == 1):
      b += 1
    else:
      b -= 1
    turn = 'Al'
    

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

using namespace std;

const int MAX_N = 100000, INDEX = 1, MOD = 1000000007;
const long long MAX_VAL = 1000000000000000000, INF = 2 * MAX_VAL + 1;

int n;

long long a, b, s[MAX_N + 1 + INDEX];

int dp[MAX_N + 2 + INDEX];
int nearesta[MAX_N + INDEX], nearestb[MAX_N + INDEX];
int repeatsa[MAX_N + 1 + INDEX], repeatsb[MAX_N + 1 + INDEX];
int defineda[MAX_N + 1 + INDEX], definedb[MAX_N + 1 + INDEX];

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

    cin >> n;

    cin >> a >> b;

    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    s[n + 1] = INF;

    nearesta[0] = 0;
    for (int i = 1; i <= n; i++) {
        nearesta[i] = nearesta[i - 1];

        while (s[nearesta[i] + 1] - s[i] < a) {
            nearesta[i]++;
        }
    }
    nearesta[n + 1] = n + 1;

    nearestb[0] = 0;
    for (int i = 1; i <= n; i++) {
        nearestb[i] = nearestb[i - 1];

        while (s[nearestb[i] + 1] - s[i] < b) {
            nearestb[i]++;
        }
    }
    nearestb[n + 1] = n + 1;

//    for (int i = 1; i <= n; i++) {
//        cout << nearesta[i] << ' ' << nearestb[i] << endl;
//    }

    repeatsa[n + 1] = n;
    for (int i = n; i >= 1; i--) {
        if (nearesta[i] == i) {
            repeatsa[i] = repeatsa[i + 1];
        } else {
            repeatsa[i] = i;
        }
    }

    repeatsb[n + 1] = n;
    for (int i = n; i >= 1; i--) {
        if (nearestb[i] == i) {
            repeatsb[i] = repeatsb[i + 1];
        } else {
            repeatsb[i] = i;
        }
    }

//    for (int i = 1; i <= n; i++) {
//        cout << repeatsa[i] << ' ' << repeatsb[i] << endl;
//    }

    defineda[n + 1] = n;
    definedb[n + 1] = n;
    for (int i = n; i >= 1; i--) {
        if (nearesta[i] <= repeatsb[i + 1]) {
            if (nearesta[i] > i) {
                defineda[i] = definedb[nearesta[i]];
            } else {
                defineda[i] = i;
            }
        } else {
            defineda[i] = n + 2;
        }

        if (nearestb[i] <= repeatsa[i + 1]) {
            if (nearestb[i] > i) {
                definedb[i] = defineda[nearestb[i]];
            } else {
                definedb[i] = i;
            }
        } else {
            definedb[i] = n + 2;
        }
    }

//    for (int i = 1; i <= n; i++) {
//        cout << defineda[i] << ' ' << definedb[i] << '\n';
//    }

    dp[n + 2] = 0;
    dp[n + 1] = 1;
    for (int i = n; i >= 1; i--) {
        dp[i] = dp[defineda[i] + 1] + dp[definedb[i] + 1];

        dp[i] %= MOD;
    }

    cout << dp[1] << endl;

    return 0;
}


Measured memory_bytes: 3840
#!/usr/bin/env python3

# from numba import njit
from math import gcd
# input = stdin.readline

def lcm(x,y):
  return x*y//gcd(x,y)

# @njit
def solve(n,m,s,t):
  L = lcm(n,m)
  G = gcd(n,m)
  s_interval = L//n
  t_interval = L//m
  for i in range(G):
    if s[i*n//G] != t[i*m//G]:
      return -1
  return L
  

def main():
  N,M = map(int,input().split())
  s = input()
  t = input()
  print(solve(N,M,s,t))
  return

if __name__ == '__main__':
  main()


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

int main() {
  string a, b;
  cin >> a >> b;
  string c = a + b;
  int n = 0;
  for (int i = 0; i < c.size(); i++) {
    n *= 10;
    n += c.at(i) - '0';
  }
  int sq = sqrt(n);
  if (sq * sq == n) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const int INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if (a == b) PRINT(c);
    else if (b == c) PRINT(a);
    else PRINT(b);
}


Measured memory_bytes: 256
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
double pi = acos(-1.0);
int main(){
    int a,b,h,m; cin >> a >> b >> h >> m;
    double angle = fabs(pi*h/6.0+pi*m/360.0-m*pi/30.0);
    printf("%.9f\n",sqrt(a*a+b*b-2*a*b*cos(angle)));
    return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n;
    double sum=0;
    cin >> n;
    vs u(n);
    vector<double> x(n);
    rep(i,n){
        cin >> x[i] >> u[i];
        if(u[i] == "JPY")sum += x[i];
        else sum += x[i]*380000;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>str;
	if((str[0]==str[1]||str[2]==str[3])&&str[1]==str[2]){
		cout<<"Yes";
	}else{
		cout<<"No";
	}







	cout<<endl;
} 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> data(N);
  for(int i=0;i<N;i++)
    cin>>data[i];

  int ans =0;
  for (int s=0;s<N;){
    int ie,de;
    
    for(ie=s+1;ie<N&&data[ie]>=data[ie-1];ie++);
    for(de=s+1;de<N&&data[de]<=data[de-1];de++);

    ans ++;
    s=max(ie,de);
  }

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


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

int main()
{
    
	int n;
	string s;

	cin >> n;

	cin >> s;

	int count = 1;
	char c = s[0];
	for (int i = 1; i < s.size(); i++) {
		if (c == s[i]) {
			continue;
		}
		else {
			count++;
			c = s[i];
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 512