akhauriyash/Code-Regression huggingface dataset:
<?php
$str = trim(fgets(STDIN));
$k = intval(fgets(STDIN));
$abc = "";
for($a = "a"; $a != "aa"; $a++){
    $abc.=$a;
}
for($i = 0; $i < strlen($str); $i++){
    if($str[$i] <> "a"){
        $left = 26-strpos($abc,$str[$i]);
        if($left <= $k){
            $k-=$left;
            $str[$i] = "a";
        }
    }
}
for($i = 0; $i < $k % 26; $i++){
    $aa = $str[strlen($str)-1];
    $aa++;
    $str[strlen($str)-1] = $aa;
}
echo $str,"\n";

Measured memory_bytes: 4728
#include<stdio.h>
int main()
{
    char a[101],b[101], c[201];
    int n, i = 0,j = 0, count = 0;
    scanf("%d",&n);
    scanf("%s%s",a,b);
    while(n--){
            c[count++] = a[i++];
            c[count++] = b[j++];
    }
    c[count] = '\0';
    puts(c);
    return 0;
}

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

int main() {
  char a;
  cin>>a;
  if(a=='a'||a=='i'||a=='u'||a=='e'||a=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

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

i = 0
s = 0
while i < K:
	s += p_list[i]
	i += 1

m = 0
while True:
	if m < s:
		m = s
	if i == N:
		break
	s += p_list[i] - p_list[i - K]
	i += 1

print((K + m) / 2)


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

typedef long long ll;
using namespace std;

int main(void){
    int N;
    cin >> N;
    ll ans = 0;
    int iBuf;
    int iBuf2;
    for(int i = 1; i < N; i++)
    {
        iBuf = N /i;
        iBuf2 = N % i;
        if(iBuf2 == 0)
        {
            ans = ans + iBuf -1;
        } 
        else
        {
            ans = ans + iBuf;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3668
#include <string.h>
#include <stdio.h>

int main()
{
  char s[4];
  scanf("%s", &s);
  if (strcmp(s, "SUN") == 0)
    printf("7");
  else if (strcmp(s, "MON") == 0)
    printf("6");
  else if (strcmp(s, "TUE") == 0) 
    printf("5");
  else if (strcmp(s, "WED") == 0) 
    printf("4");
  else if (strcmp(s, "THU") == 0) 
    printf("3");
  else if (strcmp(s, "FRI") == 0) 
    printf("2");
  else if (strcmp(s, "SAT") == 0)
    printf("1");
}


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

int mod = 998244353;
    
int main(){
    int n, s;
    cin >> n >> s;
    int a[n];
    rep(i,n) cin >> a[i];
    int DP[n+1][s+1];
    rep(i,n+1){
        rep(j,s+1) DP[i][j] = 0;
    }

    DP[0][0] += 1;

    for(int i=1; i<n+1; i++){
        rep(j,s+1){
            DP[i][j] = (DP[i][j] + (2*DP[i-1][j]) % mod) % mod;
            if(j+a[i-1]<=s){
                DP[i][j+a[i-1]] = (DP[i][j+a[i-1]] + DP[i-1][j] % mod) % mod;
            }
        }
    }

    cout << DP[n][s] << endl;
    return 0;
}

Measured memory_bytes: 38744
#include <bits/stdc++.h>
using namespace std;
     
int main() {
    int   N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);

    for (int i = 0; i < N; i++) {
      cin >> V.at(i);
    }
    for (int i = 0; i < N; i++) {
      cin >> C.at(i);
    }         
    int ans = 0;
    for (int i = 0; i < N; i++){
      if (V.at(i) - C.at(i) > 0){
        ans += V.at(i) - C.at(i);
      }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		int n = scan.nextInt();
		int sintyou[] = new int[6];
		for(int i = 0 ; i < n ; i++){
			double hito = scan.nextDouble();
			if(hito >= 185.0){
				++sintyou[5];
			}else if(hito >= 180.0){
				++sintyou[4];
			}else if(hito >= 175.0){
				++sintyou[3];
			}else if(hito >= 170.0){
				++sintyou[2];
			}else if(hito >= 165.0){
				++sintyou[1];
			}else{
				++sintyou[0];
			}
		}
		for(int i = 0 ; i < 6 ; i++){
			System.out.print(i+1 + ":");
			for(int j = 0 ; j < sintyou[i] ; j++){
				System.out.print("*");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 28092
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

vector<string> pmap;
bool skip[101];

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

	int H, W;
	string s;

	cin >> H >> W;
	rep(i, 0, H)
	{
		cin >> s;
		if (count(all(s), '#') > 0)
		{
			pmap.push_back(s);
		}
	}

	int j = 0;
	rep(j, 0, W)
	{
		skip[j] = true;
		rep(i, 0, SZ(pmap))
		{
			if (pmap[i][j] == '#')
			{
				skip[j] = false;
				break;
			}
		}
	}

	rep(i, 0, SZ(pmap))
	{
		rep(j, 0, W)
		{
			if (skip[j])continue;
			cout << pmap[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

Graph g;

vector<int> color;
void dfs(int v, int p, int d = 0){ 
  color[v] = d % 2; 
  for(auto nv : g[v]){
    if(nv == p)continue;
    dfs(nv, v, d + 1);
  }
}

int main(){
  int n;
  cin >> n;

  g.resize(n);
  for(int i = 0; i < n - 1; ++i){ 
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }


  stack<int> r0;
  stack<int> r1;
  stack<int> r2;
  for(int i = 1; i <= n; ++i){
    if(i % 3 == 0)r0.push(i);
    else if(i % 3 == 1)r1.push(i);
    else r2.push(i);
  }

  color.resize(n);
  dfs(0, -1);
  int blackcnt = 0;
  for(int i = 0; i < n; ++i){
    if(color[i] % 2)++blackcnt;
  }

  int flg = 1;
  int cnt = max(blackcnt, n - blackcnt);
  if(cnt != blackcnt)flg = 0; 

  if(r1.size() + r2.size() <= cnt){ 
    for(int i = 0; i < n; ++i){
      if(color[i] % 2 == flg){
        if(!r1.empty()){
          cout << r1.top() << " ";
          r1.pop();
        }
        else if(!r2.empty()){
          cout << r2.top() << " ";
          r2.pop();
        }
        else{
          cout << r0.top() << " ";
          r0.pop();
        }
      }
      else{
        cout << r0.top() << " ";
        r0.pop();
      }
    }
  }
  else{ 
    for(int i = 0; i < n; ++i){
      if(color[i] % 2 == flg){
        if(!r1.empty()){
          cout << r1.top() << " ";
          r1.pop();
        }
        else{
          cout << r0.top() << " ";
          r0.pop();
        }
      }
      else{
        if(!r2.empty()){
          cout << r2.top() << " ";
          r2.pop();
        }
        else{
          cout << r0.top() << " ";
          r0.pop();
        }
      }
    }
  }
}


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

int main() {
  string O,E;
  cin >> O;
  cin >> E;
  E = E + ' ';
  string answer;
  
  for(int i = 0;i < O.size();i++) {
    answer = answer + O.at(i);
    answer = answer + E.at(i);
  }
  cout << answer << endl;
}

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

typedef signed long long ll;
typedef long double ld;

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

#define DEBUG

int main()
{
	int r, d;
	ll x;
	cin >> r >> d >> x;
	rep(i, 10)
	{
		x = r*x - d;
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    q = partition(a_s, 0, n-1)

    def display(index, a):
        if index == q:
            return '[{}]'.format(a)
        else:
            return str(a)

    print(' '.join([display(i, a) for i, a in enumerate(a_s)]))


def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1


if __name__ == "__main__":
    main()



Measured memory_bytes: 16392
void main() {
	auto N = ri;
	alias Pair = Tuple!(int, "a", int, "b");
	Pair[] pairs;
	foreach(i; 1..N+1) foreach(j; i+1..N+1) {
		if(N % 2 == 0 && N - i + 1 == j) continue;
		if(N % 2 == 1 && N - i == j) continue;
		pairs ~= Pair(i, j);
	}
	pairs.count.writeln;
	pairs.each!(p => writefln("%d %d", p[0], p[1]));
}

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

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

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

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

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

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 380
import sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()
s = sorted([I() for _ in range(N)])
ans = sum(s)
if ans%10==0:
    for x in s:
        if x%10!=0:
            ans -= x
            break
    else:
        ans = 0
print(ans)


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

double dp[301][301][301];
double f(int n, int i, int j, int k) {
  if (dp[i][j][k] >= 0.0) return dp[i][j][k];
  if (i == 0 && j == 0 && k == 0) return 0.0;

  double res = 0.0;
  if (i > 0) res += f(n, i - 1, j, k) * i;
  if (j > 0) res += f(n, i + 1, j - 1, k) * j;
  if (k > 0) res += f(n, i, j + 1, k - 1) * k;
  res += n;
  res *= 1.0 / (i + j + k);
  return dp[i][j][k] = res;
}

int main() {
  int n;
  cin >> n;
  vector<int> cnt(3);
  rep(i, n) {
    int a;
    cin >> a;
    cnt[a - 1]++;
  }
  memset(dp, -1, sizeof(dp));
  double ans = f(n, cnt[0], cnt[1], cnt[2]);
  printf("%.10lf\n", ans);
  return 0;
}

Measured memory_bytes: 213376
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <time.h>

#define loop(i, num)  for (int i = 0; i < num; i++)

using namespace std;

int n, a, b;

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


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

int main(){
	int n;
	cin >> n;
	int a[n] = {0};
	int memo = 0;
	bool is_used[n] = {false};
	
	rep(i,0,n){
		cin >> a[i];
		memo += a[i];
	}
	
	if(memo % 10 != 0){
		cout << memo << endl;
		return 0;
	}
	
	sort(a,a+n);
	
	rep(i,0,n){
		rep(j,0,n){
			if(i > j){
				continue;
			}
			if((memo - a[j]) % 10 != 0){
				cout << memo - a[j] << endl;
				return 0;
			}
		}
		memo -= a[i];
	}
	
	cout << 0 << endl;
	
	return 0;
}

Measured memory_bytes: 256
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;


int main() {
    string s;
    cin>>s;

    int count = 0;
    for(int i = 0;i<s.size();i++){
        if((i+1)%2==1){
            if(s[i]=='D'||s[i]=='R'||s[i]=='U'){
                count ++;
            }
        }else if((i+1)%2==0){
            if(s[i]=='L'||s[i]=='D'||s[i]=='U'){
                count ++;
            }
        }
    }
    if(count == s.size()){
        std::cout<<"Yes";
    }else{
        std::cout<<"No";
    }

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <map>

using namespace std;

const int W = 4, H = 5;
map<string, int> memo;

inline int next(int pos, int dy, int dx)
{
    if (dy == 0 && dx == 0)
        return -1;
    int x = (pos % W) + dx, y = (pos / W) + dy;
    if (x < 0 || y < 0 || x >= W || y >= H)
        return -1;
    return y * W + x;
}

int Rec(string s)
{
    if (memo.end() != memo.find(s))
        return memo[s];

    int res = s.size();

    for (int i = 0; i < s.size(); ++i) {
        for (int dy = -1; dy <= 1; ++dy) {
            for (int dx = -1; dx <= 1; ++dx) {
                int nx = next(i, dy, dx);
                if (nx == -1 || nx >= s.size())
                    continue;
                if (s[i] != s[nx])
                    continue;

                string tmp("", (int)s.size() - 2);
                int index = 0;
                for (int l = 0; l < s.size(); ++l)
                    if (l != i && l != nx)
                        tmp[index++] = s[l];

                res = min(res, Rec(tmp));
            }
        }
    }

    memo.insert(map<string, int>::value_type(s, res));
    return res;
}

int main()
{
    int N;

    cin >> N;
    while (N--) {
        // Input
        char ch;
        string card;

        for (int i = 0; i < H * W; ++i) {
            cin >> ch;
            card += ch;
        }
        // Solve
        cout << Rec(card) << endl;
    }

    return 0;
}

Measured memory_bytes: 1576
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)

	am := make(map[int]int)
	bm := make(map[int]int)

	a := A
	for i := 2; i*i <= A; i++ {
		if a%i != 0 {
			continue
		}
		for a%i == 0 {
			am[i]++
			a /= i
		}
	}
	if a != 1 {
		am[a]++
	}
	b := B
	for i := 2; i*i <= B; i++ {
		if b%i != 0 {
			continue
		}
		for b%i == 0 {
			bm[i]++
			b /= i
		}
	}
	if b != 1 {
		bm[b]++
	}
	count := 1
	for k := range am {
		if _, ok := bm[k]; ok {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1860
use std::cmp::min;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!(
    n: usize,
    k: usize,
    );
    let ans = min(k - n % k, n % k);
    println!("{}", ans);
}


Measured memory_bytes: 4352
h,w=map(int,input().split())
alist=[]
numans=list(range(h))
for i in range(h):
    a=list(input())
    alist.append(a)
for i in range(h):
    if alist[h-i-1].count(".")==w:
        numans.remove(h-i-1)
lena=len(alist)
yn=0
for i in range(w):
    for j in range(lena):
        if alist[j][w-i-1]!=".":
            yn=1
    if yn==0:
        for j in range(lena):
            del alist[j][w-i-1]
    yn=0
c=""
lena=len(alist[0])
for i in numans:
    for j in range(lena):
        c+=alist[i][j]
    print(c)
    c=""


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main()
{
	cin>>s1>>s2;
	for(int i=0;i<=max(s1.size(),s2.size())-1;i++)
	{
		if(i>(s1.size()-1))
		{
			cout<<s2[i];
			continue;
		}
		if(i>(s2.size()-1))
		{
			cout<<s1[i];
			continue;
		}
		cout<<s1[i]<<s2[i];
	}
	return 0;
}

Measured memory_bytes: 256
package main

// http://www.prefield.com/algorithm/graph/tree_diameter.html

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

var infty = 1000000000

var scanner = bufio.NewScanner(os.Stdin)

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

type DirectedGraphNodeID int

func newDirectedGraph(nNodes int) *DirectedGraph {
	graph := DirectedGraph{}

	graph.nodes = make([]*DirectedGraphNode, nNodes)
	for iNode := 0; iNode < nNodes; iNode++ {
		graph.nodes[iNode] = &DirectedGraphNode{
			key:       DirectedGraphNodeID(iNode),
			adjacents: map[DirectedGraphNodeID]*DirectedGraphNode{},
			costs:     map[DirectedGraphNodeID]int{},
			d:         infty,
		}
	}

	return &graph
}

type DirectedGraph struct {
	nodes []*DirectedGraphNode
	time  int
}

func (graph *DirectedGraph) sedAdjacent(leftID, rightID DirectedGraphNodeID, weight int) {
	graph.nodes[leftID].adjacents[rightID] = graph.nodes[rightID]
	graph.nodes[leftID].costs[rightID] = weight
}

type DirectedGraphNode struct {
	key       DirectedGraphNodeID
	adjacents map[DirectedGraphNodeID]*DirectedGraphNode
	costs     map[DirectedGraphNodeID]int

	parent   *DirectedGraphNode
	d, f     int
	visitied bool
	distance int
}

func dfsVisit(graph *DirectedGraph, startNode *DirectedGraphNode) {
	graph.time++
	startNode.d = graph.time
	startNode.visitied = true

	for adjacentID, adjacent := range startNode.adjacents {
		if !adjacent.visitied {
			adjacent.parent = startNode
			adjacent.distance = startNode.distance + startNode.costs[adjacentID]
			dfsVisit(graph, adjacent)
		}
	}
	graph.time++
	startNode.f = graph.time
}

func fillDistances(graph *DirectedGraph, startNode *DirectedGraphNode) {
	for _, node := range graph.nodes {
		node.visitied = false
		node.parent = nil
		node.distance = infty
	}
	graph.time = 0
	startNode.distance = 0
	dfsVisit(graph, startNode)
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func getFarthestNode(graph *DirectedGraph) *DirectedGraphNode {
	maxDistance := 0
	var nodeMaxDistance *DirectedGraphNode
	for _, node := range graph.nodes {
		if node.distance >= maxDistance {
			maxDistance = node.distance
			nodeMaxDistance = node
		}
	}
	return nodeMaxDistance
}

func main() {
	scanner.Split(bufio.ScanWords)

	nNodes := nextInt()
	graph := newDirectedGraph(nNodes)
	for iNode := 0; iNode < nNodes-1; iNode++ {
		parent := DirectedGraphNodeID(nextInt())
		child := DirectedGraphNodeID(nextInt())
		weight := nextInt()
		graph.sedAdjacent(parent, child, weight)
		graph.sedAdjacent(child, parent, weight)
	}

	fillDistances(graph, graph.nodes[0])
	nodeMaxDistance := getFarthestNode(graph)
	// fmt.Println(nodeMaxDistance)

	fillDistances(graph, nodeMaxDistance)
	nodeMaxDistance = getFarthestNode(graph)
	fmt.Println(nodeMaxDistance.distance)
}



Measured memory_bytes: 101512
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}


int main(){ 
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i,s.length()){
    if(s[i] == t[i])continue;
    else{
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3928
nk = list(input().split())
n = nk[0]
k = nk[1]
a = []
c = 0
for i in range(int(k)):
  d = int(input())
  b = list(input().split())
  a.extend(b)
for j in range(1,int(n)+1):
  if str(j) not in a:
    c = c+1
print(c)

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

int main() {
  int N,K;
  cin>>N>>K;
  
  vector<int> vec(0);
  while(N>=K){
    int a=N%K;
    vec.push_back(a);
    N=N/K;
  }
  vec.push_back(N);
  reverse(vec.begin(),vec.end());
  
  cout<<vec.size()<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
int n,m;
cin>>n>>m;
cout<<n*m<<endl;

  return 0;
}


Measured memory_bytes: 3212
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();

        int[] arr = new int[]{a, b, c};
        Arrays.sort(arr);

        for (int i = 0; i < k; i++) {
            arr[2] *= 2;
        }

        int sum = 0;
        for (int i = 0; i < 3; i++) {
            sum += arr[i];
        }

        System.out.println(sum);
    }
}


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

template <class T1> void write(T1 e)
{
    cout << e << endl;
}
template <class T1,class T2> void write(T1 e1,T2 e2)
{
    cout << e1 << " "<< e2 << endl;
}
template <class T1,class T2,class T3> void write(T1 e1,T2 e2,T3 e3)
{
    cout << e1 << " " << e2 << " " << e3 << endl;
}

#define oo          (1<<30)
#define SZ(a)       (int)a.size()
#define LL          long long int
#define ULL         unsigned long long
#define ISS         istringstream
#define OSS         ostringstream
#define VS          vector <string>
#define VI          vector <int>
#define VD          vector <double>
#define VLL         vector <long long>
#define SII         set<int>::iterator
#define SI          set<int>
#define mem(a,b)    memset(a,b,sizeof(a))
#define fs          first
#define sc          second
#define pii         pair < int , int >

#define EQ(a,b)     (fabs(a-b)<ERR)
#define all(a,b,c)  for(int I=0;I<b;I++)    a[I] = c
#define CROSS(a,b,c,d) ((b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y))
#define sqr(a)      ((a)*(a))
#define FORE(i,a)   for(typeof((a).begin())i=(a).begin();i!=(a).end();i++)
#define BE(a)       a.begin(),a.end()
#define RBE(a)      a.rbegin(),a.rend()
#define rev(a)      reverse(BE(a));
#define sorta(a)    sort(BE(a))
#define pb          push_back
#define popb        pop_back
#define Round(i,a)  i = ( a < 0 ) ? a - 0.5 : a + 0.5;

#define makeint(n,s)  istringstream(s)>>n
#define string_to_int(str) atoll(str.c_str());

#define LCM(A,B)    ((__gcd(A,B))/A)*B
#define GCD(A,B)     __gcd(A,B)

#define YES     write("YES")
#define Yes     write("Yes")
#define yes     write("yes")
#define NO      write("NO")
#define No      write("No")
#define no      write("no")

#define read()      freopen("test.txt","r",stdin)
#define write_file()     freopen("WA.txt", "w", stdout);
#define Faster      {ios_base::sync_with_stdio(false); cin.tie(0);}

#define PI          3.141592653589793
#define pi          2*acos(0)
#define gama        0.57721566490
#define ERR         1e-5
#define PRE         1e-8
#define MAX         1000009

#define Scan(A)         scanf("%lld", &A)
#define Scan2(A, B) 	scanf("%lld %lld",&A, &B)
#define Scan3(A, B, C) 	scanf("%lld %lld %lld",&A, &B, &C)
#define Scan4(A, B, C, D) 	scanf("%lld %lld %lld %lld",&A, &B, &C, &D)

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

bool isvowel(char ch)
{
    ch = tolower(ch);
    return ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u';
}

struct myStruct
{
    LL Sum;
    string name;
    string Party;
};

bool cmp(myStruct a, myStruct b)
{
    return a.Sum > b.Sum ? 0 : 1;
}

map <char, int> Mp;

void Method()
{
    int j = 0;
    for(char i = 'a'; i <= 'z'; i++)
    {
        char temp = (char) i;
        Mp[temp] = j;
        j++;
    }
}

int main()
{
    string str;
    while(cin >> str)
    {
        string ans = "2018" + str.substr(4, str.length());
        write(ans);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i>=k){
            if(a[i]>a[i-k])cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4372
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define COUT(x) cout << (x) << endl
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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


int main() {
    int n, l;
    cin >> n >> l;
    int ans = 0, value = l + n - 1;
    rrep(i, n) ans += l + i -1;
    if(value < 0) COUT(ans - value);
    else if(l > 0) COUT(ans - l);
    else COUT(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;

int main(void)
{
    cout << std::fixed << std::setprecision(10);
    int n;
    int answer = 0;
    int m1;
    std::vector<int> number;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &m1);
        number.push_back(m1);
    }

    for (int i = 0; i <= n; i++)
    {
        if (number[i] == i + 1)
        {
            if (i + 1 < n && number[i + 1] == i + 2)
            {
                answer++;
                i++;
            }
            else
            {
                answer++;
            }
        }
    }

    cout << answer << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back


ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ASC(A);
    ll setG = A[0];
    REP(i,1,N) setG = gcd(A[i], setG);

    vec P(A[N-1]+1, 1);
    REP(i,0,A[N-1]+1) P[i] = i;
    for(ll i=2; i*i<=A[N-1]; ++i) {
        if(P[i] == i) {
            for(ll j=2; i*j<=A[N-1]; ++j) {
                if(P[i*j] == 1) P[i*j] = i;
                else P[i*j] = MIN(i,P[i*j]);
            }
        }
    }

    mat Q(N);
    REP(i,0,N) {
        ll k = A[i];
        while(k > 1) {
            if(SZ(Q[i]) == 0) Q[i].pb(P[k]);
            else if(Q[i].back() != P[k]) Q[i].pb(P[k]);
            k /= P[k];
        }
    }

    bool f = true;
    map<ll,ll> R;
    REP(i,0,N) {
        FORR(v,Q[i]) ++R[v];
    }
    FORR(r,R) {
        if(r.second > 1) f = false;
    }
    
    if(f) PR("pairwise coprime");
    else {
        if(setG == 1) PR("setwise coprime");
        else PR("not coprime");
    }

    return 0;
}

/*



*/

Measured memory_bytes: 117096
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        int[] a=new int[M+1];
        int[] b=new int[M+1];
        int[] count=new int[N+1];
        for(int i=0;i<M;i++){
            a[i+1]=sc.nextInt();
            b[i+1]=sc.nextInt();
        }
        for(int i=0;i<N;i++){
            count[i+1]=0;
        }
        for(int i=0;i<M;i++){
            count[a[i+1]]++;
            count[b[i+1]]++;
        }
        for(int i=0;i<N;i++){
            System.out.println(count[i+1]);
        }
    }
}

Measured memory_bytes: 21844
n,m,q=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(q)]
ans=0
for i1 in range(1,m+1): #愚直に10重ループを行っても、そのループ回数は高々92378回
  for i2 in range(i1,m+1):
    for i3 in range(i2,m+1):
      for i4 in range(i3,m+1):
        for i5 in range(i4,m+1):
          for i6 in range(i5,m+1):
            for i7 in range(i6,m+1):
              for i8 in range(i7,m+1):
                for i9 in range(i8,m+1):
                  for i10 in range(i9,m+1):
                    tmp=0
                    arrs=[0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                    for a,b,c,d in arr: #条件を満たす数列について、最大値を求める
                      if arrs[b]-arrs[a]==c:
                        tmp+=d
                    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 9156
(defun kagami-mochi (n a)
  (let ((res 0)
        (num (make-array '(110) :initial-element 0)))
    (dotimes (i n)
      (incf (aref num (aref a i))))

    (dotimes (i 101)
      (if (> (aref num i) 0)
          (incf res)))
    res))

(defun create-data ()
  (let* ((n (read))
         (a (make-array `(,n))))
    (dotimes (i n)
      (setf (aref a i) (read)))
    (values n a)))

(multiple-value-bind (n a) (create-data)
  (format t "~A~%" (kagami-mochi n a)))

Measured memory_bytes: 17256
from collections import*
I=9**9
(h,w),(s,t),(f,g)=eval('map(int,input().split()),'*3)
m,d=zip(*eval('(input(),[I]*w),'*h))
q=deque([(s-1,t-1,1)])
while q:
 y,x,c=q.popleft()
 if d[y][x]>c:
  d[y][x]=c
  for i in range(y-2,y+3):
   for j in range(x-2,x+3):
    if h>i>-1<j<w<I==d[i][j]!=m[i][j]>'#':
     if abs(y-i)+abs(x-j)<2:q.appendleft((i,j,c))
     else:q.append((i,j,c+1))
print(d[f-1][g-1]%I-1)

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


template<typename T>
vector<vector<T>> keisann(const vector<vector<T>>l, const vector<vector<T>>r) {
	vector<vector<T>>ans(l.size(), vector<T>(r[0].size()));
	assert(l[0].size() == r.size());
	for (unsigned int h = 0; h < l.size(); ++h) {
		for (unsigned int i = 0; i < r.size(); ++i) {
			for (unsigned int w = 0; w < r[0].size(); ++w) {

				ans[h][w] |= l[h][i] * r[i][w];
			}
		}
	}
	return ans;
}

template<typename T>
vector<vector<T>>powgyou(vector<vector<T>>a, const long long int n) {
	assert(a.size() == a[0].size());
	if (!n) {
		vector<vector<T>>e(a.size(), vector<T>(a[0].size()));
		for (unsigned int i = 0; i < a.size(); ++i) {
			e[i][i] = 1;
		}
		return e;
	}
	if (n == 1)return a;
	else {
		vector<vector<T>>ans(a.size(), vector<T>(a[0].size(), 0));
		ans = powgyou(a, n / 2);
		ans = keisann(ans, ans);
		if (n % 2) {
			ans = keisann(ans, a);
		}
		return ans;
	}
}


int main() {
	while (1) {
		int N, M, Z; cin >> N >> M >> Z;
		if (!N)break;
		vector<pair<int, int>>edges;
		edges.push_back(make_pair(-1, 0));
		for (int i = 0; i < M; ++i) {
			int s, d; cin >> s >> d; s--; d--;
			edges.push_back(make_pair(s, d));
			edges.push_back(make_pair(d, s));
		}
		vector<vector<int>>field(edges.size(), vector<int>(edges.size()));
		for (int i = 0; i < edges.size(); ++i) {
			for (int j = 0; j <edges.size(); ++j) {
				auto a = edges[i];
				auto b = edges[j];
				if (a.second == b.first&&a.first != b.second) {
					field[j][i] = true;
				}
			}
		}
		vector<vector<int>>start(edges.size(), vector<int>(1));
		start[0][0] = true;
		vector<vector<int>>kake = powgyou<int>(field, Z);
		vector<vector<int>>ans = keisann<int>(kake, start);
		bool ok = false;
		for (int i = 0; i <edges.size(); ++i) {
			if (edges[i].second == N - 1 && ans[i][0])ok = true;
		}
		if (ok)cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

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

int main(void){
    long long n,max_i=1;
    cin>>n;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0) max_i=i;
    }
    cout<<to_string(n/max_i).size()<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[] args){
		BufferedReader br = null;
		try{
			br = new BufferedReader (new InputStreamReader(System.in));
			double d = new Double(br.readLine());
			double s = Math.pow(d,2) *Math.PI;
			double r = 2 * d * Math.PI;
			System.out.printf("%f %f\n",s,r);
		}catch(IOException e){
			e.printStackTrace();
		}finally{
			try{
				if(br !=null)br.close();
			}catch(IOException e){
				e.printStackTrace();
			}
		}
	}
}

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

using namespace std;

int main()
{
	map <string, int> m;
	string s;
	cin >> s;
	m["MON"] = 1;
	m["TUE"] = 2;
	m["WED"] = 3;
	m["THU"] = 4;
	m["FRI"] = 5;
	m["SAT"] = 6;
	m["SUN"] = 7;
	cout << (m["SUN"] - m[s] == 0 ? 7 : m["SUN"] - m[s]);
}


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;
using P = pair<int,int>;

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> to(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	vector<int> ans(n, -1);
	ans[0] = 0;
	vector<P> q;
	for(int j: to[0]) {
		q.emplace_back(0, j);
	}
	while(!q.empty()) {
		vector<P> nxt;
		for(auto p: q) {
			int u = p.first, v = p.second;
			if (ans[v] >= 0) continue;
			ans[v] = u;
			for(int w: to[v]) {
				nxt.emplace_back(v, w);
			}
		}
		swap(q, nxt);
	}
	cout << "Yes" << endl;
	for(int i = 1; i < n; i++) {
		cout << ans[i] + 1 << endl;
	}

	
}


Measured memory_bytes: 14836
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


h, n = inpl()
data = [inpl() for i in range(n)]

dp = [[INF] * (h + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(h + 1):
        unused = dp[i][j]
        used = dp[i][j - data[i][0]] + data[i][1] if j - data[i][0] >= 0 else data[i][1]
        reused = dp[i + 1][j - data[i][0]] + data[i][1] if j - data[i][0] >= 0 else INF
        dp[i + 1][j] = min(unused, used, reused)
ans = dp[n][h]
print(ans)
# for i in dp:
#     print(i)


Measured memory_bytes: 179080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc050/tasks/abc050_b

int main() {

    int N; cin >> N;
    int T[N];
    REP(i, N) cin >> T[i];
    int M; cin >> M;

    int P, X;
    REP(i, M) {
        cin >> P >> X;
        ll cnt = 0;

        REP(i, N) {
            if (i+1 == P) {
                cnt += X;
            }
            else {
                cnt += T[i];
            }
        }

        cout << cnt << "\n";
    }


    return 0;
}


Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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 main(int argc, char const* argv[])
{
  int n, k;
  cin >> n >> k;
  if((n + 1) / 2 >= k)cout << "YES" << endl;
  else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF 1LL<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    vl sum(n+1,0);
    rep(i,n) sum[i+1] = sum[i] + a[i];
    vl dist(n);
    rep(i,n-1){
        dist[i] = abs(sum[n] - sum[i+1] - sum[i+1]);
    }
    ll ans = LINF;
    rep(i,n-1) ans = min(dist[i],ans);
    cout << ans << endl;
}

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

int main(void){
  long long int a,b,c,x,y,ans,tmp_ans;
  long long int zero;
  zero=0;
  ans=1000000009;
  cin>>a>>b>>c>>x>>y;
  if(min(a,b)>=2*c){
  	cout<<max(x,y)*2*c<<endl;
  	return 0;
  }
  if(a+b<=2*c){
  	cout<<a*x+b*y<<endl;
  	return 0;
  }
  for(int i=0;i<2*max(x,y)+1;i+=2){
  	tmp_ans=c*i+a*max(x-i/2,zero)+b*max(y-i/2,zero);
  	ans=min(tmp_ans,ans);
  }
  cout<<ans<<endl;
}


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

vector<int> visited1(200001,0);
vector<int> visited(200001,0);
vector<int>parent(200001,0);
vector<int> v[200001];



void dfs(int t) {
    visited[t] = true;
    //cout<<t<<" : ";
    for (int u : v[t]) {
        if (!visited[u])
            dfs(u);
    }
    
}


void bfs(vector<int> v[],int k,vector<int>&parent){
	
	queue<int> q;
	q.push(k);
	visited1[k]=1;
	while(!q.empty()){
		k = q.front();
		//cout<<" parent element :  "<<k<<"  :childs:= ";
		q.pop();
		for(int i=0;i<v[k].size();i++){
			if(!visited1[ v[k][i] ]){
				parent[v[k][i]]=k;
				
						q.push(v[k][i]);
						visited1[v[k][i]] = 1;
						//cout<<v[k][i]<<", ";
						//cout<<parent[v[k][i]]<<endl;
			}
			
		}
		//cout<<endl;	
	}
}

int main(){
	int n,m;
	
	
	cin>>n>>m;   
	
	while(m--){
		int a,b;
		cin>>a>>b;
	
		
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int count=0;
	for(int i=1;i<=n;i++){
			
		    if(!visited[i]){
		    	count++;
		    	dfs(i);
		    	
		    	//cout<<endl;
		    }
	    				
	
	}
	if(count>1)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
		
		
		bfs(v,1,parent);
		/*for(int i=2;i<=n;i++)
		{
			cout<<visited1[i]<<endl;
		}*/
		for(int i=2;i<=n;i++)
		cout<<parent[i]<<endl;
	}
	    
	return 0;
}


Measured memory_bytes: 16372
N=int(input())
A=list(map(int,input().split()))

"""
for i in A:
    B=2*i-1
    res_pre=0
    for j in A:
        res_pre+=B%j
        if(res<res_pre):
            res=res_pre

B=2*A[0]-1
for i in range(0,A[0]-1):
    res_pre=0
    for j in A:
        res_pre+=(B-i)%j
    print(res_pre)
    if(res<res_pre):
        res=res_pre

print(res)

for i in range(0,1100000):
    res=0
    for j in A:
        res+=i%j
    if(res==90):
        print("Y")
        print(i)
"""
res=1
resres=0
for i in A:
    res*=i
res-=1
for i in A:
    resres+=res%i
print(resres)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();
            int X = in.nextInt();
            int Y = in.nextInt();
            int res = Math.min(N, K) * X + Math.max(N - K, 0) * Y;
            System.out.println(res);
        }
    }
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

using pss = pair<string, string>;

int n;
string s;
map<pss, int> mp;

int main() {
   cin >> n >> s;

   rep (mask, 1<<n) {
      string a, b;
      rep (i, n) {
         if (mask & (1<<i)) {
            a.push_back(s[i]);
         } else {
            b.push_back(s[i]);
         }
      }
      mp[{a, b}]++;
   }

   ll ans = 0;
   string t = s;
   reverse(all(t));
   rep (mask, 1<<n) {
      string a, b;
      rep (i, n) {
         if (mask & (1<<i)) {
            a.push_back(t[i]);
         } else {
            b.push_back(t[i]);
         }
      }
      ans += mp[{a, b}];
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 91904
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n, m,a;
	cin >> n >> m;
	a = m / n;
	for (int i = a; i > 0; i--) {
		if (m % i == 0) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
from collections import defaultdict

h, w, m = map(int, input().split())

row_dict = defaultdict(int)
col_dict = defaultdict(int)
row_col_dict = defaultdict(set)
for _ in range(m):
    row, col = map(int, input().split())
    row_dict[row] += 1
    col_dict[col] += 1
    row_col_dict[row].add(col)

max_row = max(row_dict.values())
max_col = max(col_dict.values())

max_rows = {k for k, v in row_dict.items() if v == max_row}
max_cols = {k for k, v in col_dict.items() if v == max_col}
ans = max_row + max_col - 1
flg = False
if ans < m:
    for row in max_rows:
        for col in max_cols:
            if not col in row_col_dict[row]:
                ans += 1
                flg = True
                break
        if flg:
            break

print(ans)


Measured memory_bytes: 311928
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[110][41000];
int p[110];
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
		if(p[i]>20100){
			printf("No\n");return 0;
		}
	}
	c*=2;
	d*=2;
	dp[0][c]=1;
	for(int i=0;i<a;i++){
		int L=d*p[i];
		int R=b*p[i];
		if(L>2*c)break;
		if(R>2*c)R=2*c;
		for(int j=0;j<=2*c;j++){
			if(!dp[i][j])continue;
			if(j-L+1>=0){
				dp[i+1][max(0,j-R)]++;
				dp[i+1][max(0,j-L+1)]--;
			}
			dp[i+1][min(2*c+1,j+L)]++;
			dp[i+1][min(2*c+1,j+R+1)]--;
		}
		for(int j=1;j<=2*c;j++){
			dp[i+1][j]+=dp[i+1][j-1];
		}
		for(int j=0;j<=2*c;j++)dp[i+1][j]=!!dp[i+1][j];
	//	for(int j=0;j<=2*c;j++)printf("%d ",dp[i+1][j]);
		//printf("\n");
	}
	bool ok=false;
	for(int i=0;i<=2*c;i++)if(dp[a][i])ok=true;
	if(ok)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 17232