akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

LL gcd(LL a, LL b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
LL lcm(LL a, LL b) {
  if ((a == 0) || (b == 0)) return 0;
  return ((a / gcd(a, b)) * b);
}

int main() {
  LL A, B, C, D; std::cin >> A >> B >> C >> D;
  --A;
  LL E = lcm(C, D);
  LL x = (B/C) + (B/D) - B/E;
  LL y = (A/C) + (A/D) - A/E;
  std::cout << (B - x) - (A - y) << std::endl;;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;

typedef long long ll;

struct Card { char suit, value; };

// 左のカードと比較し続ける
void bubbleSort(Card cards[], int n) {
    // 5枚のカードを1枚ずつループ
    REP(i, n) {
        // 5枚目のカードからi枚目まで一枚ずつ比較して入れ替える
        for (int j = n-1; j >= i; --j) {
            // もしj枚目のカードよりj-1枚目のカードの方が大きい場合swap
            if (cards[j].value < cards[j-1].value) {
                swap(cards[j], cards[j-1]);
            }
            // 左のカードとの比較を繰り替えす
        }
    }
}

// 最小値を取り続ける
void selectionSort(Card cards[], int n) {
    int minj;
    // 5枚のカードを1枚ずつループ
    REP(i, n) {
        minj = i;
        // i枚目のカードから5枚目までループ
        FOR(j, i, n) {
            if (cards[j].value < cards[minj].value) {
                minj = j;
            }
        }
        swap(cards[i], cards[minj]);
    }
}

void printCards(Card cards[], int n) {
    REP(i, n) {
        cout << cards[i].suit << cards[i].value;
        if (i < n-1) {
            cout << ' ';
        } else {
            cout << endl;
        };
    };
}

bool isSame(Card a[], Card b[], int n) {
    REP(i, n) if (a[i].suit != b[i].suit) return false;
    return true;
}

int main() {
    cin.tie(0);

    int n;
    cin >> n;

    Card cards1[n];
    Card cards2[n];

    // 入力の読み込み
    REP(i, n) cin >> cards1[i].suit >> cards1[i].value;
    // 配列をコピー
    REP(i, n) cards2[i] = cards1[i];

    bubbleSort(cards1, n);
    printCards(cards1, n);

    // バブルソートは安定ソート
    cout << "Stable" << endl;

    selectionSort(cards2, n);
    printCards(cards2, n);

    bool isStable = isSame(cards1, cards2, n);
    if (isStable){
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
}



Measured memory_bytes: 3100
import java.util.*;

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        int X = sc.nextInt();
        int Y = sc.nextInt();

        int[] x = new int[N];
        int[] y = new int[M];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
        }
        for (int i = 0; i < M; i++) {
            y[i] = sc.nextInt();
        }

        Arrays.sort(x);
        Arrays.sort(y);

        if (x[N - 1] >= y[0]) {
            System.out.println("War");
            return;
        }

        if (y[0] <= X) {
            System.out.println("War");
            return;
        }

        if (x[N-1] >= Y) {
            System.out.println("War");
            return;
        }

        System.out.println("No War");
    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int cnt = 1;
    for (int i=1; i<n; i++) {
        if (s[i] != s[i-1]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
import sys
A,B,K = map(int,input().split())
a = []
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 
g = gcd(A,B)
s = 1 
for i in range (g,0,-1):
  if g % i == 0:
    s = s + 1
    if s-1 == K:
      print(i)
      sys.exit()

Measured memory_bytes: 3060
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    ans = 0
    # N//m=N%m=i => N=m*i, i<m => i<N**0.5
    for i in range(1, int(N ** 0.5) + 1):
        # N//m = N%m = i <=> (N-i)//i = m
        if (N - i) % i == 0:
            m = (N - i) // i
            ## 誤差のため、i==mはループで除外しきれない
            if i < m:
                ans += m

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10300
import re
def bubbleSort(c):
	flag=True
	while(flag):
		flag=False
		for i in range(len(c)-1):
			if(c[i][1] > c[i+1][1]):
				c[i],c[i+1] = c[i+1],c[i]
				flag=True
	return c

def selectionSort(c):
	for i in range(len(c)):
		minj=i
		for j in range(i,len(c)):
			if(c[j][1] < c[minj][1]):
				minj=j
		if(i!=minj):
			c[i],c[minj]=c[minj],c[i]
	return c

n=int(input())
cards=list(input().split())
c=[]
for i in range(n):
	c.append([cards[i][0],int(cards[i][1])])
c2=c.copy()

bubble=bubbleSort(c)
bubble_str=re.sub("[\[\]\,]","",str(bubble))
bubble_str=re.sub("\' ","",bubble_str)
print(re.sub("\'","",bubble_str))
print("Stable")

select=selectionSort(c2)
select_str=re.sub("[\[\]\,]","",str(select))
select_str=re.sub("\' ","",select_str)
print(re.sub("\'","",select_str))
if(bubble_str == select_str):
	print("Stable")
else:
	print("Not stable")


Measured memory_bytes: 6564
A, B, C = map(int, input().split())
R = {i: False for i in range(B)}
X = 0
while True:
    X += A
    r = X % B
    if r == C:
        print("YES")
        exit()
    if R[r]:
        print("NO")
        exit()
    R[r] = True


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;
#define ll long long
int main(){
  ll n;
  while(cin >> n && n){
    ll last = 0;
    unordered_set<ll> us;
    for(ll i = 1; i <= n; i++){
      last += i;
      us.insert(last);
    }
    ll cnt = 0;

    for(ll i : us){
      if(us.find(i + n) != us.end()){
	cnt++;
      }
    }
    if(us.find(n) != us.end()){
      cnt++;
    }
    cout << --cnt << endl;
  }
}

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

typedef long long int lli;
#define pb push_back
#define gcd __gcd
#define MOD 1000000007
#define mod2 998244353
#define PI 3.141592653589793238462643383279
#define forz(i,n) for(long long int i=0;i<n;i++)

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1,u,j;
    //cin>>t;
    for(u=1;u<=t;u++){
        lli n,m,i,j,a,b,c,d,k,n1,n2,n3,current;
        cin>>n;
        n=n%10;
        if(n==2 || n==4 || n==5 || n==7 || n==9) cout<<"hon";
        if(n==1 || n==0 || n==6 || n==8) cout<<"pon";
        if(n==3) cout<<"bon"; 
    }
}

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

const long INF = 1L << 60;
int a[200010];
long dp[200010][4];

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

int main(){
	int n, a;
	scanf("%d", &n);
	int k = n % 2 + 1;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= k; j++)
			dp[i][j] = -INF;
	dp[0][0] = 0;
	for(int i = 0; i < n; i++) {
		scanf("%d", &a);
		for(int j = 0; j <= k; j++) {
			chmax(dp[i+1][j+1], dp[i][j]);
          	if((i+j) % 2) 
				chmax(dp[i+1][j], dp[i][j]);
			else
				chmax(dp[i+1][j], dp[i][j] + a);
		}
	}
	printf("%ld\n", dp[n][k]);
}


Measured memory_bytes: 9948
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

long int M = 1e+9+7;
int main(void){
    int n,k;
    cin >> n >> k;
    ll mn=0, mx=0,tmn,tmx,sum=0;
    rep(i,k){
        tmn=i; tmx=n-i;
        mn+=tmn;
        mx+=tmx;
    }
    //cout << mn << " "<< mx << endl;
    for(int i=k; i<=n+1; i++){
        sum += (mx-mn+1);
        //cout << sum << endl;
        tmn++; tmx--;
        mn+=tmn;
        mx+=tmx;
    }
    cout << sum%M << endl;
    return 0;
}

Measured memory_bytes: 3624
var input = require('fs').readFileSync('/dev/stdin', 'utf8').replace(/\n/g,'');

function reverseSequence(str) {
	var output = '';
	var arr = str.split('');
	while (arr.length) {
		output += arr.pop();
	}
	return output;
}

console.log(reverseSequence(input));

Measured memory_bytes: 15540
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}



int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<vector<ll>> X(N),Y(N);
  REP(N){
    cin>>A[i];
    For(j,A[i]){
      ll x,y;
      cin>>x>>y;
      --x;
      X[i].push_back(x);
      Y[i].push_back(y);
    }
  }
  ll ans=0;
  REP(1<<N){
    bool f=true;
    For(j,N){
      if((i&(1<<j))){
        For(k,A[j]){
          if((i&(1<<X[j][k]))!=Y[j][k]<<X[j][k]){
            f=false;
            goto loopend;
          }
        }
      }
    }
    loopend:
    if(f){
      dump(i);
      ans=max(ans,(ll)__builtin_popcountll(i));
    }
  }
  cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int main() {
        int n, x=0, y=0, t=0;
        cin>>n;
        bool flag=true;
        for(int i=0; i<n; i++) {
            int x1, y1, t1;
            cin>>t1>>x1>>y1;
            if((abs(x1-x)+abs(y1-y)>abs(t1-t)) || ((abs(x1-x)+abs(y1-y))%2!=abs(t1-t)%2)) {
                flag=false;
            }
            x=x1;
            y=y1;
            t=t1;
        }
        if(flag) {
            cout<<"Yes";
        } else {
            cout<<"No";
        }
        return 0;
    }

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
c = input()

r_total = 0
w_total = 0
for i in c:
  if i == 'R':
    r_total += 1
  elif i == 'W':
    w_total += 1

w_left = 0
r_left = 0

ans = r_total # 仕切りが左端の場合

# iが仕切りの位置
for i in range(N):
  cnt = 0
  if c[i] == 'R':
    r_left += 1
    
  elif c[i] == 'W':
    w_left += 1
    
  if w_left <= r_total - r_left:
    cnt += w_left # 仕切りより左の白と右の赤を入れ替え
    cnt += (r_total - r_left) - w_left # 仕切りより右の赤を白に変更
  else:
    cnt += r_total - r_left  # 仕切りより左の白と右の赤を入れ替え
    cnt += w_left - (r_total - r_left) # 仕切りより左の白を赤に変更
  ans = min(ans, cnt)
print(ans)

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

int main(){
int a,b,c;
cin >> a >> b >> c;
int t;
if(a > b){
t = a;
a = b;
b = t;
}
if(a > c){
t = a;
a = c;
c = t;
}
if(b > c){
t = b;
b = c;
c = t;
}
cout << a << " " << b << " " << c << endl;
return 0;
}

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

using ll_t = int64_t;

const int MAXN = (int)1e5 + 1;
const int P = (int)1e9 + 7;

int a[MAXN];
ll_t factorial[MAXN];

void init(int n) {
  factorial[0] = 1;
  for (int i = 1; i <= n; ++i) {
    factorial[i] = factorial[i - 1] * i % P;
  }
}

// Calc x ^(P - 2) % P.
ll_t inv(ll_t x) {
  x %= P;
  int y = P - 2;
  ll_t res = 1;
  while (y > 0) {
    if (y & 1) res = res * x % P;
    x = x * x % P;
    y >>= 1;
  }
  return res;
}

// Calc C(x, y). 
ll_t comb(int x, int y) {
  if (x < y) return 0;
  if (y == 0 || y == x) return 1;
  return factorial[x] * inv (factorial[y] * factorial[x - y]) % P;
}

ll_t calc(int n, int k) {
  std::sort(a + 1, a + n + 1);
  ll_t res = 0;
  for (int i = 1; i <= n; ++i) {
    res = (res + comb(i - 1, k - 1) * a[i] % P) % P;
  }
  return res;
}

int64_t solve(int n, int k) {
  init(n);
  ll_t res1 = calc(n, k);
  for (int i = 1; i <= n; ++i) a[i] = -a[i];
  ll_t res2 = calc(n, k);
  return (res1 + res2) % P;
}

int main() {
  int n, k;
  std::cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    std::cin >> a[i];
  }
  std::cout << solve(n, k) << std::endl;
  return 0;
}


Measured memory_bytes: 1408
def levenshtein_dist(a,b):
    a_size = len(a)
    b_size = len(b)
    inf = float('inf')
    dp = [[a_size+b_size for i in range(a_size+1)] for _ in range(b_size+1)]
    for i in range(b_size+1):
        dp[i][0] = i
    for j in range(a_size+1):
        dp[0][j] = j

    for i in range(1,b_size+1):
        for j in range(1,a_size+1):
            if a[j-1] == b[i-1]:
                dp[i][j] = min(dp[i-1][j-1], dp[i-1][j]+1, dp[i][j-1]+1)
            else:
                dp[i][j] = min(dp[i-1][j-1]+1, dp[i-1][j]+1, dp[i][j-1]+1)
    return dp

a = list(input())
b = list(input())
dp = levenshtein_dist(a,b)
print(dp[-1][-1])

    


Measured memory_bytes: 46164
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
input = sys.stdin.readline

"""
H = int(input())
h = [int(ele) for ele in input().split()]
h = [0] + h
"""


def main():
    ans = "Balanced"
    A, B, C, D = map(int, input().split())
    L = A + B
    R = C + D
    if L < R:
        ans = "Right"
    elif L > R:
        ans = "Left"

    print(ans)


def bfs(queue):
    global yet, graph
    if len(queue) == 0:
        return
    yet.remove(queue[-1])

    for i, adjacency in enumerate(graph[queue[-1]]):
        if adjacency == 1 and (i in yet) and (i not in queue):  # 隣接かつ未探索であれば、stackにpush
            queue.appendleft(i)
    else:
        queue.pop()
        bfs(queue)


def dfs(stack):
    global yet, graph
    yet.remove(stack[-1])

    for i, adjacency in enumerate(graph[stack[-1]]):
        if adjacency == 1 and i in yet:  # 隣接かつ未探索であれば、stackにpush
            stack.append(i)
            dfs(stack)
    else:
        stack.pop()


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
    return divisors


class Node():

    def __init__(self):
        self.idx = None
        self.left = None
        self.right = None
        self.parent = None
        return

    def pre_order(self):
        global pre_order_str
        pre_order_str += str(self.idx) + " "
        if self.left:
            self.left.pre_order()

        if self.right:
            self.right.pre_order()

    def in_order(self):
        global in_order_str

        if self.left:
            self.left.in_order()

        in_order_str += str(self.idx) + " "

        if self.right:
            self.right.in_order()

    def post_order(self):
        global post_order_str
        if self.left:
            self.left.post_order()

        if self.right:
            self.right.post_order()

        post_order_str += str(self.idx) + " "


class HeapHelper():
    """HeapContrler.
    完全二分木を二分ヒープで表現した配列 A に対して、
    HeapHelper.parent(idx) とするとそのノードの親の添字を返す
    存在しない場合は Falseを返す

    Returns:
        [type] -- [description]
    """

    def __init__(self):
        return

    @staticmethod
    def parent(i):
        if i == 1:
            return False

        return int(i/2)

    @staticmethod
    def left(i):
        l_idx = 2*i
        if H < l_idx:
            return False

        return l_idx

    @staticmethod
    def right(i):
        r_idx = 2*i + 1
        if H < r_idx:
            return False

        return r_idx


if __name__ == "__main__":
    main()


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

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")
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    let ans: String;

    if a < b && b < c{
       ans = "Yes".to_string()
    } else {
        ans = "No".to_string()
    }

    println!("{}", ans);
}



Measured memory_bytes: 5028
//arc083_d.cpp
//Thu Jan 23 22:53:42 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll a[n][n],dp[n][n];

	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			cin >> a[i][j];
			dp[i][j] = a[i][j];
		}
	}

	for (int k=0;k<n;k++){
		for (int i=0;i<n;i++){
			for (int j=0;j<n;j++){
				if (i==k || j==k || i==j || dp[i][k]==LLINF || dp[k][j]==LLINF){
					continue;
				}
				if (a[i][j]==dp[i][k]+dp[k][j]){
					dp[i][j] = LLINF;
				}else if (a[i][j]>dp[i][k]+dp[k][j]){
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}

	ll ans = 0;
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			if (dp[i][j]!=LLINF){
				ans += dp[i][j];
			}
		}
	}
	cout << ans/2 << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 1664
#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>;
const int INF=1000000007;

int n, m;
int p[10];
vector<vector<int>> s(10);

bool fnc(ll bit) {
    rep(i,m) {
      int num=0;
      for(auto p : s[i]) {
        if(bit&(1<<p)) num++;
      }
      if(num%2!=p[i]) return false;
    }
    return true;
}


int main() {
  cin >> n >> m;
  rep(i,m) {
    int k;  cin >> k;
    rep(j,k) {
      int t;
      cin >> t;  t--;
      s[i].push_back(t);
    }
  }
  rep(i,m) cin >> p[i];

  int ans=0;
  for(ll bit=0; bit<(1<<n); bit++) {
    if(fnc(bit)) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
	
	val a = Array.fill(9)(sc.nextInt)
	
	Seq.fill(sc.nextInt)(sc.nextInt) foreach {bi =>
		val i = a.indexWhere(_ == bi)
		if (i != -1)
			a(i) = 0
	}
	
	lazy val p = (a(0) == 0 && a(1) == 0 && a(2) == 0) || (a(3) == 0 && a(4) == 0 && a(5) == 0) || (a(6) == 0 && a(7) == 0 && a(8) == 0) ||
				 (a(0) == 0 && a(3) == 0 && a(6) == 0) || (a(1) == 0 && a(4) == 0 && a(7) == 0) || (a(2) == 0 && a(5) == 0 && a(8) == 0) ||
				 (a(0) == 0 && a(4) == 0 && a(8) == 0) || (a(2) == 0 && a(4) == 0 && a(6) == 0) 
	
	pw.println( if (p) "Yes" else "No" )
	pw.flush()
}

Measured memory_bytes: 25932
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int maxn=100000;
ll fac[2*maxn+1];
ll rfac[2*maxn+1];
ll ans=0;
ll h,w,a,b;
ll mod=INF;

ll pow(ll x,ll y){
    if(y==0){
        return 1;
    }else if(y==1){
        return x;
    }else if(y%2==0){
        ll a=pow(x,y/2);
        return (a*a)%mod;
    }else{
        ll a=pow(x,(y-1)/2);
        return a*a%mod*x%mod;
    }
}

int main(){
    
    cin >> h>>w>>a>>b;
    fac[0]=fac[1]=rfac[0]=rfac[1]=1;
    
    for(ll i=1;i<=h+w;i++){
        fac[i]=fac[i-1]*i%mod;
    }
    
    rfac[h+w]=pow(fac[h+w],INF-2);
    
    for(ll i=h+w;i>=1;i--){
        rfac[i-1]=rfac[i]*i%mod;
    }
    
    //    for(ll i=0;i<=h+w;i++){
    //        cout <<i<<' '<< fac[i]*rfac[i]%mod<<endl;
    //    }
    
    for(int i=1;i<=h-a;i++){
        //          cout <<fac[i+b-2]<<' '<<rfac[b-1]*rfac[i-1]%mod<<endl;
        //          cout << fac[h-i+w-1]*rfac[w-1]*rfac[h-i]%mod<<endl;
        //          cout << i+b-2<<' '<<b-1<<endl;
        //          cout << h-i+w-b-1<<' '<<w-b-1<<endl;
        //if(ex<0)ex+=INF;
        ll X = fac[i+b-2]*rfac[b-1]%mod*rfac[i-1]%mod;
        ll Y =fac[h-i+w-b-1]*rfac[w-b-1]%mod*rfac[h-i]%mod;
        ans=(ans+X*Y%mod)%mod;
    }
    
    cout << ans<<endl;
    
    return 0;
}


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

int main()
{
    long long n,m;
    cin>>n>>m;
    long long count=0;
    if(2*n>=m){
        cout<<m/2<<endl;
    }
    else if(2*n<m){
        m=m-2*n;
        count+=n;
        count+=m/4;
        cout<<count<<endl;
    }
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;

int		main(void)
{
	int		N, K;
	cin >> N >> K;
	int		cnt = 0;
	for (int i = 1; i <= N;)
		i *= K, cnt++;
	cout << cnt << endl;
}

Measured memory_bytes: 256
nm=list(map(int,input().split()))
stair=[1]*(nm[0]+1)
for i in range(nm[1]):
    stair[int(input())]=0

i=0#現在地
b1=1#現在地までの行き方
b2=0#現在地のひとつ前までの行き方
while i <nm[0]:
    if stair[i+1]==1:
        i+=1
        b1+=b2
        b2=b1-b2
    elif stair[i+1]==0 and stair[i+2]==1:
        i+=2
        b2=0
    else:
        i=nm[0]
        b1=0
print(b1%(10**9+7))

Measured memory_bytes: 3956
import sys
# input = sys.stdin.readline
input = sys.stdin.buffer.readline
import math
from itertools import combinations
EPS = 10**-7


class P2():
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.norm2 = (self.x**2 + self.y**2)**0.5

    def __add__(self, other):
        return P2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return P2(self.x - other.x, self.y - other.y)

    def __mul__(self, other: float):
        return P2(self.x * other, self.y * other)

    def __truediv__(self, other: float):
        return P2(self.x / other, self.y / other)

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def det(self, other):
        return self.x * other.y - self.y * other.x


class Circle():
    def __init__(self, p, r):
        self.p = p
        self.r = r


n, k = map(int, input().split())
p = []
c = []
for _ in range(n):
    x, y, cc = map(float, input().split())
    p.append(P2(x, y))
    c.append(cc)

dist = [[(p[i] - p[j]).norm2 for j in range(n)] for i in range(n)]


def check(r):
    circles = [Circle(p[i], r / c[i]) for i in range(n)]

    # 半径rの円２つの交点の列挙
    cand = [pi for pi in p]
    for c_i, c_j in combinations(circles, r=2):
        d_ij = c_i.p - c_j.p
        if d_ij.norm2 < c_i.r + c_j.r - EPS:
            # 点iと点jを中心とする円が交点を持つ時
            x = (c_j.r**2 - c_i.r**2 + d_ij.norm2**2) / (2 * d_ij.norm2)
            h = math.sqrt(max(c_j.r**2 - x**2, 0.0))
            v = P2(-d_ij.y, d_ij.x) * (h / d_ij.norm2)
            dx = c_j.p + d_ij * (x / d_ij.norm2)
            cand.append(dx + v)
            cand.append(dx - v)

    for cand_p in cand:
        cnt = 0
        for c_i in circles:
            if (c_i.p - cand_p).norm2 < c_i.r + EPS:
                cnt += 1
                if cnt >= k:
                    return True

    return False


lb = 0.0  # False
ub = 3000 * 100  # True
while ub - lb > EPS:
    mid = (ub + lb) / 2
    if check(mid):
        ub = mid
    else:
        lb = mid

print(ub)


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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 256
n = int(input())

t = list(map(int, input().split()))
m = int(input())

p = []
x = []
for _ in range(m):
    pi, xi = map(int, input().split())
    p.append(pi)
    x.append(xi)

for i in range(m):
    pi = p[i]
    xi = x[i]
    ans = 0
    for j in range(n):
        if j + 1 == pi:
            ans += xi
        else:
            ans += t[j]
    print(ans)

Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, m, d, i, j, k, q, a, b, x, ans;
	cin >> n >> m >> d;
	vector<pair<int, int>> pp(n * m + 1);
	vector<long long> ds(n * m + 1, 0);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> x;
			pp[x].first = i;
			pp[x].second = j;
		}
	}

	for (i = 1; i <= n * m; i++) {
		if (i - d > 0) ds[i] = ds[i - d] + abs(pp[i].first - pp[i - d].first) + abs(pp[i].second - pp[i - d].second);
	}

	cin >> q;
	while (q--) {
		cin >> a >> b;
		ans = ds[b] - ds[a];
		cout << ans << "\n";
	}


	return 0;
}


Measured memory_bytes: 2560
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {

  case class Rotation(run: Dice => Dice){
    def apply(d: Dice): Dice = run(d)
    def compose(other: Rotation): Rotation = Rotation(run compose other.run)
  }

  object Rotation {
    def id = Rotation(d => d)
    def north = Rotation(d => Dice(List(1,5,2,3,0,4).map(d.pip)))
    def east = Rotation(d => Dice(List(3,1,0,5,4,2).map(d.pip)))
    def ccw = Rotation(d => Dice(List(0,3,1,4,2,5).map(d.pip)))

    final def axial(rotation: Rotation): Seq[Rotation] =
      for(i <- 0 to 3) yield List.fill(i)(rotation).fold(id)(_ compose _)

    def enumerateTop: Seq[Rotation] =
      for(i <- 1 to 6) yield ((0 to i).map(j => if(j % 2 == 0) north else east)).fold(id)(_ compose _)

    def enumerate: Seq[Rotation] = {
      val ax = axial(ccw)
      enumerateTop.flatMap(e => ax.map(e compose _))
    }
  }

  case class Dice(pip: List[Int]){
    lazy val all: Seq[Dice] = Rotation.enumerate.map(_.run(Dice(pip)))
    def ===(that: Dice): Boolean = pip.corresponds(that.pip)(_ == _)
    def ==(that: Dice): Boolean = all.exists(_ === that)
  }

  def main(args: Array[String]): Unit = {
    val pip = readLine.split(" ").map(_.toInt).toList
    val dice = Dice(pip)
    //val all: Seq[Dice] = Rotation.enumerate.map(_.run(Dice(pip)))
    val Array(n,_*) = readLine.split(" ").map(_.toInt)

    for(i <- 1 to n){
      val Array(a,b,_*) = readLine.split(" ").map(_.toInt)
      println(dice.all.filter(d => d.pip(0) == a && d.pip(1) == b)(0).pip(2))
    }
  }

}

Measured memory_bytes: 44520
#include <iostream>
#include <deque>
#include <cstdlib>

using namespace std;

int main(void){

  deque<int> st;

  string formula;

  int a,b;

  while(1){

    cin >> formula;

    if(cin.eof()) break;

    char c = *formula.c_str();

    switch (c) {
      case '+':
        a = st[st.size()-2];
        b = st[st.size()-1];
        st.pop_back();
        st.pop_back();
        st.push_back(a + b);
        break;

      case '-':
        a = st[st.size()-2];
        b = st[st.size()-1];
        st.pop_back();
        st.pop_back();
        st.push_back(a - b);
        break;

      case '*':
        a = st[st.size()-2];
        b = st[st.size()-1];
        st.pop_back();
        st.pop_back();
        st.push_back(a * b);
        break;

      default :
        st.push_back(atoi(formula.c_str()));
    }

  }

  for(int i = 0 ; i < st.size() ; i++){
    cout << st[i];
    if(i != st.size() - 1) cout << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=2e5+5;
#define inf 1e18+8
const int mod=1e9+7;
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int dp[N];
int func(int n,int k)
{
    if(n==k) return 1;
    int x=dp[n];int y=dp[k];int z=dp[n-k];
    int ans=x/y;
    ans/=z;
    return ans;

}
signed  main()
{
    fastio;
    
    int n,k;
    cin>>n>>k;
    dp[1]=1;
    dp[2]=2;
    for(int i=3;i<=N;i++)
    {
        dp[i]=(i*dp[i-1])%mod;
      
    }
    int sum=0;
    int min=k*(k-1)/2;int max=0;
    for(int i=0;i<k;i++)
    max+=(n-i);
    for(int i=k;i<=n+1;i++)
    {
        //cout<<func(n+1,i);
        sum+=(max-min+1);
        sum%=mod;
        max+=(n-i);
        min+=(i);
       
    }
    cout<<sum;

  
    
}

Measured memory_bytes: 5196
package main

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

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		hs[i] = eGetInt(scanner)
	}
	for i := len(hs) - 2; i >= 0; i-- {
		if hs[i] <= hs[i+1] {
			// なにもしなくてよい
		} else if hs[i] == hs[i+1]+1 {
			// 1つ高いので下げる．
			hs[i] = hs[i] - 1
		} else {
			// 無理
			fmt.Println("No")
			goto End
		}
	}
	fmt.Println("Yes")
End:
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

int main() {
	int n, result=0;
	cin >> n;
	int a[n], gcdleft[n+1], gcdright[n+1];
	gcdleft[0] = 0;
	gcdright[n] = 0;
	for(int i = 0; i<n; i++){
		cin >> a[i];
		gcdleft[i+1] = __gcd(a[i], gcdleft[i]);
	}

	for(int i = n-1; i>-1; i--){
		gcdright[i] = __gcd(a[i], gcdright[i+1]);
	}

	for(int i = 1; i<n+1; i++){
		result = max(result, __gcd(gcdleft[i-1], gcdright[i]));
	}
	cout << result << '\n';		
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

// M * (M-1)^(N-1-K) * N-1 C K
int main(int argc, const char * argv[]) {
    ll N,K; cin >> N >> K;
    vector<ll> H(N);
    ll sum = 0;
    for(ll i=0;i<N;i++){
        cin >> H[i];
        sum += H[i];
    }
    
    sort(H.begin(),H.end());
    
    for(ll i=0;i<N;i++){
        if(i>=N-K){
            sum -= H[i];
        }
    }
    
    cout << sum << endl;
    
    
    
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    vi a(n),s(n+1,0); 
    rep(i,n){
        cin >> a[i];
        s[i+1]=s[i]+a[i];
    }
    map<int,int> map;
    rep(i,n+1){
        map[s[i]%m]++;
    }
    int res=0;
    for(auto m:map){
        res+=m.S*(m.S-1)/2;
    }
    cout<<res<<endl;

}

Measured memory_bytes: 8668
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
//#define mp make_pair
#define fi first
#define se second

int main()
{
    string s1;string s2;
    while(getline(cin,s1))
    {
        if(s1==".")break;getline(cin,s2);
        if(s1==s2){cout<<"IDENTICAL"<<endl;continue;}
        bool flag=0;
        vector<int>c1(0);vector<int>c2(0);c1.pb(0);c2.pb(0);
        REP(i,s1.size())if(s1[i]=='\"')c1.pb(i);
        REP(i,s2.size())if(s2[i]=='\"')c2.pb(i);
        c1.pb(s1.size()-1);c2.pb(s2.size()-1);
        if(c1.size()!=c2.size()){cout<<"DIFFERENT"<<endl;continue;}
        int times=0;
        REP(i,c1.size()-1)
        {
            string t1=s1.substr(c1[i],c1[i+1]-c1[i]+1);
            string t2=s2.substr(c2[i],c2[i+1]-c2[i]+1);
            if(i%2)
            {
                if(t1!=t2)times++;
                if(times>1)break;
            }else
            {
                if(t1!=t2){times=10;break;}
            }
        }
        if(times>1)cout<<"DIFFERENT"<<endl;
        else if(times==1)cout<<"CLOSE"<<endl;
    }
}


Measured memory_bytes: 3172
i = gets.chomp.to_s
len = i.length

until i == "0"
	arr = i.split("")
	sum = 0
	for k in 0..len - 1
		sum += arr[k].to_i
	end
	
	puts sum
	
	i = gets.chomp.to_s
	len = i.length
end

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
typedef long long ll;

int main(){
  ll a,b;
  cin >> a >> b;
  for(int i=1;i<=b;i++){
    if((a*i)%b==0){
      cout << a*i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
ok = True
for i in a :
    if( (i%2 == 0) and (i%3 != 0) and (i%5 != 0)) :
        ok = False
if ok == True:
    print("APPROVED")
else :
    print("DENIED")


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

void solve(){
	string a, b;
	cin >> a >> b;
	
	int ans = 0;
	for(int i = 0; i < a.size(); i++){
		ans += a[i] != b[i];
	}
	cout << ans << endl;
}

int32_t main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int tc = 1;
	//cin >> tc;
	while(tc--)
		solve();
}


Measured memory_bytes: 3816
#include <stdio.h>

int N;
char yukati[16];

void sumipe(int asumi, int iguti) {
	if (asumi >= N) {
		yukati[asumi] = '\0';
		puts(yukati);
	} else {
		int i;
		for (i = 0; i <= iguti; i++) {
			yukati[asumi] = 'a' + i;
			sumipe(asumi + 1, iguti + (i >= iguti));
		}
	}
}

int main(void) {
	if (scanf("%d", &N) != 1) return 1;
	sumipe(0, 0);
	return 0;
}


Measured memory_bytes: 1624
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

vector<string> rec(int n) {
  if (n == 1) {
    return vector<string>({"a"});
  }

  vector<string> res;
  vector<string> sub = rec(n-1);
  for (string s : sub) {
    char max_c = 'a';
    for (char c : s) {
      max_c = max(max_c, c);
    }
    max_c++;
    for (char c = 'a'; c <= max_c; c++) {
      res.push_back(s + c);
    }
  }
  return res;
}

int main(){
  int n;
  cin >> n;
  
  vector<string> ans = rec(n);
  sort(all(ans));
  for (string s : ans) {
    cout << s << endl;
  }
}


Measured memory_bytes: 10956
#include <iostream>
#include <algorithm>
using namespace std;
#include <vector>
#include <map>
#include <set>
#include <cmath>    //floor ceil
#include <cstdio>
#include <climits>  //INT_MAX
#include <cstring>
#include <cstdlib>

#define endl '\n'
#define lli long long int

int main () {
    int n,x,t;
    cin >> n >> x >>t;
    cout<<(int)ceil((float)n/x)*t;
    return 0;
}

Measured memory_bytes: 3616
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

import itertools
n, k = LI()
s = []
for i in range(k):
    d = int(input())
    a = LI()
    s.append(a)
s = list(itertools.chain.from_iterable(s))
ans = 0
for i in range(1, n+1):
    if i not in s:
        ans += 1
print(ans)

Measured memory_bytes: 9200
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    h = LI()
    h.insert(0,0)
    dp = [[float("inf")]*(n+1) for i in range(n+1)]
    dp[0][0] = 0
    for i in range(n):
        ni = i+1
        hi = h[ni]
        for s in range(n):
            ns = s+1
            for j in range(ni):
                hj = h[j]
                nd = dp[j][s]+max(0,hi-hj)
                if nd < dp[ni][ns]:
                    dp[ni][ns] = nd
    ans = min([dp[i][n-k] for i in range(n+1)])
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 46044
def main():
    n , y = map( int , input().split() )
    y = y // 1000
    flag = 0
    ans = [ -1 , -1 , -1 ]
    for a in range( n + 1 ):
        # 10yen
        sum = a * 10
        if sum > y:
            break

        for b in range( n + 1 - a ):
            #5yen
            sum_ = sum
            sum_ += b * 5
            if sum_ > y:
                break
            if y - sum_ == n - a - b:
                flag = 1
                ans[0] = a
                ans[1] = b
                ans[2] = n - a - b
                break
        if flag:
            break
    print( *ans )

main()

Measured memory_bytes: 9148
#include<iostream>
#include<cmath>

using namespace std;

int main(){
    long long n;
    cin>>n;
    long long ans=0;
    for(long long i=1;i<n+1;i++){
        int x;
        x=n/i;

        ans+=x*(2*i+(x-1)*i)/2;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int a, b, avg_int;
  double avg;
  cin >> a >> b;
  avg_int = avg = (a + b) / 2.0;
  
  if ((avg - avg_int) >= 0.5)
    avg_int += 1;
  cout << avg_int << endl;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



int main()
{
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector <ll> a(X), b(Y), c(Z);
	for (int i = 0; i < X; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < Y; ++i)
	{
		cin >> b[i];
	}
	for (int i = 0; i < Z; ++i)
	{
		cin >> c[i];
	}

	vector <ll> bc;

	for (int i = 0; i < Y; ++i)
	{
		for (int k = 0; k < Z; ++k)
		{
			bc.push_back(b[i]+c[k]);
		}
	}
	sort(bc.rbegin(), bc.rend());
	sort(a.begin(), a.end());

	vector <int> bcidx(X);

	for (int turn = 0; turn < K; ++turn)
	{
		ll bestval = NG;
		ll besti = NG;

		for (int i=0;i<X;i++)
		{
			if (bcidx[i] < SZ(bc))
			{
				const ll val = a[i] + bc[bcidx[i]];
				if (val > bestval)
				{
					bestval = val;
					besti = i;
				}
			}
		}

		cout << bestval << endl;
		bcidx[besti]++;
	}

	return 0;
}


Measured memory_bytes: 10608
#include <cstdio>
using namespace std;
int main(){
  int n, x, i, j, k;
  for (; ;) {
    int cnt=0;
    scanf("%d %d", &n, &x);
    if (n==0 && x==0) break;
    for (i=1; i<n+1; i++) {
      for (j=i+1; j<n+1; j++) {
        for (k=j+1; k<n+1; k++) {
          if (i+j+k==x) cnt++;
        }
      }
    }
    printf("%d\n", cnt);
  }
}


Measured memory_bytes: 2700