akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<ll, int>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<P> fr;
  fr.emplace_back(a[0], 0);
  for (int i = 1; i < n; i++) {
    if (a[i] > fr.back().first) 
      fr.emplace_back(a[i], i);
  }
  vector<ll> res(n), num(fr.size());
  rep(i, n) {
    auto it = lower_bound(fr.begin(), fr.end(), make_pair(a[i], 0));
    if (it->first == a[i])
      num[it-fr.begin()]++;
    else {
      if (it != fr.begin()) {
        auto prev = it;
        prev--;
        res[it->second] += a[i]-prev->first;
        num[prev-fr.begin()]++;
      } else 
        res[0] += a[i];
    }
  }
  for (int i = (int)fr.size()-1; i >= 0; i--) {
    if (i) {
      res[fr[i].second] += num[i]*(fr[i].first-fr[i-1].first);
      num[i-1] += num[i];
    } else
      res[0] += num[0]*a[0];
  }
  rep(i, n)
    cout << res[i] << '\n';
  return 0;
}

Measured memory_bytes: 7148
use std::io::stdin;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let mut line = buf.split_whitespace();
    let n: u64 = line.next().unwrap().parse().unwrap();
    let blue: u64 = line.next().unwrap().parse().unwrap();
    let red: u64 = line.next().unwrap().parse().unwrap();

    println!("{}", solve(n, blue, red));
}

fn solve(n: u64, blue: u64, red: u64) -> u64{
    let quotient = n / (blue + red);
    let surplus = n % (blue + red);
    quotient * blue + min(blue, surplus)
}

Measured memory_bytes: 4352
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int n;
  cin >> n;

  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
  }
  SORT(a);

  ll four_max = -1;
  ll two_max_first = -1;
  ll two_max_second = -1;

  int counts = 1;
  ll currentNum = a[0];
  for(int i=1;i<n;i++) {
    if(currentNum == a[i]) {
      counts++;
    } else {
      counts = 1;
      currentNum = a[i];
      continue;
    }

    if(counts >= 4) {
      four_max = max(four_max, a[i]);
    } else if(counts >= 2) {
      if(a[i] > two_max_first) {
        two_max_second = two_max_first;
        two_max_first = a[i];
      } else if(a[i] > two_max_second && a[i] != two_max_first) {
        two_max_second = a[i];
      }
    }
  }

  ll ans = 0;
  if(four_max != -1) {
    ans = four_max * four_max;
  }
  if(two_max_first != -1 && two_max_second != -1) {
    // cout << two_max_first << endl << two_max_second << endl;
    ans = max(ans, two_max_first * two_max_second);
  }

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


Measured memory_bytes: 1024
N, M = map(int, input().split())
H = list(map(int, input().split()))
cnt = 0
l = [0]*N
B = [0]*N
AB = list()
for m in range(M):
    P = list(map(int, input().split()))
    AB.append(P)
for m in range(M):
    B[AB[m][0]-1] += 1
    B[AB[m][1]-1] += 1
    if H[AB[m][0]-1] < H[AB[m][1]-1]:
        l[AB[m][0]-1] += 1
    elif H[AB[m][0]-1] > H[AB[m][1]-1]:
        l[AB[m][1]-1] += 1
    elif H[AB[m][0]-1] == H[AB[m][1]-1]:
        l[AB[m][0]-1] += 1
        l[AB[m][1]-1] += 1
for i in l:
    if i == 0:
        cnt += 1
print(cnt)

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

signed main(){
	int x,a,b,n;
	cin >> x >> a >> b >> n;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		if(s == "karero") x = 0;
		else if(s == "nobiro") x = max(0,x + a);
		else x = max(0,x + b);
	}
	cout << x << endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;
typedef pair<int, int> P;



signed main()
{
    int N;
    cin >> N;
    
    if (N / 10 == 9 || N % 10 == 9) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 768
n,m = map(int,input().split())
l = []
anslist = [0]*n
while True:
  try:
    tmpa,tmpb = map(int,input().split())
    n = (tmpa,tmpb)
    l.append(n)
    
    
  except:
    break
    
for i,j in l:
  anslist[i-1] +=1
  anslist[j-1] +=1
  
for i in anslist:
  print(i)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	static int N,M;
	static int PYarr[][];
	
	public static void main(String[] args) throws NumberFormatException, IOException  {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		N = Integer.parseInt(st.nextToken());
		M = Integer.parseInt(st.nextToken());
		PYarr = new int[M][3];
		int Nnum[] = new int[N+1];
		for(int i = 0; i < M;i++){
			st = new StringTokenizer(br.readLine());
			PYarr[i][0] = Integer.parseInt(st.nextToken());
			PYarr[i][1] = Integer.parseInt(st.nextToken());
			PYarr[i][2] = i;
		}
		quick_sorc(0,M-1,0);
		for(int i = 0; i < M;i++){
			Nnum[PYarr[i][0]]++;
			PYarr[i][1] = Nnum[PYarr[i][0]];
		}
		quick_sorc(0,M-1,1);
		String P,X;
		for(int i = 0; i < M;i++){
			P = String.format("%06d", PYarr[i][0]);
			X = String.format("%06d", PYarr[i][1]);
			StringBuffer sb = new StringBuffer("");
			sb.append(P);
			sb.append(X);
			System.out.println(sb.toString());
		}
	}
	
	public static void quick_sorc(int start, int end, int flag) {
		if (start < end) {
			// 快排
			int p = random_partition(start, end, flag);
			quick_sorc(start, p - 1, flag);
			quick_sorc(p + 1, end, flag);
		}
	}

	public static int partition(int s, int e, int flag) {
		int i = s;
		if(flag == 0) {
			for (int j = s; j <= e - 1; j++) {
				if (PYarr[e][1] > PYarr[j][1]) {
					swp(i, j);
					i++;
				}
			}
			swp(i, e);
			return i;
		}else {
			for (int j = s; j <= e - 1; j++) {
				if (PYarr[e][2] > PYarr[j][2]) {
					swp(i, j);
					i++;
				}
			}
			swp(i, e);
			return i;
		}
	}

	public static int random_partition(int s, int e,int flag) {
		int i = myrandom(s, e);
		swp(i, e);
		return partition(s, e,flag);
	}

	public static int myrandom(int s, int e) {
		return (int) (s + Math.random() * (e - s + 1));
	}
	
	// 交换
	public static void swp(int a,int b) {
		int temp[] = PYarr[a];
		PYarr[a] = PYarr[b];
		PYarr[b] = temp;
	}
}

Measured memory_bytes: 113080
function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10),
          cards = args[1].split(' ').map(n => parseInt(n, 10));

    var aSum = 0,
        bSum = 0;

    cards.sort((a, b) => b-a).forEach((n, i) => {
        (i % 2 === 0)? aSum += n : bSum += n;
    });

    console.log(aSum - bSum);
}

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


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

int main() {
int N, P = 0, W = 0, G = 0, Y = 0;
string s;

cin >> N;

for (int i = 0; i < N; i++) {
  cin >> s;
  if (s == "P") {
	P = 1;
  }
  else if (s == "W") {
	W = 1;
  }
  else if (s == "G") {
	G = 1;
  }
  else if (s == "Y") {
	Y = 1;
  }
}
  if (P + W + G + Y == 4){
	cout << "Four";
  }
  else {
	cout << "Three";
  }
}

Measured memory_bytes: 256
void main() {
	(a => ((a[0] + a[1]) / 2.).ceil)(readAs!(int[])).writeln;
 }

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
/* ***********************************************
Author        :dasinlsb
Created Time  :2018/6/2 21:38:23
File Name     :C:\dasin\duipai.cpp
************************************************ */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const int N=21;
const int M=(1<<20)+5;
int n,kk,f[N][M],nxt[N][M];
char Xs[N];
int main(){
  //freopen("C:/dasin/aa.in","r",stdin);
  //freopen("C:/dasin/mine.out","w",stdout);
  int i,j,k;
  scanf("%d%d",&n,&kk);
  for(i=0;i<=n;++i){
    scanf("%s",Xs);
    for(j=0;j<1<<i;++j)if(Xs[j]-'0')f[i][j]=1;
  }
  for(i=1;i<=n;++i){
    for(j=0;j<1<<i;++j){
      int t=j>>(i-1);
      for(k=i-1;~k&&((j>>k)&1)==t;--k);
      nxt[i][j]=k+1;
    }
  }
  int x=-1,y=-1;
  for(i=0;i<=n;++i){
    for(j=1;j+i<=n;++j){
      for(k=0;k<1<<i+j;++k){
        f[i][k>>j]+=f[i+j][k];
        int t=nxt[j][((1<<j)-1)&k];
        if(!t)continue;
        f[i+t][k>>j<<t|((1<<t)-1)&k]+=f[i+j][k];
      }
    }
    for(j=(1<<i)-1;~j;--j){
      if(f[i][j]>=kk){
        x=i,y=j;
      }
    }
  }
  assert(~x);
  for(i=x-1;~i;--i)putchar(((y>>i)&1)+'0');puts("");
  return 0;
}


Measured memory_bytes: 93568
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    ret = ""
    while N != 0:
        ret = str(N%2) + ret
        N = -1 * (N//2)
    print(0 if ret == "" else ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,ans=0;
    cin>>n;
    ll x,y,ma,mb,xa,xb;
    for(int i=0;i<n;i++)
    {
    	cin>>x>>y;
    	if(i==0)
    	{
    		ma=x+y;
    		mb=x+y;
    		xa=x-y;
    		xb=x-y;
    		continue;
    	}
    	ma=min(ma,x+y);
    	mb=max(mb,x+y);
    	xa=min(xa,x-y);
    	xb=max(xb,x-y);
    }
    ma=mb-ma;
    xa=xb-xa;
    ma=max(ma,xa);
    cout<<ma<<endl;
}

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


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

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
N = gets.to_i
as = gets.split.map(&:to_i)
edges = Array.new(N){{}}
(N-1).times do
    a, b = gets.split.map(&:to_i)
    edges[a-1][b-1] = true
    edges[b-1][a-1] = true
end

stack = [0]
visited = [true]
bottomup = Array.new(N){Array.new}
while stack.length > 0
    updated = false
    s = stack[-1]
    edges[s].each do |t, _|
        next if visited[t]
        stack.push(t)
        visited[t] = true
        updated = true
        break
    end
    unless updated
        if bottomup[s].length == 0
            bottomup[stack[-2]].push(as[s])
        else
            bu = bottomup[s]
            sum = bu.inject(:+)
            uplink = 2*as[s] - sum
            lb = [2*bu.max - sum, 0].max
            ub = as[s]
            if stack.length == 1
                if edges[s].length == 1
                    if bu[0] != as[s]
                        puts 'NO'
                        exit
                    end
                else
                    if uplink != 0
                        puts 'NO'
                        exit
                    end
                end
            else
                unless uplink.between?(lb, ub)
                    puts 'NO'
                    exit
                end
                bottomup[stack[-2]].push(uplink)
            end
        end
        stack.pop
    end
end
puts 'YES'

Measured memory_bytes: 53516
//#include "stdc++.h"
#include <bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
//#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD =1000000007 ;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
#define pi 3.141592653589793238462
#define int  long long
int a[17][17];int dp[1<<18];vi v;

int32_t main()
{
    
    IOS;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    dp[0]=0;int ans,j,sz;
    for(int i=1;i<(1<<n);i++)
    {
        
        for(int j=0;j<n;j++)
            for(int k=0;k<n;k++)
            if((i&(1<<j))&&(i&(1<<k)))
                dp[i]+=a[j][k];
        dp[i]=dp[i]/2;
        for(int j=i;j>0;j=(j-1)&i)
            dp[i]=max(dp[i],dp[j]+dp[i^j]);
        
    }
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}




Measured memory_bytes: 768
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	Int H;
	cin >> H;

	Int ans = 0;
	Int cnt = 1;
	while (H > 0) {
		ans += cnt;
		H /= 2;
		cnt *= 2;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut input_iter = read_line_as_vector::<i32>().into_iter();
    let a = input_iter.next().unwrap();
    let b = input_iter.next().unwrap();
    if a <= 9 && b <= 9 {
        println!("{}", a * b);
    } else {
        println!("-1");
    }
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}

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

    #define all(v) v.begin(),v.end()
    #define rall(v) v.rbegin(),v.rend()
    #define trav(i,a) for(auto i: a)
    #define ff first
    #define ss second
    #define eb emplace_back
    #define tc(t) ll t; cin>>t; while(t--)
    #define prec(n) fixed<<setprecission(n)
    #define mst(arr,value) memset(arr,value,sizeof(arr))
    #define sz(a) a.size()
    #define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    
    const long long inf = (long long)1e18;
    const long long M = (long long)1e9+7;
    
    #define fab(i,a,b) for(ll i=a; i<b; i++)
    #define fba(i,b,a) for(ll i=b; i>=a; i--)

    ll mpw(ll a, ll b, ll M = inf) {
        if(b == 0) return 1;
        if(b % 2 == 1) 
            return a * mpw((a * a) % M, b / 2, M) % M;
        return mpw((a * a) % M, b / 2, M);        
    } 


    // ll knapsack(vector<pair<ll, ll>> items, ll n, ll w) {
    //     if(n == 0 or w == 0)
    //         return 0;
    //     if(items[n - 1].ff > w)
    //         return knapsack(items, n - 1, w);
    //     return max(items[n - 1].ss + knapsack(items, n - 1, w - items[n - 1].ff),
    //                 knapsack(items, n - 1, w));
    // }

    ll knapsack(vector<pair<ll, ll>> items, ll n, ll w) {
        ll dp[n + 1][w + 1];
        fab(i, 0, n + 1) {
            fab(j, 0, w + 1) {
                if(i == 0 or j == 0)
                    dp[i][j] = 0;
                else if(items[i - 1].ff <= j) 
                    dp[i][j] = max(
                        items[i - 1].ss + dp[i - 1][j - items[i - 1].ff],
                        dp[i - 1][j]);
                else dp[i][j] = dp[i - 1][j];
            }
        }        
        return dp[n][w];
    }



    int main() {
        fio

        ll n, w;
        cin >> n >> w;

        vector<pair<ll, ll>> items(n);

        fab(i, 0, n) { 
            cin >> items[i].ff >> items[i].ss;
        }

        cout << knapsack(items, n, w);

        
        return 0;
    }

Measured memory_bytes: 82416
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

vector<pair<int,int>> graph[100001];
int curmax = 0;
int color[100001];

void dfs(int cur, int parent, int prev_color)
{
	int cnt = 0;

	for (int i = 0; i < graph[cur].size(); i++)
	{
		int next;

		next = graph[cur][i].first;

		if (next == parent)
		{
			continue;
		}

		int next_color;

		next_color = (prev_color + cnt + 1) % curmax;

		color[graph[cur][i].second] = next_color + 1;

		dfs(next, cur, next_color);

		cnt++;
	}
}

int main()
{
	int n;

	scanf("%d", &n);

	for (int i = 0; i < n - 1; i++)
	{
		int u, v;

		scanf("%d %d", &u, &v);

		graph[u].push_back(make_pair(v, i));
		graph[v].push_back(make_pair(u, i));
	}

	for (int i = 1; i <= n; i++)
	{
		if (graph[i].size() > curmax)
		{
			curmax = graph[i].size();
		}
	}

	dfs(1, 0, -1);

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

	for (int i = 0; i < n - 1; i++)
	{
		printf("%d\n", color[i]);
	}

	return 0;
}

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

int x[2], n, m;
vector<int> g[100001];
bool vis[100001], C[100001];

pair<int, int> go(int v, int c = 0){
	vis[v] = true;
	C[v] = c;
	pair<int, int> an(1, c);
	f(i, 0, g[v].size()){
		int u = g[v][i];
		if (vis[u]){
			if (c ^ 1 ^ C[u])an.second = -1;
			continue;
		}
		pair<int, int> t = go(u, c ^ 1);
		an.first += t.first;
		if (t.second == -1)an.second = -1;
		else if (an.second != -1)an.second += t.second;
	}
	return an;
}

int main(){
	scanf("%d%d", &n, &m);
	f(i, 0, m){
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	ll an = (ll)n * n;
	int z = 0, w = 0;
	f(i, 1, n + 1)if (!vis[i] && !g[i].empty()){
		pair<int, int> t = go(i);
		if (t.second == -1)x[0] += t.first, ++w;
		else x[0] += t.second, x[1] += t.first - t.second, ++z;
	}
	an += (ll)z * z << 1;
	an += (ll)z * w << 1;
	an += (ll)w * w;
	an -= (ll)x[0] * x[0] + (ll)x[1] * x[1] + (ll)x[0] * x[1] * 2;
	printf("%lld\n", an);
}


Measured memory_bytes: 11648
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
# from bisect import *
# from collections import *
# from heapq import *
# import itertools
# import math
# INF = 10**9
# MOD = 10**9+7

N = int(input())
for i in range(1, 10):
    for j in range(1, 10):
        if i*j == N:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 38384
n, m = map(int, input().split())
list_a = list(map(int, input().split()))
votes_sum = sum(list_a)
select = votes_sum / (4*m)
popular = []

for a in list_a:
    if a >= select:
        popular.append(a)

if m <= len(popular):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
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 c=sc.nextInt();
int k=sc.nextInt();

int max = a;
int cd=0;

if(b > max) {
	max = b;
	cd = 1;	
}

if(c > max){
	max =c;
	cd =2;
}

for(int i = 0; i < k; i++) {
max = max *2;
}

if(cd == 0){
  max = max+b+c;
} else if(cd ==1) {
	max= max+a+c;
} else if(cd == 2) {
	max =max+a+b;
}

System.out.println(max);

}
}


Measured memory_bytes: 21972
#include <stdio.h>

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

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

bool f[100005];

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int ind = 0, ans = 0;
    while(true) {
        if(!f[ind]){
            f[ind] = true;
            ind = a[ind]-1;
            ans++;
        } else {
            ans = -1;
            break;
        }
        if(ind == 1) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
int a,b;cin >> a >> b;
int n=1;
if(b==1)cout << 0 << endl;
if(b!=1){
while(b>(a-1)*(n-1)+a){
    n++;
}
cout << n << endl;
}
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)



int field[100000];

int root(int x) {
	if (field[x] == x) {
		return x;
	}
	else {
		return field[x] = root(field[x]);
	}
}

bool isame(int x, int y) {
	return root(x) == root(y);
}

void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y) return;

	field[x] = y;
}


int main() {

	int n, m;
	cin >> n >> m;
	VI p(n);
	REP(i, n) {
		int t;
		cin >> t;
		p[i] = t - 1;
	}
	
	REP(i, n) {
		field[i] = i;
	}

	REP(i, m) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		unite(x, y);
	}

	int ans = 0;
	REP(i, n) {
		if (isame(i, p[i])==true) {
			ans++;
		}
	}
	ANS(ans);

	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef pair<int,pii> pip;
ll dp[2010][2010]={0};
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	queue<pip>q;
	rep(i,n){
		dp[i][1]=in[i];
		q.push(pip(1,pii(i,1)));
	}
	while(!q.empty()){
		pip a=q.front();pii b=a.second;q.pop();
		int s=b.first,t=b.first+b.second;
		if(t>=n)t-=n;s--;if(s==-1)s=n-1;if(t==n)t=0;
		if(a.first){
			if(in[s]>in[t]){
				if(dp[s][b.second+1]<dp[b.first][b.second]){
					dp[s][b.second+1]=dp[b.first][b.second];
					if(b.second+1!=n)q.push(pip(0,pii(s,b.second+1)));
				}
			}else{
				if(dp[b.first][b.second+1]<dp[b.first][b.second]){
					dp[b.first][b.second+1]=dp[b.first][b.second];
					if(b.second+1!=n)q.push(pip(0,pii(b.first,b.second+1)));
				}
			}
		}else{//JOI
			if(dp[s][b.second+1]<dp[b.first][b.second]+in[s]){
				dp[s][b.second+1]=dp[b.first][b.second]+in[s];
				if(b.second+1!=n)q.push(pip(1,pii(s,b.second+1)));
			}
			if(dp[b.first][b.second+1]<dp[b.first][b.second]+in[t]){
				dp[b.first][b.second+1]=dp[b.first][b.second]+in[t];
				if(b.second+1!=n)q.push(pip(1,pii(b.first,b.second+1)));
			}
		}
	}
	ll out=0;
	rep(i,n)out=max(out,dp[i][n]);
	cout<<out<<endl;
}

Measured memory_bytes: 32684
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18


A,B,C=rl()
yn(A==B and B==C)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using ll=long long;
using pl  = pair<ll,ll>;
using pii  = pair<int,int>;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,L,N,M,P,Q,R,W,X,Z;
string S,T,U;
vector<ll> V(100007);

int main(){
  cin >> S ;
  rep(i,S.size()){
    cout << "x";
  }
  cout << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh

ll a[nax],pre[nax];
int main()
{
	int n;
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
		a[i] += a[i-1];
	}
	ll ans = inf;
	for(int i = 1 ; i <= n - 1 ; i++){
	//	cout << a[i] << endl;
		ans = min(ans , abs(a[n] - 2 * a[i]));
	}
	cout << ans << endl;
	return 0;
} 




Measured memory_bytes: 4352
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace DigitsParades
{

    class Programk
    {
        static long H;
        static long W;
        static long D;
        static long[][] A;
        static long[] dis;
        static Tuple<long, long>[] point;
        static void Main(string[] args)
        {
            var HWD = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            H = HWD[0];
            W = HWD[1];
            D = HWD[2];
            dis = new long[H * W + 1];
            A = new long[H][];
            for (int i = 0; i < H; i++)
            {
                A[i] = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            }

            point = new Tuple<long, long>[H*W + 1];
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    point[A[i][j]] = new Tuple<long, long>(i, j);
                }
            }

            for (int i = 1; i <= D; i++)
            {
                Calculate(i);
            }

            var Q = long.Parse(Console.ReadLine());
            for (int i = 0; i < Q; i++)
            {
                var LR = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                var L = LR[0];
                var R = LR[1];

                Console.WriteLine(dis[L]-dis[R]);
            }
            
        }

        static long Calculate(long num)
        {
            if(num >= H * W)
            {
                return 0;
            }
            else
            {
                var after = num + D;
                if(after > H * W)
                {
                    return 0;
                }
                dis[num] = Calculate(after) + Abs(point[after].Item1 - point[num].Item1) + Abs(point[after].Item2 - point[num].Item2);
                return dis[num];
            }
        }
    }
}


Measured memory_bytes: 25756
#include <iostream>
#include <algorithm>

using namespace std;
int A, B, C;

void solve() {
	if (A <= C && C <= B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


int main() {
	cin >> A >> B >> C;
	solve();
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    string S; cin>>S;
    cout << "2018/" << S.substr(5, 5) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100
#define INF 10000000

int n;

void MatrixChainOrder(int p[]){
  int i, j, k, l, q;
  int m[N][N];

  for(i = 1; i <= n; i++) m[i][i] = 0;
  
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;

      m[i][j] = INF;

      for(k = i; k <= j - 1; k++){
	q = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];

	if(m[i][j] >= q) m[i][j] = q;
      }
    }
  }
  
  printf("%d\n", m[1][n]);
  return;

}

int main(){
  int i;
  int a;
  int p[N];

  scanf("%d", &n);

  for(i = 0; i < n; i++) scanf("%d%d", &p[i], &a);
  p[n] = a;

  MatrixChainOrder(p);

  return 0;
}

Measured memory_bytes: 632
/*
uchiyan ni gallan
*/

#include<bits/stdc++.h>
#define mod 1000000007
#define pp pair<long long,long long>
#define ll long long
#define ff first
#define ss second
#define horse_power ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
string s,t;
int n,m;
void solve(){
   cin>>s>>t;
    n=s.size();
    m=t.size();
    vector< vector<int> >  dp(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
         if(s[i-1]==t[j-1]){
            dp[i][j]=1+dp[i-1][j-1];
         }else{
           dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
         }
        }
    }
    int i=n,j=m;
    stack<char> stk;
    while(i>0 && j >0){
        if(dp[i][j]==1+dp[i-1][j-1] && s[i-1]==t[j-1]){
            stk.push(s[i-1]);
            i--;
            j--;
        }else if( dp[i][j]==dp[i-1][j]){
           i--;
        }else{
        j--;
        }

    }
    while(!stk.empty()){
        cout<<stk.top();
        stk.pop();
    }
    cout<<"\n";

}

int main(){
horse_power
int t=1;
//cin>>t;
while(t--){
solve();
}


}


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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

ll n,a[100000];
ll mc=LLONG_MAX;

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

	cin >> n;
	for (int i=0;i<n;i++) cin >> a[i];
	for (int s=0;s<2;s++) {
		ll cost=0;
		ll cs=0;
		for (int sgn=1-2*s,i=0;i<n;i++,sgn*=-1) {
			cs+=a[i];
			//cerr << cs << ' ' << sgn << endl;
			if (cs!=0 && ((cs>0)==(sgn>0)));
			else {
				//cerr << "hey\n";
				cost+=abs(sgn-cs);
				cs=sgn;
				//cs+=sgn-a[i];
			}
		}
		//cerr << endl;
		mc=min(mc,cost);
	}

	cout << mc << endl;
}

Measured memory_bytes: 1024
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n:i32 = read_line().parse().unwrap();
    let mut a:Vec<i64> = read_line().split_whitespace().map(|x|x.parse().unwrap())
                                  .collect::<Vec<i64>>();
    let mut count = 0;
    loop {
        if a.iter().any(|x|x % 2 != 0) {
            break
        }else{
            a = a.iter().map(|x|x/2).collect::<Vec<i64>>();
            count+=1;
        }
    }
    println!("{}",count);
}

Measured memory_bytes: 4352
L = int(input())
A = [0] * (L + 1)
DP = [[0, 0, 0, 0, 0] for i in range(L + 1)]
for i in range(L):
  a = int(input())
  DP[i + 1][0] = DP[i][0] + a
  DP[i + 1][1] = min(min(DP[i][:2]), DP[i + 1][0]) + (a % 2 if a else 2)
  DP[i + 1][2] = min(min(DP[i][:3]), DP[i + 1][1]) + ((1 - a % 2) if a else 1)
  DP[i + 1][3] = min(min(DP[i][:4]), DP[i + 1][2]) + (a % 2 if a else 2)
  DP[i + 1][4] = min(min(DP[i]), DP[i + 1][3]) + a
print(min(DP[L]))

Measured memory_bytes: 61464
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;
using Polygon=vector<Point>;

namespace std {
    bool operator<(const Point &a, const Point &b) {
        return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
    }
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

struct Line: public pair<Point, Point> {
    Line() {}
    Line(const Point &a, const Point &b) {
        first = a;
        second = b;
    }
};

struct Circle {
    Point p;
    double r;
    Circle() {}
    Circle(const Point &p, const double r): p(p), r(r) {}
};

vector<Point> get_ctangents(const Circle &c1, const Circle &c2) {
    Point v=c2.p-c1.p;
    double d=abs(v);

    vector<Point> g;
    if (abs(d) < EPS)
        return g;

    double R=max(c1.r, c2.r), r=min(c1.r, c2.r);
    if (R+r-d < -EPS) {
        // R + r < d
        double t=acos((R+r)/d);
        g.push_back(c1.p+(c1.r/d*v)*polar(1.0, t));
        g.push_back(c1.p+(c1.r/d*v)*polar(1.0, -t));
    } else if (R+r-d < EPS) {
        // R + r = d
        g.push_back(c1.p+c1.r/d*v);
    }

    if (R-r-d < -EPS) {
        // R - r < d
        double t=acos((c1.r-c2.r)/d);
        g.push_back(c1.p+(c1.r/d*v)*polar(1.0, t));
        g.push_back(c1.p+(c1.r/d*v)*polar(1.0, -t));
    } else if (R-r-d < EPS) {
        // R - r < d
        if (c1.r < c2.r) {
            g.push_back(c2.p-c2.r/d*(c2.p-c1.p));
        } else {
            g.push_back(c1.p+c1.r/d*(c2.p-c1.p));
        }
    }

    sort(g.begin(), g.end());
    return g;
}

int main() {
    double x, y, r;
    scanf("%lf %lf %lf", &x, &y, &r);
    Circle c1(Point(x, y), r);

    scanf("%lf %lf %lf", &x, &y, &r);
    Circle c2(Point(x, y), r);

    vector<Point> ctangents=get_ctangents(c1, c2);
    for (const Point &t: ctangents)
        printf("%.9f %.9f\n", real(t), imag(t));

    return 0;
}

Measured memory_bytes: 3148
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    s=input()
    if s=='AC':
        ac+=1
    elif s=='WA':
        wa+=1
    elif s=='TLE':
        tle+=1
    else:
        re+=1
print('AC x ' , ac)
print('WA x ' , wa) 
print('TLE x ', tle)
print('RE x ',re)



Measured memory_bytes: 9108
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int n = Integer.parseInt(sc.next());
int[] x=new int[n+1];
int[] y=new int[n+1];
for(int i=1;i<=n;i++){x[i]=Integer.parseInt(sc.next());y[i]=x[i];}
Arrays.sort(x);
int m=(x[n/2]+x[n/2+1])/2;
for (int i = 1; i <= n; i++) {
    if(y[i]<=m){
        out.println(x[n/2+1]);
    }else{
        out.println(x[n/2]);
    }
}
}
}

Measured memory_bytes: 91820
import Control.Monad

go :: IO ()
go = do
    a <- readLn :: IO Integer
    b <- readLn :: IO Integer
    let c = show $ a + b
    putStrLn $ if length c > 80 then "overflow" else c

main :: IO ()
main = do
    n <- readLn :: IO Int
    replicateM_ n go

Measured memory_bytes: 4300
#include<bits/stdc++.h>
#include<string>
#include<time.h>
using namespace std;
#define LL long long int
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define PI pair<int,int>
#define mem(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define scan(t) scanf("%d",&t)
#define N 100005
map<pair<int,int>,int>p,vis;
pair<int,int>f[N];
LL ans[22];
int h,w;
inline void fun(int x,int y){
    int l,r;
    PI tmp;
    rep(i,0,3){
        rep(j,0,3){
            l=x-i;
            r=y-j;
            if(l<0||r<0||l+3>h||r+3>w)
                continue;
            tmp.fi=l;
            tmp.se=r;
            ++vis[tmp];
            ++ans[vis[tmp]];
            if(vis[tmp]>1)
                --ans[vis[tmp]-1];
        }
    }
}
int main()
{
    int n,a,b;
    scanf("%d%d%d",&h,&w,&n);
    rep(i,0,n) {
        scanf("%d%d",&a,&b);
        --a;--b;
        f[i].fi=a;
        f[i].se=b;
        p[f[i]]=1;
    }
    ans[0]=1ll*(h-2)*(w-2);
    rep(i,0,n){
        fun(f[i].fi,f[i].se);
    }
    int m=10;
    rep(i,1,m) ans[0]-=ans[i];
    rep(i,0,m) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 63488
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;

int main(){
  string str;
  int min1=1000000,min2=1000000;
  map<char, int> m;
  cin>>str;
  for(int i=0;i<str.size();i++)
    m[str[i]]++;
  min1=min(m['K'],m['U']);
  min2=min(m['P'],m['C']);
  cout<<min(min1,min2)<<endl;
  return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
struct T {
  int xc;
  int yc;
  int idx;
  T(int xxc, int yyc, int iidx) : xc(xxc), yc(yyc), idx(iidx) {}
};

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int R, C, N; cin >> R >> C >> N;

  auto edge = [&](int x, int y) -> bool {
    return x == 0 || x == R || y == 0 || y == C;
  };

  auto eord = [&](int x, int y) -> int {
    if (y == 0) return x;
    if (x == R) return R + y;
    if (y == C) return R + C + (R - x);
    if (x == 0) return R + C + R + (C - y);
    assert(false);
  };

  vector<T> P;
  int idx = 0;
  for (int i = 0; i < N; i++) {
    int p, q, r, s; cin >> p >> q >> r >> s;
    if (edge(p, q) && edge(r, s)) {
      P.emplace_back(p, q, idx);
      P.emplace_back(r, s, idx);
      idx++;
    }
  }
  sort(P.begin(), P.end(),
       [&](T u, T v) { return eord(u.xc, u.yc) < eord(v.xc, v.yc); });
  stack<T> st;
  for (auto u : P) {
    if (!st.empty() && st.top().idx == u.idx) {
      st.pop();
      DLOG("popped: (%d, %d, %d)", u.xc, u.yc, u.idx);
    }else {
      st.push(u);
      DLOG("popped: (%d, %d, %d)", u.xc, u.yc, u.idx);
    }
  }
  cout << (st.empty() ? "YES" : "NO") << endl;

  return 0;
}



Measured memory_bytes: 4980
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

int main()
{
	int A, B, K;
	cin >> A >> B >> K;
	rep(i, K) {
		if (i % 2 == 0) {
			B += A / 2;
			A /= 2;
		} else {
			A += B / 2;
			B /= 2;
		}
	}
	cout << A << " " << B << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import exit, setrecursionlimit
setrecursionlimit(10**6)

def array2D(row, col ,val=0):
    return [[val]*col for i in range(row)]

n,m = map(int, input().split())

a = 0
b = 0
if n >=2:
    a = n*(n-1)//2
if m>=2:
    b = m*(m-1)//2
print(a+b)

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int x = 0, mx = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'I') x++;
    else x--;
    
    if (mx < x) mx = x;
  }
  
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()
Q = int(input())
 
a = []
b = []
rev = 0
 
for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        a, b = b, a
        rev += 1
    else:
        if q[1] == '1':
            a.append(q[2])
        else:
            b.append(q[2])
if rev % 2 == 1:
    S = S[::-1]
ans = ''.join(a[::-1]) + S + ''.join(b)
print(ans)

Measured memory_bytes: 6268
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  char d=a.at(0)-0x20;
  char e=b.at(0)-0x20;
  char f=c.at(0)-0x20;
  cout <<d<<e<<f<<endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <map>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

map<int, int> visited;
int dfs(int n) {
	if(n < 10)
		return 0;

	if(visited.count(n))
		return visited[n];

	visited[n] = -1;
	int next = 0;
	for(int i = 10; n / i; i *= 10) {
		int a = n / i;
		int b = n % i;
		chmax(next, a * b);
	}

	return visited[n] = dfs(next) + 1;
}

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

	int q;
	cin >> q;

	for(int i = 0; i < q; ++i) {
		int n;
		cin >> n;

		cout << dfs(n) << endl;
	}

	return EXIT_SUCCESS;
}

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


def read():
    N, M = map(int, input().strip().split())
    IPY = []
    for i in range(M):
        p, y = map(int, input().strip().split())
        IPY.append((i, p, y))
    return N, M, IPY


def solve(N, M, IPY):
    X = [1 for i in range(N+1)]
    IPY.sort(key=lambda ipy: ipy[2])
    zipcode = []
    for i, p, y in IPY:
        zipcode.append((i, p, X[p]))
        X[p] += 1
    zipcode.sort()
    for i, p, x in zipcode:
        print("{:06d}{:06d}".format(p, x))


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 34292
use strict;
my $N=<>;
my $s = <>; chomp $s;
my @L = split(/ /,$s);
my $count=0;
my $a;
my $b;
my $c;
if ($N<3){print"0";}
else{for($a=0;$a<$N-2;$a++){for($b=$a+1;$b<$N-1;$b++){for($c=$b+1;$c<$N;$c++){if(@L[$a]!=@L[$b]&&@L[$b]!=@L[$c]&&@L[$c]!=@L[$a]){if(@L[$a]+@L[$b]>@L[$c]&&@L[$b]+@L[$c]>@L[$a]&&@L[$c]+@L[$a]>@L[$b]){$count=$count+1;}}}}}print"$count";}

Measured memory_bytes: 4856
# -*- coding: utf-8 -*-
S = input()
ans = "Yes"
for i in range(len(S)):
    if (i+1)%2 == 1:
        if S[i] not in "RUD":
            ans = "No"
            break
    else:
        if S[i] not in "LUD":
            ans = "No"
            break
print(ans)


Measured memory_bytes: 2940
using System;

namespace ConsoleApp17
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] S = Console.ReadLine().Split('/');
            int Y = int.Parse(S[0]);
            int M = int.Parse(S[1]);
            int D = int.Parse(S[2]);

            if(Y < 2019 || Y == 2019 && M < 4 || Y == 2019 && M == 4 && D <= 30)
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.Write("TBD");
            }
        }
    }
}


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

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

  const int64_t Nlen= (int64_t) S.size();
  const int64_t Ninter= Nrep- 1;

  vector<int64_t> piece;
  int64_t Nop_intra= 0;
  int64_t right= 0;
  for(int64_t left=0; left<Nlen;){
    while(right+ 1 < Nlen && S.at(left)==S.at(right+1)){
      right++;
    }

    int64_t Lpiece= right+1 -left;
    piece.emplace_back(Lpiece);
    Nop_intra+= Lpiece/ 2;

    left= right+1;
  }

  int64_t Nop_inter= 0;
  if(S.at(0)==S.back()){
    Nop_intra-= (piece.at(0)/2)+ (piece.back()/2);
    Nop_inter= (piece.at(0)+ piece.back())/ 2;
  }

  int64_t ans= (piece.size()==1)     ? Nlen* Nrep/ 2
              :(S.at(0) != S.back()) ? Nop_intra* Nrep
                                     : Nop_intra* Nrep+ Nop_inter*(Nrep-1)+ (piece.at(0)/2)+ (piece.back()/2);


  cout << ans << endl;
}

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

int main(){
  int n, minus = 0, minn = numeric_limits<int>::max(); cin >> n;

  long long ans = 0;
  for(int i=0; i<n; ++i){
    int a; cin >> a;

    if(a < 0) ++minus;
    ans += abs(a);
    minn = min(minn, abs(a));
  }

  if(minus & 1) ans -= minn*2;

  cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
h=list(map(int,input().split()))
t=[0]*N
a=0
for i in range(N):
        while t[i]<h[i]:
                for j in range(i,N):
                        if t[j]<h[j]:
                                t[j]+=1
                        else:
                                break
                a+=1
print(a)

Measured memory_bytes: 3060