akhauriyash/Code-Regression huggingface dataset:
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vector<double> v(n);
	rep(i, n) cin >> v[i];
	double buf;
	
	rep(i, n-1) {
		sort(v.begin(), v.end());
		buf = (v[0] + v[1]) / 2.0;
		v.erase(v.begin());
		v.erase(v.begin());
		v.push_back(buf);
	}
	cout << setprecision(7) << fixed <<  v[0] << endl;
;	return 0;
}

Measured memory_bytes: 256
N = int(input())
W = [str(input()) for i in range(N)]

if len(W) != len(set(W)):
    print("No")
    exit()

else:
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            print("No")
            exit()

    print("Yes")


Measured memory_bytes: 3060
use proconio::*;
use std::cmp::min;

fn main() {
    input! {
        n:usize,
        a: i64,
        b: i64,
        x: [i64; n],
    }

    let mut res = 0i64;

    for i in 1..n {
        res += min((x[i] - x[i - 1]) * a, b);
    }

    println!("{}", res);
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int H = Cin(), N = Cin();
    vector<int> As(N);
    for (auto &i : As) i = Cin();
    int sum = accumulate(As.begin(), As.end(), 0);
    cout << (sum >= H ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace std;
#define mst(a,b) memset(a,b,sizeof(a))
#define ALL(x) x.begin(),x.end()
#define pii pair<int, int>
#define debug(a) cout << #a": " << a << endl;
#define eularMod(a, b) a < b ? a : a % b + b
inline int lowbit(int x){ return x & -x; }
typedef long long LL;
typedef unsigned long long ULL;
const int N = 1e5 + 10;
const int mod = (int) 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double eps = 1e-6;

int k;
int dis[N];
bool inq[N];

int cal(int x) {
    int res = 0;

    for (; x; x /= 10)
        res += x % 10;

    return res;
}

queue<int> Q;

void spfa() {
    mst(dis, 0x3f);

    dis[1] = 1;
    inq[1] = true;

    Q.push(1);

    for (;!Q.empty();) {
        int u = Q.front();
        Q.pop();

        inq[u] = false;

        int v = (u + 1) % k;

        if (dis[v] > dis[u] + 1) {
            dis[v] = dis[u] + 1;

            if (!inq[v])
                Q.push(v);
        }

        v = (u * 10) % k;

        if (dis[v] > dis[u]) {
            dis[v] = dis[u];

            if (!inq[v])
                Q.push(v);
        }
    }
}

int main() {
#ifdef purple_bro
    freopen("in.txt", "r", stdin);
//    freopen("out.txt","w",stdout);
#endif
    scanf("%d", &k);

    spfa();

    printf("%d\n", dis[0]);
    return 0;
}

Measured memory_bytes: 896
using System;

namespace B___Bingo
{
    class Program
    {
        static void Main (string[] args)
        {
            var a = new string[3, 3];
            for (var i = 0; i < 3; i++)
            {
                var input = Console.ReadLine ().Split ();
                for (var j = 0; j < 3; j++)
                {
                    a[i, j] = input[j];
                }
            }
            var n = int.Parse (Console.ReadLine ());
            var b = new string[n];
            for (var i = 0; i < n; i++)
            {
                b[i] = Console.ReadLine ();
                for (var j = 0; j < 3; j++)
                {
                    for (var k = 0; k < 3; k++)
                    {
                        if (b[i] == a[j, k])
                        {
                            a[j, k] = "0";
                        }
                    }
                }
            }
            for (var i = 0; i < 3; i++)
            {
                if (a[i, 0] == "0" && a[i, 1] == "0" && a[i, 2] == "0" || a[0, i] == "0" && a[1, i] == "0" && a[2, i] == "0")
                {
                    Console.WriteLine ("Yes");
                    return;
                }
            }
            if (a[0, 0] == "0" && a[1, 1] == "0" && a[2, 2] == "0" || a[2, 0] == "0" && a[1, 1] == "0" && a[0, 2] == "0")
                Console.WriteLine ("Yes");

            else
                Console.WriteLine ("No");
        }
    }
}

Measured memory_bytes: 11220
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n);
    int e=0;
    rep(i,n)cin>>a[i],e^=a[i];
    rep(i,n)cout<<(e^a[i])<<sp;
    cout<<endl;
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    ll tmp = n;
    ll sum = 0;
    while (tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }
    if (n % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1!=m2) pr(1);
  else pr(0);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999
using namespace std;
int main() {
  int A,B,C,D;
  std::cin >> A >> B >> C >> D;
  while (1) {
    C -= B;
    if (C <= 0) {
      break;
    }
    A -= D;
    if (A <= 0) {
      break;
    }
  }
  if (A <= 0) {
    std::cout << "No" << '\n';
  }
  else{
    std::cout << "Yes" << '\n';
  }
}


Measured memory_bytes: 3588
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n, m, k; cin >> n >> m >> k;
    // ある a, b が存在して, k = m * a + n * b - 2 * a * b となるか？
    rep3(a, 0, n){
        rep3(b, 0, m){
            if(k == m * a + n * b - 2 * a * b){
                puts("Yes");
                return;
            }
        }
    }
    puts("No");    
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			C();
		}

		public static void C()
		{
			Scanner cin = new Scanner();
			string s = cin.Next();
			int n = s.Length;

			int count1 = 0;
			bool zero = true;
			for (int i = 0; i < n; ++i) {
				if (zero) {
					if (s[i] != '0') {
						++count1;
					}
				} else {
					if (s[i] != '1') {
						++count1;
					}
				}

				zero = !zero;
			}

			zero = false;
			int count2 = 0;
			for (int i = 0; i < n; ++i) {
				if (zero) {
					if (s[i] != '0') {
						++count2;
					}
				} else {
					if (s[i] != '1') {
						++count2;
					}
				}

				zero = !zero;
			}

			Console.WriteLine(Math.Min(count1, count2));
		}



	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])
typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    queue<double> k;
    double now = 0;
    for(int i = 0; i < K; i++){
        double a;
        cin >> a;
        k.push(a);
        now += a;
    }
    double ans = now;
    for(int i = 0; i < N - K; i++){
        double a; 
        cin >> a;
        now -= k.front();
        k.pop();
        now += a;
        k.push(a);
        ans = max(now, ans);
    }
    double ANSWER = (ans + K) / 2;
    cout << fixed << setprecision(10)<< ANSWER << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


int main(){
    vector<int> v(3);
    int sum=0, c;

    for(int i=0;i<3;i++){
        cin >> v[i];
        sum = sum + v[i];
    }

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

    if((v[1]-v[0]) % 2 == 1) c = ((v[2] + 1) * 3 - sum) / 2;
    else c = (v[2] * 3 - sum) / 2;

    cout << c << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
'''input
3 3
.#.
#..
.#.
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
input = stdin.readline
from collections import deque


def mp(arr):
	arr = map(str, arr)
	return ' '.join(arr)


def bfs(source):
	myq = deque()
	myq.append(source)
	visited = dict()
	visited[mp(source)] = True
	dist = -1
	while len(myq) > 0:
		temp = deque()
		dist += 1
		while len(myq) > 0:
			x, y  = myq.popleft()
			if x - 1 >= 0:
				if maze[x - 1][y] != '#' and mp([x - 1, y]) not in visited:
					visited[mp([x -1, y])] = True
					temp.append([x - 1, y])
			if x + 1 < n:
				if maze[x + 1][y] != '#' and mp([x + 1, y]) not in visited:
					visited[mp([x + 1, y])] = True
					temp.append([x + 1, y])
			if y - 1 >= 0:
				if maze[x][y - 1] != '#' and mp([x, y - 1]) not in visited:
					visited[mp([x, y - 1])] = True
					temp.append([x, y - 1])
			if y + 1 < m:
				if maze[x][y + 1] != '#' and mp([x, y + 1]) not in visited:
					visited[mp([x, y + 1])] = True
					temp.append([x, y + 1])
		myq = temp
	return dist		


# main starts
n, m = list(map(int, input().split()))
maze = []
for _ in range(n):
	state = list(input().strip())
	maze.append(state)

# from random import randint
# for _ in range(1000):
# maze = []
# n = randint(1, 20)
# m = randint(1, 20)
# for i in range(n):
# 	temp = []
# 	for j in range(m):
# 		k = randint(1, 2)
# 		if k == 1:
# 			temp.append('.')
# 		else:
# 			temp.append('#')
# 	maze.append(temp)

ans = 0
for i in range(n):
	for j in range(m):
		if maze[i][j] != '#':
			first = [i, j]
			ans = max(ans, bfs(first))
print(ans)

Measured memory_bytes: 90712
#include <bits/stdc++.h>
main(){char* s[]={"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};float f[]={0,48,51,54,57,60,64,69,75,81,91,1e9};while(std::cin>>*f){int i=1;for(;*f>f[i++];){}printf("%s\n",s[i-2]);}}

Measured memory_bytes: 1184
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, z, w;
	cin >> n >> z >> w;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int ans = abs(a[n-1] - w);
	if(n >= 2) ans = max(abs(a[n-1] - w), abs(a[n-1] - a[n-2]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
n, x, y = map(int, input().split())
x = x - 1
y = y - 1

l = [[] for _ in range(n)]

for i in range(n):
    if (i != n - 1):
        l[i].append(i + 1)
    if (i == x - 1):
        l[i].append(y - 1)

kl = [0] * (n - 1)

for s in range(n - 1):
    for e in range(s+1, n):
        d = e-s
        if (e <= x)or(s >= y):
            kl[d - 1] += 1
        else:
            kl[min(d, abs(s-x)+abs(e-y)+1)-1] += 1

for i in kl:
    print(i)


Measured memory_bytes: 47068
#include<stdio.h>

int main(){
  int a,b,c;
  scanf("%d%d%d", &a, &b, &c);
  if ( a < b && b < c ){
    printf("Yes\n",a,b,c);
    }
  else {
    printf("No\n",a,b,c);
    }
  return 0;
}

Measured memory_bytes: 580
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			long[] e = new long[n];
			long[] o = new long[n*(n-1)/2];
			for(int i=0;i<n;i++){
				e[i]=sc.nextLong();
			}
			for(int i=0;i<o.length;i++){
				o[i]=sc.nextLong();
			}
			Arrays.sort(e);
			Arrays.sort(o);
			if(o[0]==0){
//				System.out.println("jpoirwajtpoia");
//				continue;
			}
			
			BigInteger bi=new BigInteger(""+e[0]);
			bi=bi.multiply(new BigInteger(""+e[1]));
			bi=bi.divide(new BigInteger(""+o[0]));
			long E = (long)Math.sqrt(Long.parseLong(bi.toString())); 
//			long E = (long)Math.sqrt((e[0]*e[1])/o[0]);
			System.out.println(E);
			for(int i=0;i<e.length;i++){
				if(E==0){
//					System.out.println("jpoirwajtpoia");
//					break;
				}
				System.out.print(e[i]/E);
				if(i!=e.length-1)System.out.print(" ");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 159140
#include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll mod_pow(ll x,ll n,ll mod){
	ll bit=1;
	while(n){
		if(n&1)bit=bit*x%mod;
		x=x*x%mod;
		n/=2;
	}
	return bit;
}
ll dp[114514][13];
signed main() {
	string s;
	cin>>s;
	ll n=s.size();
	string t;
	for(int i=n-1;i>=0;i--)t+=s[i];
	if(t[0]=='?'){
		rep(i,10)dp[0][i]=1;
	}
	else dp[0][(t[0]-'0')]=1;
	for(ll i=0;i<n-1;i++){
		for(ll j=0;j<13;j++){
		if(t[i+1]=='?'){
			for(ll k=0;k<=9;k++){
				dp[i+1][(j+(mod_pow(10,i+1,13)*k)%13)%13]+=dp[i][j];
				dp[i+1][(j+(mod_pow(10,i+1,13)*k)%13)%13]%=inf;
			}
		}
		else{
			dp[i+1][(j+(mod_pow(10,i+1,13)*(t[i+1]-'0'))%13)%13]+=dp[i][j];
			dp[i+1][(j+(mod_pow(10,i+1,13)*(t[i+1]-'0'))%13)%13]%=inf;
	      }
	   }
    }
	cout<<dp[n-1][5]%inf<<endl;
	ggr
}



Measured memory_bytes: 10752
#include<iostream>
#include<cstdio>
#include<stack>

using namespace std;

int main(){
	int operation;
	stack<int> s;

	while(cin >> operation){
		if(operation != 0){
                  s.push(operation);
		}  
		else if(operation == 0){
                  cout << s.top() << endl;
		  s.pop(); 
		}
	}
}

Measured memory_bytes: 1200
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
 
        while (true) {
            int n = scan.nextInt();
            if (n == 0)
                break;
            int[] s = new int[n];
            double m = 0;
            for (int i = 0; i < n; i++) {
                s[i] = scan.nextInt();
                m += s[i];
            }
            m /= n;
            double a = 0;
            for (int i = 0; i < n; i++) {
                a += Math.pow(s[i] - m, 2);
            }
            a = Math.sqrt(a / n);
 
            System.out.println(a);
 
        }
 
        scan.close();
        System.exit(0);
    }
 
}


Measured memory_bytes: 30832
#include<bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define vv(dt) vector<vector<dt>>
#define vec vector<int>
#define un unsigned
#define mp(x,y) make_pair(x,y)
#define dbl double
#define wking(t) cout<<"Working "<<t<<endl;
#define loop(i,s,n) for(auto i=s;i!=n;i++)
#define min2(a,b) (a)<(b)?(a):(b)
#define eps 0.000000001
#define inf 100000000000000001
using namespace std;



int f(int n,int m,string &s,string &t,vv(int) &dp)
{
    if(n<0 or m<0) return 0;
    if(dp[n][m]!=-1) return dp[n][m];
    if(s[n]==t[m]) dp[n][m] = 1+f(n-1,m-1,s,t,dp);
    else dp[n][m] = max(f(n-1,m,s,t,dp),f(n,m-1,s,t,dp));
    return dp[n][m];
}

void calc(int n,int m,string &s,string &t,vv(int) &dp,string &ans)
{
    if(n<0 or m<0) return;
    if(s[n]==t[m])
    {
        ans += s[n];
        calc(n-1,m-1,s,t,dp,ans);
    }
    else
    { 
        if(f(n-1,m,s,t,dp)>f(n,m-1,s,t,dp)) calc(n-1,m,s,t,dp,ans);
        else calc(n,m-1,s,t,dp,ans);
    }
}


int main()
{
    string s,t;
    string ans="";
    cin>>s>>t;
    int n=s.size(),m=t.size();
    vv(int) dp(n,vec (m,-1));
    f(n-1,m-1,s,t,dp);
    // loop(i,0,n)
    // {
    //     loop(j,0,m) cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    calc(n-1,m-1,s,t,dp,ans);
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 35968
#include<bits/stdc++.h>
//#pragma GCC optimize("trapv")
#define I inline void 

using namespace std ; 
using ll = long long ; 
using ld = long double ; 
	
const int N = 1e5 + 7 , mod = 1e9 + 7 ; 

// How interesting!
	
int n , m; 
	
int main(){	
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 
	//freopen("in.in" , "r" ,stdin) ; 
	ll x , y ; 
	cin >> x >> y ;
	cout<< max(0ll  , ( 4 - x ) * 100000) + max(0ll , (4 - y) ) * 100000  + (x + y == 2 ? 400000 : 0) ;  
	return 0 ; 
	
}

Measured memory_bytes: 3636
N, Q = map(int, input().split())
EDGES = [list(map(int, input().split())) for i in range(N-1)]
OPES = [list(map(int, input().split())) for i in range(Q)]
VALUES = [0 for i in range(N)]
#operation1
for o in OPES:
    VALUES[o[0]-1] += o[1]
#operation2
EDGES.sort(key=lambda e:e[0])
for e in EDGES:
    VALUES[e[1]-1] += VALUES[e[0]-1]
print(" ".join(map(str, VALUES)))


Measured memory_bytes: 125468
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

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

sys.setrecursionlimit(10 ** 8)

S = input()
if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 7712
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  long n;
  cin >> n;
  long l[n], r[n];
   for(int i=0; i<n; i++){
  cin >> l[i] >> r[i];
   }
  int sum=0;
  for(int i=0; i<n; i++){
  	sum= sum+(r[i]-l[i]+1);
  }
  cout << sum << endl;
}

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

int main(){
    int n; cin>>n;
    set<int> st;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        st.insert(a);
    }
    if(st.size()==n) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

int main(){
    int x;
    cin >> x;
    while(true){
        bool b = false;
        for(int i = 2; i*i <= x; i++){
            if(x%i == 0){
                b = true;
                break;
            }
        }
        if(b){
            x++;
            continue;
        }
        cout << x << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define hell 998244353
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
#define pii pair<int,int>
#define L LLONG_MAX
#define all(v) (v).begin(),(v).end()
#define tcFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
//vector<int>prime(15000005,0);
ll mM(ll a,ll b,ll p=hell){ll res = 0;if(a>=p)a %= p;while(b){if (b & 1ll)res = (res + a);if(res>=p) res%= p;a = (2 * a); if(a>=p)a%=p;b >>= 1ll;}return res;}
ll fpow(ll x,ll y,ll p=hell){if(x>=p)x=x%p;ll res=1;while(y){if(y&1ll)res*=x;if(res<0)res+=p;if(res>=p)res%=p;y=y>>1ll;x*=x;if(x<0)x+=p;if(x>=p)x%=p;}return res;}
ll inv(ll n,ll p=hell){return fpow(n,p-2,p);}
ll modmul(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;return (x*y)%p;}
ll modadd(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;ll temp=x+y;if(temp>=p)temp%=p;return temp;}
/*void sieve(){
    prime[0] = -1;
    prime[1] = 0;
    for(int i=2;i<=15000000;i++)
        if(!prime[i])
            for(int j=i;j<=15000000;j+=i)
            	if(!prime[j])
            		prime[j] = i;
}*/
int main(){
	ios
	int t = 1,tc = 0;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		vector<int>a(n), dp(n, 0);
		for (int i = 0; i < n; i++)
			cin >> a[i];
		for (int i = 1; i < n; i++)
			if (i == 1)
				dp[i] = dp[i-1] + abs(a[i] - a[i-1]);
			else
				dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
		cout << dp[n-1] << "\n";
	}
}


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

#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define for1(i, n) for (int i = 1; i <= (int)n; ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long i64;
typedef vector<int> vi;
typedef vector<i64> vi64;
typedef vector<vi> vvi;
typedef vector<vi64> vvi64;
typedef double ld;

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m, p;
    cin >> n >> m >> p;

    vector<tuple<int, int, int>> es;
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        es.emplace_back(a, b, p - c);
    }

    const int inf = (1 << 30);
    vector<int> d(n, inf);
    d[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            int from, to, cost;
            tie(from, to, cost) = es[j];
            if (d[from] == inf)
                continue;

            if (d[to] > d[from] + cost)
            {
                d[to] = d[from] + cost;
            }
        }
    }

    vector<bool> negative(n, false);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {

            int from, to, cost;
            tie(from, to, cost) = es[j];
            if (d[from] == inf)
                continue;

            if (d[to] > d[from] + cost)
            {
                negative[to] = true;
            }

            if (negative[from])
                negative[to] = true;
        }
    }

    if (negative[n - 1])
    {
        cout << -1 << endl;
    }
    else
    {
        cout << max(0, -d[n - 1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

int main() {
  size_t k;
  std::cin >> k;

  size_t ans = k % 2 == 1 ?
    (k / 2) * (k / 2 + 1) :
    (k / 2) * (k / 2);

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

  return 0;
}


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

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

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

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

    int ans;
    ans = d.at(N / 2) - d.at(N / 2 - 1);
    cout << ans << endl;
}

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

int main(){
  int n,count=0;
  cin>>n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  for(int i=0;i<n-2;i++){
    if(num[i]<num[i+1]&&num[i+1]<num[i+2]) count++;
    else if(num[i]>num[i+1]&&num[i+1]>num[i+2]) count++;
    else if(num[i]==num[i+1]&&num[i+1]<num[i+2]) count++;
    else if(num[i]>num[i+1]&&num[i+1]==num[i+2]) count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;



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

	int l=s.length();
	
	cout << s[0] << l-2 << s[l-1] << endl;

	return 0;
}




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

int main(){
  int n,m;
  while(cin >> n >> m && n){
    vector<int> days(101,0);
    for(int i=0,s;i<n;i++){
      cin >> s;
      for(int j=0,l;j<s;j++){
        cin >> l;
        days[l]++;
      }
    }
    int max = 0,a;
    for(int i=0;i<101;i++){
      if(max < days[i]) max=days[i],a=i;
    }
    cout << (max<m?0:a) << endl;
  }
}

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

int main() {
    long N;
    cin >> N;
    long ans = 0;
    for (long i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5+10;
ll a[N];
ll pre[N];
int main(){
   int n,k;
   scanf("%d %d",&n,&k);
   pre[0]=1;
    for (int i = 1; i <=n ; ++i) {
        scanf("%lld",&a[i]);
    }

        for (int i = k+1; i <=n ; ++i) {
            if(a[i]>a[i-k])cout<<"Yes\n";
            else cout<<"No\n";
        }

   return 0;
}

Measured memory_bytes: 5324
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <string>
 
using namespace std;
 
#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll; 
typedef pair<int,int> P;

struct UnionFind{
    int size;
    vector<int> par;
    vector<int> rank;
    UnionFind(int x){
        size=x;
        par=vector<int> (x);
        rank=vector<int> (x,1);
        for (int i=0;i<x;i++){
            par[i]=i;
        }
    }
    int root(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=root(par[x]);
        }
    }
    void unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y){
            return;
        }
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
        }
        if(rank[x]==rank[y]){
            rank[x]++;
        }
    }
    bool check(int x,int y){
        return root(x)==root(y);
    }
    void initialize(){
        for (int i=0;i<size;i++){
            par[i]=i;
            rank[i]=1;
        }
    }
};

int main(){
	int n;
	cin >> n;
	vector<P> x(n),y(n);
	rip(i,n,0){
		cin >> x[i].first >> y[i].first;
		x[i].second=i;
		y[i].second=i;
	}
	sort(all(x));
	sort(all(y));
	priority_queue<pair<int,P>, vector<pair<int,P>>, greater<pair<int,P>>> pq;
	rip(i,n,1){
		pq.push(make_pair(x[i].first-x[i-1].first,make_pair(x[i].second,x[i-1].second)));
		pq.push(make_pair(y[i].first-y[i-1].first,make_pair(y[i].second,y[i-1].second)));
	}
	ll ans=0;
	UnionFind uf(n);
	while(pq.size()){
		//printf("%lld\n",ans);
		pair<int,P> now=pq.top();
		pq.pop();
		if(!uf.check(now.second.first,now.second.second)){
			uf.unite(now.second.first,now.second.second);
			ans=(ll)ans+now.first;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 6516
#include <iostream>
using namespace std;
int main(){
	string s;
	getline(cin,s);
	for(int i=0;i<s.size();i++){
		for(int j=-34;j<100;j++){
		   if(s[i]==('A'+j)){
			 if(123>'A'+j&&'A'+j>96){
			   cout<<(char)('A'+j-32);
			 }
		     else if(64<'A'+j&&'A'+j<91){
		              cout<<(char)('A'+j+32);
		     }
		     else {
        		   cout<<(char)('A'+j);
		       }	
		   }   
	     }	   
	    }
    cout<<endl;
   return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int keta(int x){
  for(int i=1;i<11;i++){
    if(x==0||x==1){
      return 1;
    }

    if(x!=0&&x!=1){
    if(x%int(pow(10,i))==x){
return i;
      break;
    }
  }
}

}

int main(){
  
  ll N;
  cin>>N;
  ll mini=INF;
  for(ll i=1;i<=N;i++){
    if(i>N/i){
      break;
    }

    if(N%i==0){

mini=min(max(keta(N/i),keta(i)),mini);
    }
  }
  

  cout<<mini<<endl;
}


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

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

    for (int i = 0; i < S.size(); ++i) {
        int c = (S[i] - 'A' + N) % 26 + 'A';
        printf("%c", c);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
int main()
{
    int n; cin >> n;
    vector< int > v(n);
    long long int sum=0;
    map< int , int > mp;

    for(int i=0;i<n;i++)
    {
        cin >> v[i];
        sum+=v[i];
        mp[v[i]]++;
    }

    int tt; cin >> tt;

    while(tt--)
    {
        int a,b; cin >> a >> b;

        sum-=(mp[a]*a);
        sum+=(mp[a]*b);
        mp[b]=mp[b]+mp[a];
        mp.erase(a);
        cout << sum << endl;
    }




    #ifdef TarekHasan
        main();
    #endif // TarekHasan

    return 0;
}



Measured memory_bytes: 6256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final int n = scanner.nextInt();
    int c = 0;
    int[] pos = new int[2];
    for (int i = 0; i < n; i++) {
      int t = scanner.nextInt();
      int[] next = new int[2];
      next[0] = scanner.nextInt();
      next[1] = scanner.nextInt();
      int m = Math.abs(pos[0] - next[0]) + Math.abs(pos[1] - next[1]);
      int d = t - c;
      if (m > d || (d - m) % 2 == 1) {
        System.out.println("No");
        return;
      }
      c = t;
      pos = next;
    }
    System.out.println("Yes");
  }
}


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

using namespace std;

string A, B, C;

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

    cin >> A >> B >> C;

    if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int main()
{
	char s[4];
	scanf("%s", s);

	if (s[0] == '7' || s[1] == '7' || s[2] == '7')
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 1660
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(n):
  temp=0
  A=list(map(int,input().split()))
  for a,b in zip(A,B):
    temp+=a*b
  if temp+c>0:
    ans+=1
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
const long long mod=1000000007;
int c[1000000];
int main()
{
	int n,m,j=1;
	long long a,b,temp;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d",&c[i]);
	sort(c+1,c+1+m);
	if(c[1]==1||c[1]==2){
		a=0;
		b=1;
		j++;
		temp=0;
	}else{
		a=1;
		b=2;
		temp=0;
	}
	for(int i=3;i<=n;i++){
		if(i==c[j]&&j<=m){
			a=b;
			b=0;
			j++;
			continue;
		}
		temp=a+b;
		a=b;
		b=temp%mod;
	}
	if(c[2]-c[1]==1){
		printf("0\n");
	}else if(n==1){
		printf("1\n");
	}else if(n==2&&m==1){
		printf("1\n");
	}else if(n==2&&m==0){
		printf("2\n");	
	}else{
		printf("%lld\n",b);
	}
	return 0;
}

Measured memory_bytes: 512
x, n = gets.split.map(&:to_i)

if n == 0
  puts x
  exit
end

p = gets&.split&.map(&:to_i)

i = 0
while
  a = x - i
  b = x + i

  unless p.include?(a)
    puts a
    break
  end
  unless p.include?(b)
    puts b
    break
  end

  i += 1
end

Measured memory_bytes: 14292
n, m= map(int, input().split())
high = list(map(int, input().split()))
ans = [1]*n

for i in range(m):
    a, b = map(int, input().split())
    if high[a-1] > high[b-1]:
        ans[b-1] = 0
    elif high[a-1] < high[b-1]:
        ans[a-1] = 0
    else:
        ans[a-1] = 0
        ans[b-1] = 0
print(sum(ans))

Measured memory_bytes: 86240
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define shosu setprecision(10)
typedef long long ll;
typedef pair<int,pair<int,pair<int,int>>> P;

ll longinf=1ll<<60;
int inf=1<<29;

int A[3];
int main(){
    rep0(i,3){
        cin>>A[i];
    }
    int ans=inf;
    rep0(i,3){
        ans=min(ans,abs(A[i]-A[(i+1)%3])+abs(A[i]-A[(i+2)%3]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from math import gcd
K = int(input())
sum = 0
for a in range(1, K+1):
  for b in range(a+1, K+1):
    for c in range(b+1, K+1):
      sum += gcd(gcd(a, b), c)
sum *= 6
for j in range(1, K+1):
  for k in range(j+1, K+1):
    sum += gcd(j, k)*6
for l in range(1, K+1):
  sum += l 
print(sum)

Measured memory_bytes: 67992
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int

int main(){
  ll n,num=0,r;
  cin>>n;
  if(n%10==0){
     cout<<10<<endl;
  }
  else{
     while(n>0){
        r = n%10;
        num=num+r;
        n=n/10;
     }
    cout<<num<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a[100005],b,ans,n,m;
int binarysearch(int key){
	int left=0;
	int right=n;
	int mid;
	while(left<right){
		mid=(left+right)/2;
		if(key==a[mid]) return 1;
		if(key>a[mid]) left=mid+1;
		else if(key<a[mid]) right=mid;
	}
	return 0;
}
int main()
{

	cin>>n;
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	cin>>m;
	for(int i=0;i<m;i++)
	{
		scanf("%d",&b);
		if(binarysearch(b)) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3536
hoge=list(input())
huga=list(input())
hoge.sort()
huga.sort(reverse=True)
flag=0

for i in range(min(len(hoge),len(huga))):
  if(hoge[i]>huga[i]):
    flag=1
    break
  elif(hoge[i]<huga[i]):
    flag=-1
    break

if(flag==0):
  if(len(hoge)>=len(huga)):
    flag=1
    
    
if(flag==1):
  print("No")
else:
  print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

#include <functional>
template<typename T>
class SegmentTreeOneAll {
    using Func = function<T(T, T)>;

public:
    vector<T> data;
    int n;
    T init;
    Func update_func;
    Func query_func;
    SegmentTreeOneAll(int _n, T _init, Func up, Func qu) {
        init = _init;
        update_func = up;
        query_func = qu;
        for (n = 1; n < _n; n *= 2)
            ;
        data.resize(2 * n - 1, init);
    }
    void update(int pos, T val) {
        pos += n - 1;
        data[pos] = update_func(data[pos], val);
        while (pos > 0) {
            pos = (pos - 1) / 2;
            data[pos] = query_func(data[2 * pos + 1], data[2 * pos + 2]);
        }
    }
    T query(int l, int r) {
        T resL = init, resR = init;
        for (l += n - 1, r += n - 1; l < r; l = l / 2, r = (r - 1) / 2) {
            if (!(l & 1)) {
                resL = query_func(resL, data[l]);
            }
            if (!(r & 1)) {
                resR = query_func(data[r - 1], resR);
            }
        }
        return query_func(resL, resR);
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    auto UPDATE = [](ll a, ll b) { return b; };
    auto MIN = [](ll a, ll b) { return min(a, b); };
    SegmentTreeOneAll<ll> segtree(n, (1LL << 31) - 1, UPDATE, MIN);
    REP(i, 0, q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com) {
            cout << segtree.query(x, y + 1) << endl;
        } else {
            segtree.update(x, y);
        }
    }

    return 0;
}



Measured memory_bytes: 4868
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


void solve(int n, vector<string> s) {
    bool l = false, r = false;
    bool pre = false;
    int cnt = 0;
    rep (i, s.size()) {
        if (s[i][0] == 'l') l = !l;
        else r = !r;
        if (l == r) {
            if (l != pre) {
                cnt++;
                pre = !pre;
            }
        }
    }
    cout << cnt << endl;
}

signed main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) return 0;
        vector<string> s(n);
        rep (i, n) cin >> s[i];
        solve(n, s);
    }
}


Measured memory_bytes: 3168
///
// File:  1193.cpp
// Author: ymiyamoto
//
// Created on Sat Nov 25 23:05:51 2017
//

#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

void print_board(vector<vector<int32_t>> board)
{
  for (uint32_t i = 0; i < board.size(); i++) {
    for (uint32_t j = 0; j < board[i].size(); j++) {
      cout << board[i][j] << " ";
    }
    cout << endl;
  }
}

void erase(vector<vector<int32_t>> &board, vector<pair<uint32_t, uint32_t>> disps)
{
  for (uint32_t i = 0; i < disps.size(); i++) {
    for (uint32_t j = disps[i].first; j < disps[i].second; j++) {
      board[i][j] = -1;
    }
  }

  for (uint32_t i = 0; i < 5; i++) {
    for (uint32_t j = 0; j < board.size() - 1; j++) {
      while (board[j][i] == -1) {
        for (uint32_t k = j; k < board.size() - 1; k++) {
          board[k][i] = board[k + 1][i];
        }
      }
    }
  }
}

int32_t main()
{
  while (true) {
    int32_t H;
    cin >> H;
    if (H == 0) break;
    vector<vector<int32_t>> board(H + 1);
    for (int32_t i = H; i >= 0; i--) {
      for (uint32_t j = 0; j < 5; j++) {
        uint32_t b;
        if (i == H) {
          b = 0;
        } else {
          cin >> b;
        }
        board[i].push_back(b);
      }
    }

    uint32_t points = 0;
    while (true) {
      vector<pair<uint32_t, uint32_t>> disps(H);
      bool is_erase = false;
      for (uint32_t i = 0; i < H; i++) {
        uint32_t max_rep = 0;
        uint32_t start = 0;
        uint32_t end = 0;
        uint32_t max_start = 0;
        uint32_t max_end = 0;
        for (uint32_t j = 0; j < 5; j++) {
          if (board[i][j] != 0 && board[i][start] == board[i][j]) {
            end++;
            uint32_t rep = end - start;
            if (max_rep < rep) {
              max_rep = rep;
              max_start = start;
              max_end = end;
            }
          } else {
            start = j;
            end = j + 1;
          }
        }

        if (max_rep >= 3) {
          disps[i] = {max_start, max_end};
          points += board[i][max_start] * max_rep;
          is_erase = true;
        }
      }

      if (!is_erase) break;

      erase(board, disps);
    }

    cout << points << endl;
  }
  return 0;
}

Measured memory_bytes: 3140
from collections import deque

_ = input()
S = input()

que = deque([])

flag = False # White
tmp = 0

for s in S:
    if flag:
        if s == "#":
            tmp += 1
        else:
            que.append(tmp)
            tmp = 1
            flag = not flag
    else:
        if s == ".":
            tmp += 1
        else:
            que.append(tmp)
            tmp = 1
            flag = not flag

que.append(tmp)

if not flag:
    que.append(0)

cost = 0
fe_cost = []
fe_cost.append(cost)
flag = True
for q in que:
    if flag:
        flag = not flag
    else:
        cost += q
        fe_cost.append(cost)
        flag = not flag
fe_cost.pop()

cost = 0
be_cost = []
be_cost.append(cost)
flag = True
for q in reversed(que):
    if flag:
        flag = not flag
    else:
        cost += q
        be_cost.append(cost)
        flag = not flag
be_cost.pop()
be_cost.reverse()
fe_cost = list(fe_cost)
be_cost = list(be_cost)

cost = [x + y for (x, y) in zip(fe_cost, be_cost)]
print(min(cost))


Measured memory_bytes: 17096
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
#define fe(i, start, end) for (lli i = start; i <= end; ++i)
#define pi 3.14159265359
#define L(T)  \
    lli T;    \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
int main()
{
    FASTIO
    //   L(T)
    {
        lli n, m;
        cin >> n >> m;
        lli s = 0;
        lli a[m + 2];
        fw(i, 0, m)
        {
            cin >> a[i];
            s += a[i];
        }
        if (s > n)
        {
            cout << "-1"
                 << "\n";
        }
        else
        {
            cout << n - s << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3728
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    R = int(readline())
    ans = 2 * R * np.pi
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27144