akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: u64,
    }
    println!("{}", n * (n + 1) / 2);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    
    vector<int> dp(n,1e9);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    
    rep(i,n-2){
        dp[i+2] = min(dp[i+2],dp[i+1] + abs(h[i+2] - h[i+1]));
        dp[i+2] = min(dp[i+2],dp[i]+ abs(h[i+2] - h[i]));
    }
    cout << dp[n-1];
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

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

const int INF = 1 << 24;

typedef unsigned long long ull;
typedef long long ll;

int N, a[110];

std::vector<char> _q;

template <class T>
void print(const std::vector<T>& q){
    for(auto i : q){
        printf("%c ", i);
    }
    puts("");
}

ull dp[110][30];
bool isMade[110][30];

ull rec(int index, int sum){
    if(index == N && sum == a[N]){return 1;}

    if(index >= N){return 0;}
    if(0 <= sum && sum <= 20);
    else{return 0;}

    if(isMade[index][sum]){
        return dp[index][sum];
    }

    ull res = 0;
    //_q.push_back('+');
    res += rec(index+1, sum + a[index]);
    //_q.erase(_q.end() - 1);
    //_q.push_back('-');
    res += rec(index+1, sum - a[index]);
    //_q.erase(_q.end() - 1);

    isMade[index][sum] = true;
    return dp[index][sum] = res;
}

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

    REP(i, N){
        std::cin >> a[i];
    }

    REP(i, 110){
        REP(j, 30){
            isMade[i][j] = false;
            dp[i][j] = 0;
        }
    }

    std::cout << rec(1, a[0]) << std::endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector <int> A;
  A.reserve(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  vector<int> B(A.begin(), A.end());
  sort(B.begin(), B.end());
  
  for (int i = 0; i < N; i++) {
    if (A[i] == B[N-1]) {
      cout << B[N-2] << endl;
    } else {
      cout << B[N-1] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3200
N = int(input())
*A, = map(int, input().split())
mod = 10**9 + 7

col = [0, 0, 0]
ans = 1
for a in A:
    if a not in col:
        print(0)
        break
    ans = ans * col.count(a) % mod
    col[col.index(a)] += 1
else:
    print(ans)


Measured memory_bytes: 86512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            int[][] l = new int[n][n];
            int f=0;
            for (int i = 0; i < n; i++) {
                String s = sc.next();
                for (int j = 0; j < n; j++) {
                    l[i][j] = s.charAt(j) - '0';
                    if(l[i][j]==1)f=1;
                }
            }
            int max=0;
            for (int i = 0; i < n; i++) {
                int sum1=f;
                int sum2=f;
                for (int j = 1; j < n; j++) {
                    if(l[i][j-1]+l[i][j]==2) {
                        sum1++;
                    }else if(l[i][j]==1){
                       max=Math.max(max, sum1); 
                       sum1=f;
                    }
                    if(l[j-1][i]+l[j][i]==2) {
                        sum2++;
                    }else if(l[j][i]==1){
                       max=Math.max(max, sum2); 
                       sum2=f;
                    }
                }
                max=Math.max(max, sum1); 
                max=Math.max(max, sum2); 
            }
            for(int i=0,x=1,y1=n,y2=-1;i<n*2-3;i++) {
                int sum3=f;
                int sum4=f;
                if(x<y1) {
                    y1--;
                    y2++;
                }else {
                    x++;
                }
                for(int j=x,k=y1;j<n&&k<n;j++,k++) {
                    if(l[k-1][j-1]+l[k][j]==2) {
                        sum3++;
                    }else if(l[k][j]==1){
                       max=Math.max(max, sum3); 
                       sum3=f;
                    }
                }
                for(int j=x,k=y2;j<n&&k>=0;j++,k--) {
                    if(l[k+1][j-1]+l[k][j]==2) {
                        sum4++;
                    }else if(l[k][j]==1){
                       max=Math.max(max, sum4); 
                       sum4=f;
                    }
                }
                max=Math.max(max, sum3); 
                max=Math.max(max, sum4); 
            }
            System.out.println(max);
        }
    }
}


Measured memory_bytes: 40824
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

ans = 0
sum = a.inject(:+)

ans = 2020202020

left = 0
right = sum - left
n.times do |i|
  left += a[i]
  right = sum - left
  ans = [ans, (left - right).abs].min
end

puts ans




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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long N;
		N = sc.nextLong();
		long K;
		K = sc.nextLong();
		solve(N, K);
	}

	static void solve(long N, long K) {
		long n = N / K;
		if (K % 2 == 1) {
			System.out.println(n * n * n);
		} else {
			long a = n * n * n;
			if (K / 2 > N) {
				System.out.println(a);
			} else {
				long b = (N - K / 2) / K + 1;
				a += b * b * b;
				System.out.println(a);
			}
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<long long>a(n);
    vector<long long>c(n + 1,0);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        c[a[i]]++;
    }
    long long sum = 0;
    for(int i = 0;i < n + 1;i++){
        sum += c[i] * (c[i] - 1)/2;
    }
    for(int i = 0;i < n;i++){
        long long  pat;
        pat = sum - (c[a[i]] - 1);
        cout << pat << endl;
    }
}




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

public class Main {

	public static void main(String[] args)
	{
			Scanner in = new Scanner(System.in);
			int A = in.nextInt(), B = in.nextInt();
			int cnt = 0;

			for(int i = A; i <= B; i++)
			{
				String val = String.valueOf(i);
				String str = "";
				for(int j = val.length() - 1; j >= 0; j--)
					str += val.charAt(j) + "";

				if(val.equals(str))
					cnt++;
			}
			System.out.println(cnt);
	}
    
}

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

using namespace std;

constexpr static int MAXN = 1e6;

int n;
int64_t a[MAXN];
int64_t s[MAXN];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);

    s[0] = a[0];
    for (int i = 1; i < n; i++)
        s[i] = s[i - 1] + a[i];

    int cnt = 1;
    for (int i = n - 2; i >= 0; i--) {
        if (a[i + 1] <= 2 * s[i])
            cnt++;
        else
            break;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 5120
<?php
	list($x, $y) = explode(" ", trim(fgets(STDIN)));
	$g = gcd($x, $y);
	echo $g . "\n";

	function gcd($x, $y) {
		if ($x < $y) {
			$t = $y;
			$y = $x;
			$x = $t; 
		}

		while ($y) {
			$r = $x % $y;
			$x = $y;
			$y = $r;
		}
		return $x;
	}

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


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

using namespace std;




int main(){
    int n;
    cin >> n;
    vector<int> d;
    int d_;
    for(int i=0;i<n;i++){
        cin >> d_;
        d.push_back(d_);
    } 
    sort(d.begin(),d.end());
    int half = n/2;
    vector<int>::iterator it=d.begin();
    it+= (half-1);
    //cout << (*it) << " " <<  *(it+1) << endl;
     int ans = *(it+1) - (*it);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
N, M = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(M)]
#for _ in range(M) :
#    l.append()
p = list(map(int, input().split()))

ans = 0

for a in range(2) :
    for b in range(2) :
        for c in range(2) :
            for d in range(2) :
                for e in range(2) :
                    for f in range(2) :
                        for g in range(2) :
                            for h in range(2) :
                                for i in range(2) :
                                    for j in range(2) :
                                        sl = [a, b, c, d, e, f, g, h, i, j]
                                        sl = sl[0:N]
                                        judge = [0] * M
                                        for m in range(M) :
                                            cnt = 0
                                            for ss in range(1, len(l[m])) :
                                                #cnt = 0
                                                if sl[l[m][ss] - 1] == 1 :
                                                    cnt += 1
                                                #print(cnt)
                                            if cnt % 2 == p[m] :
                                                #print(m, judge)
                                                judge[m] = 1
                                        #print(judge)
                                        if sum(judge) == M :
                                            #print(sl)
                                            ans += 1



ans /= (2 ** (10 - N))
ans = int(ans)

print(ans)

#for i in range(M) :


Measured memory_bytes: 3192
# -*- coding: utf-8 -*-
# Queue


class Process:
    def __init__(self, line):
        self.name = line[0]
        self.time = int(line[1])


LEN = 100000
n = 0
head = 0
tail = 0
Q = [0] * LEN


def enqueue(x):
    global tail
    Q[tail] = x
    tail = (tail + 1) % LEN

def dequeue():
    global head
    x = Q[head]
    head = (head + 1) % LEN
    return x


def main():
    n, q = map(int, input().split())
    ps = [Process(input().split()) for _ in range(n)]
    for p in ps:
        enqueue(p)

    global head, tail

    elaps = 0
    while(head != tail):
        u = dequeue()
        c = min(q, u.time)
        u.time -= c
        elaps += c
        if u.time > 0:
            enqueue(u)
        else:
            print(u.name, elaps)

if __name__ == '__main__':
    main()



Measured memory_bytes: 18196
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

int main(){
    int N, T, i, j, k, ans = 0;
    scanf("%d %d", &N, &T);

    vector<int> t_i(N);
    for(i = 0; i < N; i++){
        scanf("%d", &t_i[i]);
    }

    for(i = 0, j = 0, k = 0; i < (t_i[N - 1] + T); i++, k--){
        if(t_i[j] == i){
            k = T;
            j++;
        }
        if(k > 0) ans++;
    }

    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<climits>
#include<queue>
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
const int N=500001;
int n,a[N],minn[N<<2],k;
struct node{
	int u,v,nex;
}x[N<<1];
int head[N];
struct segment_tree{
	void insert(int k,int l,int r,int x,int y,int val){
		if(l==r){minn[k]=val;return;}
		int mid=l+r>>1;
		if(x<=mid) insert(k<<1,l,mid,x,y,val);
		if(mid<y) insert(k<<1|1,mid+1,r,x,y,val);
		minn[k]=min(minn[k<<1],minn[k<<1|1]);
		return; 
	}
	int query(int k,int l,int r,int x,int y){
//		printf("x:%d y:%d\n",x,y);
		if(x>y) return INT_MAX;
		if(x<=l&&r<=y) return minn[k];
		int res=INT_MAX,mid=l+r>>1;
		if(x<=mid) res=min(res,query(k<<1,l,mid,x,y));
		if(mid<y) res=min(res,query(k<<1|1,mid+1,r,x,y));
		return res;
	}
}seg;
int cnt,du[N];
void add(int u,int v){
//	printf("u:%d v:%d\n",u,v);
	x[cnt].u=u,x[cnt].v=v,x[cnt].nex=head[u],head[u]=cnt++;
	du[v]++;
	return;
}
priority_queue<int> que;
int id[N];
int main(){
	memset(head,-1,sizeof(head));
	int inf=INT_MAX;
	memset(minn,127/3,sizeof(minn));
	n=read(),k=read();
	for(int i=1;i<=n;i++) a[read()]=i;
	for(int i=n;i>=1;i--){
		int pos=seg.query(1,1,n,a[i]+1,min(n,a[i]+k-1));
		if(pos>=1&&pos<=n) add(a[i],a[pos]);
		pos=seg.query(1,1,n,max(1,a[i]-k+1),a[i]-1);
		if(pos>=1&&pos<=n) add(a[i],a[pos]);
		seg.insert(1,1,n,a[i],a[i],i);
	}
	for(int i=1;i<=n;i++) if(!du[i]) que.push(-i);
	while(!que.empty()){
		int xx=-que.top();que.pop();
		id[xx]=++id[0];
		for(int i=head[xx];i!=-1;i=x[i].nex){
			du[x[i].v]--;
			if(!du[x[i].v]) que.push(-x[i].v);
		} 
	}
	for(int i=1;i<=n;i++) printf("%d\n",id[i]);
}


Measured memory_bytes: 31352
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(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 tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    string s;
    cin >> s;
    n = s.size();
    rrep(i,n) {
        if(i%2) continue;
        string a = s.substr(0,i/2);
        string b = s.substr(i/2,i/2);
        if(a == b) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>

using namespace std;

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

    if(S=="Sunny"){

        cout<<"Cloudy"<<endl;
    }

    else if(S=="Cloudy"){

        cout<<"Rainy"<<endl;
    }

    else if(S=="Rainy"){

        cout<<"Sunny"<<endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(){
    ll x;
    cin >> x;
    ll ans = 0;
    ll a = x/500;
    x %= 500;
    ll b = x/5;
    ans = a*1000+5*b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

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

void solve(){
    ll a, b;
    cin>>a>>b;
    print((a/gcd(a, b))*b);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const double pi=acos(-1);
int A,B,n,m;
int main(){
	scanf("%d%d%d%d",&A,&B,&n,&m);
	reg double t1=m*pi/30.0,t2=n*pi/6.0+m*pi/30.0/12.0;
	reg double theta=fabs(t1-t2);
	printf("%.15lf\n",sqrt(A*A+B*B-cos(theta)*A*B*2));
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

char s[111111];
ll k;

int main(){
	cin.sync_with_stdio(false);
	cin>>s;
	cin>>k;
	rep(i,strlen(s)){
		if(i==strlen(s)-1){
			//dbg(k);
			k%=26;
			//dbg(k);
			if(s[i]+k>'z')k-=26;
			s[i]+=k;
			//if(s[i]>'z')s[i]='a'+(s[i]-'z')-1;
			//dbg(s[i]);
		}else{
			if(s[i]=='a'||s[i]+k<='z')continue;
			else{
				k-=('z'-s[i]+1);
				s[i]='a';
			}
		}
	}
	cout<<s<<endl;
	return 0;
}


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

const int N = 2e5+10;

int a[N], b[N];

void solve() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d%d", a+i, b+i);
    sort(a+1, a+n+1);
    sort(b+1, b+n+1);

    if (n&1) {
        printf("%d\n", b[(n+1)/2]-a[(n+1)/2]+1);
    } else {
        printf("%d\n", b[n/2]+b[n/2+1]-a[n/2]-a[n/2+1]+1);
    }

}

int main(){

    solve();
	return 0;
}


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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

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

using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  typedef long long ll;
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  bool operator>(const mint a) const {
    mint res(*this);
    return res.x > a.x;
  }
  bool operator<(const mint a) const {
    mint res(*this);
    return res.x < a.x;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


struct FenwickTree {
  vector<mint> v;
  int n;
  FenwickTree(int n) : n(n), v(n) {}
  void add(int i, mint x) {
    i++;
    while (i <= n) {
      v[i - 1] += x;
      i += i & -i;
    }
  }

  mint get(int i) {
    mint r = 0;
    while (i >= 1) {
      r += v[i - 1];
      i -= i & -i;
    }
    return r;
  }
};

struct ExFenwickTree {
  FenwickTree p, q;
  ExFenwickTree(int n) : p(n + 1), q(n + 1) {}
  void add(int l, int r, mint w) {
    p.add(l, mint(-1)*w * l);
    p.add(r, w * r);
    q.add(l, w);
    q.add(r, mint(-1)*w);
  }
  
  mint get(int r) {
    return p.get(r) + q.get(r) * r;
  }
};


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n, k; std::cin >> n >> k;
  ExFenwickTree seg( n+2 );
  seg.add(1,2,1);

  std::vector<int> L(k), R(k);
  rep(i,k) std::cin >> L[i] >> R[i];

  for(int i=1; i<=n; i++) {
    rep(j,k) {
      if ( i + L[j] > n ) continue;
      int right = std::min(n+1, i+R[j]+1);
      mint v = seg.get(i+1) - seg.get(i);
      seg.add(i+L[j], right, v);
    }
  }
  mint ans = seg.get(n+1) - seg.get(n);
  std::cout << ans.x << std::endl;

  return 0;
}



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

int main(){
	int n,k;
	cin>>n>>k;
	vector<int> a(n,0);
	for(int i=0;i<n;i++){
		int b;
		cin>>b;
		a[b]++;
	}
	
	sort(a.begin(),a.end());
	
	int ans=0;
	int np=0;
	
	for(int i=0;i<k;i++){
		np+=a[n-1-i];
	}
	
	ans=n-np;
	if(ans<0)ans=0;
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){cin >> a[i];}
  rep(i,n){
    int t;
    cin >> t;
    a[i] -= t;
  }
  int total = 0;
  rep(i,n){
    if (a[i]>0) total += a[i]; 
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
//	"bufio"
	"fmt"
//	"os"
)

func main() {
//	stdin := bufio.NewScanner(os.Stdin)
//	stdin.Scan()
//	text := stdin.Text()
    var text string
    fmt.Scan(&text)

	var E0, E1, O0, O1 int
	for i, t := range text {
		if i%2 == 0 {
			if t == '0' {
				E0++
			} else {
				E1++
			}
		} else {
			if t == '0' {
				O0++
			} else {
				O1++
			}
		}
	}
	fmt.Println(min(E0+O1, E1+O0))

/*	
	ret1 := 0
	for i, t := range text {
	    if i % 2 == 0 {
	        if t != '0' {
	            ret1++
	        }
	    }else {
	        if t != '1' {
	            ret1++
	        }
	    }
	}
	ret2 := 0
	for i, t := range text {
	    if i % 2 == 0 {
	        if t != '1' {
	            ret2++
	        }
	    }else {
	        if t != '0' {
	            ret2++
	        }
	    }
	}
	fmt.Println(min(ret1,ret2))
	*/
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 1280
n = int(input())
b = list(map(int,input().split()))
a = [int(b[0])]*n

for i in range(n-1):
    a[i+1] = max(a[i],b[i])
    if(i == n-2):
        break
    if(b[i+1]<=b[i]):
        a[i+1] = b[i+1]
print(sum(a))

Measured memory_bytes: 3064
n,a,b,c,d=(int(i) for i in input().split())
s=input()
r="Yes"
for i in range(d-a+1):
  if s[i+a-1]=="#":
    if s[i+a]=="#":
      r="No"
      break
if r=="Yes" and c>d:
  r="No"
  for i in range(d-b+1):
    if s[i+b-2]==".":
      if s[i+b-1]==".":
        if s[i+b]==".":
          r="Yes"
          break
print(r)

Measured memory_bytes: 3572
//48
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int main(){
  for(;;){
    int a[8];
    for(int i=0;i<8;i++){
      cin>>a[i];
      if(!cin)return 0;
    }
    int g=1<<30;
    int v[]={1,4,1,4,1,2,1,2};
    int b[8];
    for(int i=0;i<8;i++){
      rotate(v,v+1,v+8);
      int r=0;
      for(int j=0;j<8;j++){
	r+=max(0,a[j]-v[j]);
      }
      if(r<g||(r==g&&lexicographical_compare(v,v+8,b,b+8))){
	memcpy(b,v,sizeof(b));
	g=r;
      }
    }
    for(int i=0;i<8;i++){
      cout<<b[i]<<((i==7)?'\n':' ');
    }
  }
  return 0;
}

Measured memory_bytes: 1176
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		try {
			Scanner scanner = new Scanner(System.in);

			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int K = scanner.nextInt();

			List<Integer> answerList = new ArrayList<>();

			int loopCountMax = A > B ? B : A;

			for (int i = 1; i <= loopCountMax; i++) {
				if (A % i == 0 && B % i == 0) answerList.add(i);
			}

			System.out.println(answerList.get(answerList.size() - K));
			scanner.close();
		} catch (InputMismatchException e) {
			System.out.println("整数を入力してください。");
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int n,k;
  cin>>n>>k;
  vector<int>a(n+1);
  rep(i,n) cin>>a[i+1];
  for(int i=k+1;i<=n;i++){
    if(a[i]>a[i-k]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 4048
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  int a, b, c, d, e, f,	g, h;
  cin >> a >> b >> c >> d >> e >> f >> g >> h;
  if(a + b + c + d > e + f + g + h)
    printf("%d\n", a + b + c + d);
  else
    printf("%d\n", e + f + g + h);

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

ll memo[20][20];
set<pii> st;

ll solve(int x, int y) {
  if (memo[x][y]) return memo[x][y];
  if (st.find(pii(x, y)) != st.end()) return memo[x][y] = 0;
  ll res = 0;
  if (x > 1) res += solve(x - 1, y);
  if (y > 1) res += solve(x, y - 1);
  return memo[x][y] = res;
}

int main(void) {
  int a, b, n;
  while (cin >> a >> b, a) {
    cin >> n;
    memset(memo, 0, sizeof(memo));
    st.clear();
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      st.insert(pii(x, y));
    }
  
    memo[1][1] = 1;
    cout << solve(a, b) << endl;
  }


  return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int x[100005];
int main() {
	
	int n;
	cin>>n;
	long long sum = 0;
	for(int i = 1; i <= n; i++)
	{
		cin>>x[i];
		sum+=abs(x[i]-x[i-1]);
	}
	sum+=abs(x[n]);
	long long o = sum;
	for(int i = 1; i <= n; i++)
	{
		o = sum;
		o-=abs(x[i-1]-x[i]);
		o-=abs(x[i]-x[i+1]);
		o+=abs(x[i-1]-x[i+1]);
		cout<<o<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 4052
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        while(!(x==0&&y==0)){
            if (x>=y){
                System.out.println(y+" "+x);
            } else {
                System.out.println(x+" "+y);
            }
            x = sc.nextInt();
            y = sc.nextInt();
        }
    }
}


Measured memory_bytes: 35760
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(void) {
  int a, b;
  cin >> a >> b;
  cout << max(0, a - (b << 1)) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline().strip()

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()

CB = []
for i in range(M):
	B, C = list(map(int, input().split()))
	CB.append((C, B))
CB.sort()

sumb = 0
change = []
while sumb <= N and len(CB) > 0:
	C, B = CB.pop()
	sumb += B
	change.extend([C]*B)

change = change[0:N]

for i in range(len(change)):
	if A[i] < change[i]:
		A[i] = change[i]
	else:
		break

print(sum(A))

Measured memory_bytes: 70016
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: i32, a: i32, b: i32
    }
    let ans = if (x - a).abs() > (x - b).abs() {
        'B'
    } else {
        'A'
    };
    println!("{}", ans);
}


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

#include <cmath>
using namespace std;
int main()
{

const double PI = 3.141592653589793;
   float n;
    cin>>n;
    n=2*PI*n;
    cout<<fixed<<setprecision(6)<<n<<endl;


    return 0;
}


Measured memory_bytes: 3784
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <set>
using namespace std;

struct Event {
  int type;
  int time;
  int x;
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<Event> events;
  for (int i = 0; i < n; ++i) {
    int s, t, x;
    cin >> s >> t >> x;
    events.push_back((Event){1, s-x, x});
    events.push_back((Event){0, t-x, x});
  }
  sort(events.begin(), events.end(), [&](const Event &lhs, const Event &rhs) {
    if (lhs.time == rhs.time) {
      if (lhs.x == rhs.x) return lhs.type < rhs.type;
      return lhs.x < rhs.x;
    }
    return lhs.time < rhs.time;
  });
  int eid = 0;
  set<int> sx;
  for (int i = 0; i < q; ++i) {
    int d;
    cin >> d;
    Event &e = events[eid];
    while (e.time <= d && eid < events.size()) {
      if (e.type == 1) { sx.insert(e.x); }
      else { sx.erase(e.x);}
      e = events[++eid];
    }
    if (sx.size() == 0) {
      cout << -1 << endl;
    }
    else {
      auto it = sx.begin();
      cout << *it << endl;
    }
  }
}



Measured memory_bytes: 15596
# coding: utf-8

n = int(input())

l = []

l.append(list(map(int,input().split())))
l.append(list(map(int,input().split())))

#print(l)

ans = []

for i in range(0,n):
    p1 = sum(l[0][0:i])
    p2 = sum(l[1][i:n])
    ans.append(p1+l[0][i]+p2)
    #print("{}, {}".format(p1,p2))
print(max(ans))

Measured memory_bytes: 3064
<?php
fscanf(STDIN, '%d', $k);
fscanf(STDIN, '%d %d', $min, $max);
$flag = false;
for ($i=$min; $i <= $max; $i++) { 
    if ($i % $k == 0) {
        $flag = true;
        break;
    }
}
echo $flag ? 'OK' : 'NG';
?>

Measured memory_bytes: 16196
#include <stdio.h>

int main(void){
    int H,W;
    while(1){
  
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)
    break;
    for(int i=0;i<W;i++)printf("#");
    printf("\n");
    for(int i=1;i<H-1;i++){
        printf("#");
        for(int j=1;j<W-1;j++) printf(".");
        printf("#\n");
    }
    for(int i=0;i<W;i++)printf("#");
    printf("\n\n");}
    return 0;
}

            
            
            


Measured memory_bytes: 2104
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
	int N, K;
	cin >> N >> K;
	int A = 0;

	vector<int>H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	sort(H.begin(), H.end()); 
	reverse(H.begin(), H.end());
	bool a = true;
	if (K >= N) {
		cout << 0 << endl;
		a = false;
	}
	if (a) {
		for (int i = 0; i < K; i++) {
			H[i] = 0;
		}

		for (int i = 0; i < N; i++) {
			A += H[i];
		}
      cout << A << endl;
	}


}


Measured memory_bytes: 4844
package main

import (
	"fmt"
)

func main() {
	var s string; fmt.Scan(&s)
	res := ""
	for _, c := range s {
		if c == 'B' {
			if len(res) > 0 {res = res[:len(res)-1]}
		} else {
			res += string(c)
		}
	}
	fmt.Println(res)

}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include"stdio.h"
#include <cstring>
#include<math.h>
#include<map>
#include<queue>
#include<stack>
#include"time.h"
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
ll n, r, g, b;
ll ans;
string s;
int main()
{
    read(n);
    cin>>s;
    s=" "+s;
    for(int i=1;i<=n;i++){
        if (s[i] == 'R') r++;
        if (s[i] == 'G') g++;
        if (s[i] == 'B') b++;
    }
    ans = r * g * b;
    int k = (n - 3)/2;  //计算(n-3)/2
    for (int i = 0; i <= k; i++){  //枚举两个字符之间的差
        for (int j = 1; j + 2 * i + 2 <= n; j++){  //枚举j的大小
            if (s[j] != s[j+i+1] && s[j] != s[j+i*2+2] && s[j+i+1] != s[j+i*2+2]){  //如果满足条件1，就讲ans--
                ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long int> A(N);
  int num;
  int maxA = 0;
  int maxA2 = 0;
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
    if (maxA < A.at(i)){
      maxA = A.at(i);
      num = i;
    } else if (maxA2 < A.at(i)){
      maxA2 = A.at(i);
    }
  }
  for (int i = 0; i < N; i++){
    if (i == num){
      cout << maxA2 << endl;
    } else {
      cout << maxA <<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = b;
    if((a >= 6) && (a <= 12)) {
      ans = b / 2;
    } else if(a <= 5) {
      ans = 0;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int l[500000],r[500000];
int main(){
    string S;
    cin>>S;
    for(int i=0;i<S.size();i++){
        if(S[i]=='<')l[i+1]=l[i]+1;
    }
    for(int i=S.size();0<=i;i--){
        if(S[i]=='>')r[i]=r[i+1]+1;
    }
    long long int ans=0;
    for(int i=0;i<S.size()+1;i++)ans+=(long long int)max(l[i],r[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s ;
if(s.length()>=6)
{
 if(s[2]==s[3] && s[4]==s[5])
 cout << "Yes" << "\n";
 else
cout << "No" << "\n" ;
}
else
cout << "No" << "\n";
return 0;
}

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

int main() {
	while(scanf("%d %d", &n, &m) != EOF) {
		int ans = 0;
		if(m % n == 0) ans = m / n;
		else {
			int t = m / n;
			for(int i = 1; i <= t; i++) {
				if(m % i == 0 && i <= m / n) ans = max(ans, i);
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main (){
  int num;
  int Value[50];
  int Cost[50];
  int sum,a;

  scanf("%d",&num);

  for(int i = 0 ; i < num ; i++){
    scanf("%d",&Value[i]);
  }

  for(int i = 0 ; i < num ; i++){
    scanf("%d",&Cost[i]);
  }

  for(int i = 0 ; i < num ; i++){
    a = Value[i] - Cost[i];
    if(0 < a){
      sum += a;
    }
  }

  printf("%d\n",sum);

return 0;
}

Measured memory_bytes: 128
def draw_rect_outline(h, w):
    for i in range(h):
        for j in range(w):
            if (i == 0 or i == h-1) or (j == 0 or j == w-1):
                print("#", end="")
            else:
                print(".", end="")

        print("")

    print("")

while True:
    [h, w] = map(int, input().split(" "))
    if h == 0 and w == 0:
        break
    
    draw_rect_outline(h, w)





Measured memory_bytes: 7012
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i,p=0;
	ll x,a[123];
	cin >> n >> x;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	sort(a,a+n);
	for(i=0; i<n; ++i){
		if(x < a[i]){
			break;
		}else{
			++p;
			x -= a[i];
		}
	}
	if(p == n && x){
		--p;
	}
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}
const int maxn = 1e5+10;
int a[maxn], num[maxn][2];

int main()
{
    int n; sc(n);
    for(int i = 0; i < n; i++){
        int x; sc(x);
        num[x][i%2]++;
    }
    vector<pii> vec[2];
    for(int i = 0; i < maxn; i++){
        vec[0].pb(mk(num[i][0], i));
        vec[1].pb(mk(num[i][1], i));
    }
    sort(ALL(vec[0]), greater<pii>());
    sort(ALL(vec[1]), greater<pii>());
    int ans = 0;
    for(int i = 0; i < 2 && i < SZ(vec[0]); i++){
        for(int j = 0; j < 2 && j < SZ(vec[1]); j++){
            if(vec[0][i].se == vec[1][j].se)continue;
            else ans = max(ans, vec[0][i].fi+vec[1][j].fi);
        }
    }
    printf("%d\n", n-ans);
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ld l; cin>>l;
	cout<<(l*l*l/27.0)<<endl;

	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>

using namespace std;

int main(){
    int  n,m;
    
    cin>>n>>m;
    vector<vector<int>>an(n,vector<int>(m));
    vector<int>op(m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>an.at(i).at(j);
        }
    }
    for(int i=0;i<m;i++)cin>>op.at(i);
    for(int i=0;i<n;i++){
        int k=0;
        for(int j=0;j<m;j++){
            
            k+=an.at(i).at(j)*op.at(j);
        }
        cout<<k<<endl;

    }

}


Measured memory_bytes: 3160
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;

class Main{
  public static void main(String[] a){
    Scanner sc = new Scanner(System.in).useDelimiter("\n");
    ArrayList<String> alstr = new ArrayList<String>();
    while(sc.hasNext()){
      alstr.add(sc.next());
    }

    int[] foo = null;
    String[] strarr = null;
    int strlen = 0;

    for (String str : alstr) {
      strarr = str.split(" ");
      strlen = strarr.length;
      foo = new int[strlen];

      for (int iter = 0; iter < strlen; iter++) {
        foo[iter] = Integer.parseInt(strarr[iter]);
      }

      Arrays.sort(foo);

      for (int iter = 0; iter < strlen / 2; iter++) {
        int tmp = foo[iter];
        foo[iter] = foo[strlen-iter-1];
        foo[strlen-iter-1] = tmp;
      }

      for (int iter = 0; iter < strlen; iter++) {
        System.out.print(foo[iter]);
        if (iter == strlen-1) System.out.println();
        else System.out.print(" ");
      }
    }
  }
}

Measured memory_bytes: 17148
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
	while(true){
		int x,y;
		cin >> x >> y;
		if(x == 0 && y == 0) break;
		
		if(x > y) printf("%d %d\n", y,x);
		else printf("%d %d\n", x, y);
	
	}
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int n,num[10],x[10],y[10],a,b,pos=1;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) num[i]=i;
	for(int i=1;i<=n;++i) scanf("%d",&x[i]);
	for(int i=1;i<=n;++i) scanf("%d",&y[i]);
	do {
		bool flag=true;
		for(int i=1;i<=n;++i)
			if(num[i]!=x[i]) {
				flag=false;
				break;
			}
		if(flag) a=pos;
		flag=true;
		for(int i=1;i<=n;++i)
			if(num[i]!=y[i]) {
				flag=false;
				break;
			}
		if(flag) b=pos;
		++pos;
	} while(next_permutation(num+1,num+n+1));
	printf("%d",abs(a-b));
	return 0;
}

Measured memory_bytes: 256
use std::ops::Range;

#[derive(Clone, Debug)]
pub struct Scan2<I, St, F> {
    iter: I,
    f: F,
    state: St,
}

impl<I, St, F> Scan2<I, St, F> {
    fn new(iter: I, state: St, f: F) -> Scan2<I, St, F> {
        Scan2 { iter: iter, state: state, f: f }
    }
}

impl<I, St, F> Iterator for Scan2<I, St, F>
where
    I: Iterator,
    F: Fn(&St, I::Item) -> St,
    St: Clone,
{
    type Item = St;

    #[inline]
    fn next(&mut self) -> Option<St> {
        let o = self.iter.next();
        if let Some(a) = o {
            self.state = (self.f)(&self.state, a);
            Some(self.state.clone())
        } else {
            None
        }
    }
}

trait Iterator2 {
    type Item;

    fn scan2<St, F>(self, initial_state: St, f: F) -> Scan2<Self, St, F>
    where
        F: Fn(&St, Self::Item) -> St,
        Self: std::marker::Sized,
    {
        Scan2::new(self, initial_state, f)
    }
}

impl<T> Iterator2 for Range<T> {
    type Item = T;
}

fn solve(a: i32, b: i32, c: i32) -> bool {
    (0..b).scan2(a % b, |&s, _| (s + a) % b).any(|x| x == c)
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let mut iter = s.split_whitespace().map(|w| w.trim().parse().ok().unwrap());
    let a = iter.next().unwrap();
    let b = iter.next().unwrap();
    let c = iter.next().unwrap();
    let ans = solve(a, b, c);
    println!("{}", if ans { "YES" } else { "NO" });
}


Measured memory_bytes: 4352