akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            int X = 2 * in.nextInt();
            int Y = 2 * in.nextInt();

            long ans = Long.MAX_VALUE;

            for (int c = 0; c <= Math.max(X, Y); c++) {
                int needA = Math.max(0, X - c);
                int needB = Math.max(0, Y - c);

                ans = Math.min(ans, 1L * c * C + 1L * A * ((needA + 1) / 2) + 1L * B * ((needB + 1) / 2));
            }


            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
 
int main(void){
  int i,j,k,n,s;
  char ca[201],can[201];
 
  while(1){
    scanf("%s\n%d", ca, &n);
    if(!strcmp(ca, "-")) break;
    
    for(i=0;i<n;i++){
      scanf("%d", &s);
      for(j=s;ca[j]!='\0';j++)
        can[j-s] = ca[j];
      for(k=0;k<s;k++)
        can[j-s+k] = ca[k];
      
      for(j=0;ca[j]!='\0';j++)
        ca[j] = can[j];
    }
 
    printf("%s\n", ca);
  }
 
  return 0;
}


Measured memory_bytes: 2060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            int locateOfAntennaA = Integer.parseInt(br.readLine());
            br.readLine();
            br.readLine();
            br.readLine();
            int locateOfAntennaE = Integer.parseInt(br.readLine());
            int availableDistance = Integer.parseInt(br.readLine());

            String result = "Yay!";
            if (availableDistance < locateOfAntennaE - locateOfAntennaA) {
                result = ":(";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	
	scanf("%d", &n);
	for (i = 1; i <= n; i++){
		int s;
		int j;
		
		scanf("%d", &s);
		printf("Case %d:\n", i);
		for (j = 0; j < 10; j++){
			char str[16];
			
			sprintf(str, "%08d", s * s);
			s = (str[2] - '0') * 1000;
			s += (str[3] - '0') * 100;
			s += (str[4] - '0') * 10;
			s += str[5] - '0';
			printf("%d\n", s);
		}
	}
	
	return 0;
}

Measured memory_bytes: 616
import java.util.Scanner;

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

        while(in.hasNext()){
            String s = in.nextLine();
            if(s.length() == 2){
                System.out.println(s);
            }else{
                for (int i = s.length() - 1; i >= 0; i--) {
                    System.out.print(s.charAt(i));
                }
                System.out.println();
            }
        }
    }
}


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

int alp[27];
int main() {
    string a;
    cin >> a;
    ll ans=0;
    rep(i, a.size()) {
        ans += i - alp[a[i]-'a'];
        alp[a[i]-'a']++;
    }
    cout << ans+1 << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int m[10];
	rep(i,10)
		cin>>m[i];
	sort(m,m+10);
	cout<<m[9]<<endl;
	cout<<m[8]<<endl;
	cout<<m[7]<<endl;
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=5005,MOD=1e9+7;
int n;
long long dp[MAXN][MAXN];
char s[MAXN];
long long ksm(long long x,long long y)
{
	long long k=1;
	while(y)
	{
		if(y&1)
			k=(k*x)%MOD;
		x=(x*x)%MOD;
		y>>=1;
	}
	return k;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	int len=strlen(s);
	if(n<len)
	{
		printf("0\n");
		return 0;
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i+1][j+1]+=(2*dp[i][j])%MOD;
			dp[i+1][j+1]%=MOD;
			dp[i+1][(j-1)>0?(j-1):0]+=dp[i][j];
			dp[i+1][(j-1)>0?(j-1):0]%=MOD;
		}
	}
	long long ans=(dp[n][len]*ksm((1e9+8)/2,len))%MOD;
	printf("%lld\n",ans);
}

Measured memory_bytes: 195712
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

type Weight = i64;
#[allow(dead_code)]
#[derive(Clone, Debug, Eq, PartialEq)]
struct Edge {
    index: usize,
    src: usize,
    dest: usize,
    weight: Weight,
}
#[allow(dead_code)]
impl Edge {
    fn new(index: usize, src: usize, dest: usize, weight: Weight) -> Edge {
        Edge {
            index: index,
            src: src,
            dest: dest,
            weight: weight,
        }
    }
}
impl std::cmp::Ord for Edge {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        (self.weight, self.src, self.dest).cmp(&(other.weight, other.src, other.dest))
    }
}
impl std::cmp::PartialOrd for Edge {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
type Edges = Vec<Edge>;
type Graph = Vec<Edges>;
#[allow(dead_code)]
fn graph_new(n: usize) -> Graph {
    vec![vec![]; n]
}
#[allow(dead_code)]
fn add_bi_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    graph[dest].push(Edge::new(*index, dest, src, weight));
    *index += 1;
}
#[allow(dead_code)]
fn add_uni_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    *index += 1;
}

fn dfs(from: usize, parent: usize, g: &Graph, weights: &Vec<i64>, counter: &mut Vec<i64>, v: i64) {
    let v = v + weights[from];
    counter[from] = v;
    for edge in g[from].iter() {
        if edge.dest == parent {
            continue;
        }
        dfs(edge.dest, from, g, weights, counter, v);
    }
}

fn main() {
    let n = read::<usize>();
    let q = read::<usize>();
    let mut g = graph_new(n);
    let mut e = 0;
    for _i in 0..n - 1 {
        let a = read::<usize>() - 1;
        let b = read::<usize>() - 1;
        add_bi_edge(&mut g, &mut e, a, b, 0);
    }
    let mut weights = vec![0; n];
    for _i in 0..q {
        let p = read::<usize>() - 1;
        let x = read::<i64>();
        weights[p] += x;
    }
    let mut counter = vec![0; n];
    dfs(0, 0, &g, &weights, &mut counter, 0);
    for i in 0..n {
        if i != 0 {
            print!(" ");
        }
        print!("{}", counter[i]);
    }
    println!("");
}


Measured memory_bytes: 56828
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define int long long 
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; scanf("%d", &___T); for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
int v[maxn], w[maxn], dp[maxn], N , V;
int32_t main()
{
    cin >> N >> V;
    for(int i = 1; i <= N; i++){
        cin >> v[i] >> w[i];
    }
    memset(dp , 0x3f, sizeof dp);
    dp[0] = 0;
    int zz = 0;
    for(int i = 1; i <= N; i++){
        for(int j = zz + w[i]; j >= w[i]; j--){
            dp[j] = min(dp[j], dp[j-w[i]]+v[i]);
        }
        zz+=w[i];
    }
    for(int i = zz;  i>=0; i--){
        dp[i] = min(dp[i],dp[i+1]);
    }
    int ans = 0;
    // for(int i = 1; i<= V;i++){
    //     printf("dp[%lld]===%lld\n",i,dp[i]);
    // }
    while(dp[ans] <= V)ans++;
    cout << ans - 1;
}

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

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

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

string s;
int k;
ll dp[101][2][5];

int main() {
  // INPUT
  cin >> s;
  int n = (int)s.size();
  cin >> k;
  // 初期化
  for (int i = 0; i < 101; i++) for (int j = 0; j < 2; j++) for (int l = 0; l < 5; l++) dp[i][j][l] = 0;
  dp[0][0][0] = 1;
  // ここからDPの遷移定義
  // dp[i][j][l] := 上からi桁目を考えていて、j == 1ならN未満であることが確定、j == 0ならN未満が未確定であり、
  //　上からi桁目までに0以外の数字がl個あるような数の個数
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      for (int l = 0; l <= k; l++) {
        int lim = j == 1 ? 9 : (s[i] - '0');
        for (int m = 0; m <= lim; m++) {
          if (m == lim) {
            if (m == 0) {
              dp[i + 1][j][l] += dp[i][j][l];
            } else {
              dp[i + 1][j][l + 1] += dp[i][j][l];
            }
          } else {
            if (m == 0) {
              dp[i + 1][1][l] += dp[i][j][l];
            } else {
              dp[i + 1][1][l + 1] += dp[i][j][l];
            }
          }
        }
      }
    }
  }
  // 答え
  cout << dp[n][0][k] + dp[n][1][k] << endl;
  return 0;
}


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

using std::cin;
using std::cout;
using std::endl;
using std::string;

int
main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  char color = S[0];
  int variation = 1;
  for (int i = 1; i < N; i++)
  {
    if (S[i] != color)
    {
      color = S[i];
      variation++;
    }
  }
  cout << variation << endl;
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var nums = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);

            for (int i = 0; i < N; i++)
            {
                if (i + 1 != nums[i])
                {
                    var a = nums[i];
                    var b = nums[a - 1];
                    nums[a - 1] = a;
                    nums[i] = b;
                    break;
                }

            }
            Console.WriteLine(Judge(nums));



        }

        private static string Judge(int[] nums)
        {
            var i = 1;
            foreach (var item in nums)
            {
                if (item != i) return "NO";
                i++;
            }
            return "YES";
        }
    }
}



Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll a[MAX * 2];
ll bit[55];
ll le, ri;
int main(void) {
  cin >> n;
  FOR(i, 0, n) {
	cin >> a[i];
  }

  FOR(i, 0, n) {
	ri = i;
	FOR(j, 0, 55) {
	  if (a[ri] >> j&1) bit[j]++;
	}
	while (1) {
	  ok = true;
	  FOR(j, 0, 55) {
		if (bit[j] > 1) ok = false;
	  }
	  if (ok) break;
	  FOR(j, 0, 55)	if (a[le] >> j&1) bit[j]--;
	  le++;
	}
	if (ri - le > 0) {
	  ans += ri - le;
	}
  }

  cout << ans + n << endl;


  return 0;
}

Measured memory_bytes: 1792
import sys

Z = 998244353


def input():
    return sys.stdin.readline().rstrip('\n')


def calc(N, K, LR):
    f = [0] * N
    a = [0] * N
    f[0] = 1
    a[0] = -1
    for i in range(N - 1):
        for (l, r) in LR:
            if i + l - 1 < N:
                a[i + l - 1] = a[i + l - 1] + f[i]
            if i + r < N:
                a[i + r] = a[i + r] - f[i]
        f[i + 1] = (a[i] + f[i]) % Z
    return f[N - 1]


(N, K) = tuple([int(s) for s in input().split()])
LR = [tuple([int(s) for s in input().split()]) for _ in range(K)]
print(calc(N, K, LR))

Measured memory_bytes: 70996
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W, n = map(int, input().split())
    AB = set(tuple(tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(n)))

    d = ((1, 1), (1, 0), (1, -1), (0, 1), (0, 0), (0, -1), (-1, 1), (-1, 0), (-1, -1))
    target = set()
    res = [0] * 10
    for h, w in AB:
        cnt = 0
        flg = True
        for dh, dw in d:
            next_h, next_w = h + dh, w + dw
            if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W:
                flg = False
            if (next_h, next_w) in AB:
                cnt += 1
            else:
                if (next_h, next_w) not in AB:
                    target.add((next_h, next_w))
        if flg:
            res[cnt] += 1

    for h, w in target:
        cnt = 0
        for dh, dw in d:
            next_h, next_w = h + dh, w + dw
            if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W:
                break
            if (next_h, next_w) in AB:
                cnt += 1
        else:
            res[cnt] += 1

    total = (H - 2) * (W - 2)
    res[0] = total - sum(res)
    print(*res, sep="\n")


if __name__ == '__main__':
    resolve()


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

int main() {
  string A;
  cin >> A;
  
  if (A.at(0) == A.at(1)) {
    if (A.at(1) == A.at(2)) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else {
    if (A.at(1) == A.at(2)) {
      if (A.at(2) == A.at(3)) cout << "Yes" << endl;
      else cout << "No" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  
}

Measured memory_bytes: 256
import sys
from collections import deque
if sys.platform =='win32':
  sys.stdin=open('./input.txt')
input = sys.stdin.readline
def MAP(): return [int(x) for x in input().split()]

dy = [-1,0,1,0]
dx = [0,-1,0,1]

H, W = [int(s) for s in input().split()]

M = []

for i in range(H):
	M.append([s for s in input().rstrip()]) 

syx = []
for i in range(H):
	for j in range(W):
		if M[i][j] == '#': syx.append([i,j])
# print(syx)

dist = [[-1 for _ in range(W)] for _ in range(H)]
queue = deque()

for s in syx:
	dist[s[0]][s[1]] = 0

queue.append(syx)

while queue:
	nodelist = queue.popleft()
	# print(nodelist)
	nextnode = []

	for node in nodelist:
		y, x = node
		# print(y,x)
		
		for i in range(4):
			ny = y+dy[i]
			nx = x+dx[i]
			# print(ny, nx)
			
			if ny>=H or ny<0 or nx>=W or nx<0:
				continue
			if dist[ny][nx] != -1:
				continue
			
			if M[ny][nx] == '.':
				dist[ny][nx] = dist[y][x]+1
				nextnode.append([ny,nx])

	# print(nextnode)
	if len(nextnode)!=0:
		queue.append(nextnode)

ans = 0
for d in dist:
  ans = max(ans, max(d))
print(ans)

Measured memory_bytes: 179452
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, m, c, b[20], a[20][20];

signed main() {
	cin >> n >> m >> c;
	rep(i, m)cin >> b[i];
	rep(i, n) {
		rep(j, m) {
			cin >> a[i][j];
		}
	}
	int ta = 0;
	int mu = 0;
	rep(i, n) {
		ta = c;
		rep(j, m) {
			ta += a[i][j] * b[j];
		}
		if (ta > 0)mu++;
	}
	cout << mu << endl;
	ggr
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
using Int = long long;
#include <bitset>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
#define P(r) do{for(auto i:r){cout<<i<<' ';}cout<<'\n';}while(0)
int main()
{
    int N, M; cin >> N >> M;
    int path[8] = {};
    REP(i, M) {
        int a, b; cin >> a >> b;
        a--, b--;
        path[a] |= 1 << b;
        path[b] |= 1 << a;
    }
    function<int(int, int)> recur;
    int finish = (1 << N) - 1;
    recur = [&](int i, int visited) -> int {
        visited |= 1 << i;
        if (visited == finish) return 1;
        int cnt = 0;
        int next = path[i] & ~visited;
        REP(j, N) if (next & (1 << j)) {
            cnt += recur(j, visited);
        }
        return cnt;
    };
    cout << recur(0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <string>
#include <stdio.h>
#include <math.h>
#include <string.h>
#define N 15

using namespace std;

long long number[N];
char s[N];
long long sum;
int len;

void cal()
{
    char t[N];
    sum += (s[0]-'0')*number[len-2];
    sum += (s[len-1]-'0')*number[len-2];
    for (int i=1;i<=len-2;i++)
    {
        sum += (s[i] - '0')*number[len-3];
    }
    int n = 2;
    while (n<len)
    {
        for (int i=0;i<=len-n;i++)
        {
            int k=0;
            for (int j=i;j<i+n && j<len;j++)
            {
                t[k++] = s[j];
            }
            t[k] = '\0';
            long long temp = atoll(t);
            if (!i || i==len-n)
            {
                sum += temp*number[len-3-n+2];
            }
            else
            {
                sum += temp*number[len-4-n+2];
            }
        }
        n++;
    }
    sum += atoll(s);
    return;
}

int main()
{
    scanf("%s",s);
    sum = 0;
    len = strlen(s);
    number[0] = 1;
    for (int i=1;i<N;i++)
    {
        number[i] = number[i-1]*2;
    }
    if (len==1)
    {
        printf("%s\n",s);
    }
    else
    {
        cal();
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int mod = 1e9+7;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> dp(h + 1, vector<int>(w, 0));
    dp[0][0] = 1;

    rep(i, h) {
        rep(j, w) {
            for (int bit = 0; bit < (1 << (w - 1)); ++bit) {
                bool ok = true;
                rep(l, w - 2) {
                    if (((bit >> l) & 1) && ((bit >> (l + 1)) & 1)) {
                        ok = false;
                    }
                }
                if (ok) {
                    if (j >= 1 && ((bit >> (j - 1)) & 1)) {
                        dp[i + 1][j - 1] += dp[i][j];
                        dp[i + 1][j - 1] %= mod;
                    }
                    else if (j <= w - 2 && ((bit >> j) & 1)) {
                        dp[i + 1][j + 1] += dp[i][j];
                        dp[i + 1][j + 1] %= mod;
                    }
                    else {
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= mod;
                    }
                }
            }
        }
    }
    cout << dp[h][k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
#define reg register 
#define LL long long 
using namespace std;

int val,cnt;
int n,a[N],b[N];
vector<int> p,q;

inline int qr()
{
	int x=0,w=1;char a=0;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a<='9'&&a>='0'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

inline LL qrl()
{
	LL x=0,w=1;char a=0;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a<='9'&&a>='0'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

bool mycmp(int a,int b)
{
	return a>b;
}

int main()
{
	n=qr();
	for(register int i=1;i<=n;i++)
		a[i]=qr();
	for(register int i=1;i<=n;i++)
		b[i]=qr();
	sort(b+1,b+n+1,mycmp);
	for(register int i=1;i<=n;i++)
	{
		if(a[i]!=b[i])
			continue;
		cnt++;
		p.push_back(i);
		val=b[i];
	}
	for(register int i=1;i<=n;i++)
	{
		if(!cnt)
			break;
		if(a[i]==b[i])
			continue;
		if(a[i]!=val&&b[i]!=val)
		{
			cnt--;
			q.push_back(i);
		}
	}
	if(cnt)
	{
		printf("No\n");
		return 0;
	}
	for(int i=0;i<q.size();i++)
		swap(b[p[i]],b[q[i]]);
	printf("Yes\n");
	for(register int i=1;i<=n;i++)
		printf("%d ",b[i]);
	printf("\n"); 
	return 0;
} 




Measured memory_bytes: 5784
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int r, d, x;
int main() {
	cin >> r >> d >> x;
	int now = x;
	for (int i = 1; i <= 10; ++i) {
		cout << (x = r * x - d) << endl;
	}
	return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k,q; cin>>n>>k>>q;
  vector<int> P(n,k-q);
  rep(i,q) {
    int a=0; cin>>a;
    P.at(a-1)++;
  }
  rep(i,n){
    if(P.at(i)>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
ll int MMM=inf;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%MMM)if(y&1)z=1ll*z*x%MMM;return z;}
using namespace std;
vi pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.pb(p);
}
bool sortbysecdesc(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    return a.first>b.first;
}
bool cmp(int x,int y){return x>y;}
int cost[100002];
int main()
{
	faltu;
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cost[0]=0;
	for(int i=1;i<n;i++)
	{
		cost[i]=inf;
		for(int j=1;j<=k;j++)
		{
    	    if(j<=i)cost[i]=min(cost[i],cost[i-j]+abs(a[i]-a[i-j]));		
		}
	//	cout<<cost[i]<<endl;
	}
cout<<cost[n-1]<<endl;
}








Measured memory_bytes: 1024
from heapq import heappush as hp, heappushpop as hppp
import sys
Q = int(input())

sumis = 0
sumib = 0
S = []
B = []

geta = 0
k = 0
med = 0

for _ in range(Q):
    #q = input().split()
    q = sys.stdin.readline().split()
    if q[0] == '1':
        k += 1
        m = int(q[1])
        geta += int(q[2])
        if k % 2 == 1:
            if med < m:
                x = hppp(B, m)
                sumib += m - x
                hp(S, -x)
                sumis += x
            else:
                hp(S, -m)
                sumis += m
        else:
            if med < m:
                hp(B, m)
                sumib += m
            else:
                x = -hppp(S, -m)
                sumis += m - x
                hp(B, x)
                sumib += x
        med = -S[0]
        
    else:
        print(med, geta + med*(k%2) - sumis + sumib)


Measured memory_bytes: 70232
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
typedef vector<int> ve;
int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<char>>a(H,vector<char>(W));
    rep(i,H){
        rep(j,W){
            cin>>a[i][j];
        }
    }
  

    rep(i,H){
        if(i==0){
                rep(i,W+2){
                    cout<<"#";
                }
                cout<<endl;
            }
        cout<<"#";
        rep(j,W){
            cout<<a[i][j];
        }
        cout<<"#"<<endl;
      
        if(i==H-1){
             rep(i,W+2){
                    cout<<"#";
                }
                cout<<endl;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
1000000000 1000000000 1000000000 1000000000000000000
)");
#define cin input
#endif

int main()
{
	ll a, b, c, n;
	cin >> a >> b >> c >> n;

	cout << (n % 2 ? b - a : a - b) << endl;

	return 0;
}


Measured memory_bytes: 256
/*
ID: rajiv
TASK: test
LANG: C++14
*/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>
#include<sstream>
#include<iterator>
#include<random>
#include<chrono>

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

using namespace std;

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << '[' << *it << " = " << a << "]  ";
    err(++it, args...);
}
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
int rnd(int a, int b){ // including a and b
	return a+(rng()%(b-a+1));
}
#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sortr(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb push_back
#define endl '\n'

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<lli, lli> tii;
typedef tuple<lli, lli, lli> tiii;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

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

void solve(){
	lli n,k; cin>>n>>k;
	lli ans=k;
	rep(i,n-1){
		ans*=k-1;
	}
	cout<<ans<<endl;
	
}

int main(){
	fast_io
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	freopen("test.out", "w", stdout);
	#endif 
	int tc=1;
	//cin>>tc;
	while(tc--){solve();}
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int X, A, B;
    cin >> X >> A >> B;
    cout << ((X - A) % B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
#define MAX 1000
#define WHITE 0
#define BLACK 1
#define GRAY 2
 
int n,d[MAX],f[MAX],g[MAX][MAX],cl[MAX],t=0;
 
void DFSV(int u){
  int v;
   
  cl[u] = GRAY;
  t++;
  d[u] = t;
   
  for(v=1; v<=n; v++){
    if((g[u][v] == 1)&& (cl[v] == WHITE)){
      DFSV(v);
 
    }
  } 
  cl[u] = BLACK;
  f[u]= ++t;
}
 
int main(){
  int i,j,u,v,k;
   
  scanf("%d",&n);
 
  for(i=1;i<= n; i++){
    for(j=1; j<= n; j++){
      g[i][j] = 0;
    }
  }
 
  for(i=1; i<= n; i++){
    scanf("%d%d",&u,&k);

    for(j=0; j<k; j++){
      scanf("%d",&v);

      g[u][v] = 1;
    }
  }
 
   for(i=1; i<=n; i++){
     cl[i] = WHITE;
    }
 
   for(i=1; i<=n; i++){
     if(cl[i] == WHITE) DFSV(i);
   }
 
  for(i=1; i<=n; i++){
    printf("%d ",i);
    printf("%d ",d[i]);
    printf("%d\n",f[i]);
  }
   
  return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 100007;
const char *YES = "Yes" , *NO = "No";

int n,val[_];
unordered_map<int,int> cnt;
vector<pair<int,int>> temp;

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty(),cnt[val[i]]++;

	if(cnt.count(0) && cnt[0]==n){puts(YES);return 0;}
	if(n%3!=0){puts(NO);return 0;}

	for(auto i:cnt)temp.emplace_back(i);
	
	if(cnt.size()==1)puts(NO);
	else if(cnt.size()==2)
	{
		if(temp[0].second>temp[1].second)swap(temp[0],temp[1]);
		if(temp[0].second!=n/3)puts(NO);
		else if(temp[0].first!=0)puts(NO);
		else puts(YES);
	}
	else if(cnt.size()==3)
	{
		if(temp[0].second!=n/3 || temp[1].second!=n/3 || temp[2].second!=n/3)puts(NO);
		else if((temp[0].first^temp[1].first^temp[2].first)!=0)puts(NO);
		else puts(YES);
	}
	else puts(NO);

	return 0;
}


Measured memory_bytes: 5540
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
A=LI()
print(max(A)-min(A))

Measured memory_bytes: 3316
import java.util.*;

class Rectangle {
    public static void main(String...args) {
        final Scanner sc = new Scanner(System.in);
        final int a = sc.nextInt();
        final int b = sc.nextInt();
        System.out.printf("%d %d\n", a * b, (a + b) * 2);
    }
}
public class Main {
    public static void main(String... args) {
        Rectangle.main();
    }
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
using namespace std;
#define endl              "\n"
#define pb              push_back
#define fir               first
#define sec               second
#define all(v)            ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define ll              long long
#define ld              long double
#define lp(i, n)        for(int i = 0 ; (int)i<n ; i++)
#define loop(i, x, n)       for(int i=x ; (int)i<=n ; i++)
#define isPowerOfTwo(s) (!(s & (s-1)))
typedef vector<int> vi;
typedef deque<int> de;
void origi() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
//vector<pair<int, pair<int , pair<int, int>>>>vec;
void tiranga() {
    int n;
    cin >> n;
    vector<int>orig;
    vector<int>arr;
    lp(i, n) {
        int x;
        cin >> x;
        orig.pb(x);
        arr.pb(x);
    }
    sort(arr.begin() , arr.end());
    int Max = arr[n - 1], pre = arr[n - 2];
    lp(i, n) {
        if (orig[i] == Max)
            cout << pre << endl;
        else
            cout << Max << endl;
    }
}
int main() {
#ifndef ONLINE_JUDGE.
    //freopen("input.txt", "r", stdin);
#else
#endif
    
    origi();
    tiranga();
    //cout << sumOfDig(123654);
   // genLarge(10, 10);
   // genSmall(10);

}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define PB push_back
#define MP make_pair
#define IN insert
#define F first
#define S second

#define repa(i,fr,to,inc) for(int i = fr ; i <= to ; i += inc)
#define repb(i,fr,to,dec) for(int i = fr ; i >= to ; i -= dec)

clock_t present = clock();
void complexiti(){present = clock() - present;cerr << "TIME : " << float(present)/CLOCKS_PER_SEC << '\n';}
ll nax = 1000000LL * 1000000LL * 1000000LL;


void solver(){
	//~ type your code here
	ll n;
	cin >> n;
	cout << n*(n-1)/2 << endl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int queries = 1;
	//~ cin >> queries;
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	complexiti();
	return 0;
}


Measured memory_bytes: 256
S = input()
S1 = int(S[:2])
S2 = int(S[2:])
if 0 < S1 and S1 < 13:
	if 0 < S2 and S2 < 13:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 0 < S2 and S2 < 13:
		print("YYMM")
	else:
		print("NA")

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

int main()
{
    int n;
    cin>>n;
    int counter=1,j=1,flag=0,k=0;

   for(int i=1;i<=9;i++)
   {
       if(i<=n)flag++;
   }

      for(int i=100;i<=999;i++)
   {
       if(i<=n)flag++;
   }

      for(int i=10000;i<=99999;i++)
   {
       if(i<=n)flag++;
   }



   cout<<flag<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll T;
  cin >> T;
  vector<ll> t;
  for (int i = 0; i < N; ++i) {
    ll time;
    cin >> time;
    t.push_back(time);
  }
  t.push_back(Mod * 100LL);
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (t[i+1] - t[i] > T) {
      ans += T;
    } else {
      ans += t[i+1] - t[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5296
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int CH[300002] = {0};
int CW[300002] = {0};

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H, W, M;
	cin >> H >> W >> M;
	map<int, int> HM, WM;
	map<pair<int, int>, int> MM;
	for(int i=0; i<M; i++){
		int h, w;
		cin >> h >> w;
		CH[h]++;
		CW[w]++;
		MM[make_pair(h, w)] = 1;
	}
	
	int hmax = 0, wmax = 0;
	for(int i=1; i<=max(H, W); i++){
		if(i <= H && hmax < CH[i]){
			hmax = CH[i];
		}
		if(i <= W && wmax < CW[i]){
			wmax = CW[i];
		}
	}
	map<int, int> M1, M2;
	for(int i=1; i<=max(H, W); i++){
		if(i <= H && CH[i] == hmax){
			M1[i] = hmax;
		}
		if(i <= W && CW[i] == wmax){
			M2[i] = wmax;
		}
	}
	LL prod = (LL)M1.size() * (LL) M2.size() ;
	if(prod > M){
		printf("%d\n", hmax + wmax);
		return 0;
	}

	int exist = 0;
	for(auto itr1 = M1.begin(); itr1 != M1.end(); itr1++){
		for(auto itr2 = M2.begin(); itr2 != M2.end(); itr2++){
			int a = itr1->first;
			int b = itr2->first;
			if(MM.count(make_pair(a, b)) == 0){
				exist = 1;
				break;
			}
		}
		if(exist == 1){
			break;
		}
	}
	if(exist == 1){
		printf("%d\n", hmax + wmax );
	}
	else{
		printf("%d\n", hmax + wmax - 1);
	}
	return 0;
}

Measured memory_bytes: 52896
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Scanner.Scan<string>();
            Console.WriteLine(new string(Enumerable.Repeat('x', S.Length).ToArray()));
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

int imos[100005];
int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        imos[l]++;
        imos[r + 1]--;
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) imos[i + 1] += imos[i];
    for (int i = 0; i <= n; i++) {
        if (imos[i] == m) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#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(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#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 pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n, k;
  cin >> n >> k;
  vi l(n + 1, -1), dice(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    dice[i] = i;
  }
  int cnt = 0, ok = 0;
  while (ok!=n) {
    for (int i = 1; i <= n; i++) {
      if (l[i] != -1) continue;
      if (dice[i] >= k) {
        l[i] = cnt;
        ok++;
      }
      dice[i] *= 2;
    }
    cnt++;
  }
  long double ans = 0,ave = 1.0/(long double)n;
  for(int i = 1;i<=n;i++){
    //show(l[i]);
    ans+= powf64x(0.5,l[i]);
  }
  printf("%.10Lf\n",ave*ans);
  return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define LL long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 1e6 + 5;

LL n, m, tmp, ans;

void solve() {
    scanf("%lld %lld", &n, &m);
    if(n == 1LL || m == 1LL) {
        puts("1"); return ;
    }
    tmp = n * m;
    ans = tmp % 2LL;
    tmp = tmp / 2LL;
    ans = ans + tmp;
    printf("%lld\n", ans);
}

int main() {
//    int _; scanf("%d", &_);
//    while(_--) solve();

    solve();

    return 0;
}


Measured memory_bytes: 256
N,W = map(int,input().split())
item = [list(map(int,input().split())) for _ in range(N)]

dp = [0 for _ in range(W+1)]

for i in range(N):
    v,w = item[i]
    for j in range(W+1):
        if j-w>=0:
            dp[j] = max(dp[j-w]+v,dp[j])

print(dp[W])


Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
int n,i,u,v,par[100005],dis[100005]={0},far[100005]={0};
vector<int> g[100005];
bool used[100005]={0};

void dfs(int x){
    used[x]=true;
    dis[x]=dis[par[x]]+1;
    far[x]=dis[x];
    for(int ii=0;ii<g[x].size();ii++){
        if(!used[g[x][ii]]){
            par[g[x][ii]]=x;
            dfs(g[x][ii]);
        }
    }
    far[par[x]] = max(far[par[x]],far[x]);
}

int main() {
    // your code goes here
    int a,b,d=0,dk=0,e,p,ans=0,memo=0,pb,mp,ff,ss;
    cin >> n >> u >> v;
    for(i=1;i<n;i++){
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    par[v]=0;
    dis[0]=-1;
    dfs(v);
    for(i=1;i<=n;i++) if(far[i]==0) far[i]=dis[i];
    p = u;
    dk=dis[u];
    while(1){
    	mp=0; //kaisuu
    	pb=dk; //kyori
    	memo++;
        p = par[p];
        mp=memo;
        if(pb%2==0) ss=pb/2;
        else ss=(pb-1)/2;
        if(pb<=2*memo){
        	ans=max(ans,ss);
        	break;
        }
        pb=pb-2*memo;
        ff=far[p]-dis[p];
        mp+=ff;
        if(pb%2==0) ss=pb-1;
        else ss=pb-1;
        mp+=ss;
        ans=max(ans,mp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10880