akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	dp := make([]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = N
	}
	dp[0] = 0
	for i := 0; i <= N; i++ {
		for j := 6; N-(i+j) >= 0; j *= 6 {
			dp[i+j] = min(dp[i+j], dp[i]+1)
		}
		for k := 9; N-(i+k) >= 0; k *= 9 {
			dp[i+k] = min(dp[i+k], dp[i]+1)
		}
	}

	min := N
	for i := 0; i <= N; i++ {
		A := dp[i] + (N - i)
		if min > A {
			min = A
		}
	}
	fmt.Println(min)

}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(void) {
  int N, mi = 1000;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    int cnt = 0;
    while (a % 2 == 0) {
      cnt++;
      a /= 2;
    }
    mi = min(mi, cnt);
  }
  cout << mi << endl;
  return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main(){
    int N;
    cin>>N;
    N %= 1000;
    int ans = 1000-N;
    if(ans==1000) ans = 0;
    cout<<ans<<endl;
}

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

bool data[10010];

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

	int n;
	while(cin >> n && n != 0){
		fill(data, data + n + 1, true);

		data[1] = false;
		data[0] = false;
		for(int i = 2; i <= n; ++i){
			for(int j = 2; i * j <= n; ++j){
				data[i * j] = false;
			}
		}

		for(int i = n; i >= 2; --i){
			if(data[i] && data[i - 2]){
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1208
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int max = 0;
		int idx = 0;
		for (int i = 0; i < 3; i++) {
		    int x = sc.nextInt();
		    if (max < x) {
		        max = x;
		        idx = i;
		    }
		}
		System.out.println((char)('A' + idx));
	}
}



Measured memory_bytes: 26376
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M):
    return 'Yes' if N == M else 'No'


def main():
    N, M = read_int_n()
    print(slv(N, M))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6724
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),a=nxtl(),b=nxtl();
    vector <int> v(n);
    generate(all(v),nxt);
    ll test=0;
    for(int i=0;i<n-1;i++)
    {
        test+=min(b,a*(v[i+1]-v[i]));
    }
    cout<<test<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 640
#include <stdio.h>

int main() {
	int i, k;
	int N, gu=0, ki=0;
	scanf("%d", &N);
	for (i=0; i < N ;i++) {
		scanf("%d", &k);
		if (k%2 == 0) gu++;
		else ki++;
	}
	if (gu==0&&ki%2==0) {
		printf("YES\n");
	} else if (ki==0&&gu%2==0) {
		printf("YES\n");
	} else if (ki%2==0&&gu%2!=0) {
		printf("YES\n");
	} else if (gu%2==0&&ki%2==0) {
		printf("YES\n");
	} else printf("NO\n");
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)


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


Measured memory_bytes: 256
# B
N, M, X, Y = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
war = True

for Z in range(X + 1, Y+1):
    if max(x) < Z <= min(y):
        war = False
        break

if war:
    print('War')
else:
    print('No War')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define rep(i,x) for(int (i)=1;(i)<=(x);(i)++)
#define repp(i,x,y) for(int (i)=(x);(i)<=(y);(i)++)
#define forn(i,x) for(int (i)=0;(i)<(x);(i)++)
#define foreach(i,x) for(auto (i):(x))
using namespace std;
typedef pair<int,int>pii;
int n,h,w;
int main(){
	cin>>n>>h>>w;
	int ans=0;
	for(int i=1;i<=n;i++){
		int x,y;
		cin>>x>>y;
		if(x>=h&&y>=w)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    set<string> palabras;
    string s;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        palabras.insert(s);
    }
    cout << (int)(palabras.size()) << endl;
    return 0;
}


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

a = []
b = []

for i in range(n):
  x, y = map(int, input().split())
  a.append(x)
  b.append(y)

max_a = max(a)

ans = 0
for x in reversed(sorted(filter(lambda x: x >= max_a, b))):
  h -= x
  ans += 1
  if h <= 0: break

ans += max(0, (h + max_a - 1) // max_a)
print(ans)



Measured memory_bytes: 12112
MOD = 10**9+7         # 問題に合わせて適宜書き換え
list_size = 10000    # 問題に合わせて適宜書き換え

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(1,list_size):
	f_list[i] = f_list[i-1]*i % MOD

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(-2, -list_size-1, -1):
	f_r_list[i] = ((f_r_list[i+1] * (list_size + 1 + i)) % MOD)

def comb(n,r):
    if n < r:
        return 0
    if n==0 or r == 0 or n == r:
        return 1
    return (((f_list[n] * f_r_list[n - r]) % MOD) * f_r_list[r]) % MOD

def P(n,r):
    if n < r:
        return 0
    if r == 0 or n == 0:
        return 1
    return (f_list[n] * f_r_list[n - r]) % MOD

S = int(input())
ans = 0
for i in range(S//3):
    hoge = comb(S-3*(i+1)+i,i)
    ans = (hoge+ans)%MOD
print(ans)

Measured memory_bytes: 9604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n;
    double sum;
    rep(i, n){
        double a;cin>>a;
        sum += 1/a;
    }
    printf("%.9f\n", 1/sum);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
    int X;
    while(~scanf("%d",&X))
    {
        int res=0,i=0;
        for(i=1;res<X;i++)
        {
            res=i*(i+1)/2;
        }
        printf("%d\n",--i);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if(b>=c)
		cout<<b+c;
	else
	{
		if((a+b)>=c)
			cout<<b+c;
		else
			cout<<a+b+b+1;
	}
	return 0;
}

Measured memory_bytes: 888
/*
 * @Author: Kaizyn
 * @Date: 2020-03-12 11:21:40
 * @LastEditors: Kaizyn
 * @LastEditTime: 2020-03-12 12:03:34
 * @FilePath: \Code\atcoder\abc158F_2.cpp
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 2e5+7;
const int MOD = 998244353;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;

template <typename T, typename U = greater<T>>
struct SegmentTree
{
    U cmp = U();
    int n;
    T tr[N<<2], init_val = cmp(0, 1) ? INF : -INF;
    SegmentTree(){}
    T mv(const T &x, const T &y) { return cmp(x, y) ? x : y;}
    void build(const int &_n) { n = _n; _build(1, n); }
    void modify(const int &x, const T &k) { _modify(x, k, 1, n); }
    T query(const int &x) { return _query(x, x, 1, n); }
    T query(const int &l, const int &r) { return _query(l, r, 1, n); }
private :
    void push_up(const int &i) { tr[i] = mv(tr[i<<1], tr[i<<1|1]); }
    void _build(const int &l, const int &r, const int &i = 1) {
        if (l == r) { tr[i] = l; return; }
        int mid = (l+r)>>1;
        _build(l, mid, i<<1);
        _build(mid+1, r, i<<1|1);
        push_up(i);
    }
    void _modify(const int &x, const T &k, const int &trl, const int &trr, const int &i = 1) {
        if (trl == x && trr == x) {
            tr[i] = k;
            return;
        }
        int mid = (trl+trr)>>1;
        if (x <= mid) _modify(x, k, trl, mid, i<<1);
        else _modify(x, k, mid+1, trr, i<<1|1);
        push_up(i);
    }
    T _query(const int &l, const int &r, const int &trl, const int &trr, const int &i = 1) {
        if (trl >= l && trr <= r) return tr[i];
        int mid = (trl+trr)>>1;
        T res = init_val;
        if (l <= mid) res = mv(res, _query(l, r, trl, mid, i<<1));
        if (r >  mid) res = mv(res, _query(l, r, mid+1, trr, i<<1|1));
        return res;
    }
};

struct Node
{
    int x, d;
    Node(){}
    Node(const int _x ,const int _d = 0) : x(_x), d(_d) {}
    friend bool operator < (const Node &n1, const Node &n2) {
        return n1.x < n2.x;
    }
    friend istream& operator >> (istream &is, Node &nd) {
        return is >> nd.x >> nd.d;
    }
} a[N];

int n;
int rig[N], dp[N];
SegmentTree<int> ST;

inline void solve()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a+1, a+n+1);
    ST.build(n); // ST.query(i) == i
    dp[n+1] = 1;
    for (int i = n; i; --i) {
        int p = lower_bound(a+i, a+n+1, (Node)(a[i].x+a[i].d))-a-1;
        rig[i] = ST.query(i, p);
        ST.modify(i, rig[i]);
        // i'th is choose or not
        dp[i] = (dp[rig[i]+1]+dp[i+1])%MOD;
    }
    cout << dp[1] << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

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

using ll = long long;
using namespace std;

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

int main(void) {
	int n;
	cin >> n;
	n--;
	cout << n / 2 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,d=0;
int p[50],s[50];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>p[i];
	for(int i=0;i<n;i++)
	s[i]=i+1;
	for(int i=0;i<n;i++)
	if(s[i]!=p[i])
	d++;
	if(d==0||d==2)
	{
		cout<<"YES";
	}
	else
	cout<<"NO";
	return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) ((n)*(n))

using namespace std;
using ll = long long;
const int INF = 2e9;
const int MOD = 1e9+7;

#define N 1005
char grid[N][N];
int dp[N][N];

int main() {
    FAST;

    int h, w, i, j;
    cin >> h >> w;

    for (i = 0; i < h; ++i) {
        for (j = 0; j < w; ++j) cin >> grid[i][j];
    }

    for (i = 1, j = 0; i < h; ++i) {
        if (grid[i][j] == '#') break;
        dp[i][j] = 1;
    }

    for (i = 0, j = 1; j < w; ++j) {
        if (grid[i][j] == '#') break;
        dp[i][j] = 1;
    }

    for (i = 1; i < h; ++i) {
        for (j = 1; j < w; ++j) {
            if (grid[i][j] == '#') continue;
            dp[i][j] = (dp[i-1][j]+dp[i][j-1]) % MOD;
        }
    }

    cout << dp[h-1][w-1];

    return 0;
}


Measured memory_bytes: 5248
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map { it.toInt() }
    val cnt = IntArray(n)
    d.forEach { cnt[it]++ }
    var ans = 1L
    val div = 998244353
    val max = d.max()!!
    if(d.first()!=0 || d.count { it==0 } != 1) {
        println(0)
        return
    }
    for(i in (1..max)) {
        repeat(cnt[i]) {
            ans*=cnt[i-1]
            ans%=div
        }
    }
    println(ans)
}

Measured memory_bytes: 50012
using System;
using System.Collections.Generic;

class Program {
	static void Main() {
		var N = NextInt();
		var max = int.MinValue;
		var min = int.MaxValue;

		for (var i = 0; i < N; i++) {
			var a = NextInt();
			max = Math.Max(max, a);
			min = Math.Min(min, a);
		}

		Console.WriteLine(max - min);
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Console.Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}


Measured memory_bytes: 13268
from collections import defaultdict


def solve(row, col, d):
    x_map = defaultdict()

    for i in range(row):
        a_i = list(map(int, input().split()))
        for j in range(col):
            x_map[a_i[j]] = (i, j)

    q = int(input())

    dp = [0]*(row*col+1)
    for j in range(d+1, row*col+1):
        x_map_y = abs(x_map[j][0] - x_map[j-d][0])
        x_map_x = abs(x_map[j][1] - x_map[j-d][1])
        dp[j] = dp[j-d]+x_map_y+x_map_x
#        print("j {0} x_map_y : {1} x_map_x : {2} dp[j] : {3}".format(
#            j, x_map_y, x_map_x, dp[j]))

    for _ in range(q):
        l, r = map(int, input().split())
        print(dp[r]-dp[l])


if __name__ == '__main__':
    row, col, d = map(int, input().split())
    solve(row, col, d)


Measured memory_bytes: 22880
#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() {
  string s;
  cin >> s;
  rep(i,s.length()) printf("%s","x");
  printf("\n");
  return 0;
}


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

N = int(input())

F = []
F.append(2)
F.append(1)

if N >= 2:
    for i in range(2, N + 1):
        F.append(F[i - 1] + F[i - 2])
    print(F[N])
else:
    print(F[N])


Measured memory_bytes: 2940
n,k = map(int,input().split())
li1 = []
li2 = [0]*n
for i in range(n):
    li2[i] = i+1
for i in range(k):
    a = input()
    b = [int(j) for j in input().split()]
    for j in range(len(b)):
        li1.append(b[j])
print(len(set(li1) ^ set(li2)))

Measured memory_bytes: 67732
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); ++i)
#define rep2(i,n) for(int i=1;i<=(n);++i)

using namespace std;
typedef long long ll;
typedef vector<int> vi;

const int NMAX = 100000;
const int MMAX = 100000;
const int k = 200000;
static const int INF = 1<<21;
static const int NIL = -1;
static const int mod = 1e9+7;


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

    int h,w;
    cin >> h >> w;

    string str(w+2, '#');
    cout << str << endl;
    rep(i,h){
        char data[101];
        cin >> data;

        cout << '#' << data << '#' << endl;
    }
    cout << str << endl;

    return 0;
}

Measured memory_bytes: 256
def solve(n, s):
    counts = [0, 0]
    for l in s:
        if l == ')':
            if counts[0] > 0:
                counts[0] -= 1
            else:
                counts[1] += 1
        if l == '(':
            counts[0] += 1
    return '(' * counts[1] + s + ')' * counts[0]

_n = int(input())
_s = input()
print(solve(_n, _s))


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

int main() {
	char a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=(a-'0')*10+b-'0';
	int y=(c-'0')*10+d-'0';
	if(x>12 or x<=0){
		if(y>12 or y<=0) cout<<"NA";
		else cout<<"YYMM";
	}
	else{
		if(y>12 or y<=0) cout<<"MMYY";
		else cout<<"AMBIGUOUS";
	}
}

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

#define all(v) (v).begin(), (v).end()
using namespace std;

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

    vector <int> length(no_of_sides);
    for(int i = 0; i < no_of_sides; i++)
        cin >> length[i];

    sort(all(length));

    int sum = 0;
    for(int i = 0; i < no_of_sides - 1; i++)
        sum += length[i];

    cout << (sum > length[no_of_sides - 1] ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int h, w, d;
    cin >> h >> w >> d;
    int sz = h * w;
    vector<P> pos(sz);
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            int a;
            cin >> a;
            pos[--a] = P(i, j);
        }
    }
    vector<vector<int>> a(d, vector<int>(sz / d + 1, 0));
    for(int i = 0; i < sz; ++i){
        if(i + d >= sz) continue;
        int foo = i % d;
        int bar = i / d;
        int x = pos[i].first, y = pos[i].second;
        int nx = pos[i + d].first, ny = pos[i + d].second;
        int cost = abs(x - nx) + abs(y - ny);
        a[foo][bar + 1] = cost;
    }
    for(int i = 0; i < d; ++i){
        for(int j = 0; j < sz / d; ++j){
            a[i][j + 1] += a[i][j];
        }
    }
    cerr << sz / d << endl;
    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        --l, --r;
        int m = l % d;
        int st = l / d, ed = r / d;
        // cerr << "m=" << m << " ";
        // cerr << "(st,ed) = ";
        // cerr << "(" << st << "," << ed << ")\n";
        cout << a[m][ed] - a[m][st] << "\n";
    }
}

Measured memory_bytes: 6144
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
p=tuple(limii())
q=tuple(limii())

c = list(permutations(range(1,n+1), n))

print(abs(c.index(p)-c.index(q)))



Measured memory_bytes: 69612
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
N = readline()
A = parseMap(split(readline()))
Q = parseInt(readline())


D = Dict{Int, Int}()

before_sum = sum(A)
for a in A
    if a in keys(D)
        D[a] += 1
    else
        D[a] = 1
    end
end


for _ in 1:Q
    B, C = parseMap(split(readline()))
    if B in keys(D)
        before_sum += D[B] * (C - B)
    else
        println(before_sum)
        continue
    end
    if C in keys(D)
        D[C] += D[B]
    else
        D[C] = D[B]
    end
    D[B] = 0
    println(before_sum)
end
end

main()


Measured memory_bytes: 205808
// Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#define pc(...)
#endif

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        double l;
        cin >> l;
        l /= 3;
        cout << fixed << setprecision(10);
        cout << l * l * l << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i,j,H,W;cin>>H>>W;
	static char coins[601][601];
	for(i=0;i<=600;i++){
		for(j=0;j<=600;j++){coins[i][j]='.';}
	}
	for(int i=0;i<H;i++){
		string str;cin>>str;
		for(int j=0;j<W;j++){coins[i+j+1][i+W-j]=str[j];}
	}
	static int imo[602][602]={0};
	vector<int>aru;aru.reserve(H+W);
	for(i=1;i<H+W;i++){
		aru.clear();
		for(j=1;j<H+W;j++){
			
			if(coins[i][j]=='.'){continue;}
			for(auto x:aru){
				int sa=j-x;
				imo[max(0,i-sa)][x]++;
				imo[max(0,i-sa)][j+1]--;
				imo[min(H+W,i+sa)][x]++;
				imo[min(H+W,i+sa)][j+1]--;
			}
			aru.pub(j);
		}
		
	}
	llint ans=0;
	for(i=0;i<=H+W;i++){
		int gen=0;
		for(j=0;j<=H+W;j++){
			gen+=imo[i][j];
			if(coins[i][j]=='#'){ans+=gen;}
		}
	}
	for(i=0;i<=H+W;i++){
		imo[i][i]=0;
		for(j=i+1;j<=H+W;j++){
			imo[i][j]=0;imo[j][i]=0;
			swap(coins[i][j],coins[j][i]);
		}
	}
	for(i=1;i<H+W;i++){
		aru.clear();
		for(j=1;j<H+W;j++){
			if(coins[i][j]=='.'){continue;}
			for(auto x:aru){
				int sa=j-x;
				imo[max(0,i-sa)][x+1]++;
				imo[max(0,i-sa)][j]--;
				imo[min(H+W,i+sa)][x+1]++;
				imo[min(H+W,i+sa)][j]--;
			}
			aru.pub(j);
		}
	}
	
	for(i=0;i<=H+W;i++){
		int gen=0;
		for(j=0;j<=H+W;j++){
			gen+=imo[i][j];
			if(coins[i][j]=='#'){ans+=gen;}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 100100;

int n,k;
vector<int> g[N];
pii t[N];
int p[N], vis[N];

bool test() {
	scanf("%d", &n);
	FOR(i,n-1) {
		int a,b;
		scanf("%d%d", &a, &b);
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	FOR(i,n) p[i] = -1;
	scanf("%d", &k);
	int mi=1e9;
	FOR(i,k) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		p[a] = b;
		mi = min(mi, b);
	}
	queue<int> q;
	int val = mi;
	FOR(i,n) t[i] = mp(p[i], i);
	sort(t,t+n);
	int j=0;
	for (; j<n && t[j].fi==-1; j++) ;
	for (; j<n && t[j].fi==val; j++) {
		vis[t[j].se]=1;
		q.push(t[j].se);
	}
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		//printf("u=%d (%d)\n", u+1, p[u]);
		if (p[u]>val) {
			val++;
			for (; j<n && t[j].fi==val; j++) if (!vis[t[j].se]) {
				vis[t[j].se]=1;
				q.push(t[j].se);
			}
		}
		FOR(i,SZ(g[u])) {
			int v=g[u][i];
			//printf("v=%d\n", v+1);
			if (p[v] != -1 && abs(p[v]-val) != 1) {
				return 0;
			}
			if (vis[v]) continue;
			p[v] = val+1;
			vis[v] = 1;
			q.push(v);
		}
	}
	return 1;
}

int main() {
	bool ok = test();
	if (ok) {
		printf("Yes\n");
		FOR(i,n) printf("%d\n", p[i]);
	} else {
		printf("No\n");
	}
	return 0;
}


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

mint fact_inverse(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		memo[n]=inverse(fact(n));
		for(int i=n;i>k;i--) memo[i-1]=memo[i]*i;
	}
	return memo[n];
}

mint choose(int n,int k,int type=0){
	if(k<0 || n<k) return 0;
	if(type==0){
		return fact(n)*fact_inverse(k)*fact_inverse(n-k);
	}
	else{
		if(k>n-k) k=n-k;
		mint res=fact_inverse(k);
		rep(i,k) res*=n-i;
		return res;
	}
}

int n,k,a[20];

mint f(int i,int x){
	static bool memo1[20][1001];
	static mint memo2[20][1001];
	if(memo1[i][x]) return memo2[i][x];
	memo1[i][x]=true;
	return memo2[i][x]=choose(n-x,a[i]-x)/fact(x);
}

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

	mint dp[1001][21];
	dp[0][0]=1;
	rep(i,n+1) rep(j,k) rep(x,i+1) dp[i][j+1]+=f(j,x)*dp[i-x][j];

	cout<<fact(n)*dp[n][k]<<'\n';

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int a[101];
int main()
{
	int i,area;
	for(i=0 ; i<3 ; i++)
	{
		scanf("%d",&a[i]);
	}
	area = (a[0]+a[1])*a[2]/2;
	printf("%d",area);
	return 0;
}

Measured memory_bytes: 128
Ss = '>' + input() + '<'

N = len(Ss) - 1

A1s = [0] * N
for i in range(N):
    if Ss[i:i+2] == '><':
        A1s[i] = 0
    elif Ss[i:i+2] != '>>':
        A1s[i] = A1s[i-1] + 1

A2s = [0] * N
for i in reversed(range(N)):
    if Ss[i:i+2] == '><':
        A2s[i] = 0
    elif Ss[i:i+2] != '<<':
        A2s[i] = A2s[i+1] + 1

As = [A1 if A1 >= A2 else A2 for A1, A2 in zip(A1s, A2s)]
print(sum(As))


Measured memory_bytes: 31920
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

/*
  AOJ :: 0100
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=jp
 */

typedef long long ll;

int main(){
    int n,num,tanka,count,i;
    vector<int> jun;
    set<int> S;
    map<int,ll> mll;

    while( cin >> n, n ){
        // init
        jun.clear(); S.clear(); mll.clear();

        rep(i,n){
            cin >> num >> tanka >> count;

            if( S.count(num) == 0 ){
                jun.push_back(num);
                S.insert(num);
            }
            mll[num] += (ll)tanka * (ll)count;
        }

        bool ok = false;
        rep(i,jun.size()){
            if( mll[jun[i]] >= 1000000 ){
                ok = true;
                printf("%d\n",jun[i]);
            }
        }
        if( !ok ){
            puts("NA");
        }
    }

    return 0;
}

Measured memory_bytes: 0
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 301010
int n , m , BIT[ N ];
inline int lb( int x ){
  return x & (-x);
}
void modify( int x , int dlt ){
  for( int i = x ; i <= m ; i += lb( i ) )
    BIT[ i ] += dlt;
}
int query( int x ){
  int ret = 0;
  for( int i = x ; i ; i -= lb( i ) )
    ret += BIT[ i ];
  return ret;
}
void build(){

}
int ans[ N ] , l[ N ] , r[ N ];
vector<int> v[ N ];
void init(){
  n = getint();
  m = getint();
  for( int i = 0 ; i < n ; i ++ ){
    l[ i ] = getint();
    r[ i ] = getint();
    ans[ r[ i ] - l[ i ] + 1 ] ++;
    v[ r[ i ] - l[ i ] + 2 ].push_back( i );
  }
  for( int i = N - 2 ; i >= 0 ; i -- )
    ans[ i ] += ans[ i + 1 ];
}
void solve(){
  for( int i = 1 ; i <= m ; i ++ ){
    for( int x : v[ i ] ){
      modify( l[ x ] , + 1 );
      modify( r[ x ] + 1 , - 1 );
    }
    for( int j = i ; j <= m ; j += i )
      ans[ i ] += query( j );
    printf( "%d\n" , ans[ i ] );
  }
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 14976
from itertools import combinations as cmbs
import sys
c = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(int(input())):
  si = sys.stdin.readline()
  if si[0] in c:
    c[si[0]] += 1
ans = sum(i*j*k for i,j,k in cmbs(c.values(),r=3))
print(ans)


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    char a, b;
    cin >> a >> b;
    if (a == b)
        cout << 'H' << endl;
    else
        cout << 'D' << endl;
    return 0;
}

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

using namespace std;

int main(){
    int N, a, Q, B, C;
    long long ans = 0;
    cin >> N;
    vector<int> A_count(100000, 0);
    for (int i=0; i < N; i++) {
        cin >> a;
        A_count[a - 1]++;
        ans += a;
    }
    cin >> Q;
    for (int i=0; i < Q; i++) {
        cin >> B >> C;
        A_count[C - 1] += A_count[B - 1];
        ans += (C - B) * A_count[B - 1];
        
        A_count[B - 1] = 0;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3780
import math
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]


N = getInput()[0]
sums = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        n = math.gcd(i, j)
        for k in range(1, N+1):
            sums += math.gcd(n, k)

print(sums)


Measured memory_bytes: 9172
n = int(input())
l = list(map(int,input().split()))
flg = 0
cnt=0
for i in range(n-1):
    if l[i+1]==l[i]:
        continue
    elif l[i+1]>l[i]:
        if flg==-1:
            cnt+=1
            flg=0
        else:
            flg=1
    else:
        if l[i+1]<l[i]:
            if flg==1:
                cnt+=1
                flg=0
            else:
                flg=-1
print(cnt+1)

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N;
int A[222222];

vint get(int n){
    vint ret;
    for(int i=1;i<=n;i++){
        if(n%i==0)ret.pb(i);
    }
    return ret;
}

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];

    vint lis=get(N);

    for(int k:lis){
        bool ok=true;
        for(int i=0;i+k<N;i++){
            if(A[i]!=A[i+k])ok=false;
        }
        if(ok){
            cout<<N/k<<endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
	
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

	string ans = "";
	int tmp;

	tmp = ty - sy;
	while (tmp--) {
		ans += "U";
	}
	tmp = tx - sx;
	while (tmp--) {
		ans += "R";
	}
	tmp = ty - sy;
	while (tmp--) {
		ans += "D";
	}
	tmp = tx - sx;
	while (tmp--) {
		ans += "L";
	}

	ans += "L";
	tmp = ty - sy + 1;
	while (tmp--) {
		ans += "U";
	}
	tmp = tx - sx + 1;
	while (tmp--) {
		ans += "R";
	}
	ans += "D";
	ans += "R";
	tmp = ty - sy + 1;
	while (tmp--) {
		ans += "D";
	}
	tmp = tx - sx + 1;
	while (tmp--) {
		ans += "L";
	}
	ans += "U";

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

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

vector<int> parent(100005,0);
vector<int> size(100005,0);

void make_set(int a)
{
    parent[a] = a;
    size[a] = 1;
}

int find_set(int a)
{
    if(a == parent[a])
        return a;
    return parent[a] = find_set(parent[a]);
}

void union_set(int a, int b)
{
    a = find_set(a);
    b = find_set(b);
    if(a!=b)
    {
        if(size[a] < size[b])
            swap(a,b);
        parent[b] = a;
        size[a]+=size[b];
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
    }
    int solved = 0;
    for(int i=0;i<n;i++)
    {
        int answer = 0;
        for(int j=0;j<m;j++)
        {
            int temp;
            cin>>temp;
            answer=answer+(temp*b[j]);
        }
        answer+=c;
        if(answer>0)
            solved++;
    }
    cout<<solved;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
int a, b, c;
int cnt_a, cnt_b, cnt_c;
bool flag = true;
int main() {
	int i = 0;
	while (cin >> a >> b >> c, flag) {
		int maxV, minV, cen;
		maxV = max(a, max(b, c));
		minV = min(a, min(b, c));
		cen = a + b + c - minV - maxV;
		
		if (a + b > c&&a + c > b&&b + c > a) {
			if (minV*minV + cen * cen - maxV * maxV == 0) {
				cnt_b++; i++;
				continue;
			}
			 else if (minV*minV + cen * cen - maxV * maxV > 0) {
				cnt_a++; i++;
				continue;
			}
			
			else if (minV*minV + cen * cen - maxV * maxV < 0) {
				cnt_c++; i++;
				continue;
			}
		}else {
			flag = false;
		}
		if (!flag) break;
	}
	cout << i << " " << cnt_b << " " << cnt_a << " " << cnt_c << endl;
	return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	int n;
	cin >> n;

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

	int ans = 1;
	bool up = false, down = false;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] < a[i + 1]) {
			up = true;
		}

		if (a[i] > a[i + 1]) {
			down = true;
		}

		if (up && down) {
			up = down = false;
			ans++;
		}
	}

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

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int A[101];
int B[101];
int C[101];

int main()
{
	int n, r; 
	while(1) {
		cin >> n >> r;
		if (!n && !r) break;
		rep(i,0,n) A[i] = n-i;
		rep(i,0,r) {
			int t, c; cin >> t >> c;
			t--;
			// ??????
			rep(j,0,t) B[j] = A[j];
			rep(j,t,t+c) C[j-t] = A[j];
			// ??????
			rep(j,0,c) A[j] = C[j];
			rep(j,c,c+t) A[j] = B[j-c];
		}
		cout << A[0] << endl;
	}

 	return 0;
}

Measured memory_bytes: 3080