akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  string s;
  cin >> s;
  if(s.back() == 's') {
    cout << s << "es" << endl;
  }
  else {
    cout << s << "s" << endl;
  }
}


Measured memory_bytes: 3624
import sys
import math
import collections
import heapq
import queue
import itertools
import functools
import operator
import time

readline = sys.stdin.readline
 
IPS = lambda: readline().rstrip()
IP = lambda: int(readline().rstrip())
MP = lambda: map(int, readline().split())
LS = lambda: list(map(int, readline().split()))

def solve():
    for _ in range(1):
        n = IP()
        ans = 0 
        for i in range(1,n+1):
            j = n//i
            ans += i*j*(j+1)//2
 
        print(ans)
        
        
if __name__ == "__main__":
    solve()

Measured memory_bytes: 9612
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(3 * n);
    rep(i, 0, 3 * n) cin >> a[i];
    int ans = 0;
    sort(a.rbegin(), a.rend());
    rep(i, 0, n){
        ans += a[2 * i + 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = long long;


int main() {

	int n, m;

	cin >> n >> m;

	vector<int> h(n);
	vector<int> f(n,0);
	rep(i, n)cin >> h[i];

	rep(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		if (h[x] > h[y]) {
			f[y] = -1;
		}
		else if (h[x] < h[y]) {
			f[x] = -1;
		}
		else { f[x] = -1; f[y] = -1; }

	}
	int ans = 0;
	rep(i, n)if (f[i] == 0)ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4060
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;
    private StringBuilder sb;
 
    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }
 
    private void solve() {
        try {
            int sx = scanner.nextInt();
            int sy = scanner.nextInt();
            int tx = scanner.nextInt();
            int ty = scanner.nextInt();
            int dx = tx - sx;
            int dy = ty - sy;
            if (dx < 0) {
                dx *= -1;
            }
            if (dy < 0) {
                dy *= -1;
            }
            sb = new StringBuilder();
            printUDLR(dy, "U");
            printUDLR(dx, "R");
            printUDLR(dy, "D");
            printUDLR(dx+1, "L");
            printUDLR(dy+1, "U");
            printUDLR(dx+1, "R");
            printUDLR(1, "D");
            printUDLR(1, "R");
            printUDLR(dy+1, "D");
            printUDLR(dx+1, "L");
            printUDLR(1, "U");
            System.out.println(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void printUDLR (int n, String s) {
        for (int i = 0; i < n; i++) {
            sb.append(s);
        }
    }
 
    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
 
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }
 
        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }
 
        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
 
        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int d; cin >> d;
    if(d==25) print("Christmas");
    else if(d==24) print("Christmas Eve");
    else if(d==23) print("Christmas Eve Eve");
    else print("Christmas Eve Eve Eve");
}



Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()
    MOD = 10 ** 9 + 7
    ans = 1

    if K % 2 == 1 and A[-1] < 0:
        for i in range(K):
            ans = ans * A[N - (i + 1)] % MOD

        print(ans)
        return

    l = 0
    r = N - 1
    if K % 2 == 1:
        ans = ans * A[r]
        r -= 1
    
    for _ in range(K // 2):
        ml = A[l] * A[l + 1]
        mr = A[r] * A[r - 1]
        if ml > mr:
            ans = ans * ml % MOD
            l += 2
        else:
            ans = ans * mr % MOD
            r -= 2

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 31564
// https://atcoder.jp/contests/abc128/tasks/abc128_e

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 2*1e5;
const int Q_MAX = 2*1e5;
const int T_I_MAX = 1e9;
const int X_I_MAX = 1e9;
const int D_Q_MAX = 1e9;

int N, Q;
int S[N_MAX];
int T[N_MAX];
int X[N_MAX];
int D[Q_MAX];

vector<pair<double, int>> vs;
set<int> st;

void solve() {
  REP(i, N) {
    vs.push_back({ S[i] - 0.5 - X[i], i + 1 });
    vs.push_back({ T[i] - 0.5 - X[i], -(i + 1) });
  }
  REP(i, Q) {
    vs.push_back({ D[i], 0 });
  }
  sort(vs.begin(), vs.end());
  for(auto v : vs) {
    // printf("%.1lf %d\n", v.first, v.second);
    int k = v.second;
    if (k == 0) {
      auto it = st.begin();
      if (it == st.end()) {
        puts("-1");
      } else {
        printf("%d\n", *it);
      }
    } else if (k > 0) {
      st.insert(X[k - 1]);
    } else {
      st.erase(X[-k - 1]);
    }
  }
}

void input() {
  scanf("%d%d", &N, &Q);
  REP(i, N) scanf("%d%d%d", S + i, T + i, X + i);
  REP(i, Q) scanf("%d", D + i);
}

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


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

#define int long long

int n;
int a[200010];

signed main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i+1];
        a[i+1] += a[i];
    }

    int ans = LLONG_MAX;
    for(int i = 0;i < n-1;i++){
        ans = min(ans, abs((a[n]-a[i+1])-a[i+1]));
    }

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



Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], m = tmp[1];

	int[][] students = new int[n][];
	for (int i = 0; i < n; i++)
	{
	    students[i] = ReadIntArray();
	}

	int[][] checkpoints = new int[m][];
	for (int i = 0; i < m; i++)
	{
	    checkpoints[i] = ReadIntArray();
	}

	const int M = 4 * 100000000 + 1;
	for (int i = 0; i < n; i++)
	{
	    int a = students[i][0], b = students[i][1];
	    int minD = M;
	    int ans = 0;
	    for (int j = 0; j < m; j++)
	    {
		int c = checkpoints[j][0], d = checkpoints[j][1];
		int distance = Math.Abs(c-a) + Math.Abs(d-b);
		if (distance < minD)
		{
		    ans = j + 1;
		    minD = distance;
		}
	    }
	    WriteLine(ans);
	}
    }
}


Measured memory_bytes: 13396
from collections import deque

H, W = map(int, input().split())
S = [input() for _ in range(H)]

max_cnt = 0

for h in range(H):
    for w in range(W):
        d = [[-1 for _ in range(W)] for _ in range(H)]
        que = deque([(h, w, 0)])
        while len(que) > 0:
            x, y, c = que.popleft()
            if x >= H or x < 0 or y >= W or y < 0:
                continue
            if d[x][y] == -1 and S[x][y] == ".":
                d[x][y] = c
                max_cnt = max(c, max_cnt)
            else:
                continue
            que.append((x + 1, y, c + 1))
            que.append((x - 1, y, c + 1))
            que.append((x, y + 1, c + 1))
            que.append((x, y - 1, c + 1))


print(max_cnt)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD =998244353;

     signed main(){
        int n,s,a,ans=0;
        cin>>n>>s;
        int dp[s+1]={};
         for(int i=1;i<=n;i++){
                 cin>>a;
                 for(int j=s;j>=a;j--)dp[j]=(dp[j]+dp[j-a])%MOD;
                 if(a<=s)dp[a]=(dp[a]+i)%MOD;
                 ans=(ans+dp[s])%MOD;
         }
         
         cout<<ans;

         
}

        


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

int main() {
    string a;
    cin >>a;
    if (a[0]==a[1] && a[1]==a[2]){
        cout << "Yes" << endl;
    }else if (a[3]==a[2] && a[1]==a[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int N; readf("%d\n", &N);
    if (N % 10 == 9 || N / 10 == 9) {
        writeln("Yes");
    } else {
        writeln("No");
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
	int n;
	scanf("%d", &n);
	char str[50][101];
	int input[50];
	for (int i = 0; i < n; i++)
	{
		scanf("%s %d", str[i], &input[i]);
	}
	char temp[101];
	scanf("%s", temp);
	int index;
	for (index = 0; index < n; index++)
	{
		if (strcmp(temp, str[index]) == 0) break;
	}
	int time = 0;
	for (index += 1; index < n; index++)
	{
		time += input[index];
	}
	printf("%d", time);
}

Measured memory_bytes: 128
N, *A = map(int, open(0).read().split())

v1 = 0
v2 = 0
v3 = 0
m = N // 2 *2 
if N % 2 == 0:
  for i in range(0, m, 2):
    v1 += A[i]
    v2 += A[i+1]
    v2 = max(v1,v2)
  print(v2)  
#
else:
  for i in range(0, m, 2):
    v1 += A[i]
    v2 += A[i+1]
    v3 += A[i+2]
    v2 = max(v1,v2)
    v3 = max(v2,v3)
  print(v3)
#
  


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> image(H+2);
  
  string sharp;
  
  for (int i = 0; i < W+2; i++) sharp += "#";
  
  image.at(0) = sharp;
  image.at(H+1) = sharp;
  
  for (int i = 0; i < H; i++) {
    string a;
    cin >> a;
    a = "#" + a + "#";
    image.at(i+1) = a;
  }
  
  for (int i = 0; i < (H+2); i++) {
    cout << image.at(i) << endl;;
  }
}

Measured memory_bytes: 3536
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
int h,w,n;
int a[200000];
int ans[200][200];
signed main(){
  cin >> h >> w >> n;
  REP(i,n) cin >> a[i];
  int now = 0;
  int zan = 0;
  REP(i,h){
    REP(j,w){
      if(zan == 0){
        zan = a[now];
        now ++;
      }
      if(i%2==0){
        ans[i][j] = now;
      }
      else{
        ans[i][w-1-j] = now;
      }
      zan --;
    }
  }
  REP(i,h){
    REP(j,w-1){
      cout << ans[i][j] << " ";
    }
    cout << ans[i][w-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin>>n>>x;
    int a[n];
    int minv=1000000;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<minv)
            minv=a[i];
        sum+=a[i];
    }
    int ans=n+(x-sum)/minv;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,m,t=0;
    cin>>n>>m;
    ll a[m+10];
    for(int i = 0;i < m;i++)
    {
        cin>>a[i];
        t += a[i];
    }
    m = n-t;
    if(m < 0)
    {
        cout<<"-1\n";
    }
    else
    {
        cout<<m<<endl;
    }

}


Measured memory_bytes: 3628
S = input()
y = 0
sum_t = 0
up = False
pre = y
for c in S:
	if c == '<':
		if up:
			y += 1
		else:
			y = 1
		sum_t += y
		up = True
	elif c == '>':
		if up:
			pre = y
			y = 1
		else:
			y += 1
			sum_t += y
			if y <= pre:
				sum_t -=1
		up = False
print(sum_t)

Measured memory_bytes: 4108
#include<bits/stdc++.h>
using namespace std;
const int maxx=1e5+10;
vector<int>graph[maxx];
bool vis[maxx]={0};
int dp[maxx]={0};
int maxdep=0;
int dfs(int n){
	if(graph[n].size()==0)return 0;
	if(vis[n])return dp[n];
	vis[n]=1;
	for(int i=0;i<graph[n].size();i++){
		int t=graph[n][i];
			dp[n]=max(dfs(t)+1,dp[n]);
		}
	return dp[n];
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int v,w;
		scanf("%d%d",&v,&w);
		graph[v].push_back(w);
	}
	fill(dp,dp+n+1,0);
	for(int i=n;i>0;i--){
	if(graph[i].size()!=0){
		for(int j=0;j<graph[i].size();j++){
				int t=graph[i][j];
				dp[i]=max(dfs(t)+1,dp[i]);
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(maxdep<dp[i])
		maxdep=dp[i];
	}
	printf("%d",maxdep);
}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    map<int, int> m;
    for(int i : a) m[i]++;
    
    vector<bool> is_divisible(1000010, false);
    
    int ans = 0;
    for(auto [x, cnt] : m){
        for(int i = 2 * x; i <= 1000000; i += x){
            is_divisible[i] = true;
        }
        if(cnt > 1) continue;
        if(is_divisible[x]) continue;
        ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 17556
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <map>
#include <tuple>
using namespace std;


int main()
{
    int n, k;
    long x;
    cin >> n >> k;
    vector<long> a(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[i] = x;
    }
    for (int i = k; i < n; i++) {
        if (a[i] > a[i - k]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i=0;i<n+1;i++){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  cout << abs(vec[0]-vec[n-1]) << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const ll MAX = 10000;
static const ll INFTY = 1e12;

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

// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
using P = pair<ll, ll>;
// 入力
// 入力
ll h, w;
ll startX, startY, endX, endY;
vector<vector<char>> s;
vector<vector<ll>> cnts; // 魔法使った回数


int main() {

  ll N; cin >> N;
  vector<vector<ll>> A(2, vector<ll>(N, 0));
  // ll A[2][N] = {0};
  ll sum = 0;

  REP(i, 2){
    REP(j, N){
      cin >> A[i][j];
      sum += A[i][j];
    }
  }

  ll sum1[N] = {0};
  sum1[0] = 0;
  REP1(i, N){
    sum1[i] = A[1][i-1]+sum1[i-1];
  }

  ll sum2[N] = {0};
  sum2[N-1] = 0;
  REP1(i, N){
    sum2[N-1-i] = A[0][N-i]+sum2[N-i];
  }
  ll min_ = MAX;
  REP(i, N){
    min_ = min(min_, sum1[i]+sum2[i]);
  }
  // REP(i, N){
  //   cout << sum1[i] << " ";
  // }cout << endl;
  // REP(i, N){
  //   cout << sum2[i] << " ";
  // }cout << endl;
  cout << sum-min_ << endl;


   
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, 0, n){
        cin >> p[i];
        p[i]--;
    }
    map<int, int> mp;
    int ans = 0;
    rep(i, 0, n){
        mp[p[i]] = mp[p[i] - 1] + 1;
        chmax(ans, mp[p[i]]);
    }
    cout << n - ans << endl;
}

Measured memory_bytes: 16000
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	map<int, int>mp;
	mp[1] = 6000;
	mp[2] = 4000;
	mp[3] = 3000;
	mp[4] = 2000;
	for (int i = 0; i < 4; ++i) {
		int t, n; cin >> t >> n;
		cout << mp[t] * n << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
/*
    ALWAYS REMMEMBER:
        NEVER GIVE UP !
        DON'T MESS WITH ME !!!
        "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    ll n,mx=INF,s;
    cin >> n;
    vll a(n);

    f(i,0,n-1)
    {
        cin >> a[i];
    }

    f(i,-110,110)
    {
        s=0;
        f(j,0,n-1)
            s= s + (a[j]-i)*(a[j]-i);
        mx=min(mx,s);
    }
    cout << mx << endl;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int> > Graph;
 
int N;
vector<string> name;
Graph G;
 
void dfs(int v, int depth) {
  cout << string(depth, '.') << name[v] << endl;
  for(int i = 0; i < G[v].size(); ++i) {
    dfs(G[v][i], depth+1);
  }
}
 
int main() {
  cin >> N;
  name = vector<string>(N);
  G = Graph(N);
  for(int i = 0; i < N; ++i) {
    int par; cin >> par; --par;
    cin >> name[i];
    if(par != -1) G[par].push_back(i);
  }
  dfs(0, 0);
  return 0;
}

Measured memory_bytes: 1448
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#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>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


int main() {
	ll n;
	cin >> n;
	vi a(n);
	rep(i,n)
		cin >> a[i];

	sort(reall(a));

	ll ans = 0;
	rep(i,n) {
		if (i % 2 == 0) {
			ans += a[i];
		}
		else {
			ans -= a[i];
		}
	}

	cout << ans << endl;
}

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

int main() {
  int A,B,k,sum=0;cin>>A>>B;
  for(int i=A;i<=B;i++){int j[5];k=0;k+=i;                     
  j[0] = k % 10; k /= 10; j[1] = k % 10; k /= 10; j[2] = k % 10; k /= 10;
  j[3] = k % 10; k /= 10; j[4] = k % 10; k /= 10;
  if(j[0]==j[4]&&j[1]==j[3]){sum++;}
  }
  cout<<sum<<endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll n;
	cin >> n;
	cout << (n/2)*((n+1)/2) << endl;
    return 0;
}

Measured memory_bytes: 256
# 初見分からず
# 各桁数の取り出し方：
# 数値を文字列に変換→文字列を一つずつリストの要素として分離することで可能
n, a, b = map(int, input().split())

sum_number = 0
for i in range(1, n+1):
    sum_digit = sum(map(int, list(str(i))))
    if sum_digit >= a and sum_digit <= b:
        sum_number += i
        
print(sum_number) 

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  vector<int> x(4), y(4);
  cin >> x[0] >> y[0];
  cin >> x[1] >> y[1];
  int dx = x[1] - x[0];
  int dy = y[1] - y[0];
  dump(dx, dy);
  x[2] = x[1] - dy;
  y[2] = y[1] + dx;
  x[3] = x[0] - dy;
  y[3] = y[0] + dx;
  cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
using namespace std;
const int N = 5e5+5;
ll n, m, k, x, y, a, b, t,two,one,q, ans, sum;
char c;
string str;
vector< ll >v;
main()
{
	ios::sync_with_stdio(0);
	cin>>k>>a>>b;
	if(b<=a || (b-a)<=2){
		cout<<k+1<<endl;
		return 0;
	}
	
	k-=(a-1);
	n=a;
	n+=(b-a)*(k/2);
	
	if(k%2==1)
	n++;
	cout<<n<<endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007LL
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    rep(i, sz(v)) cout << v[i] << ",";
    cout << "]";
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N;
int H[100000];
int dp[100000];
int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N;
    rep(i, N) cin >> H[i];

    dp[0] = 0, dp[1] = abs(H[1]-H[0]);
    repp(i, 2, N) dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]));
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 100100;

int n;

ll a[MAXN], b[MAXN], tmp;

int main() {
	scanf("%d",&n);
	REP(i, n) scanf("%lld %lld",&a[i],&b[i]);

	for (int i = n - 1; i >= 0; i--) {
		if ((a[i] + tmp) % b[i] == 0) continue;
		ll t = (a[i] + tmp) / b[i];
		ll raz = (t + 1) * b[i] - (a[i] + tmp);
		tmp += raz;
	}

	printf("%lld\n",tmp);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	ll r;
	cin >> r;
	cout << 3*r*r << endl;

}


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

int main() {
  string s, t;

  cin >> s >> t;

  for ( int i = 0; i < s.size(); i++ ) {
    for ( int j = 0, k = i; j < t.size(); k++) {
      if ( s[k] != t[j++] ) break;
      if ( t[j] == '\0' ) {
        cout << i << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3144
/**   
 *   Author:    @glaucoacassioc
 *   Created on 11.09.2020, 15:32:16
**/
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
vector<vii> AdjList;

vi pai, color, dist, ts;
ll vals[1000002];
ll maxnr = 400000000;
set<ll> s;
void bkt(ll x)
{
	if(s.find(x) != s.end())
		return;

	s.insert(x);
	if(x >= maxnr)
		return;

	if(x == 0)
		for(int i=1; i<=9; i++)
			bkt(i);	
	else
	{
		int lst = x%10;
		if(lst > 0)
			bkt(x*10 + (lst-1));
		bkt(x*10 + lst);
		if(lst < 9)
			bkt(x*10 + (lst+1));
	}
}

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

	cin >> k;
	bkt(0);
	while(k)
	{
		s.erase(s.begin());
		--k;
	}
	cout << *s.begin() << endl;
	return 0;
}             

Measured memory_bytes: 8908
from collections import deque
n, m = map(int, input().split())
E = [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]
V = [[] for _ in range(n)]
for a,b in E:
    V[a].append(b)
    V[b].append(a)

def dfs(a,b,f,i):
    # if i>=n:
    #     return
    if vis[f] == 1: return
    vis[f] = 1
    # print('f',f)
    for t in V[f]:
        if f==a and t == b: continue
        # if t == b: continue
        if vis[t] == 1: continue
        # print(t)
        dfs(a,b,t,i+1)

ans = 0
for a, b in E:
    vis = [0]*n
    dfs(a,b,a,1)
    # print(a,b,vis)
    if vis[b] == 0:
        ans += 1
    # print('----')

# print(E)
# print(V)

print(ans)


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

using namespace std;

int N;
char s[104];

int main(){
    scanf("%d %s", &N, &s);
    int cnt1 = 0, cnt2 = 0;
    for(int i=0;i<N;++i) s[i]=='R'? ++cnt1:++cnt2;
    printf("%s\n", cnt1>cnt2? "Yes":"No");
    return 0;
}


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

using ll = long long;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    rep(i, H) cin >> s[i];
    vector<vector<int>> ans(H, vector<int>(W));
    int a = -1;
    rep(i, H) {
        rep(j, W) {
            if (s[i][j] == '#') a = i;
            if (a != -1) break;
        }
        if (a != -1) break;
    }
    int c = 1;
    for (int i = a; i < H; i++) {
        bool f = false;
        for (int j = 0; j < W; j++) {
            if (s[i][j] == '#') {
                if (f) c++;
                else f = true;
            }
            ans[i][j] = c;
        }
        c++;
        if (i == a) continue;
        if (!f) {
            rep(j, W) ans[i][j] = ans[i - 1][j];
            c--;
        }
    }
    for (int i = a - 1; i >= 0; i--) {
        rep(j, W) {
            ans[i][j] = ans[i + 1][j];
        }
    }
    rep(i, H) {
        rep(j, W) {
            cout << ans[i][j];
            if (j < W - 1) cout << " ";
            else cout << endl;
        }
    }
}

Measured memory_bytes: 1280
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    double l; cin >> l;
    cout << fixed << setprecision(10) << l*l*l/27.0 << endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

template<uint MD>
struct ModInt {
    uint v;
    ModInt() : v{0} {}
    ModInt(ll v) : v{normS(v%MD+MD)} {}
    static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
    static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
    ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
    ModInt operator-(const ModInt &r) const {return make(normS(v+MD-r.v));}
    ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
    ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
    ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
    ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
    static ModInt inv(const ModInt &x) {
        return pow(ModInt(x), MD-2);
    }
};
using Mint = ModInt<TEN(9)+7>;
const int MN = 3030;
int co;
int A[MN], B[MN];

Mint calc(int n, int b) {
    static Mint dp[MN][MN];
    static bool used[MN][MN];
    if (n == co) return 1;
    if (B[n] <= b) return 0;
    if (used[n][b]) return dp[n][b];
    used[n][b] = true;
    Mint &ans = dp[n][b];
    ans = calc(n, b+1);
    if (A[n] <= b) ans += calc(n+1, b+1);
    return ans;
}

int main() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    string t = s;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r; l--;
        sort(s.begin()+l, s.begin()+r);
        sort(t.begin()+l, t.begin()+r, greater<char>());
    }
    co = 0;
    for (int i = 0; i < n; i++) {
        if (t[i] == '0')continue;
        A[co++] = i;
    }
    co = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '0') continue;
        B[co++] = i+1;
    }
    /*  cout << co << endl;
        for (int i = 0; i < co; i++) {
        cout << A[i] << " " << B[i] << endl;
    }*/
    cout << calc(0, 0).v << endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    bool flag=true;
    for (int i=0;i<s.size()/2;i++)
        if(s[i]!=s[s.size()-1-i])
            flag=false;
    int l=0;
    int r=(s.size()-1)/2-1;
    while (l<r){
        if(s[l]!=s[r])
            flag=false;
        l++;
        r--;
    }
    l=(s.size()+3)/2-1;
    r=s.size()-1;
    while (l<r){
        if(s[l]!=s[r])
            flag=false;
        l++;
        r--;
    }
    if(flag) cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;

int main() {
	unsigned long long int n, a[200], count = 0;
	bool f = false;
	cin >> n;
	for (unsigned long long int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] % 2 != 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	while (1) {
		for (unsigned long long int i = 0; i < n; ++i) {
			if (a[i] % 2 != 0) {
				f = true;
			}
			a[i] /= 2;
		}
		if (f) break;
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll mod = 1000000007;

void solve()
{
	string n; cin >> n;
	int k; cin >> k;
	int m=sz(n);
	//dp[i+1][smaller][j]:i桁目までで0以外の数がj個あるものの数
	int dp[105][2][5]={};
	dp[0][0][0]=1;
	rep(i,m)
	{
		rep(j,k+1)
		{
			if(n[i]=='0')
			{
				dp[i+1][0][j]+=dp[i][0][j];
				dp[i+1][1][j]+=dp[i][1][j];
				if(j>0)dp[i+1][1][j]+=dp[i][1][j-1]*9;
			}
			else
			{
				if(j>0)dp[i+1][0][j]+=dp[i][0][j-1];
				dp[i+1][1][j]+=dp[i][0][j]+dp[i][1][j];
				if(j>0)dp[i+1][1][j]+=dp[i][1][j-1]*9+dp[i][0][j-1]*((n[i]-'0')-1);
			}
		}
	}
	int ans = dp[m][0][k]+dp[m][1][k];
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define head(xs) *(xs).begin()
#define last(xs) *(xs).rbegin()
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i32 n;
i64 x[200000], y[200000];
vec<pair<i64, i32>> p;

i32 main()
{
    cin >> n;
    times(n, i) {
        cin >> x[i] >> y[i];
        if (x[i] > y[i]) swap(x[i], y[i]);
        p.append(make_pair(x[i], i));
        p.append(make_pair(y[i], i));
    }
    sortall(p);
    i64 xmin = INT_MAX, xmax = 0;
    i64 ymin = INT_MAX, ymax = 0;
    times(n, i) {
        xmin = min(xmin, x[i]);
        xmax = max(xmax, x[i]);
        ymin = min(ymin, y[i]);
        ymax = max(ymax, y[i]);
    }
    i64 ans = (xmax-xmin)*(ymax-ymin);
    i32 l = p.size() - 1;
    if (p[0].second != p[l].second) {
        i64 a = p[p.size() - 1].first - p[0].first;
        set<pair<i64, i32>> bs;
        bs.insert(make_pair(p[0].first == x[p[0].second] ? y[p[0].second] : x[p[0].second], p[0].second));
        bs.insert(make_pair(p[l].first == x[p[l].second] ? y[p[l].second] : x[p[l].second], p[l].second));
        times(n, i) {
            if (i != p[0].second && i != p[l].second) {
                bs.insert(make_pair(x[i], i));
            }
        }
        i64 b = bs.rbegin()->first - bs.begin()->first;
        times(n, i) {
            if (bs.begin()->second == p[0].second || bs.begin()->second == p[l].second) break;
            if (y[bs.begin()->second] == bs.begin()->first) break;
            i64 v = bs.begin()->first;
            i32 j = bs.begin()->second;
            bs.erase(bs.begin());
            bs.insert(make_pair(y[j], j));
            b = min(b, bs.rbegin()->first - bs.begin()->first);
        }
        ans = min(ans, a*b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//const ll MOD=(ll)1e9+7;
const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

const int MAX = 300010;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//main関数にCOMinit();を忘れない

void solve(int ca){
    COMinit();
    ll N,A,B,K; cin>>N>>A>>B>>K;

    if(A<B) swap(A,B);

    ll maxi=K/A;

    ll ans=0ll;

    for (ll i = maxi; i >= 0; --i) {
        if((K-A*i)/B+i>K) break;
        if((K-A*i)%B!=0) continue;
        ll j = (K-A*i)/B;
        //cout<<i<<" "<<j<<endl;
        (ans+=(COM(N,i)*COM(N,j))%MOD)%=MOD;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

//#define MULTI
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(1);
#endif
    return 0;
}


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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;

#define N 200020
vector<int> adj[N];
vector<lli> prop(N), ans(N);
vector<bool> vis(N);

void dfs(int x, lli pro)
{
    pro += prop[x];
    ans[x] = pro;
    vis[x] = true;
    for(auto y: adj[x]){
        if(vis[y] == false){
            dfs(y, pro);
        }
    }
}

int main()
{
    int n, q;
    cin >> n >> q;
    for(int i=1; i<n; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    while(q--){
        int p, x;
        scanf("%d %d", &p, &x);
        prop[p] += x*1LL;
    }
    dfs(1, 0LL);
    for(int i=1; i<=n; i++){
        cout << ans[i] << " ";
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 25856
'use strict'
function Main(input) {
	input = input.split(' ');
  	let a = input[0];
  	let b = input[1];
	let sum = a*b;
  	let conditionA = a >= 1 && a <= 9;
  	let conditionB = b >= 1 && b <= 9;
  	if (conditionA && conditionB) {
    	console.log(sum);
    } else {
    	console.log('-1')
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int [] ary = new int[k];
    int a = 0;
    for(int c = 0;c<k;c++){
      ary[c] = 1;
        n--;
    }
    ary[0] += n; 
    if(k!=1){
    a = ary[0]-ary[1];
    }
    System.out.print(a);
  } 
}


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

int counter(int x){
    if(x==0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> x(n);
    vector<vector<bool>> y(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < a[i]; j++) {
            int t;
            cin >> t;
            x[i].push_back(t-1);
            bool tt;
            cin >> tt;
            y[i].push_back(tt);
        }
    }

    int cntmax = 0;
    for (int i = 0; i < (1 << n); i++) {
        bool c = true;
        for (int j = 0; j < n; j++) {
            if(i&(1<<j)){
                
                for (int k = 0; k < a[j]; k++) {
                    if(((i>>x[j][k])&1)^y[j][k]){
                        c = false;
                    }
                }
            }
        }

        if(c){
            cntmax = max(cntmax, counter(i));
        }
    }

    cout << cntmax << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N, res = 0;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] & 1) res++;
	}
	cout << (res & 1 ? "NO" : "YES") << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  int N, MA, MB;
  cin >> N >> MA >> MB;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  rep(i, N) cin >> A[i] >> B[i] >> C[i];

  vector<vector<vector<int>>> DP(
      N + 1, vector<vector<int>>(401, vector<int>(401, 1e5)));
  DP[0][0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int a = 400; a >= 0; --a) {
      if ((a + A[i]) > 400) continue;
      for (int b = 400; b >= 0; --b) {
        if ((b + B[i]) > 400) continue;
        DP[i + 1][a][b] = DP[i][a][b];
        DP[i + 1][a + A[i]][b + B[i]] =
            min(DP[i + 1][a + A[i]][b + B[i]], DP[i][a][b] + C[i]);
      }
    }
  }

  int answer = 1e5;
  rep(i, N) {
    for (int a = 1; a <= 400; ++a) {
      for (int b = 1; b <= 400; ++b) {
        // a : b == MA : MB
        if (a * MB != b * MA) continue;
        answer = min(answer, DP[i + 1][a][b]);
      }
    }
  }
  if (answer == 1e5)
    cout << -1 << endl;
  else
    cout << answer << endl;
  return 0;
}


Measured memory_bytes: 30188
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int p,q,r;
    cin>>p>>q>>r;

    cout<<p+q+r-max(max(p,q),r)<<endl;

    return 0;
}






Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

long int FiveTimes(const long int &n){
    return n * n * n * n * n;
}

int main(){
    long int x;
    bool bFind =false;
    scanf("%ld", &x);
    for(long int i = 1; i <= 120; i++){
        if(bFind){
            break;
        }
        for(long int j = -119; j <= 119; j++){
            if(FiveTimes(i) - FiveTimes(j) == x){
                printf("%ld %ld", i, j);
                bFind = true;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3232