akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------
		String s = sc.next();
		boolean ok = true;
		for (int i = 0; i < s.length(); i++) {
			if (i % 2 == 1) {
				if (s.charAt(i) == 'R') {
					ok = false;
					break;
				}
			} else {
				if (s.charAt(i) == 'L') {
					ok = false;
					break;
				}
			}
		}
		if (ok) {
			out.println("Yes");
		} else {
			out.println("No");
		}

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<cstdlib>
int main(){
	std::ios_base::sync_with_stdio(false);std::cin.tie(nullptr);
	int ncol,nrow;std::cin>>ncol>>nrow;
	std::vector<std::vector<int>>mat(nrow);
	for(auto&row:mat){
		row.resize(ncol);
		for(int&cell:row)std::cin>>cell;
		row.push_back(0);
	}
	mat.emplace_back(ncol+1,0);
	//convert mat to postfix sum array
	for(int row=nrow;row-->0;)for(int col=ncol;col-->0;)
		mat[row][col]+=mat[row+1][col]+mat[row][col+1]-mat[row+1][col+1];
	#define sum(r0,c0,r1,c1) /* r0<=r1,c0<=c1 */ \
	(mat[r0][c0]-mat[r0][c1]-mat[r1][c0]+mat[r1][c1])
	auto dp=mat;//difference between UR and DL.border=0.
	for(int row=nrow;row-->0;)for(int col=ncol;col-->0;){
		int parity=(row+col)&1;//even:first:UR(maximize diff),otherwise:
		//second:DL(minimize diff)
		int d1=dp[row+1][col]+sum(row,col,row+1,ncol);
		int d2=dp[row][col+1]-sum(row,col,nrow,col+1);
		dp[row][col]=parity?std::min(d1,d2):std::max(d1,d2);
	}
	std::cout<<std::abs(dp[0][0])<<'\n';
	#undef sum
}


Measured memory_bytes: 14692
use std::collections::BinaryHeap;
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

// input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        return x;
    }
    gcd(y, x % y)
}

#[test]
fn test_primes() {
    assert_eq!(primes(1), vec![1]);
    assert_eq!(primes(140), vec![1, 2, 2, 5, 7])
}

fn primes(num: i64) -> Vec<i64> {
    let mut ans = vec![1];
    let mut cur = num;
    for i in 2.. {
        if i * i > num { break; }
        if cur % i == 0 {
            while cur % i == 0 {
                ans.push(i);
                cur /= i;
            }
        }
    }
    if cur > 1 {
        ans.push(cur);
    }
    return ans;
}


test! {
r"3 3
2 13 8
" => r"9",

r"4 4
1 9 3 5
" => r"6",

r"1 100000
1000000000
" => r"0",

r"10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
" => r"9500000000"
}

fn solve(src: &str) -> String {
    input! {
        source=src,
        n:i64,
        m:i64,
        a:[i64;n],
    }
    let n: i64 = n;
    let m: i64 = m;
    let a: Vec<i64> = a;

    let mut heap = BinaryHeap::new();
    for x in a {
        heap.push(x);
    }

    for _ in 0..m {
        let &p = heap.peek().unwrap();
        heap.pop();
        heap.push(p / 2);
    }
    let mut ans = 0;
    for x in heap.into_iter() {
        ans += x;
    }

    format!("{}", ans)
}


fn main() {
    println!("{}", solve(&stdin!()));
}



Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n,m,ans;
	cin >> n >> m;
	vpll ab(n),cd(m);
	rep(i,n) cin >> ab[i].first >> ab[i].second;
	rep(i,m) cin >> cd[i].first >> cd[i].second;
	rep(i,n){
		ll tmp=INF;
		for(ll j=m-1;j>=0;--j){
			ll dist=abs(ab[i].first-cd[j].first)+abs(ab[i].second-cd[j].second);
			if(tmp>=dist){
				tmp=dist;
				ans=j+1;
			}
		}
		cout << ans << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;
const i64 MOD = 1e9 + 7;

int main()
{
  i64 n;
  cin >> n;
  vector<vector<i64>> s(n);
  for (i64 i = 0; i < n; i++)
  {
    i64 m;
    cin >> m;
    s[i].resize(m);
    for (i64 j = 0; j < m; j++)
      cin >> s[i][j];
  }
  priority_queue<i64> que;
  i64 ans = 0;
  for (i64 i = n - 1; 0 <= i; i--)
  {
    i64 size = s[i].size();
    for (i64 j = 0; j < size; j++)
      que.push(s[i][j]);
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 19080
n, d = input().split()
n = int(n)
d = int(d)
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
c = 0

for i in range(n):
  if x[i]*x[i]+y[i]*y[i] <= d*d:
    c +=1

print(c)

Measured memory_bytes: 116736
#include<stdio.h>
#include<math.h>
int main()
{
    int n, p;
    scanf("%d %d", &n, &p);
    int i;
    int a[55];
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int o, e;
    o = e = 0;
    for (i = 0; i < n; i++)
        if (a[i] % 2 == 0)
            e++;
        else
            o++;
    if (o == 0)
    {
        if (p == 1)
            printf("0\n");
        else
            printf("%.0lf\n", pow(2, e));
    }
    else
    {
        printf("%.0lf\n", pow(2, e + o - 1));
    }
    return 0;
}

Measured memory_bytes: 128
#pragma comment(linker, "/STACK:64777216")
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <stdio.h>
#include <cctype>
#include <algorithm>
#include <utility>
#include <cassert>
#include <complex>
#include <time.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back

typedef long long Int;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;

const int MAX = 512;
const int CNT = 17;

int n, h, c0, c1, bal, e;
VI G[MAX];
VI GG[MAX];
int D[MAX];
int U[MAX];

int getNext(int a, int b)
{
	return (a == 0 ? b : h + a);
}

int getPrev(int a, int b)
{
	return (a == 0 ? h + b : a);
}

void nope()
{
	cout << "NO" << endl;
	exit(0);
}

void dfs(int v)
{
	U[v] = 1;
	if (v < h)
	{
		++ c0;
		bal -= D[v];
	}
	if (v >= h)
		++ c1;

	FOR (i,0,SZ(GG[v]))
	{
		int to = GG[v][i];
		if (U[to] == 0)
			dfs(to);
		++ e;
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);

	cin >> n >> h;
	++ h;

	FOR (i,0,n)
	{
		int a, b, c, d;
		scanf("%d %d %d %d", &a, &b, &c, &d);
		int u = getPrev(c, a);
		int v = getNext(d, b);
		G[u].PB(v);
		GG[u].PB(v);
		GG[v].PB(u);
		++ D[u];
		-- D[v];
	}


	FOR (i,0,h)
		if (D[i] > 0)
			nope();

	FOR (i,h,2*h)
		if (D[i] < 0)
			nope();

	int cnt = 0, alone = 0, bal0 = 0;
	FOR (i,0,2*h)
	{
		if (U[i]) continue;
		c0 = 0, c1 = 0, bal = 0, e = 0;
		dfs(i);
		if (e == 0) continue;

		++ cnt;
		if (c0 == 0 || c1 == 0)
			++ alone;
		if (bal == 0)
			++ bal0;
	}

	if (alone > 0)
		nope();

	if (bal0 >0)
		nope();

	if (bal0 == 1 && cnt > 1)
		nope();

	cout << "YES" << endl;




	return 0;
}


Measured memory_bytes: 2432
N = int(input())
F = 10
for A in range(1,100000):
    if N % A == 0:
        B = N // A
        if len(str(A)) < len(str(B)):
            if len(str(B)) < F:
                F = len(str(B))
        else:
            if len(str(A)) < F:
                F = len(str(A))
print(F)

Measured memory_bytes: 3064
// JavaScript source code
"use strict";

let myFunc = (input) => {
    input = input.split(" ");
    let a, b, c, d;
    a = parseInt(input[0]);
    b = parseInt(input[1]);
    c = parseInt(input[2]);
    d = parseInt(input[3]);
    if((a + b) > (c + d)) console.log("Left");
    if((a + b) === (c + d)) console.log("Balanced");
    if((a + b) < (c + d)) console.log("Right");
};

myFunc(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30396
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  if(N==1){
    std::cout << 1 << '\n';
    return 0;
  }
  vvi xy = vv(N, 2, 0, int);
  vvi ans = vv(0, 2, 0, int);
  range(i, N) std::cin >> xy[i][0] >> xy[i][1];
  sort(xy.begin(), xy.end());
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      ans.push_back(std::vector<int> {xy[i][0]-xy[j][0], xy[i][1]-xy[j][1]});
    }
  }
  sort(ans.begin(), ans.end());
  int count=0, X=ans[0][0], Y=ans[0][1], an=0;
  for(int i=0;i<ans.size();i++){
    if(ans[i][0]==X && ans[i][1]==Y) count++;
    else count = 1, X=ans[i][0], Y=ans[i][1];
    an = max(count, an);
  }
  //std::cout << an << '\n';
  std::cout << N - an << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main (void)
{
	int n,m;
	char a;
	cin >> n >> m >> a;

	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i == 0 || i == m - 1)
			{
				if (j == 0 || j == n - 1)
				{
					cout << '+';
				}
				else
				{
					cout << '-';
				}
			}
			else if (i == (m - 1) / 2 && j == (n - 1) / 2)
			{
				cout << a;
			}
			else if (j == 0 || j == n - 1)
			{
				if (i != 0 && i != m - 1)
				{
					cout << '|';
				}
			}
			else
			{
				cout << '.';
			}
			if (j == n - 1)
			{
				cout << endl;
			}
		}
	}
}


Measured memory_bytes: 3120
import bisect

def snuke_festival(N,arr):
    n_pair = 0
    for item in arr[1]:
        up_pair = bisect.bisect_left(arr[0],item)
        down_pair = bisect.bisect_right(arr[2],item)
        n_pair += up_pair*(N-down_pair)
    return n_pair


if __name__ == "__main__":
    N  =int(input())
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))
    arr_sorted = []
    for j in range(3):
        arr_sorted.append(arr[j].sort())
    print(snuke_festival(N,arr))

Measured memory_bytes: 22720
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	if (A + B >= 10) {
		printf("error\n");
	}
	else {
		printf("%d\n", A + B);
	}
}


Measured memory_bytes: 256
s = input()

def dfs(i, f, ans):
    if i == len(s)-1:
        if ans == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i+1, f+'+'+s[i+1], ans+int(s[i+1]))
        dfs(i+1, f+'-'+s[i+1], ans-int(s[i+1]))

dfs(0, s[0], int(s[0]))

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

int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int ans=0;
    int han=min(x,y);
    int nokori=max(x,y)-han;
    if(c>=(a+b)/2.0){
         ans=a*x+b*y;
    }
    else{
        ans+=han*2*c;
        if(x>y && c<=a/2)ans+=c*nokori*2;
        else if(x>y)ans+=a*nokori;
        else if(y>x && c<=b/2) ans+=c*nokori*2;
        else if(y>x) ans+=b*nokori;    
    }

    cout<<ans<<endl;
}


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

int n, m, k, x, y, z, ma=1e9, mb=1e9, mn, a[100005], b[100005];
int main() {
	int i;
	cin >> n >> m >> k;
	for(i=1; i<=n; i++) scanf("%d", &a[i]), ma = min(ma, a[i]);
	for(i=1; i<=m; i++) scanf("%d", &b[i]), mb = min(mb, b[i]);
	mn = ma + mb;
	while(k--) {
		scanf("%d%d%d", &x, &y, &z);
		mn = min(mn, a[x] + b[y] - z);
	}
	cout << mn;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    x, y, z = map(int, input().split(" "))
    C.append(x)
    S.append(y)
    F.append(z)

for j in range(N-1):
    ans = 0
    for k in range(j, N-1):
        if ans < S[k]:
            ans = S[k]
        if ans%F[k] != 0:
            ans += F[k]-ans%F[k]
        ans += C[k]
    print(ans)
print(0)

Measured memory_bytes: 3064
def cal(N,A,B):
    C=int(N/(A+B))
    W=N%(A+B)
    if W > A:
        return C*A+A
    else:
        return C*A+W

    

if __name__ == "__main__":
    N,A,B = input().split()
    N=int(N)
    A=int(A)
    B=int(B)
    cal(N,A,B)
    print(cal(N,A,B))


Measured memory_bytes: 3060
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		int result = 0;
		result = n/3;
		
		// 出力
		System.out.println(result);
	}
}




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

const int maxn = 1e5+10;

struct edge{
	int to,dis,cost;
	edge(){}
	edge(int to,int dis,int cost) : to(to),dis(dis),cost(cost){}
};

typedef pair<int,int> P;

vector<edge> G[maxn];

int d[maxn];
int V,M;

void dijkstra(int s){
	priority_queue<P> Q;
	memset(d,0x3f,sizeof(d));
	d[s] = 0;
	Q.push(P(0,s));

	while(!Q.empty()){
		P p = Q.top(); Q.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i=0; i<G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v]+e.dis){
				d[e.to] = d[v]+e.dis;
				Q.push(P(-d[e.to],e.to));
			}
		}
	}
}


int main(){
	while(scanf("%d%d",&V,&M) && V){
		for(int i=0; i<V; i++) G[i].clear();

		for(int i=0; i<M; i++){
			int u,v,d,c;
			scanf("%d%d%d%d",&u,&v,&d,&c);
			--u,--v;
			G[u].push_back(edge(v,d,c));
			G[v].push_back(edge(u,d,c));
		}

		dijkstra(0);

		int ans = 0;
		for(int i=1; i<V; i++){
			int min_cost = 0x3f3f3f3f;
			for(int j=0; j<G[i].size(); j++){
				if(d[G[i][j].to]+G[i][j].dis==d[i] && G[i][j].cost<min_cost)
					min_cost = G[i][j].cost;
			}
			ans += min_cost;
		}
		printf("%d\n",ans);	
	}
}

Measured memory_bytes: 7600
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    string S;
    cin >> S;
    rep(i,sz(S)-1) if(S[i] == 'A' && S[i+1] == 'C'){ pr("Yes"); return 0;}
    pr("No");
}

Measured memory_bytes: 256
/*---------------------------------- NEVER GIVE UP --------------------------------------------*/

#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;

typedef long long ll;
typedef double ld;
typedef pair<ll,ll> pii;
typedef tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug1(x) cerr<<#x<<" : "<<x<<endl
#define debug2(x,y) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl

const ll modd=1e9+7;
const ll inf=1e18;

ll poww(ll a,ll b){
  ll ans=1;
  while(b){
    if(b&1LL) ans=(ans*a);
    a=(a*a);
    b=b>>1LL;
  }
  return ans;
}

/*    
         -> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
         -> cout<<"Case #"<<casee<<": "<<ans<<endl; // for google kickstart

*/

/*-----------------------------------------------------------------------------------------------*/

const ll N=1e5+5;

vector <ll> adj[N];
ll visited[N];

void dfs(ll node){
  if(visited[node]) return;
  visited[node]=1;

  for(auto j : adj[node]){
    if(visited[j]) continue;
    dfs(j);
  }
}

int main(){
   fastt;
   
   ll n,m,ans=0;
   cin>>n>>m;

   for(ll i=1;i<=m;i++){
      ll x,y,z;
      cin>>x>>y>>z;
      adj[x].pb(y);
      adj[y].pb(x);
   }

   for(ll i=1;i<=n;i++){
     if(visited[i]) continue;
     ans++;
     dfs(i);
   }

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


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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    scanf("%d", &n);
    set <int> st;
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        st.insert(x);
    }
    if ((int)st.size() == n) {
        printf("YES");
    } else {
        printf("NO");
    }
    return 0;
}


Measured memory_bytes: 13148
<?php
  fscanf(STDIN, "%d %d", $k, $n);
  $a = explode(" ", trim(fgets(STDIN)));

  $dist = $a[0] + ($k - $a[$n-1]);
  $max_d = $a[0] + ($k - $a[$n-1]);
  for ($i=1; $i<$n; $i++) {
    $d = $a[$i] - $a[$i-1];
    $dist += $d;
    $max_d = max($max_d, $d);
  }

  echo $dist - $max_d . "\n";
?>

Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int a,b,c;
    cin >> a >> b >>c;
    if(b+c<=a)cout << 0;
    else cout << c-(a-b);
}



Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()
	X := nextInt()
	T := nextInt()

	fmt.Println((N + X - 1) / X * T)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;

int main(void) {
	LL n, i, j, k;
	cin >> n;
	char s;

	for (i = 0; i < n; i++) {
		cin >> s;
		if (s == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<set>
#include<tuple>
#include<utility>
#include<algorithm>
using namespace std;

int main(void)
{
    int N, Q;
    cin >> N >> Q;

    vector<int> S(N), T(N), X(N);
    for (int i = 0; i < N; i++)
        cin >> S[i] >> T[i] >> X[i];

    vector<int> D(Q);
    for (int i = 0; i < Q; i++)
        cin >> D[i];

    using tiii = tuple<int, int, int>;
    vector<tiii> v(N);
    for (int i = 0; i < N; i++)
        v[i] = tiii(X[i], S[i]-X[i], T[i]-X[i]);
    sort(v.begin(), v.end());

    using pii = pair<int, int>;
    set<pii> st;
    for (int i = 0; i < Q; i++)
        st.insert(pii(D[i], i));

    vector<int> ans(Q, -1);
    for (int i = 0; i < N; i++) {
        int x, s, t;
        tie(x, s, t) = v[i];

        auto it = st.lower_bound(pii(s, -1));
        while (it != st.end()) {
            if (it->first >= t)
                break;
            
            ans[it->second] = x;
            st.erase(it++);
        }
    }

    for (int i = 0; i < Q; i++)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 17536
function main(input) {
  var H = input[0].split(" ")[0]-0;
  var W = input[0].split(" ")[1]-0;
  var list = [];
  for(var i=0;i<H;i++){
    if(input[i+1].indexOf("#") >= 0){
      list.push(input[i+1].split(""));
    }
  }
  var ans = [];
  for(var i=0;i<W;i++){
    var flg = !!list.find(v=>v[i]=="#");
    if(flg) ans.push(i);
  }
  var anstxt = "";
  list.forEach(w=>{
    ans.forEach(v=>{
      anstxt+=w[v];
    });
    anstxt+="\n";
  });

  console.log(anstxt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 9420
#if loc||local
#define _GLIBCXX_DEBUG
#endif

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
constexpr ll dx[]={1,0,-1,0,1,1,-1,-1};
constexpr ll dy[]={0,1,0,-1,1,-1,1,-1};
constexpr ll ddx[] = {2,2,2,2,2,-2,-2,-2,-2,-2,1,0,-1,1,0,-1};
constexpr ll ddy[] = {0,1,2,-1,-2,2,1,0,-1,-2,2,2,2,-2,-2,-2};
using T3 = tuple<ll,ll,ll>;
using T4 = tuple<ll,ll,ll,ll>;
signed main(){

  int h,w;
  cin>>h>>w;
  int ch,cw;
  cin>>ch>>cw;
  int dh,dw;
  cin>>dh>>dw;
  auto s = vec<char>(h,w);
  cin>>s;
  ch--;cw--;dh--;dw--;

  auto dist = vec<ll>(h,w);
  for(auto& di:dist)for(auto& dij:di)dij=INF;
  priority_queue<T3,vector<T3>,greater<>> que;
  que.emplace(0,ch,cw);
  while(!que.empty()){
    auto [cost,y,x] = que.top();
    que.pop();
    if(!chmin(dist[y][x],cost))continue;
    rep(i,4){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny==-1||nx==-1||ny==h||nx==w)continue;
      if(s[ny][nx]=='#')continue;
      if(dist[ny][nx]!=INF)continue;
      que.emplace(cost,ny,nx);
    }
    rep(j,4){
      int ny = y+dy[j+4];
      int nx = x+dx[j+4];
      if(ny==-1||nx==-1||ny==h||nx==w)continue;
      if(s[ny][nx]=='#')continue;
      if(dist[ny][nx]!=INF)continue;
      que.emplace(cost+1,ny,nx);
    }
    rep(k,16){
      int ny = y+ddy[k];
      int nx = x+ddx[k];
      if(ny<0||nx<0||ny>=h||nx>=w)continue;
      if(s[ny][nx]=='#')continue;
      if(dist[ny][nx]!=INF)continue;
      que.emplace(cost+1,ny,nx);
    }
  }
  cout<<(dist[dh][dw]==INF?-1:dist[dh][dw])<<endl;

}


Measured memory_bytes: 13700
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
const int maxn=2e5+2;
LL cnt[30];
char str[maxn];
int change(char ch){return ch-'a';}
int main(){
	scanf("%s",str+1);
	LL len=strlen(str+1);
	LL ans=len*(len-1)/2+1;
	for (int i=1;i<=len;i++) cnt[change(str[i])]++;
	for(int i=0;i<26;i++) ans-=cnt[i]*(cnt[i]-1)/2;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 384
n,m,l=map(int,input().split())
abc=[list(map(int,input().split())) for _ in range(m)]

"""
g=[[] for _ in range(n)]
for a,b,c in abc:
  if c>l:continue
  a,b=a-1,b-1
  g[a].append([b,c])
  g[b].append([a,c])
"""
q=int(input())
st=[list(map(int,input().split())) for _ in range(q)]

def warshall_floyd(d):
  for k in range(n):
    for i in range(n):
      for j in range(n):
        d[i][j] = min(d[i][j],d[i][k] + d[k][j])
  return d
inf=float('inf')
d=[[inf]*n for _ in range(n)]

for a,b,c in abc:
  a,b=a-1,b-1
  d[a][b]=c
  d[b][a]=c
for i in range(n):
  d[i][i]=0
d=warshall_floyd(d)
nabc=[]
dd=[[inf]*n for _ in range(n)]
#g=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if d[i][j]<=l:
      dd[i][j]=1
for i in range(n):
  dd[i][i]=0
dd=warshall_floyd(dd)
for s,t in st:
  s,t=s-1,t-1
  tmp=dd[s][t]
  print(max(0,tmp-1) if tmp!=inf else -1)
#print(dd)

Measured memory_bytes: 98404
N = int(input())
A = [list(map(int,input().split())) for i in range(N)]

for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()

ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        for k in range(N):
            if k==i or k==j: continue
            if A[i][j] == A[i][k] + A[k][j]:
                break
        else:
            ans += A[i][j]
print(ans)

Measured memory_bytes: 74908
def is_u(c):
    return c == c.upper()
S = input()
a = S[0] == "A"
b = S[2:-1].count("C") == 1
c = sum([int(is_u(c)) for c in S]) == 2
# print(a, b, c)
if a and b and c:
    print("AC")
else:
    print("WA")

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

const int inf = 1e9;
const ll linf = 1e18;

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

    string s, t; cin >> s >> t;
    const int ls = s.length();
    const int lt = t.length();

    for (int i = ls - lt; i >= 0; i--) {
        bool flag = true;
        for (int j = 0; j < lt; j++) {
            if (s[i + j] != t[j] && s[i + j] != '?') flag = false;
        }
        if (flag) {
            for (int j = 0; j < lt; j++) s[i + j] = t[j];
            for (int j = 0; j < ls; j++) if (s[j] == '?') s[j] = 'a';
            cout << s << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp
Q = gets
Qs = readlines.map(&:split)

@h = Hash.new{|h, k| h[k] = []}
@s = "_" + S.dup
S.each_char.with_index(1){|c, i| @h[c] << i}

def update(i, c)
  d = @s[i]
  return if c == d
  @s[i] = c
  @h[d].delete_at(@h[d].bsearch_index{|x| x >= i})
  @h[c].insert((@h[c].bsearch_index{|x| x >= i} || -1), i)
end

def kind(l, r)
  ('a' .. 'z').count{|c| (@h[c].bsearch_index{|x| x >= l} || N + 1) < (@h[c].bsearch_index{|x| x > r} || N + 1)}
end

Qs.each do |a, b, c|
  if a == '1'
    update(b.to_i, c)
  else
    puts kind(b.to_i, c.to_i)
  end
end

Measured memory_bytes: 16672
#include<iostream>
using namespace std;
#define MAX 100000
 
int parent(int i) { return i / 2; }
int left(int i) { return 2*i; }
int right(int i ) { return 2*i +1;}
 
int main() {
  int H, i, A[MAX + 1];
  //1-origin
  cin >> H;
  for ( i = 1; i <= H; i++) cin >> A[i];
 
  for(i = 1; i <= H; i++) {
    cout << "node " << i << ": key = " << A[i] << ", ";
    if(parent(i) >= 1)cout << "parent key = " << A[parent(i)] << ", ";
    if(left(i) <= H)cout << "left key = " << A[left(i)] << ", ";
    if(right(i) <= H)cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

int64 ar[3002];
int64 dp[3002][3002][2];
int64 solve(int i, int j, int turn){
    if(i > j)   return 0;
    if(dp[i][j][turn] != -1)    return dp[i][j][turn];
    int64 ans = 0;
    if(turn == 0){
        ans = max(ar[i] + solve(i + 1, j, 1 - turn), ar[j] + solve(i, j - 1, 1 - turn));
    }
    else{
        ans = min(solve(i + 1, j, 1 - turn) - ar[i], solve(i, j - 1, 1 - turn) - ar[j]);
    }
    dp[i][j][turn] = ans;
    return ans;
}
int main(){
    FAST
    //Do awesome things here
    int n;
    cin >> n;
    memst(dp, -1);
    rp(i, n){
        cin >> ar[i];
    }
    int64 ans = solve(0, n - 1, 0);
    cout << ans << endl;
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

Measured memory_bytes: 141440
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
ll ord(ll N, ll p) {
    ll res = 0;
    while (N % p == 0) {
        res++;
        N /= p;
    }
    return res;
}
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    rep(i, N) cin >> a[i], a[i] /= 2;
    ll x = ord(a[0], 2);
    rep(i, N) {
        if (x != ord(a[i], 2)) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll l = a[0];
    rep(i,N) {
        l = lcm(l, a[i]);
        if (l > M) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 0;
    for (int i = 1; l * i <= M; i+=2) {
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3772
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;
	int[] a;

	public boolean check(int m){
		String mStr = String.valueOf(m);
		int pre = mStr.charAt(0) - '0';
		for(int i = 1;i < mStr.length();i++){
			if(pre + 1 == mStr.charAt(i) - '0'){
				pre = mStr.charAt(i) - '0';
				continue;
			}
			return false;
		}
		return true;
	}

	public void solve() {
		N = nextInt();
		a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
		}

		int ans = -1;

		for(int i = 0;i < N;i++){
			for(int j = i + 1;j < N;j++){
				int m = a[i] * a[j];
				if(check(m)){
					ans = Math.max(ans, m);
				}
			}
		}
		out.println(ans);
	}

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 46232
import math

a,b,h,m=map(int,input().split())
t=60*h+m

rada=t*0.5
radb=m*6
rad=rada-radb

rad=math.radians(min(rad,360-rad))

ans=math.sqrt(a**2+b**2-2*a*b*math.cos(rad))

print(ans)

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

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

	cin>>b;
	if(b=='A')
		cout<<'T';
	else if(b=='T')
		cout<<'A';
	else if(b=='C')
		cout<<'G';
	else
		cout<<'C';
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
int taro=0,hana=0,a,k=0;
char z[100],t[100];
scanf("%d",&a);
for(k=0;k<a;k++){
    scanf("%s %s",&z,&t);
    if(strcmp(z,t)>0){
        taro++;
        taro++;
        taro++;
    }else if(strcmp(z,t)<0){
        hana++;
        hana++;
        hana++;
    }else if(strcmp(z,t)==0){
        taro++;
        hana++;
    }

}
printf("%d %d\n",taro,hana);

return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

int main(void) {
    long long int n;
    bool flag=true; 

    cin>>n;
    vector<long long int> h(n+1);
    FOR(i,1,n){
        cin>>h[i];
    }
    FOR(i,2,n){
        if(h[i-1]>h[i]+1){
            flag=false;
        }else if(h[i-1]>h[i]){
            h[i]++;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


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

typedef long long ll;
typedef pair<ll, ll> Pairs;

int sx, sy, tx, ty;
Pairs t;

string s;

void add_string(int n, char c){
    for (int i = 0; i < n; i++){
        s += c;
    }
}

void solve(Pairs t){
    if (t.first > 0 && t.second > 0){
        add_string(t.first, 'R');
        add_string(t.second, 'U');
        add_string(t.first, 'L');
        add_string(t.second, 'D');
        s += 'L';
        add_string(t.second+1, 'U');
        add_string(t.first+1, 'R');
        s += 'D';
        s += 'R';
        add_string(t.second+1, 'D');
        add_string(t.first+1, 'L');
        s += 'U';
        cout << s << endl;
    } else if (t.first > 0 && t.second < 0){
        add_string(t.first, 'R');
        add_string(t.second, 'D');
        add_string(t.first, 'L');
        add_string(t.second, 'U');
        s += 'L';
        add_string(t.second+1, 'D');
        add_string(t.first+1, 'R');
        s += 'U';
        s += 'R';
        add_string(t.second+1, 'U');
        add_string(t.first+1, 'L');
        s += 'D';
        cout << s << endl;
    } else if (t.first < 0 && t.second > 0){
        add_string(t.first, 'L');
        add_string(t.second, 'U');
        add_string(t.first, 'R');
        add_string(t.second, 'D');
        s += 'R';
        add_string(t.second+1, 'U');
        add_string(t.first+1, 'L');
        s += 'D';
        s += 'L';
        add_string(t.second+1, 'D');
        add_string(t.first+1, 'R');
        s += 'U';
        cout << s << endl;
    } else if (t.first < 0 && t.second < 0){
        add_string(t.first, 'L');
        add_string(t.second, 'D');
        add_string(t.first, 'R');
        add_string(t.second, 'U');
        s += 'R';
        add_string(t.second+1, 'D');
        add_string(t.first+1, 'L');
        s += 'U';
        s += 'L';
        add_string(t.second+1, 'U');
        add_string(t.first+1, 'R');
        s += 'D';
        cout << s << endl;
    }
}

int main(){
    cin >> sx >> sy >> tx >> ty;
    t.first = tx - sx;
    t.second = ty - sy;
    solve(t);
}


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

using namespace std;

using pii = pair<int, int>;
using lli = long long int;

#define debug(args...) fprintf(stderr, args)
#define pb push_back
#define all(xs) xs.begin(), xs.end()

const int INF = 1e9;

int main() {
	int n;
	scanf("%d", &n);

	vector<lli> xs, ys;
	for (int i = 0; i < n; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		xs.pb(1LL*x + y);
		ys.pb(1LL*x - y);
	}

	sort(all(xs));
	sort(all(ys));

	printf("%lld\n", max(xs[n - 1] - xs[0], ys[n-1] - ys[0]));
}

Measured memory_bytes: 6628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s1 = sc.nextLine().split(" ");

        int h = Integer.parseInt(s1[0]);
        int w = Integer.parseInt(s1[1]);

        String s[][] = new String[h][w];
        for (int i = 0;i < h;i++) {
        	String row = sc.nextLine();
        	for (int j = 0;j < w;j++) {
        		s[i][j]=String.valueOf(row.charAt(j));
        	}
        }

        String result="Yes";
        for (int i = 0;i < h;i++) {
        	for (int j = 0;j < w;j++) {
        		if (".".equals(s[i][j])) {
        			continue;
        		}
        		boolean flg=false;
        		//上
        		if (i != 0 && "#".equals(s[i-1][j])) {
        			flg=true;
        		}
        		//下
        		if (i != h-1 && "#".equals(s[i+1][j])) {
        			flg=true;
        		}
        		//左
        		if (j != 0 && "#".equals(s[i][j-1])) {
        			flg=true;
        		}
        		//右
        		if (j != w-1 && "#".equals(s[i][j+1])) {
        			flg=true;
        		}

        		if (!flg) {
        			result="No";
        		}
        	}
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21460
import copy
T = list(input())
P = [0]*(len(T)+10)
P[0] = 0
if T[0] == '?':
    T[0] = 'D'
for i in range(len(T)):
    if T[i] == '?':
        if T[i-1] == 'D':
            T[i] = 'D'
            P[i+1] = P[i] + 1
        else:
            T[i] = 'D'
            P[i+1] = P[i] + 2
    else:
        if T[i] == 'D':
            if T[i-1] == 'D':
                P[i+1] += P[i]+1
            else:
                P[i+1] = P[i]+2
        else: 
            P[i+1] = P[i]   


print(''.join(T))


Measured memory_bytes: 18788
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
   
int main(){
    u_int n;    // the number of vegetable
    u_int m;    // capacity
      
    while(std::cin >> n >> m){
        if(n == 0 && m == 0){
            break;
        }
           
        std::vector<u_int> p(n);  // price
        for(int i = 0; i < n; ++i){
            std::cin >> p[i];
        }
          
        //m, 2*m, 3*m, ... = free(sort by descending)
        std::sort(p.begin(), p.end(), std::greater<u_int>());
        for(int i = m; i <= n; i += m){
            p[i-1] = 0;
        }
          
        std::cout << std::accumulate(p.begin(), p.end(), 0) << std::endl;
    }
       
    return 0;
}

Measured memory_bytes: 3108
#include<iostream>
#include<vector>

using namespace std;

bool check(vector<int>& vec,int h)
{
  vector<int> newvec;
  for(int i=0;i<vec.size();i++)
    if(h != i)
      newvec.push_back(vec[i]);

  int diff = newvec[1]-newvec[0];

  for(int i=1;i<newvec.size()-1;i++)
    if(newvec[i]+diff != newvec[i+1])
      return false;

  return true;
}

int main()
{
  int n;
  while(cin >> n,n)
    {
      vector<int> vec;
      vec.resize(n+1);
      for(int i=0;i<=n;i++)
	cin >> vec[i];

      for(int i=0;i<=n;i++)
	{
	  if(check(vec,i))
	    {
	      cout << vec[i] << endl;
	      break;
	    }
	}

    }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const LL MOD = 1e9+7;
const LL INF = 1LL<<60;
int MAXN = 1e7+2;
const double eps = 1e-13;

LL a[100009],b[100009],c[100009];
vector<PLL> v;
LL l[100009],r[100009];

int main(){
	int n;
	DRIII(x,y,z);
	n=x+y+z;
	REP(i,n){
		scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
		v.PB(MP(b[i]-a[i],i));
	}
	sort(ALL(v));
	LL cur=0;
	priority_queue<LL,vector<LL>,greater<LL>> pq;
	REP(ii,n){
		int i=v[ii].S;
		pq.push(a[i]-c[i]);
		cur+=a[i];
		while(SZ(pq)>x){
			cur-=pq.top();pq.pop();
		}
		l[ii]=cur;
	}
	cur=0;
	while(SZ(pq))pq.pop();
	for(int ii=n-1;ii>=0;ii--){
		int i=v[ii].S;
		pq.push(b[i]-c[i]);
		cur+=b[i];
		while(SZ(pq)>y){
			cur-=pq.top();pq.pop();
		}
		r[ii]=cur;
	}
	LL ans=0;
	REPP(i,x-1,n-y){
		ans=max(ans,l[i]+r[i+1]);
	}
	printf("%lld",ans);
}


Measured memory_bytes: 7408
def solve():
    N, K = map(int, input().split())
    
    mod_zero, mod_half = 0, 0
    for i in range(1, N+1):
        if i % K == 0:
            mod_zero += 1
        elif i % K == K // 2:
            mod_half += 1
    
    ans = mod_zero ** 3
    if K % 2 == 0:
        ans += mod_half ** 3
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
n = int(input())
b = []
b_old = []
for i in range(n):
    tmp = int(input())
    b.append(tmp)
n_b = 1
count = 0
flag = 0
while(count < n):
    n_b = b[n_b-1]
    count += 1
    if n_b == 2:
        print(count)
        flag = 1
        break
if flag == 0:
    print("-1")


Measured memory_bytes: 7084
#include<bits/stdc++.h>
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=(1<<62)-1;
const double eps=1e-6;
int main(){
	int n;
	cin>>n;
	cout<<(long long)(n/2)*((n+1)/2);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

for i in range(N-1):
    if H[i] <= H[i+1]:
        continue
    elif H[i]-1 == H[i+1]:
        H[i+1] += 1
    else:
        # print(i)
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 14224
#include<iostream>
using namespace std;
int main()
{

int i;

    int cnt=0;
string s;
cin>>s;

int n=s.size();
for( i=0;i<n;i++){
    if(s[i]=='R'){
        cnt++;
    }

}
if(cnt==2){
    if( s[0]=='R' && s[2]=='R'){
        cout<<cnt/2<<endl;
    }
    else{
        cout<<cnt<<endl;
    }
}
else
cout<<cnt<<endl;

return 0;
}








Measured memory_bytes: 3592