akhauriyash/Code-Regression huggingface dataset:
# -*- Coding: utf-8 -*-

import numpy as np

INPUT=input().split()
Input=input().split()
H,W=int(INPUT[0]),int(INPUT[1])
h,w=int(Input[0]),int(Input[1])

mat=np.ones((H,W))
mat[0:h,:]=0
mat[:,0:w]=0

print(int(np.sum(mat)))

Measured memory_bytes: 13340
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

int main() {
  long long x, y;
  cin >> x >> y;
  long long ans = 1;
  while(y >= x * 2) {
    x *= 2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;


int main() {
    int n;
    cin >> n;
    vector<vector<int>> dp(10, vector<int>(10, 0));
    int keta = 1;
    rng(i, 1, n+1) {
        int r = i%10;
        int l = i/keta;
        if (l == 10) {
            keta *= 10;
            l = 1;
        } 
        if (r==0) continue;
        dp[l][r]++;
    }
    ll ans = 0;
    rng(l, 1, 10) {
        rng(r, 1, 10) {
            ans += dp[l][r] * dp[r][l];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
first = 0
second = 0
third = 0
for P in input().split():
    P = int(P)
    if P <= A:
        first += 1
    elif P <= B:
        second += 1
    else:
        third += 1
print(min(first, second, third))


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a >= 13){
    cout << b << endl;
  }
  if(a <= 12 && a >= 6){
    cout << b/2 << endl;
  }
  if(a <= 5){
    cout << 0 << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<ll> length(N);
    lrep(i, 0, N) cin >> length[i];
    ll sum = 0, sum2 = 0, a;
    lrep(i, 0, N) sum +=length[i];
    lrep(i, 0, N){
        sum2 += length[i];
        if(sum2*2 >= sum){
            a = i;
            goto end;
        }
    }
    end:
    ll ans = min(2*sum2 - sum, sum + 2*length[a] - 2*sum2);
    cout << ans << endl;
}


Measured memory_bytes: 1792
/*
 * If you're not willing to make sacrifices yourself, you'll never be
 * able to change anything. In order to overcome monsters, you must
 * be willing to abandon your own humanity.
 * ~ Arlert
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)

#define endl '\n'

int main() {
  fast_io;
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (s.find(a) == s.end())
      s.insert(a);
    else
      s.erase(a);
  }
  cout << SZ(s) << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <vector>
#define FOR(a,b,c) for(int a=b;a<=c;a++)
using namespace std;
struct T{
	long long a, b;
	T(long long _a = 0, long long _b = 0){
		a = _a;
		b = _b;
	}
}A[200010], B[200010], C[200010];
vector<T> f[200010];
int cnta, cntb;
int n, x;
int a[200010];
int tr[200010][2];
long long mx, dep[200010];
void pre(int x){
	if (tr[x][0]){
		dep[tr[x][0]] = dep[x] + a[tr[x][0]];
		dep[tr[x][1]] = dep[x] + a[tr[x][1]];
		pre(tr[x][0]);
		pre(tr[x][1]);
	}
}
void dfs(int x){
	if (!tr[x][0]){
		f[x].push_back(T(dep[x], dep[x]));
		return;
	}
	int ls = tr[x][0], rs = tr[x][1], l = 0;
	dfs(ls);
	dfs(rs);
	cnta = 0;
	for (int i = 0; i < f[ls].size(); i++){
		int key = -1;
		while (l < f[rs].size() && f[ls][i].b + f[rs][l].a - 2 * dep[x] <= mx){
			key = l;
			l++;
		}
		if (key != -1) A[++cnta] = T(f[ls][i].a, f[rs][key].b);
	}
	l = 0;
	cntb = 0;
	for (int i = 0; i < f[rs].size(); i++){
		int key = -1;
		while (l < f[ls].size() && f[rs][i].b + f[ls][l].a - 2 * dep[x] <= mx){
			key = l;
			l++;
		}
		if (key != -1) B[++cntb] = T(f[rs][i].a, f[ls][key].b);
	}
	f[ls].clear();
	f[rs].clear();
	int l1 = 1, l2 = 1, cntc = 0;
	FOR(i, 1, cnta + cntb){
		if (l2 > cntb || (l1 <= cnta && l2 <= cntb && A[l1].a < B[l2].a)){
			if (!cntc) C[++cntc] = A[l1++];
			else if (C[cntc].a == A[l1].a){
				C[cntc].b = min(C[cntc].b, A[l1++].b);
			}
			else C[++cntc] = A[l1++];
		}
		else{
			if (!cntc) C[++cntc] = B[l2++];
			else if (C[cntc].a == B[l2].a){
				C[cntc].b = min(C[cntc].b, B[l2++].b);
			}
			else C[++cntc] = B[l2++];
		}
	}
	f[x].clear();
	FOR(i, 1, cntc) f[x].push_back(C[i]);
}
bool judge(long long x){
	mx = x;
	dfs(1);
	if (f[1].size()) return 1;
	return 0;
}
int main(){
	scanf("%d", &n);
	FOR(i, 2, n){
		scanf("%d%d", &x, &a[i]);
		if (tr[x][0]) tr[x][1] = i;
		else tr[x][0] = i;
		mx += a[i];
	}
	pre(1);
	long long l = 0, r = mx, mid, ans = mx;
	while (l <= r){
		mid = (l + r) >> 1;
		if (judge(mid)){
			r = mid - 1;
			ans = mid;
		}
		else l = mid + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);

    printf("%lld",max(a*c,max(a*d,max(b*c,b*d))));
    
    return 0;
}

Measured memory_bytes: 3824
// B - Multiplication 2
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int n; cin>>n;
	ll inf = 1e18;
	ll ans = 1;
	bool ng = false;
	while(n--){
		ll a; cin>>a;
		if(a == 0){ puts("0"); return 0; }
		if(ng || inf/a < ans) ng = true;
		else ans *= a;
	}
	if(ng) puts("-1");
	else cout<< ans <<endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,H, W;
    cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int x;
    scanf("%lld",&x);
    long long int temp=100;
    int count=0;
    while(temp<x)
    {
        count++;
        temp+=temp/100;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 3824
import java.util.ArrayList;
import java.util.Scanner;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        List<Task> tasks = new ArrayList<Task>();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            tasks.add(new Task(a[i], b[i]));
        }
        Collections.sort(tasks);
        boolean flag = true;
        int day = 0;
        for (int i = 0; i < n; i++) {
            Task t = tasks.get(i);
            if (day + t.time > t.fin) {
                flag = false;
                break;
            } else {
                day += t.time;
            }
        }
        if (flag) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
}

class Task implements Comparable<Task> {
    int time;
    int fin;

    Task(int time, int fin) {
        this.time = time;
        this.fin = fin;
    }

    @Override
    public int compareTo(Task other) {
        if (this.fin < other.fin) {
            return -1;
        } else if (this.fin > other.fin) {
            return 1;
        } else {
            if (this.time < other.time) {
                return -1;
            } else {
                return 1;
            }
        }
    }

}


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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

long dist[30][30];

long solve(auto &a, long i, long j, long h, long w)
{
    queue<pair<long, long>> q;
    q.push({i, j});
    long worst = -INF;
    dist[i][j] = 0;
    a[i][j] = '*';
    while (not q.empty()) {
        auto p = q.front();
        i = p.first;
        j = p.second;
        q.pop();
        vector<pair<long, long>> next = {
            {i, j-1}, {i, j+1}, {i-1, j}, {i+1, j}
        };
        for (auto &x : next) {
            long l = x.first;
            long r = x.second;
            if (l < 0 or l >= h or r < 0 or r >= w) continue;
            if (a[l][r] != '.') continue;
            a[l][r] = '*';
            dist[l][r] = dist[i][j] + 1;
            worst = max(worst, dist[l][r]);
            q.push({l, r});
        }
    }
    return worst;
}

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long h, w;
        cin >> h >> w;

        vector<string> a(h);
        for (auto &x : a) cin >> x;

        long best = -1;
        for (long i = 0; i < h; i++) {
            for (long j = 0; j < w; j++) {
                if (a[i][j] == '#') continue;
                long x = solve(a, i, j, h, w);
                best = max(best, x);
                for (long i = 0; i < h; i++) {
                    for (long j = 0; j < w; j++) {
                        if (a[i][j] == '*') {
                            a[i][j] = '.';
                        }
                    }
                }
            }
        }
        printf("%lld\n", best);
    }
}


Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        int res = 0;
        for (char ch : str.toCharArray()) {
            if (ch == '+') {
                res ++;
            } else {
                res --;
            }
        }
        System.out.println(res);
    }
}


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

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

using namespace std;

int main(){
  
  int n,total=0,now,pre=-1;
  cin>>n;
  int order[n-1], gain[n-1], add[n-2];
  
  rep(i,n) cin>>order[i];
  rep(i,n) cin>>gain[i];
  rep(i,n-1) cin>>add[i];
  
  rep(i,n) {
    now=order[i];
    total += gain[now-1];
    if (pre+1 == now ) total += add[pre-1];
    pre = now;
  }
  
  cout<<total;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    ll n , m ;
    cin >> n >> m ;
    vector<ll> dp(n+5,0) ;
    dp[0] = 1 ;
    rep( i , 1 , m + 1 )
    {
        ll x ;
        cin >> x ;
        dp[x] = -hell ;
    }
    rep( i , 1 , n + 1 )
    {
        if( dp[i] >= 0 )
        {
            dp[i] = ( max( 0LL , dp[i-1] ) + max( 0LL , ( i > 1 ? dp[i-2] : 0 )))%hell ;
        }
    }
    cout << dp[n] ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*fact[0] = 1 ;
    rep( i , 1 , N )
        fact[i] = ( fact[i-1] * i ) % hell ;*/
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>

using namespace std;

struct TRAMP{
	char mark;
	int number;
};

int main(){
	int n,min;
	char buf[3];
	scanf("%d",&n);

	TRAMP selectArray[n],bubbleArray[n];

	for(int i = 0; i < n; i++){
		scanf("%s",buf);
		selectArray[i].mark = buf[0];
		selectArray[i].number = buf[1] - '0';
		bubbleArray[i] = selectArray[i];
	}

	for(int i = n-1; i >= 0; i--){
		for(int j = 0; j < i; j++){
			if(bubbleArray[j].number > bubbleArray[j+1].number) swap(bubbleArray[j], bubbleArray[j+1]);
		}
	}

	for(int i = 0; i < n-1; i++){
		min = i;
		for(int j = i+1; j < n; j++){
			if(selectArray[j].number < selectArray[min].number){
				min = j;
			}
		}
		if(i != min){
			swap(selectArray[i],selectArray[min]);
		}
	}

	for(int i = 0; i < n-1; i++) printf("%c%d ",bubbleArray[i].mark,bubbleArray[i].number);
	printf("%c%d\n",bubbleArray[n-1].mark,bubbleArray[n-1].number);
	printf("Stable\n");
	for(int i = 0; i < n-1; i++) printf("%c%d ",selectArray[i].mark,selectArray[i].number);
	printf("%c%d\n",selectArray[n-1].mark,selectArray[n-1].number);

	int p;
	for(p=0; p < n; p++){
		if(selectArray[p].number != bubbleArray[p].number || selectArray[p].mark != bubbleArray[p].mark)
			break;
	}
	if(p == n){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}

	return 0;
}


Measured memory_bytes: 2716
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>

using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> alphabet(30,0);
    for (int i = 0; i < n; i++)
    {
        string title;
        cin >> title;
        alphabet[title[0] - 'A']++;
    }
    int ans = 0;
    while ([&]()
    {
        sort(alphabet.begin(), alphabet.end(), [](int n, int m) { return n > m; });
        for (int i = 0; i < k; i++)
        {
            if (alphabet[i] > 0) alphabet[i]--;
            else return false;
        }
        ans++;
        return true;
    }());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

ma=0
ans=0
for i in range(n):
    if a[i]>ma:
        ma=a[i]
    elif a[i]<ma:
        ans+=ma-a[i]

print(ans)

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

#define ALL(a) (a).begin(), (a).end()
#define PB push_back

int main(){
    int X, Y, Z;
    cin >> X  >> Y >> Z;
    int stay1, stay2;
    stay1 = X;
    X = Y;
    Y = stay1;
    stay2 = X;
    X = Z;
    Z = stay2;
    cout << X << " " <<  Y << " " << Z << endl;
}

Measured memory_bytes: 256
/*
 *Author - Abhas Jain
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
    string s;
    cin >> s;
    int n = s.length();
    vector<int> pr(n);
    int prev = -1, r = 0, l = 0;
    for (int i = 0; i < n; ++i) {
    	if (s[i] == 'L') {
    		l++;
    		r = 0;
    	}
    	else {
    		r++;
    		l = 0;
    	}
    	if (s[i] == 'R' && s[i + 1] == 'L') {
    		pr[i] = (r + 1) / 2;
    		pr[i + 1] = r / 2;
    		prev = i;
    	}
    	if (s[i] == 'L' && s[i + 1] == 'R') {
    		pr[prev] += l / 2;
    		pr[prev + 1] += (l + 1) / 2;
    	}
    }
    pr[prev] += l / 2;
    pr[prev + 1] += (l + 1) / 2;
    for (int j : pr) cout << j << " ";
    cout << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>=b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/


int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n,m,points;
cin>>n>>m>>points;
map<pi,ll>mp;
vi row(n+1),col(m+1);
rep(i,0,points)
{
    ll x,y; cin>>x>>y;
    mp[{x,y}]++;
    row[x]++,col[y]++;
}
ll r = *max_element(all(row)) , c = *max_element(all(col));
vi arr,brr;
rep(i,1,n+1)
{
    if(row[i]==r)arr.pb(i);
}
rep(i,1,m+1)
{
    if(col[i]==c)brr.pb(i);
}

ll ans = r+c;
bool flag = false;
for(auto x:arr)
{
    for(auto y:brr)
    {
        if(mp.find({x,y})==mp.end())
        {
            flag = true;
            break;
        }
    }
    if(flag)break;
}
if(!flag)ans--;
cout<<ans<<"\n";
return 0;

}
/*
1
4
1 2
2 3
3 4
2
2 2
*/


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

int main() {
  string strO,strE,strP;
  cin >> strO >> strE;
  int o;
  int e;
  o = strO.size();
  e = strE.size();
  strP = strO + strE;

  for(int i = 0; i < (e + o); i++){
   if(i % 2 == 0 ){
       strP.at(i) = strO.at(i / 2);
    }else{
       strP.at(i) = strE.at(i / 2);
    } 
  }
  
  cout << strP << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i;
    int n;
    scanf("%d", &n);
    int R[n];
    for( i = 0; i < n; ++i )
        scanf("%d", &R[i]);

    int min = R[0], max = R[1] - R[0];
    for( i = 1; i < n; ++i ){
        max = max < R[i] - min ? R[i] - min : max;
        min = min > R[i] ? R[i] : min;
}

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

    return 0;
}


Measured memory_bytes: 3504
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

from collections import defaultdict

n,k,l=map(int,input().split())
load=UnionFind(n)
train=UnionFind(n)
for i in range(k):
    a,b=map(int,input().split())
    load.union(a,b)
for i in range(l):
    a,b=map(int,input().split())
    train.union(a,b)

ar=[(load.find(i),train.find(i)) for i in range(1,n+1)]
dic=defaultdict(int)

for i in ar:
    dic[i]+=1

ans=[]
for i in range(n):
    ans.append(dic[ar[i]])
print(*ans)

    

Measured memory_bytes: 58856
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	String O,E;
	void solve(){
		Scanner sc=new Scanner(System.in);
		O=sc.next();
		E=sc.next();
		int len=0;
		if(O.length()-E.length()>0){
			
			for(int i=0;i<E.length();i++){
				System.out.print(O.charAt(i));
				System.out.print(E.charAt(i));
			}
			System.out.println(O.charAt(O.length()-1));
			
		}else if(E.length()-O.length()>0){
			
			for(int i=0;i<O.length();i++){
				System.out.print(O.charAt(i));
				System.out.print(E.charAt(i));
			}
			System.out.println(E.charAt(E.length()-1));
			
		}else{
			
			for(int i=0;i<O.length();i++){
				System.out.print(O.charAt(i));
				System.out.print(E.charAt(i));
			}
		}
	}
}

Measured memory_bytes: 21844
import sys
input = sys.stdin.readline

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

S = 0
for i in range(K):
    S += (A[i]+1)/2
ans = S
for i in range(N-K):
    S += (A[i+K]+1)/2 - (A[i]+1)/2
    ans = max(ans, S)
print(ans)

Measured memory_bytes: 25188
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;

struct Edge
{
	int from;
	int to;
};

void solve()
{
	int N, M;
	cin >> N >> M;
	vector<P> path(M);
	vector<int> mediumIsland1, mediumIsland2;
	for (int i = 0; i < M; ++i)
	{
		cin >> path[i].first >> path[i].second;
		if (path[i].first == 1)
		{
			mediumIsland1.push_back(path[i].second);
		}
		else if (path[i].second == 1)
		{
			mediumIsland1.push_back(path[i].first);
		}

		if (path[i].first == N)
		{
			mediumIsland2.push_back(path[i].second);
		}
		else if (path[i].second == N)
		{
			mediumIsland2.push_back(path[i].first);
		}
	}
	sort(mediumIsland2.begin(), mediumIsland2.end());
	for (int i = 0; i < mediumIsland1.size(); ++i)
	{
		if (binary_search(mediumIsland2.begin(), mediumIsland2.end(), mediumIsland1[i]))
		{
			cout << "POSSIBLE" << endl;
			return;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

int main()
{
	solve();
	return(0);
}

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

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

    int a[N], b[N], c[N];
    for (int i = 0; i < N; ++i) {
	cin >> a[i] >> b[i] >> c[i];
    }
    
    // dp[i][0] = max(bi + dp[i-1][1], ci + dp[i-1][2])
    // dp[i][1] = max(ai + dp[i-1][0], ci + dp[i-1][2])
    // dp[i][2] = max(ai + dp[i-1][0], bi + dp[i-1][1])
    int dp[N][3];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = max(b[0], c[0]);
    dp[0][1] = max(a[0], c[0]);
    dp[0][2] = max(a[0], b[0]);

    for (int i = 1; i < N; ++i) {
	dp[i][0] = max(b[i] + dp[i-1][1], c[i] + dp[i-1][2]);
	dp[i][1] = max(a[i] + dp[i-1][0], c[i] + dp[i-1][2]);
	dp[i][2] = max(a[i] + dp[i-1][0], b[i] + dp[i-1][1]);
    }

    cout << max({dp[N-1][0], dp[N-1][1], dp[N-1][2]}) << endl;
}


Measured memory_bytes: 2560
/*******************************************
* AUTHOR : Adnan Masroor :-)
* NICK : adnanlari
* COLLEGE : NIT Durgapur
********************************************/

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll MOD=1000000007,BMOD=100000000700000;

int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	/*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif*/
	//the main code starts here
    
	ll l;
	cin>>l;
	ll ans=l*l*l;
	double a = ((double)ans)/27;
	
	cout<<setprecision(16)<<a<<"\n";



	return 0;
}

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

int main(){
int a,s,v=1;
  cin >>a;
  vector<int> z(a);
  for(s=0;s<a;s++){
  cin >>z.at(s);
  }
  reverse(z.begin(),z.end());
  for(s=0;s<a-1;s++){
  if(z.at(s)+1==z.at(s+1)){
  z.at(s+1)-=1;}
    if(z.at(s)+1<z.at(s+1)){
    v=0;
      break;
    }
  }
  if(v==0){
  cout <<"No" <<endl;
  }
if(v==1){
cout <<"Yes" <<endl;}}

Measured memory_bytes: 640
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q.insertBack(e);}T deq(T)(ref Queue!T q){T e=q.front;q.removeFront;return e;} 
alias Stack=SList;auto push(T)(ref Stack!T s,T e){s.insert(e);}T pop(T)(ref Stack!T s){T e=s.front;s.removeFront;return e;} 
struct UnionFind(T){T[T]u;ulong[T] rank;@property{bool inc(T e){return e in u;}auto size(){return u.keys.length;}auto dup(){T[] child=u.keys;T[] parent=u.values;auto res=UnionFind!T(child);child.each!(e=>res.add(e));size.iota.each!(i=>res.unite(child[i],parent[i]));return res;}}this(T e){e.add;}this(T[] es){es.each!(e=>e.add);}auto add(T a,T b=a){assert(b.inc);u[a]=a;rank[a];if(a!=b)unite(a,b);}auto find(T e){if(u[e]==e)return e;return u[e]=find(u[e]);}auto same(T a,T b){return a.find==b.find;}auto unite(T a,T b){a=a.find;b=b.find;if(a==b)return;if(rank[a]<rank[b])u[a]=b;else{u[b]=a;if(rank[a]==rank[b])rank[a]++;}}}
struct PriorityQueue(T,alias less="a<b"){BinaryHeap!(T[],less) heap;@property{bool empty(){return heap.empty;}auto length(){return heap.length;}auto dup(){return PriorityQueue!(T,less)(array);}T[] array(){T[] res;auto tp=heap.dup;foreach(i;0..length){res~=tp.front;tp.removeFront;}return res;}void push(T e){heap.insert(e);}void push(T[] es){es.each!(e=>heap.insert(e));}}T look(){return heap.front;}T pop(){T tp=look;heap.removeFront;return tp;}this(T e){ heap=heapify!(less,T[])([e]);}   this(T[] e){ heap=heapify!(less,T[])(e);}}
//END OF TEMPLATE

void main(){
    auto n=scan!ulong;
    bool[string] s;
    foreach(i;0..n)
        s[scan!string()]=true;
    s.keys.length.writeln;

}

Measured memory_bytes: 27716
#include <iostream>
#include <string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	string s, t;
	int i, ans=0;
	cin >> s >> t;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])ans++;
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define INF 1LL<<60

long long chose2(long long x){
    return x*(x-1)/2;
}

int main(){
    long long N;
    cin >> N;
    vector<long long>A(N,0);
    for(long long i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        A[i]--;
    }

    vector<long long>cnt(N,0);
    for(int i=0;i<N;i++){
        cnt[A[i]]++;
    }

long long tot=0;
for(long long i=0;i<N;i++)tot+=chose2(cnt[i]);

for(long long i=0;i<N;i++){
    long long ans=tot;
    ans-=chose2(cnt[A[i]]);
    ans+=chose2(cnt[A[i]]-1);
    cout << ans << endl;
}

}

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

string person = "JCEAPM";

string change5(string t) {
  string s = t;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '9') s[i] = '0';
    else if ('0' <= s[i] && s[i] <= '8') s[i]++;
  }
  return s;
}

string change4(string t) {
  string s = t;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') s[i] = '9';
    else if ('1' <= s[i] && s[i] <= '9') s[i]--;
  }
  return s;
}

string change3(string t) {
  string s = t;
  int half = s.size() / 2;
  for (int i = 0; i < half; i++) {
    char t = s[i];
    s[i] = s[s.size() - 1 - i];
    s[s.size() - 1 - i] = t;
  }
  return s;
}

string change2(string t) {
  string s = t;
  int half = s.size() / 2;
  string a = "\0";
  string b = "\0";
  string c = "\0";
  for (int i = 0; i < half; i++)
    a.push_back(s[i]);
  for (int i = s.size() - half; i < s.size(); i++)
    b.push_back(s[i]);
  if (s.size() % 2) c = s[half];

  string k = b;
  if (s.size() % 2) k += c;
  k += a;
  s = k;
  return s;
}

string change1(string t) {
  string s = t;
  char a = s[0];
  for (int i = 1; i < s.size(); i++)
    s[i - 1] = s[i];
  s[s.size() - 1] = a;
  return s;
}

string change0(string t) {
  string s = t;
  char a = s[s.size() - 1];
  for (int i = s.size() - 1 - 1; i + 1 >= 0; i--)
    s[i + 1] = s[i];
  s[0] = a;
  return s;
}

int main() {
  int n;
  cin >> n;
  while (n--) {
    string people;
    cin >> people;

    string str;
    cin >> str;
    for (int i = people.size() - 1; i >= 0; i--) {
      if (people[i] == person[0]) {
	str = change0(str);
      } else if (people[i] == person[1]) {
	str = change1(str);
      } else if (people[i] == person[2]) {
	str = change2(str);
      } else if (people[i] == person[3]) {
	str = change3(str);
      } else if (people[i] == person[4]) {
	str = change4(str);
      } else {
	str = change5(str);
      }
    }
    cout << str << endl;
  }
}

Measured memory_bytes: 3096
dic_s = {x:input() for x in 'abc'}

dic_i = {x:i for x,i in zip('abc',[0,0,0])}
dic_max = {x:len(dic_s[x]) for x in 'abc'}
nt = 'a'
while True:  
  if dic_max[nt] == dic_i[nt]:
    break
  else:
    dic_i[nt] += 1
    nt = dic_s[nt][dic_i[nt]-1]    
print(nt.upper())      

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		
		int i=1;
		int x=Integer.parseInt(sc.next());
		while(x!=0){
			System.out.println("Case "+i+": "+x);
			i++;
			x=Integer.parseInt(sc.next());
		}

	}

}

Measured memory_bytes: 40468
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}


// min
int main(void){
  char s[101];

  scanf("%s", s);

  for(int i = 0; i / 2 < strlen(s); i++){
    if(s[i * 2] == 'L'){
      printf("No\n");
      return 0;
    }
    if(s[i * 2 + 1] == 'R'){
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");
  return 0;
}


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

int main() {
  string a;
  string b;
  cin >> a;
  cin >> b;
  
  for (int i = 0; i < a.size(); i++){
    if (a[i] != b[i]){
      cout << "No";
      return 0;
    }
  }
  
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 3632
//
// Created by Akifumi Ohata on 2017/09/28.
//

#include<iostream>
#include <vector>
#include <math.h>

using namespace std;

int main(){

    char prezent[10];

    cin.getline(prezent, sizeof(prezent));

    std::string ans ;

    char yaki[4];
    strncpy(yaki,prezent+0,4);
    ans = yaki;
    if (ans=="YAKI"){
    cout << "Yes" << endl;
    }else{
        cout << "No" << endl;

    }

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.length();
	int rem=15-n;
	for(int i=0;i<n;i++)
		if(s[i]=='o')rem++;
	if(rem>=8)printf("YES\n");
	else printf("NO\n");
	return 0;
}

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

const int INF = 1e9;

int main() {
  int a1, a2, a3;
  cin>>a1>>a2>>a3;
  int c1 = abs(a1-a2);
  int c2 = abs(a2-a3);
  int c3 = abs(a3-a1);
  cout<<min(c1+c2, min(c2+c3, c3+c1))<<endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		105										// 最大配列数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列 - 取得
	si1Array[0] = INT_MAX;
	for (i = 1; i <= siACnt - 1; i++) {
		fscanf(szpFpI, "%d", &si1Array[i]);
	}
	si1Array[siACnt] = INT_MAX;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 合計 - 取得
	int liSum = 0;
	for (i = 0; i < siACnt; i++) {
		if (si1Array[i] < si1Array[i + 1]) {
			liSum += si1Array[i];
		}
		else {
			liSum += si1Array[i + 1];
		}
	}

	return liSum;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1Array, 0, sizeof(si1Array));						// 配列

																// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;
import java.lang.Math;
public class Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.next());
	call(n);
    }
    public static void call(int n) {
	for (int i = 1; i <= n; i++) {
	    if (i % 3 == 0) {
		System.out.print(" " + i);
		continue;
	    }
	    include3(i);
	}
	System.out.println();
    }
    public static void include3(int i) {
	int x = i;
	while (x > 0) {
	    if (x % 10 == 3) {
		System.out.print(" " + i);
		return;
	    }
	    x /= 10;
	}
    }
}

Measured memory_bytes: 29484
alf=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
n=int(input())
li=[]
ans=[]
STR=""
for h in range(n):
    li.append([0]*26)

for i in range(n):
    S=input()
    for j in range(len(S)):
        li[i][alf.index(S[j])]+=1


for k in range(26):
    temp=1000000000000000000000000000000000000000000
    for l in range(n):
        if temp>li[l][k]:
            temp=li[l][k]
        
    if temp!=1000000000000000000000000000000000000000000:
        ans.append(temp)

for m in range(26):
    STR=STR+alf[m]*ans[m]
print(STR)


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))

class dijkstra{ 
//0indexed 
public: 
	ll v,startv; 
	vector<ll> d; 
	vector<vector<pair<ll,ll> > >e; 

	void initsize(ll n0){ 
		d.resize(n0); 
		for(ll i=0;i<n0;i++)d[i]=INF;
		vector<pair<ll,ll> > ep; 
		for(ll i=0;i<n0;i++)e.push_back(ep); 
		v=n0; 
	} 

	void initstart(ll s){ 
		startv=s;
		d[s]=0;
	}

	void make_edge(ll x,ll y,ll cost){ 
		e[x].push_back(make_pair(y,cost)); 
		e[y].push_back(make_pair(x,cost)); 
	}

	void make_edgedir(ll x,ll y,ll cost){ 
		e[x].push_back(make_pair(y,cost)); 
	}

	void calcdistance(){ 
		// <-cost,x> 
		//cost startv->x 
		priority_queue<pair<ll,ll> > q; 
		pair<ll,ll> p; 
		vector<bool> did; 
		for(ll i=0;i<v;i++)did.push_back(false); 
		did[startv]=true; 
		for(ll i=0;i<e[startv].size();i++){ 
			p.first=-e[startv][i].second; 
			p.second=e[startv][i].first; 
			q.push(p); 
		}
		while(q.size()!=0){
			pair<ll,ll> p;
			p=q.top();
			q.pop();
			ll x,costsx;
			x=p.second;
			costsx=-p.first;
			if(did[x]==true)continue;
			did[x]=true;
			d[x]=costsx;
			for(ll i=0;i<e[x].size();i++){
				p.first=-(d[x]+e[x][i].second);
				p.second=e[x][i].first;
				if(did[p.second]==false)q.push(p);
			}
		}
	}
};

int main(){
	ll N,M;
	cin >> N >> M;
	dijkstra di;
	di.initsize(3*N);
	FOR(i,0,M){
		ll a,b;
		cin >> a >> b;
		a--;b--;
		di.make_edgedir(a,b+N,1);
		di.make_edgedir(a+N,b+N*2,1);
		di.make_edgedir(a+2*N,b,1);
	}
	ll S,T;
	cin >> S >> T;
	S--;T--;
	di.initstart(S);
	di.calcdistance();
	ll ans = di.d[T];
	if(ans==INF)ans = -3;
	cout << ans/3 << endl;
}



Measured memory_bytes: 20200
#include<bits/stdc++.h>
using namespace std;
const int mx=1234567;
#define ll long long
#define p push_back
#define ff first
#define ss second
ll n ;
int main(){
    cin>>n;
    if(n%2==0){
        cout<<n<<endl;
    }
    else{
        cout<<2*n<<endl;
    }
    return 0;
}


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

int main() {

    ll N;
    cin >> N;

    ll ans = 0;
    FOR(i, 1, N+1) {
        ll num = N / i;
        ans += ((i + i*(num)) * num / 2);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    string s,t;
    int cnt=0;
    int i;
    cin >> s >> t;
    for(i=0;i<s.length();i++){
        if(s[i]!=t[i])
            cnt++;
    }
    cout << cnt;

}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a), greater<ll>());
  ll ok = p - 1, ng = n;
  while(ok + 1 < ng) {
    ll x = (ok + ng) / 2;
    ll now = 0;
    rep(i, n) {
      if(i < p - 1 || x <= i)
        now += m;
      else
        now += m - a[i] + a[x];
    }
    if(a[p - 1] > a[x] + m) now = -1e18;
    if(now < m * v)
      ng = x;
    else
      ok = x;
  }
  cout << ok + 1 << endl;
}

Measured memory_bytes: 4028
s = input()
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']
ans = 'Yes'
for i in range(len(s)):
    if i % 2:
        if s[i] not in even:
            ans = 'No'
    else:
        if s[i] not in odd:
            ans = 'No'
print(ans)

Measured memory_bytes: 3060
# 先に相手の隣に陣取った方の勝ち
N, A, B = map(int, input().split())
# AliceとBorysの間に奇数個のマスがあった場合，Aliceが勝つ
if (B - A + 1) % 2 == 1:
    print('Alice')
# 偶数個（0を含む）のマスがあった場合，Borysが勝つ
else:
    print('Borys')
# Drawはない
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,k;
   cin>>n>>k;
   int arr[n];
   for(int i=0;i<n;i++) cin>>arr[i];
   int dp[n];
   fill(dp,dp+n,0);
   for(int i=1;i<=k && i<n;i++)
   {
       dp[i]=abs(arr[i]-arr[0]);
   }
   for(int i=k+1;i<n;i++)
   {  int temp=INT_MAX;
      for(int j=i-1;j>=i-k;j--)
      {
          temp=min(temp,dp[j]+abs(arr[i]-arr[j]));
      }
     dp[i]=temp;
   }
    cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<array>
#include<bitset>
#include<cmath>

using namespace std;

#define square(s) ((s)*(s))
#define scast(type,e) static_cast<type>(e)
#define rep(i,n) for(decltype(n) i = 0; i < n;i++)
#define repp(i,s,u) for(decltype(s) i = s; i < u;i++)
#define range(a) a.begin(),a.end()
#define pr(l,r) make_pair((l),(r))
#define INF (1145141919)


template<class T>
using vec = vector<T>;
template<class T,size_t S>
using arr = array<T,S>;
template<class T1,class T2>
using pr = pair<T1, T2>;

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

template<class T>
void chmax(T& dest, const T& target) {
	dest = max(dest, target);
}
template<class T>
void chmin(T& dest, const T& with) {
	dest = min(dest, with);
}

int main(){
	int N;
	cin >> N;
	vec<int> L(N);
	rep(i, N) {
		cin >> L[i];
	}
	sort(range(L));
	int ans = 0;
	rep(i, N) {
		rep(j, i) {
			auto n = lower_bound(range(L), L[i] + L[j]) - L.begin() - 1;
			ans += n - i;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
 
  int x,y,t;
  int i;
 
 
  while(1) {
  scanf("%d %d",&x,&y);
  if(x*y == 0) break;
 
  if(y >=x) {
    t = y;
    y = x;
    x = t;
  }
 
 
  i= 0;
  while(1) {
    i++;
    x = x % y;
 
    t =x;
    x = y;
    y = t;
 
    if(y == 0) break;
 
  }
 
 
  printf("%d %d\n",x,i);
 
 
  }
 
  return 0;
 
}

Measured memory_bytes: 600
N, M = gets.split.map(&:to_i)
Xs = gets.split.map(&:to_i)

Xs.sort!
sum = 0
diff = []

(Xs.length - 1).times do |i|
  diff.push( [Xs[i + 1] - Xs[i], i] ) 
end

diff.sort!{ |b, a| a[0] <=> b[0] }

diff = diff.slice(0, N-1)

diff.sort!{ |b, a| b[1] <=> a[1] }

head = Xs[0]

diff.length.times do |i|
  b_i = (diff[i][1])
  sum += Xs[b_i] - head
  head = Xs[b_i+1]
end

sum += Xs.last - head

puts sum

Measured memory_bytes: 14968
#![allow(unused_imports)]
use std::cmp;
use std::collections::*;

pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

fn main() {
    let mut scan = Scanner::new();
    let s = scan.next_string();
    println!("{}", if s[1] == 'B' { "ARC" } else { "ABC" });
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X = sc.nextInt();
    int[] L = new int[N];
    int cnt = 1;
    int length = 0;

    for(int i = 0; i < N; i++) {
    	L[i] = sc.nextInt();
    	length += L[i];
    	if(length <= X) {
    		cnt++;
    	}
    }
    System.out.println(cnt);
  }
}

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  int ans=0;
  int i=A;
  while(ans<K){
    if(A%i==0 && B%i==0) ans++;
    i--;
  }
  cout << i+1 << endl;  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

struct line{
    ll a, b;
    bool operator==(const line other)const{
        return a==other.a && b==other.b;
    }
};

ll f(line l, ll x){
    return l.a*x + l.b;
}

const ll INF = 1ll<<55;

struct LiChaoTree{
    int n;
    vector<ll> xs;
    vector<line> v;
    line tmp{0, INF};
    LiChaoTree(vector<ll> x) : xs(x){
        n = 1;
        while(n < xs.size())  n *= 2;
        while(xs.size() < n)    xs.push_back(x.back());
        v.resize(2*n+1, tmp);
    }
    void add_line(line p, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        int m = (l+r)/2;
        if(v[k] == tmp){
            v[k] = p;
            return;
        }
        ll lx = xs[l], mx = xs[m], rx = xs[r-1];
        bool left = f(p,lx) < f(v[k], lx);
        bool mid = f(p,mx) < f(v[k], mx);
        bool right = f(p,rx) < f(v[k], rx);
        if(left == right){
            if(left)    v[k] = p;
            return;
        }
        if(mid){
            swap(v[k], p);
        }
        // v[k]とpが交わっている部分について更新していくと考えるとわかりやすい
        if(left != mid){
            add_line(p, 2*k+1, l, m);
        }else{
            add_line(p, 2*k+2, m, r);
        }
    }
    ll query(int k){
        ll x = xs[k];
        k += n-1;
        ll ret = INF;
        while(true){
            if(!(v[k]==tmp)) ret = min(ret, f(v[k], x));
            if(k==0)    break;
            k = (k-1)/2;
        }
        return ret;
    }
};

int main(){
    int n;
    ll c;
    cin >> n >> c;
    vector<ll> h(n);
    for(int i = 0; i < n; i++)  cin >> h[i];
    LiChaoTree lct(h);
    vector<ll> dp(n, INF);
    dp[0] = 0;
    lct.add_line(line({-2*h[0], h[0]*h[0]+dp[0]}));
    for(int i = 1; i < n; i++){
        dp[i] = lct.query(i)+h[i]*h[i]+c;
        lct.add_line(line({-2*h[i], h[i]*h[i]+dp[i]}));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 14580
#include <stdio.h>
#include <math.h>
int main()
{
	int N, K, i, total = 1;
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++) {
		if (total + K < total * 2)
			total = total + K;
		else
			total = total * 2;
	}
	printf("%d\n", total);
	return 0;
}

Measured memory_bytes: 128