akhauriyash/Code-Regression huggingface dataset:
// Algorithm: Brute-force

#include "cstdio"
using namespace std;

const int maxn=30+10;
int n,c,d[maxn][maxn],t[4][maxn],x,y,z,ans;

int main()
{
    ans=0x7fffffff;    // 先把答案记为一个极大值，出现更小的就更新
    scanf("%d%d",&n,&c);

    register int i,j,k,l;
    for(i=1;i<=c;i++)
    {
        // 输入D矩阵(i-j)为颜色i变为颜色j的代价为(i,j)
        for(j=1;j<=c;j++)
        {
            scanf("%d",&d[i][j]);
        }
    }

    for(i=1;i<=n;i++)
    {
        // 输入矩阵C
        for(j=1;j<=n;j++)
        {
            scanf("%d",&x);
            t[(i+j)%3][x]++;    // 计算横坐标加纵坐标mod3的数值,颜色为x的个数+1
        }
    }

    for(i=1;i<=c;i++)
    {
        // 枚举坐标余数为0的颜色，统一变成颜色i，其代价之和为x
        // 比如例1中，坐标为1行2列的余数为(1+2)%3=0，其值2，变成i=1则D_21=1
        // 坐标2列1行的余数为(2+1)%3=0，其值为3，变成i=1则有D_31=31
        // x = D_21 + D_31 = 2
        x=0;
        for(j=1;j<=c;j++)
        {
            x+=t[0][j]*d[j][i];
        }

        for(j=1;j<=c;j++)
        {    // 枚举余数为1的颜色，统一变成颜色j,其代价之和为y
            if(j==i)
            {
                continue;    // 不同余数的颜色不能相同
            }

            y=0;
            for(k=1;k<=c;k++)
            {
                y+=t[1][k]*d[k][j];
            }

            for(k=1;k<=c;k++)
            {
                // 枚举坐标余数为2的颜色，统一变成颜色k,其代价之和为z
                if(k==j || k==i)
                {
                    continue;    // 不同余数的颜色不能相同
                }

                z=0;
                for(l=1;l<=c;l++)
                {
                    z+=t[2][l]*d[l][k];
                }

                if(ans>x+y+z)
                {
                    // 如果当前转换的代价和比之前的最优答案更小，就更新代价和
                    ans=x+y+z;
                }
            }
        }
    }

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


Measured memory_bytes: 128
import sys
input = sys.stdin.buffer.readline
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
mod = 10 ** 9 + 7
dp = [[0] * (M + 1) for _ in range(N + 1)]
for i in range(N):
  for j in range(M):
    if S[i] == T[j]:
      dp[i + 1][j + 1] = (1 + dp[i + 1][j] + dp[i][j + 1]) % mod
    else:
      dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1] - dp[i][j]) % mod
print((dp[-1][-1] + 1) % mod)

Measured memory_bytes: 72540
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-9-1 20:53:31
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

ll N, K;

int main()
{
  cin >> N >> K;
  if (K % 2 == 0)
  {
    ll cnt[2] = {0, 0};
    for (auto i = 1; i <= N; i++)
    {
      if (i % (K / 2) == 0)
      {
        cnt[(i / (K / 2)) % 2]++;
      }
    }
    // cerr << "cnt = " << cnt[0] << " " << cnt[1] << endl;
    cout << cnt[0] * cnt[0] * cnt[0] + cnt[1] * cnt[1] * cnt[1] << endl;
  }
  else
  {
    ll cnt = 0;
    for (auto i = 1; i <= N; i++)
    {
      if (i % K == 0)
      {
        cnt++;
      }
    }
    cout << cnt * cnt * cnt << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main(){
	int r;
	cin >> r;
	cout << r * r << endl;

	return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

char s[110];
int main()
{
  scanf("%s", s);
  putchar(s[0]);
  printf("%lu", strlen(s) - 2);
  putchar(s[strlen(s) - 1]);
  puts("");
  return 0;
}

Measured memory_bytes: 128
n = int(input())
h = list(map(int, input().split()))

s = list(0 for i in range(n))
s[1] = abs(h[0] - h[1])
for i in range(2,n):
    s[i] = min(s[i-1] + abs(h[i-1] - h[i]), s[i-2] + abs(h[i-2] - h[i]))
print(s[-1])

Measured memory_bytes: 13980
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt();
        if (n % k == 0) {
            System.out.println(0);
        } else {
            System.out.println(1);
        }
    }
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;

    if (N == 1) {
    } else {
        vector<int> carr(N - 1, 0);
        vector<int> sarr(N - 1, 0);
        vector<int> farr(N - 1, 0);
        for (int i = 0; i < N - 1; i++) {
            int c, s, f;
            cin >> c >> s >> f;
            carr[i] = c;
            sarr[i] = s;
            farr[i] = f;
        }

        for (int j = 1; j < N; j++) {
            int idx = j - 1;
            int64_t ans = 0;
            for (int k = idx; k < N - 1; k++) {
                if (k == idx) {
                    ans = carr[idx] + sarr[idx];
                } else {
                    //cout << "sarr[k] " << sarr[k] << endl;
                    //cout << "farr[k] " << farr[k] << endl;
                    //cout << "carr[k] " << carr[k] << endl;
                    //cout << ((ans / sarr[k]) * sarr[k]) + farr[k] + carr[k] << endl;
                    int64_t start = sarr[k];
                    if (ans > sarr[k]) {
                        if (ans % farr[k] == 0) {
                            start = ans;
                        } else {
                            start = ans + farr[k] - (ans % farr[k]);
                        }
                    }
                    //cout << "start:" << start << endl;;
                    ans = start + carr[k];
                }
                //cout << "ans:" << ans << endl;
            }
            cout << ans << endl;
        }
    }
    cout << 0 << endl;
   
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
	public static void main(String[] args)                                        
	{
		Scanner sc=new Scanner(System.in);
		int t,k;
		t=sc.nextInt();
		k=sc.nextInt();
		int sum=0;
		int a[]=new int[k];
		for(int i=0;i<k;i++)
		a[i]=sc.nextInt();
	for(int i=0;i<k;i++)
	sum+=a[i];
	if(t>=sum)	
		System.out.println(t-sum);
		else
		
		 System.out.println(-1);
	
		
	}
	
	
			
	
		
}



Measured memory_bytes: 39304
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

template<typename T>
T gcd(T a, T b) {
	if( a < b ) swap(a, b);
	
	T r;
	while( r = a % b ) {
		a = b;
		b = r;
	}
	
	return b;
}

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	int ans = a[0];
	for(int i = 1; i < n; ++i) {
		ans = gcd(ans, a[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin>>s;
    if(s=="SUN")
    {
        cout<<7;
    }
    if(s=="MON")
    {
        cout<<6;
    }
    if(s=="TUE")
    {
        cout<<5;
    }
    if(s=="WED")
    {
        cout<<4;
    }
    if(s=="THU")
    {
        cout<<3;
    }
    if(s=="FRI")
    {
        cout<<2;
    }
    if(s=="SAT")
    {
        cout<<1;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
	/* time: O(n^2), space: O(n^2) */
	int league(const vector<vector<int>>& A) {
		/* Build the dependency graph of all matches */
		const int n = A.size();
		vector<vector<int>> adjLists(n * n);
		for (int i = 1; i <= n; ++i) {
			int prevMatch = -1;
			for (int j : A[i - 1]) {
				const int playerX = min(i - 1, j - 1), playerY = max(i - 1, j - 1);
				const int currMatch = playerX * n + playerY;
				if (prevMatch != -1)
					adjLists[prevMatch].push_back(currMatch);
				prevMatch = currMatch;
			}
		}

		/* Compute the length of the topological ordering (DFS + DP) */
		vector<bool> inStack(n * n);
		vector<int> depth(n * n);
		using F = function<int(int)>;
		F dfs = [&](int u) {
			if (inStack[u])
				return -1; /* failed */
			if (depth[u])
				return depth[u];

			inStack[u] = true;
			depth[u] = 1;
			for (int v : adjLists[u]) {
				const int len = dfs(v);
				if (len == -1) {
					depth[u] = -1;
					break;
				}
				depth[u] = max(depth[u], 1 + len);
			}
			inStack[u] = false;
			return depth[u];
		};

		int ans = 0;
		for (int u = 0; u < n * n; ++u) {
			const int len = dfs(u);
			if (len == -1)
				return -1; /* failed */
			ans = max(ans, len);
		}
		return ans;
	}
};

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

	Solution sol;
	int ans = sol.league(A);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 47488
from bisect import bisect_left, bisect_right

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

A.sort()
B.sort()
C.sort()

cnt = 0
for b in B:
    a_cand = bisect_left(A,b)
    c_cand = N - bisect_right(C,b)
    
    cnt += a_cand * c_cand
    
print(cnt)

Measured memory_bytes: 23360
#include <iostream>
#include <map>
using namespace std;
int main(void) {
	int n, a;
	cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n - 1; ++i) {
		cin >> a;
		++mp[a];
	}
	for (int i = 0; i < n; ++i) {
		cout << mp[i + 1] << '\n';
	}
	return 0;
}

Measured memory_bytes: 12996
fun main(args:Array<String>?): Unit {
    val n = readLine()!!.trim().toInt()
    val materials = Array(n){
        val (a, x) = readLine()!!.trim().split(' ')
        Material(a, x.toInt())
    }.sortedBy(Material::name)
    val unionFind = UnionFind(n)
    val m = readLine()!!.trim().toInt()
    repeat(m){
        val (s, t) = readLine()!!.trim().split(' ')
        val sId = materials.binarySearchBy(s){it.name}
        val tId = materials.binarySearchBy(t){it.name}
        unionFind.merge(sId, tId)
    }
    val minCost = IntArray(n){Int.MAX_VALUE}
    for (i in 0 until unionFind.size){
        val root = unionFind.find(i)
        if (minCost[root] > materials[i].price) {
            minCost[root] = materials[i].price
        }
    }
    println((0 until unionFind.size).map{i -> minCost[unionFind.find(i)]}.sum())
}
class Material(val name: String, val price: Int)
class UnionFind(val size: Int){
    private val mArray: IntArray = IntArray(size){-1}
    fun find(a: Int): Int {
        return if (mArray[a] < 0) a
        else {
            mArray[a] = find(mArray[a])
            mArray[a]
        }
    }
    fun isSame(u: Int, v: Int): Boolean = find(u) == find(v)
    fun merge(u: Int, v: Int): Unit {
        val ur = find(u)
        val vr = find(v)
        if (ur != vr){
            if (mArray[ur] < mArray[vr]) {
                mArray[ur] += mArray[vr]
                mArray[vr] = ur
            }else {
                mArray[vr] += mArray[ur]
                mArray[ur] = vr
            }
        }
    }
}


Measured memory_bytes: 40424
#![allow(dead_code)]
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    // idx[p[i]] = i
    let idx = {
        let mut idx: Vec<usize> = vec![0; n];
        for i in 0..n {
            let p: usize = sc.read();
            idx[p - 1] = i;
        }
        idx
    };

    let mut p_i = 0;

    // l_i[j] = max{k| k<j, p[k]>p_i}
    // r_i[j] = min{k| k>j, p[k]>p_i}
    let mut l_i: Vec<_> = vec![None];
    l_i.extend((0..n - 1).map(Some));
    let mut r_i: Vec<_> = (1..n).map(Some).collect();
    r_i.push(None);

    let mut ans = 0;
    while p_i < n {
        let i = idx[p_i];

        let (l, l2) = {
            if let Some(l) = l_i[i] {
                if let Some(l2) = l_i[l] {
                    (l as isize, l2 as isize)
                } else {
                    (l as isize, -1)
                }
            } else {
                (-1, -1)
            }
        };

        let (r, r2) = {
            if let Some(r) = r_i[i] {
                if let Some(r2) = r_i[r] {
                    (r as isize, r2 as isize)
                } else {
                    (r as isize, n as isize)
                }
            } else {
                (n as isize, n as isize)
            }
        };

        let i = i as isize;
        let c_i = (l - l2) * (r - i) + (r2 - r) * (i - l);
        ans += (p_i + 1) * c_i as usize;

        p_i += 1;

        // l_i <- l_(idx[p_i+1])
        // r_i <- r_(idx[p_i+1])
        if l >= 0 {
            r_i[l as usize] = r_i[i as usize]
        }
        if r < n as isize {
            l_i[r as usize] = l_i[i as usize]
        }
    }

    format!("{}\n", ans)
}
#[test]
fn test_solve() {
    assert_eq!(solve("3\n2 3 1\n"), "5\n");
    assert_eq!(solve("5\n1 2 3 4 5\n"), "30\n");
    assert_eq!(solve("8\n8 2 7 3 4 5 6 1\n"), "136\n");
}
fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf).unwrap();
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<I> {
    src: I,
}
impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner {
            src: src.split_whitespace(),
        }
    }
}
impl<'a, I> Scanner<I>
where
    I: std::iter::Iterator<Item = &'a str>,
{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
}


Measured memory_bytes: 12540
def calc(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n //= 10
    return sum


N = int(input())

answer = None

for i in range(1, N):
    A = i
    B = N - i

    C = calc(A) + calc(B)

    if answer is None or answer > C:
        answer = C

print(answer)


Measured memory_bytes: 40812
#include<bits/stdc++.h>
using namespace std;
 
int editDistance(string a,string b){
  int n=a.size();
  int m=b.size();
  vector< vector< int > > dp;
  dp.resize(n+1);
 
  for(int i=n;i>=0;i--){
    dp[i].resize(m+1);
     
    for(int j=m;j>=0;j--){
      if(i==n){
        dp[i][j]=m-j;
      }else if(j==m){
        dp[i][j]=n-i;
      }else{
        dp[i][j]=1e9;
        if(a[i]==b[j])dp[i][j]=dp[i+1][j+1];
        else dp[i][j]=min(dp[i+1][j+1],min(dp[i][j+1],dp[i+1][j]))+1;
      }
    }
  }
  return dp[0][0];
}
 
 
int main(){
  string a,b;
  cin>>a>>b;
  cout<<editDistance(a,b)<<endl;
  return 0;
}

Measured memory_bytes: 6900
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

ll N, M;
ll a[100010], two[100010];
bool fl = true;

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

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

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

    if( a[i]&1 )
      fl = false;
    else
      a[i] >>= 1;
  }

  if( !fl )
  {
    std::cout << 0 << std::endl;

    return 0;
  }

  ll L = 1;
  ll mi = 1ll<<60;

  rep( i, N )
  {
    L = lcm( L, a[i] );

    ll x = a[i];

    while( x%2 == 0 )
      ++two[i], x /= 2;

    chmin( mi, two[i] );
  }

  rep( i, N )
  {
    if( two[i] != mi )
    {
      std::cout << 0 << std::endl;

      return 0;
    }
  }

  ll ans = M/L;

  ans = ans-(ans/2);

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

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    ll h, w; cin >> h >> w;

    if(h%3==0 || w%3==0){
        cout << 0 << endl;
        return 0;
    }

    dump(h);
    ll ht = h/3LL;
    ll ht1 = (h+2)/3LL;

    ll tmp = max(w*ht, (h-ht)*((w+1)/2LL)) - min(w*ht, (h-ht)*(w/2LL));
    dump(tmp);
    tmp = min(tmp, max(w*ht1, (h-ht1)*((w+1)/2LL)) - min(w*ht1, (h-ht1)*(w/2LL)));
    dump(tmp);

    ll wt = w/3LL;
    ll wt1 = (w+2)/3LL;

    ll tmp2 = max(h*wt, (w-wt)*((h+1)/2LL)) - min(h*wt, (w-wt)*(h/2LL));
    dump(tmp2);
    tmp2 = min(tmp2, max(h*wt1, (w-wt1)*((h+1)/2LL)) - min(h*wt1, (w-wt1)*(h/2LL)));
    dump(tmp2);

    ll ans = min(tmp, tmp2);
    ans = min(w, min(h, ans));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

int dist[305][305];
int stops[305][305];
void solve(){  
	memset(dist,63,sizeof dist);
	memset(stops,63,sizeof stops);
	int lim=stops[0][0];
	int n,m,l;
	cin>>n>>m>>l;
	rep(i,1,n+1) dist[i][i]=0;
	rep(i,0,m){
		int u,v,w;
		cin>>u>>v>>w;
		dist[u][v]=min(dist[u][v],w);
		dist[v][u]=min(dist[v][u],w);
	}
	rep(k,1,n+1){
		rep(i,1,n+1){
			rep(j,1,n+1){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	rep(i,1,n+1){
		rep(j,1,n+1){
			if(dist[i][j]<=l) stops[i][j]=0;
		}
	}
	rep(k,1,n+1){
		rep(i,1,n+1){
			rep(j,1,n+1){
				stops[i][j]=min(stops[i][j],stops[i][k]+1+stops[k][j]);
			}
		}
	}
	int q;
	cin>>q;
	while(q--){
		int s,t;
		cin>>s>>t;
		if(stops[s][t]==lim){
			cout<<-1<<endl;
		}
		else cout<<stops[s][t]<<endl;
	}
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 2048
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int x,y,c;
int main(){
	in(x);in(y);in(c);
    if((x==y||x==c||y==c)&&!(x==y&&x==c))puts("Yes");
    else puts("No");
	return 0;
}


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

// 💖 Hi, thanks for using ICIE! 💖
// 🔧 To use a custom code template, set it in Settings(Ctrl+,) in "Icie Template List" entry 🔧
// 📝 If you spot any bugs or miss any features, create an issue at https://github.com/pustaczek/icie 📝

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int w, h, x, y;
    cin>>w>>h>>x>>y;

    printf("%lf %d", 
        double(h)*double(w)*0.5,
        2*x == w && 2*y == h);
}


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

#define ll long long

int main()
{
    int n;
    cin >> n;
    int c=0,f=0;
    while(n--)
    {
        int d1,d2;
        cin >> d1 >> d2;
        if(d1 == d2)
        {
            c++;
        }
        else
        {
            c = 0;
        }
        if(c == 3)
        {
            cout << "Yes" << endl;
            f = 1;
            break;
        }
    }
    if(f == 0)
    {
        cout << "No" << endl;
    }
    return 0;
}

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<int> v(N + 1, 0);
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i]--;
        v[a[i]]++;
    }
    vector<int> l(N + 1);
    vector<int> r(N + 1);
    l[0] = 0;
    r[N] = 0; // (r[i] でi以降)
    for (int i = 0; i < N; i++) {
        l[i + 1] = l[i] + v[i] * (v[i] - 1) / 2;
    }
    for (int i = N; i > 0; i--) {
        r[i - 1] = r[i] + v[i - 1] * (v[i - 1] - 1) / 2;
    }
    for (int k = 0; k < N; k++) {
        cout << l[a[k]] + r[a[k] + 1] + max((v[a[k]] - 1) * (v[a[k]] - 2) / 2, 0LL) << endl;
    }

    return 0;
}



Measured memory_bytes: 8832
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    string s;
    cin >> s;
    if(s.length() % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    for(int i=0;i<s.length()/2;i+=2){
        if(s[i] == 'h' && s[i+1] == 'i'){
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll m;

int main(){
  ll nm=0;
  cin >> m;
  string s;
  vi c(m);
  vector<ll> d(m);
  vi ans(m);
  

  REP(i,m){
    cin>>d[i]>>c[i];
  }


  REP(i,m){

    ll tc=c[i];
    vi ms(128);
    ll w=0;
    ll nown=d[i];
    while(tc!=0){
      if (tc%2==1){
        ms[w]=nown;
        w++;
      }
      nm+=tc/2;
      if (nown>=5)nm+=tc/2;

      switch(nown){
      case 0:
        nown=0;
        break;
      case 1:
        nown=2;
        break;
      case 2:
        nown=4;
        break;
      case 3:
        nown=6;
        break;
      case 4:
        nown=8;
        break;
      case 5:
        nown=1;
        break;
      case 6:
        nown=3;
        break;
      case 7:
        nown=5;
        break;
      case 8:
        nown=7;
        break;
      case 9:
        nown=9;
        break;
      default:
        break;
    }

      tc/=2;
    }
    


    tc=0;
    nm--;
    for(ll j=0;j<w;j++){
      tc+=ms[j];
      nm++;
      if (tc>=10){
        tc=tc%10+tc/10;
        nm++;
      }
    }
    ans[i]=tc;
    
  }




  ll tc=0;
  nm--;
  for(ll j=0;j<m;j++){
    tc+=ans[j];
    nm++;
    if (tc>=10){
      tc=tc%10+tc/10;
      nm++;
    }
  }





  cout<<nm<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;

#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, N = 5e5 + 10;
const ll LINF = LLONG_MAX;
int a,b,c,d;
str s1,s2;
char ch;
int32_t main() {
    fast();
    cin >> a >> b;
  if(a>b){
 	f(i,0,a){
      cout<<b;
    }
  }
  else if(a<b){
 	f(i,0,b){
      cout<<a;
    }
  }
  else{
    f(i,0,a)
      	cout<<a;
  }
    
    return 0;
}
 

Measured memory_bytes: 256
#include <stdio.h>
#define N_MAX 1000000
#define M_MAX 1000000

int n,m;
char s[M_MAX + 1];

void solve(void){
	int i,mict[2] = {0,0};
	char lotte[2] = {0,0};
	int ans = 0;
	i = m;
	while(i--){
		if(s[i] == lotte[i % 2]){
			mict[i % 2]++;
		}else{
			lotte[i % 2] = s[i];
			mict[i % 2] = 1;
		}
		if(mict[i % 2] < n+((s[i] == 'I')?1:0)){
			s[i] = 0;
		}
	}
	while(++i < m){
		if(s[i] != 'I')continue;
		if(s[i+1] != 'O')continue;
		ans++;
	}
	printf("%d\n", ans);
	return;
}

int main(void){
	while(scanf("%d",&n),n){
		scanf("%d",&m);
			scanf("%s",s);
			solve();
		
	}
	return 0;
}

Measured memory_bytes: 1580
N, C, K = map(int, input().split())
T = [0 for _ in range(N)]
for __ in range(N):
    T[__] = int(input())
 
T.sort()
bus_count = 1
bus_rest = C
bus_depert = T[0]+K
 
for ix in range(N):
 
    if T[ix] <= bus_depert and bus_rest > 0:
        bus_rest -= 1
 
    else:
        bus_count += 1
        bus_depert = T[ix] + K
        bus_rest = C - 1
 
print(bus_count)

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

int main()
{
    int n, k;
    long long a[1024];
    std::vector<long long> subarrays;
    scanf("%d%d", &n, &k);
    a[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", a + i);
        a[i] += a[i - 1];
    }
    for (int l = 0; l < n; l++)
    {
        for (int r = l + 1; r <= n; r++)
            subarrays.push_back(a[r] - a[l]);
    }

    auto end = subarrays.end();
    for (long long exp = 1152921504606846976; exp != 0; exp /= 2)
    {
        std::sort(subarrays.begin(), end, [&](const long long &a, const long long &b) { return (a & exp) > (b & exp); });
        auto tmp_end = std::upper_bound(subarrays.begin(), end, exp, [&](const long long &value, const long long &j) { return (value & j) != value; });
        if ((tmp_end - subarrays.begin()) >= k) end = tmp_end;
    }
    long long ans{-1};
    for (int i = 0; i < k; i++)
        ans &= subarrays[i];
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 6384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,L; cin >> N >> L;
    vector<string> S(N); for(auto& in:S) cin >> in;
    sort(S.begin(),S.end());
    for(auto s:S) cout << s; cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T,V> &x){cerr<<'{';__print(x.first);cerr<<',';__print(x.second);cerr<<'}';}
template<typename T>
void __print(const T &x){int f=0;cerr<<'{';for(auto &i:x)cerr<<(f++ ? "," : ""),__print(i);cerr<<"}";}
void _print(){cerr<<"]\n";}
template<typename T,typename... V>
void _print(T t, V... v) {__print(t);if(sizeof...(v))cerr<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define sz(x) (int)x.size()                         					
#define all(x) x.begin(), x.end()           		
#define lb lower_bound                  	
#define ub upper_bound             		
                                   	
typedef long long ll;           		
typedef pair<int, int> pii;     	
typedef pair<ll, ll> pll;       	
typedef long double ld;
          						
template<typename T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;    
template<typename T> void print(T x){cerr<<x<<'\n';}
inline ll bip(ll x,ll n,ll mod){ll res=1;while(n){if(n&1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}                 		
																															 
const int maxn = 1e9;
const ll inf = 1e18;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const int N = 3e5 + 10;


void solve() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while (b <= a) {
		b *= 2;
		k--;
	}
	while (c <= b) {
		c *= 2;
		k--;
	}
	if (k >= 0) cout << "Yes";
	else cout << "No";
}   	            
 
int main() {
    SpeedForce;
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
        cout << '\n';
    }
}    

Measured memory_bytes: 3640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
    
    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};


//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<int> h(N+1), a(N+1);
    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < N; i++) cin >> a[i];

    auto f = [](long long a, long long b) { return max(a, b); };
    SegTree<long long> dp(N+1, f, 0);

    for (int i = 0; i < N; i++) {
        long long A = dp.get(0, h[i]);
        if (dp.get(h[i], h[i]+1) < A + a[i]) {
            dp.update(h[i], A + a[i]);
        }
    }

    cout << dp.get(0, N+1) << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, dp[1100000], c[3] = {0,1,2}, rc[3] = {0,1,2}, sz, u=1;
char s[200005];
int main(){
	scanf("%d\n%s", &n, s);
	sz = strlen(s);

	for(int i=0, t=1; i<n; i++, t*=3) rep(j,3) rep(k,t) dp[t*(3+j)+k] = j;
	rep(i,sz){
		if(s[i] == 'S'){
			rep(j,3) if(c[j]) rc[c[j] = 3 - c[j]] = j;
		}else for(int i=0, t=1, k=0, nk=0; i<n; i++, k=nk, t*=3) rep(j,3){
			if(c[dp[t*(3+j)+k]] == 2) nk = t * j + k;
			dp[t*(3+j)+k] = rc[(c[dp[t*(3+j)+k]]+1)%3];
		}
	}
	rep(i,n) u *= 3;
	rep(i,u){
		int ans = 0;
		for(int j=0, t=3, t2=1; j<n; j++, t*=3, t2*=3) ans += c[dp[i%t+t]] * t2;
		printf("%d%c", ans, i==u-1 ? '\n' : ' ');
	}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}

int main(void){
    int n, m, c;
    cin >> n >> m >> c;
    int a[n][m], b[m];
    rep(i, m)cin >> b[i];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int count = 0;
    for(int i = 0; i < n; i++){
        int sum = c;
        for(int j = 0; j < m; j++){
            sum += a[i][j] * b[j];
        }
        if(sum > 0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>

typedef long long ll;
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)



#define MOD 998244353


int main()
{
	string s;
	cin >> s;
	int last = s.size() - 1;
	if (s[last] == '3') {
		cout << "bon" << endl;
	}
	else if (s[last] == '0' || s[last] == '1' || s[last] == '6' || s[last] == '8')
		cout << "pon" << endl;
	else
		cout << "hon" << endl;
}



Measured memory_bytes: 3596
#include<algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
	int n,i,f,ans=0;
	cin>>n;
	long long int a[n];
	for(i=0;i<n;i++)cin>>a[i];
	do{
		f=1;
		for(i=0;i<n;i++){
			if(a[i]%2==0)a[i]/=2;
			else f=0;
		}
		if(f)ans++;
	}while(f);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int n;
char s[11];

void dfs(int x, int y) {
    int i;
    
    if (x == n) {
        printf("%s\n", s);
    } else {
        for (i = 0; i < y; i++) {
            s[x] = 'a' + i;
            dfs(x + 1, y);
        }
        
        s[x] = 'a' + y;
        dfs(x + 1, y + 1);
    }
}

int main() {
    int i;
    
    scanf("%d", &n);
    
    dfs(0, 0);
    
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
int lll[100020];
int ok=0;
int uu=0;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>lll[i];
		if(lll[i]%4==0){
			ok++;
		}
		else if(lll[i]%2==0){
			uu++;
		}
	}
	uu--;
	n-=max(0,uu);
	if(ok>=n/2){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 768
/*{{{*/
//#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &_x) { cin >> _x; }
void _R(int &_x) { scanf("%d", &_x); }
void _R(int64_t &_x) { scanf("%" SCNd64, &_x); }
void _R(double &_x) { scanf("%lf", &_x); }
void _R(char &_x) { scanf(" %c", &_x); }
void _R(char *_x) { scanf("%s", _x); }
template<class T, class U> void _R(pair<T, U> &_x) {_R(_x.F); _R(_x.S);}
void R() {}
template<class T, class... U> void R(T &_head, U &... _tail) { _R(_head); R(_tail...); }

template<class T> void _W(const T &_x) { cout << _x; }
void _W(const int &_x) { printf("%d", _x); }
void _W(const int64_t &_x) { printf("%" PRId64, _x); }
void _W(const double &_x) { printf("%.16f", _x); }
void _W(const char &_x) { putchar(_x); }
void _W(const char *_x) { printf("%s", _x); }
template<class T, class U> void _W(const pair<T, U> &_x) {_W(_x.F); putchar(' '); _W(_x.S);}
template<class T> void _W(const vector<T> &_x) { for (auto i = _x.begin(); i != _x.end(); _W(*i++)) if (i != _x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &_head, const U &... _tail) { _W(_head); putchar(sizeof...(_tail) ? ' ' : '\n'); W(_tail...); }
template<class T, class... U> void DB(const T &_head, const U &... _tail) {
#ifdef HOME
    W('#', _head, _tail...);
#endif
}

#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()
#define RAN(x,n) (x).begin(), (x).begin()+(n)
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
//#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)
#define IT3(i,st,ed) for (auto i = st; i != ed; ++i)
#define IT2(i,range) IT3(i,range)

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

inline int LG (const unsigned int &_x) { return 31-__builtin_clz(_x); }  // floor: LG(x), ceil: LG(x-1)+1
/*}}}*/

int n;
ll k;
vector<ll> as;
map<ll, int> cnt;

int main(){
    R(n, k);
    as.assign(n+1, 0);
    as[0] = 0;
    FORI(i, n) R(as[i]);

    partial_sum(ALL(as), as.begin());

    //DB(as);
    ll ans = 0;
    FOR(i, SZ(as)){
        ll d = (as[i] - i) % k;
        if(d < 0) d += k;
        ans += cnt[d];
        cnt[d]++;

        if(i-k+1 >= 0){
            ll d2 = (as[i-k+1] - (i-k+1)) % k;
            if(d2 < 0) d += k;
            cnt[d2]--;
        }
        //DB(ans, d, cnt[d]);
    }

    W(ans);

    return 0;
}


Measured memory_bytes: 14336
from itertools import accumulate

def solve():
    N, M = map(int, input().split())
    l = []
    for i in range(N):
        l.append(M + i)
    
    s = list(accumulate(l))
    
    if 0 in l:
        return s[-1]

    if M >= 0:
        return s[-1] - s[0]
    else:
        return s[-1] - l[-1]
    
print(solve())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n, k;
  cin >> n >> k;
  vi p(n);
  rep(i,n) cin >> p[i];
  rep(i,n) p[i]++;
  int mx = 0;
  int s = 0;
  queue<int> q;
  rep(i,n) {
    s += p[i];
    q.push(p[i]);
    if (q.size() > k) {
      s -= q.front(); q.pop();
    }
    if (q.size() == k) {
      mx = max(mx, s);
    }
  }
  double ans = mx;
  ans /= 2;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 1792
N = int(input())

def base(x, n):
  ret = []
  while x != 0:
    ret.append( x % abs(n))
    if n < 0:
      x = - ( (-x)//n )
    else:
      x //= n
  return ret

if N == 0:
  print(0)
else:
  print("".join(map(str, reversed(base(N, -2)))))

Measured memory_bytes: 9056
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    string s;
    cin >> s;
    if(s=="Sunny")s="Cloudy";
    else if(s=="Cloudy")s="Rainy";
    else s="Sunny";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		System.out.println(a*b/gcd(a,b));
	}
	private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}


Measured memory_bytes: 21844
{-# LANGUAGE Strict #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.Set              as S

main :: IO ()
main = do
  n <- readLn
  ss <- B.lines <$> B.getContents
  print $ solve n ss

solve :: Int -> [B.ByteString] -> Int
solve _ ss = S.size $ S.fromList ss


Measured memory_bytes: 43856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  Int N;
  cin >> N;
  vector<Int> P(N);
  
  rep(i,N) cin >> P[i];
  
  Int m = P[0], ans = 1;
  
  rep1(i,N-1) {
    if (m >= P[i]) ans++;
    m = min(m, P[i]);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
    double w, h, x, y;
    scanf("%lf%lf%lf%lf", &w, &h, &x, &y);
    printf("%.10lf ", w / 2.0000000 * h);
    if (2 * x == w && 2 * y == h)
        printf("1\n");
    else
        printf("0\n");
}


Measured memory_bytes: 256
s = input()

while True:
    if s[-5:] == 'dream':
        s = s[:-5]
        continue
    elif s[-7:] == 'dreamer':
        s = s[:-7]
        continue
    elif s[-5:] == 'erase':
        s = s[:-5]
        continue
    elif s[-6:] == 'eraser':
        s = s[:-6]
        continue
    elif len(s) == 0:
        print('YES')
        break
    else:
        print('NO')
        break

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  
  int x;
  int distance = 0;
  int i;
  for( i=0; i < N; i++){
    cin >> x;
    
    if(x < K - x)		distance += x * 2;
    else				distance += (K - x) * 2;
  }
  
  cout << distance << endl;
 
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int a,b;

signed main() {
    cin >> a >> b;
    if (a <= 5) cout << 0 << endl;
    else if (a <= 12 ) cout << b/2 << endl;
    else cout << b << endl;
}


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

using namespace std;


#define ll long long int


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)


ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

//..............................!!!!!!Get ready to fight!!!!!!............................
string lcs(string x,string y){
    int n=x.length(),m=y.length(),i,j;
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            if(x[i-1]==y[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string res="";
    i=n,j=m;
    while(i>0&&j>0){
        if(x[i-1]==y[j-1]){
            res.push_back(x[i-1]);
            i--;j--;
        }
        else{
            if(dp[i][j-1]>dp[i-1][j])
            j--;
            else
            i--;
        }
    }
    reverse(res.begin(),res.end());
    return res;
}
int main()
{   
    
    string x,y;
    cin>>x>>y;
    cout<<lcs(x,y);
    
    return 0;
}

Measured memory_bytes: 35456