akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define loop(i,l,r) for(int i=(l);i<=(r);i++)
typedef long long LL;
const int maxn=2e5+5;
const int p=1e9+7;
LL quick_mod(LL a, LL b)
{
    LL ans = 1;
    a %= p;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * a % p;
            b--;
        }
        b >>= 1;
        a = a * a % p;
    }
    return ans;
}
 
LL C(LL n, LL m)
{
    if(m > n) return 0;
    LL ans = 1;
    for(int i=1; i<=m; i++)
    {
        LL a = (n + i - m) % p;
        LL b = i % p;
        ans = ans * (a * quick_mod(b, p-2) % p) % p;
    }
    return ans;
}
 
LL Lucas(LL n, LL m)
{
    if(m == 0) return 1;
    return C(n % p, m % p) * Lucas(n / p, m / p) % p;
}
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int m=n-k;
    printf("%d\n",m+1);
    for(int i=2;i<=k;i++)
    {
        int cnt=m-i+1;
        LL ans;
        ans=(Lucas(k-1,i-1)*Lucas(cnt+i,i))%p;
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 3836
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n,m):
        xd = collections.defaultdict(int)
        nd = collections.defaultdict(int)
        for i in range(1,n+1):
            nd[i] = 0
            xd[i] = 0

        for _ in range(m):
            t = LI()
            s = t[0]
            if t[1] == 1:
                nd[t[2]] += s
            for i in t[2:]:
                xd[i] += s

        na = sorted(nd.items(), key=lambda x: [x[1], x[0]])
        xa = sorted(xd.items(), key=lambda x: [-x[1], x[0]])
        if na[0][0] != xa[0][0]:
            return xa[0][1] - na[0][1] + 1
        r = xa[1][1] - na[0][1] + 1
        t = xa[0][1] - na[1][1] + 1
        if r < t:
            r = t

        return r

    while 1:
        n,m = LI()
        if n == 0:
            break
        rr.append(f(n,m))

    return '\n'.join(map(str, rr))


print(main())



Measured memory_bytes: 13024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int N = Console.ReadLine().ToInt();

        var xyList =
            ReadLines(N)
            .Select(line => line.ToIntArray())
            .Select(arr => new { x = arr[0], y = arr[1] })
            .ToArray();

        if (N == 1)
        {
            Console.WriteLine(1);
            return;

        }

        var candList = xyList.Take(0).ToList();

        for(int i = 0; i < xyList.Length; i++)
        {
            for(int j = i + 1; j < xyList.Length; j++)
            {
                var xy1 = xyList[i];
                var xy2 = xyList[j];
                var x = xy1.x - xy2.x;
                var y = xy1.y - xy2.y;

                candList.Add(new { x, y });
            }
        }

        int min = int.MaxValue;

        foreach(var cand in candList)
        {
            var val = 0;
            foreach(var xy in xyList)
            {
                var x = xy.x - cand.x;
                var y = xy.y - cand.y;
                var ddd = new { x, y };
                if (xyList.Contains(ddd) == false)
                {
                    val += 1;
                }
            }

            min = Math.Min(val, min);
        }

        Console.WriteLine(min);
    }
}

Measured memory_bytes: 13536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
 
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
  ll a,b; cin>>a>>b;
  cout << (a+b==15?'+':(a*b==15?'*':'x'))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int odp = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        odp += b - a + 1;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define SORT(a) sort(a.begin(),a.end())
 
int main() {
	
	//string ans="";
	//vector<int> c(30,0);
	//cout << a << b << endl;
	
	
	int ans=0;
	
	int n;
	
	cin >> n;// >> b;
	
	vector<int> a(n);
	
	rep(i,n) cin >> a[i];
	
	rep(i,n-1){
		for(int j=i+1;j<n;j++){
			ans+=a[i]*a[j];
		}
	}

	
    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 256
S = input()

if S == 'SUN':
  output = 7
elif S == 'MON':
  output = 6
elif S == 'TUE':
  output = 5
elif S == 'WED':
  output = 4
elif S == 'THU':
  output = 3
elif S == 'FRI':
  output = 2
elif S == 'SAT':
  output = 1

print(output)

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

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
typedef pair<double, pair<int, int> > pii;

int a, b, c, d, e, f;
bool ab[3001], cd[3001];
vector<pii> dens;

int main(){
    cin >> a >> b >> c >> d >> e >> f;
    a = 100*a; b = 100*b;
    
    REP(i, f+1){
        ab[i] = false; cd[i] = false;
    }
    ab[0] = true; cd[0] = true;

    REP(i, f+1){
        if(i-a >= 0 && ab[i-a]) ab[i] = true;
        if(i-c >= 0 && cd[i-c]) cd[i] = true;
    }
    REP(i, f+1){
        if(i-b >= 0 && ab[i-b]) ab[i] = true;
        if(i-d >= 0 && cd[i-d]) cd[i] = true;
    }

    dens = vector<pii>();
    REP(i, f+1){
        if(ab[i]){
            int max_s = min(i*e/100, f-i);
            int sugar;
            for(int j=max_s; j>=0; j--){
                if(cd[j]){
                    sugar = j; break;
                }
            }
            pii d;
            d.first = (double)sugar * 100 / (sugar + i);
            d.second.first = i + sugar;
            d.second.second = sugar;
            dens.push_back(d);
        }
    }

    sort(dens.begin(), dens.end(), greater<pii>());
    cout << dens[0].second.first << " " << dens[0].second.second << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	bool takaTurn = true;
	while(a>0 && c>0){
		if(takaTurn)
		{
			c-=b;
			takaTurn = false;
		}
		else
		{
			a-=d;
			takaTurn = true;
		}
	}
	if(a>0)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3604
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        Map<String, Integer> map = new HashMap<>();
        for(int i = 0; i < 4; i++) {
            if(map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i])+1);
            }else {
                map.put(s[i], 1);
            }
        }
        
        String ans = "Yes";
        for(int i = 0; i < 4; i++) {
            if(map.get(s[i]) == 2) {
                continue;
            }else {
                ans = "No";
                break;
            }
        }
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node {
    int key;
    int left;
    int right;
};

int n;
char command[7];

Node tree[500000];
int tree_num;
int root = -1;

inline int create_node(int key) {
    Node& node = tree[tree_num];
    node.key = key;
    node.left = -1;
    node.right = -1;
    return tree_num++;
}

inline void insert(int key) {

    if (root == -1) {
        root = create_node(key);
        return;
    }

    int node = root, parent = 0;
    while (node != -1) {
        parent = node;
        if (key < tree[node].key) {
            node = tree[node].left;
        }
        else {
            node = tree[node].right;
        }
    }

    int newnode = create_node(key);
    if (key < tree[parent].key) {
        tree[parent].left = newnode;
    }
    else {
        tree[parent].right = newnode;
    }
}

inline int find(int key) {
    int node = root;
    while (node != -1) {
        if (tree[node].key == key) {
            return node;
        }
        else if (tree[node].key > key) {
            node = tree[node].left;
        }
        else {
            node = tree[node].right;
        }
    }
    return -1;
}

void pre_order(int root) {
    Node& node = tree[root];
    printf(" %d", node.key);
    if (node.left != -1) {
        pre_order(node.left);
    }
    if (node.right != -1) {
        pre_order(node.right);
    }
}

void in_order(int root) {
    Node& node = tree[root];
    if (node.left != -1) {
        in_order(node.left);
    }
    printf(" %d", node.key);
    if (node.right != -1) {
        in_order(node.right);
    }
}

int main(void) {

    scanf("%d", &n);

    for (int i = 0, key; i < n; ++i) {
        scanf("%s", command);
        if (command[0] == 'i') {
            scanf("%d", &key);
            insert(key);
        }
        else if (command[0] == 'f') {
            scanf("%d", &key);
            int found = find(key);
            printf("%s\n", found != -1 ? "yes" : "no");
        }
        else {  // print 
            if (root == -1) { continue; }
            in_order(0);
            printf("\n");
            pre_order(0);
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 5896
#include <iostream>
#include <string>
#include <vector>
#include <cctype>

using namespace std;

int recur(const vector<string> &pieces, int used, const char *conn){
	int index = __builtin_popcount(used);
	if(index >= 9){ return 1; }
	int x = index % 3, y = index / 3;
	char nextConn[5] = { conn[0], conn[1], conn[2], conn[3], '\0' };
	int answer = 0;
	for(int i = 0; i < pieces.size(); ++i){
		if(used & (1 << i)){ continue; }
		for(int j = 0; j < 4; ++j){
			char up = pieces[i][j], left = pieces[i][(j + 3) % 4];
			if(conn[x] != '\0' && conn[x] != (up ^ 0x20)){ continue; }
			if(conn[3] != '\0' && conn[3] != (left ^ 0x20)){ continue; }
			char down = pieces[i][(j + 2) % 4], right = pieces[i][(j + 1) % 4];
			nextConn[x] = down;
			nextConn[3] = (x == 2 ? '\0' : right);
			answer += recur(pieces, used | (1 << i), nextConn);
		}
	}
	return answer;
}

int main(){
	int N;
	cin >> N;
	while(N--){
		vector<string> pieces(9);
		for(int i = 0; i < 9; ++i){ cin >> pieces[i]; }
		char initConn[5] = { 0 };
		cout << recur(pieces, 0, initConn) << endl;
	}
	return 0;
}

Measured memory_bytes: 932
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

template<int D>
bool solve(double a[][D], double x[], double b[], int n)
{
	double m[D][D+1];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			m[i][j]=a[i][j];
		}
		m[i][n]=b[i];
	}
	for(int i=0;i<n;i++){
		double u=0;
		int uj=-1;
		for(int j=i;j<n;j++){
			int v=abs(m[j][i]);
			if(v>u){
				u=v;
				uj=j;
			}
		}
		// 一意の解がない
		if(uj==-1){
			return false;
		}
		double d=m[uj][i];
		for(int k=i;k<=n;k++){
			swap(m[uj][k],m[i][k]);
			m[i][k]/=d;
		}
		for(int j=0;j<n;j++){
			if(j==i)continue;
			double p=m[j][i];
			for(int k=i;k<=D;k++){
				m[j][k]-=p*m[i][k];
			}
		}
	}
	for(int i=0;i<n;i++){
		x[i]=m[i][n];
	}
	return true;
}
int main() {
while(1){
	int d=0;
	double a[5+2][5+1];
	double b[5+2];
	cin >> d;
	if(d==0)return 0;
	double w[5+3][5+1];
	double v[5+3]; 
	for(int i=0;i<d+3;i++){
		cin >> v[i];
		double p=1;
		for(int j=0;j<d+1;j++){
			w[i][j]=p;
			p*=i;
		}
	}
	for(int p=0;p<d+3;p++){
		int k=0;
		for(int i=0;i<d+3;i++){
			if(p==i)continue;
			for(int j=0;j<d+1;j++){
				a[k][j]=w[i][j];
			}
			b[k]=v[i];
			k++;
		}
		double x[5+1];
		solve(a,x,b,d+1);
		double dot=0;
		for(int i=0;i<d+1;i++){
			dot+=x[i]*a[d+1][i];
		}
		if(abs(dot-b[d+1])<0.1){
			cout << p << endl;
			break;
		}
	}
}}

Measured memory_bytes: 1240
import java.io.*;
import java.util.*;

public class Main {
		
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int Q = sc.nextInt();
		
		int[][] table = new int[N+1][N+1];
		for(int i = 0; i < M; i++){
			int L = sc.nextInt();
			int R = sc.nextInt();
			table[L][R]++;
		}
		
		int[][] sum = new int[N+1][N+1];
		for(int i = 1; i <= N; i++){
			for(int j = 1; j <= N; j++){
				sum[i][j] = table[i][j] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
			}			
		}
		
		for(int i = 0; i < Q; i++){
			int p = sc.nextInt();
			int q = sc.nextInt();
			int ans = sum[q][q] - sum[p-1][q] - sum[q][p-1] + sum[p-1][p-1];
			System.out.println(ans);
		}
		
	}//end main
	
}//end Main

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 67412
package main

import (
    "fmt"
    "os"
)

func main() {

    var A int
    var B int
    var C int
    var X int
    fmt.Fscanf(os.Stdin, "%d\n", &A)
    fmt.Fscanf(os.Stdin, "%d\n", &B)
    fmt.Fscanf(os.Stdin, "%d\n", &C)
    fmt.Fscanf(os.Stdin, "%d\n", &X)

    ans := 0
    for a := 0; a <= A; a++ {
        if a*500 > X {
            continue
        }
        for b := 0; b <= B; b++ {
            remain := X - a*500 - b*100
            if remain < 0 {
                continue
            }
            if remain/50 <= C {
                ans++
            }
        }
    }
    fmt.Printf("%v\n", ans)
}

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

using namespace std;
const int maxn = 200005;
int a[maxn];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int mx = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
        mx = max(mx, a[i]);
    }
    int l = 1, r = mx;
    int ans = mx;
    while (l <= r) {
        int mid = (l + r) >> 1;
        long long tmp = 0;
        for (int i = 1; i <= n; i++) {
            tmp += (a[i] + mid - 1) / mid - 1;
        }
        if (tmp <= k) {
            ans = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 4432
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)

    if len(kind) > 3:
        return False

    if len(kind) == 1 and 0 in kind:
        return True

    if n % 3 != 0:
        return False

    if len(kind) == 3:
        if len(set([nums.count(k) for k in kind])) != 1:
            return False
        kind = list(kind)
        if kind[0] ^ kind[1] ^ kind[2] == 0:
            return True
        else:
            return False
    else:
        if 0 not in kind:
            return False
        elif n / 3 != nums.count(0):
            return False
        else:
            return True


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")


if __name__ == "__main__":
    main()


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

int main() {
    int X, N;  cin >> X >> N;
    vector<int> p(N);
    for (int i = 0; i < N; ++i) cin >> p[i];

    int d = 0;
    while (true) {
        if (find(p.begin(), p.end(), X - d) == p.end()) {
            cout << X - d << endl;
            return 0;
        }
        else if (find(p.begin(), p.end(), X + d) == p.end()) {
            cout << X + d << endl;
            return 0;
        }
        else ++d;
    }
}


Measured memory_bytes: 3580
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const MOD: i64 = 1000000007;

pub fn power(x: i64, y: i64) -> i64 {
    if y == 0 {
        1
    } else if y == 1 {
        x % MOD
    } else if y % 2 == 0 {
        power(x, y / 2).pow(2) % MOD
    } else {
        power(x, y / 2).pow(2) * x % MOD
    }
}

pub fn div(a: i64, b: i64) -> i64 {
    mul(a, power(b, MOD - 2))
}

pub fn add(a: i64, b: i64) -> i64 {
    (a + b) % MOD
}

pub fn mul(a: i64, b: i64) -> i64 {
    ((a % MOD) * (b % MOD)) % MOD
}

pub fn sub(a: i64, b: i64) -> i64 {
  return (a + MOD - b) % MOD;
}

fn main() {
    input! {
    n: usize,
    mut a: [i64; n],
    }

    let mut cnt = 0_i64;
    let mut modsum = 0_i64;
    for i in 0..n {
      modsum = add(modsum, a[i]);
    }

    for i in 0..n-1 {
      modsum =  sub(modsum, a[i]);
      let res = mul(a[i], modsum);
      cnt = add(res, cnt);
    }

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


Measured memory_bytes: 5548
let max_m = 2000

let make_dp a n =
  let dp = Array.make_matrix (n + 1) (max_m + 1) false in
  let rec duduwa i =
    if i <= n then begin
      dp.(i).(a.(i-1)) <- true;
      duduwa (i + 1)
    end in
  let rec doit = function
    | (i, _) when i > n -> dp
    | (i, j) when j > max_m -> doit (i + 1, 1)
    | (i, j) ->
      if dp.(i-1).(j) then dp.(i).(j) <- true
      else if j > a.(i-1) && dp.(i-1).(j-a.(i-1)) then dp.(i).(j) <- true;
      doit (i, j + 1) in
  duduwa 1;
  doit (1, 1)

let () =
  let read_ns () = List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) in
  let n = read_int () in
  let a = Array.of_list (read_ns ()) in
  let _ = read_int () in
  let dp = make_dp a n in
  let m = read_ns () in
  List.iter (fun e -> print_endline (if dp.(n).(e) then "yes" else "no")) m

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

ll f(string s) {
  ll res = 0;
  rep(i, s.size()) {
    res |= (ll)(s[i] - 'a' + 1) << (i * 5);
  }
  return res;
}

void solve() {
  int n;
  cin >> n;
  map<ll, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    ll k = f(s);
    dump(s, k);
    mp[k]++;
  }
  int ans = 0;
  for (auto m : mp) {
    ans++;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 16072
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n);
    REP(i, n){
        cin >> x[i];
    }
    
    ll ans = INF;
    for(ll i = 0; i < n - k + 1; i++){
        if(x[i] <= 0 && x[i + k - 1] <= 0){
            ans = min(ans, -x[i]);
        }
        else if(x[i] >= 0 && x[i + k - 1] >= 0){
            ans = min(ans, x[i + k - 1]);
        }
        else{
            ans = min({ans, -x[i] * 2 + x[i + k - 1], -x[i] + x[i + k - 1] * 2});
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10) cout << a * b << endl;
    else cout << -1 << endl;
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,m,ans,c;
string a,b;

main() {
    cin >> n >> m >> a >> b;
    if (a[0] != b[0]) {
        ct(-1)
        return 0;
    }
    ans = n*m;
    while(n!=m) {
        if(n>m) n -= m;
        else m -= n;
    }
    if (n==1) {
        ct(ans)
        return 0;
    }
    ans /= n;
    c = n;
    n = a.size()/n;
    m = b.size()/m;
    rep(i,c) {
        if (a[n*i] != b[m*i]) {
            ct(-1)
            return 0;
        }
    }
    ct(ans)

}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;
using pii = pair<int, int>;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		--a[i];
	}
	int answer = 0;
	if(a[0] != 0){
		a[0] = 0;
		answer = 1;
	}
	vector<vector<int>> conn(n);
	for(int i = 1; i < n; ++i){ conn[a[i]].push_back(i); }
	vector<int> d(n, n);
	queue<int> q;
	d[0] = 0;
	q.push(0);
	while(!q.empty()){
		const int u = q.front();
		q.pop();
		for(const auto v : conn[u]){
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	vector<pii> dv(n);
	for(int i = 0; i < n; ++i){ dv[i] = pii(d[i], i); }
	sort(dv.begin(), dv.end(), greater<pii>());
	vector<int> r(n);
	for(const auto &p : dv){
		const auto u = p.second;
		int maxval = 0;
		for(const auto v : conn[u]){
			maxval = max(maxval, r[v]);
		}
		if(maxval + 1 == k){
			if(a[u] != 0){ ++answer; }
			r[u] = 0;
		}else{
			r[u] = maxval + 1;
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define REP(i,n)    for(int i = 0; i < (n); ++i)
#define RREP(i,n)   for(int i = (n); i >= 0; --i)
#define FOR(i,m,n) for(int i = (m); i < (n); ++i)
#define SZ(x)       ( (int)(x).size() )
#define BIT(n)      ( 1LL << (n) )
#define EXIST(x)    ( (x).find()		!= (x).end() )
#define DEBUG(n)    cerr << #n << " : " << n << '\n';
#define PB  push_back
#define UB  upper_bound			//k <
#define LB  lower_bound			//k	<= 
#define F   first
#define S   second
#define INF 1.0e9


using namespace std;

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

template<class T> void chmax(T &	a, const T & b){ if( a < b ) a = b; }
template<class T> void chmin(T &	a, const T & b){ if( a > b ) a = b; }

int r_up(const int a, const int b){ return (a + b - 1) / b; }

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

bool isM(int n){
  return n>=1 && n <=12;
}

int main(){
  string s;cin>>s;
  int a = (int)(s[0] - '0')*10 + (int)(s[1] - '0');
  int b = (int)(s[2] - '0')*10 + (int)(s[3] - '0');

  if(isM(a)){
	if(isM(b))cout<<"AMBIGUOUS"<<endl;
	else cout<<"MMYY"<<endl;
  }else{
	if(isM(b))cout<<"YYMM"<<endl;
	else cout<<"NA"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
ll n,k,x,y;
 
int main(){
  ll ans=0;
  cin >> n ;
  vi a(n+1),b(n+1),c(n+1),d(n+1);
  REP(i,n+1) cin>>a[i];



  if (n==0){
    if (a[0]==1){
      cout<<1<<endl;
      return 0;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }
  
 
  if (a[0]!=0){
    cout<<-1<<endl;
    return 0;
  }

 
 


  ll nown=1;
  b[0]=1;
  c[0]=1;
  for(ll i=1;i<n+1;i++){
    nown=min(nown,llMAX/2)*2;
    b[i]=nown;
    nown-=a[i];
    c[i]=nown;
    if (nown<0){
      cout<<-1<<endl;
      return 0;
    }
  }

  
  d[n]=a[n];
  for(ll i=n-1;i>=0;i--){
    d[i]=d[i+1]+a[i];
  }

  for(ll i=n;i>=0;i--){
    if (b[i]<=d[i]){
      //この時点のnownとしたから数えたやつを比較
      i++;
      if (i==n+1)break;
      b[i]=d[i];
      c[i]=d[i]-a[i];
      for(ll j=i+1;j<n+1;j++){
        b[j]=d[j];
      }
      break;
      
    }
  }
  

 
  
 
 
 
  int flag=0;
  for(ll i=0;i<n+1;i++){
    ans+=b[i];
    flag+=(b[i]<=0);
    //flag+=(c[i]<0);
  }
  if (flag!=0){
    cout<<-1<<endl;
    return 0;
  }
 
 
 
  cout<<ans<<endl;
  return 0;
}
 
/*
10
0 0 1 1 2 3 5 8 28 21 34
*/

Measured memory_bytes: 6428
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    string N;
    int K;
    cin>>N>>K;
    int SIZE=N.size();
    auto dp = make_vec<ll>(SIZE+1,2,K+1);
    REP(j,2){
        REP(k,K+1){
            dp[0][j][k]=0;
        }
    }
    dp[0][0][0]=1;
    REP(i,N.size()){
        REP(j,2){
            REP(k,K+1){
                REP(x,j ? 10 : N[i]-'0'+1){
                    if(x==0){dp[i+1][j||x<(N[i]-'0')][k]+=dp[i][j][k];}
                    else if(k>=1){
                        dp[i+1][j||x<(N[i]-'0')][k]+=dp[i][j][k-1];
                    }
                }
            }
        }
    }
    cout<<(dp[SIZE][0][K]+dp[SIZE][1][K])<<endl;
    
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef vector<P> vp;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
    
int main(){
    ll N, Y; cin >> N >> Y;
    
    for(ll i = 0; i <= N; i++){
        for(ll j = 0; j <= N - i; j++){
            ll k = N - i - j;
            if(i * 10000 + j * 5000 + k * 1000 == Y){
                cout << i << " " << j << " " << k << endstr;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endstr;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto n = readInt();
		if(n == 0) {
			return;
		}
		auto s = readln().strip().split();
		bool l, u;
		int ans;
		for(int i; i < s.length-1; ++i) {
			if(s[i..i+2].dup.sort == ["lu", "ru"].sort) {
				++ans;
			}
			if(s[i..i+2].dup.sort == ["ld", "rd"].sort) {
				++ans;
			}
		}
		writeln(ans);
	}
}

Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char c = sc.next().charAt(0);
		sc.close();
		
		switch(c) {
		case 'a':
		case 'i':
		case 'u':
		case 'e':
		case 'o':
			System.out.println("vowel");
			break;
		default:
			System.out.println("consonant");
			break;
		}
	}
}


Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    static int n;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for(int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        for(int i = 0 ; i < n ; i++) {
            b[i] = sc.nextInt();
        }
        for(int i = 0 ; i < n ; i++) {
            c[i] = sc.nextInt();
        }
        long ans = 0;
        Arrays.sort(a);
        Arrays.sort(c);
        for(int i = 0 ; i < n ; i++) {
            ans += 0L + binary_search(a, b[i]) * (n - binary_search(c, b[i]+1));
        }
        System.out.println(ans);
    }

    public static long binary_search(int[] a, int x) {
        int l = -1;
        int r = n;
        while(r - l > 1) {
            int i = (l + r) / 2;
            if(x <= a[i]) r = i;
            else l = i;
        }
        return r;
    }
}


Measured memory_bytes: 94712
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    s = inputInt()
    A = inputList()
    
    ans = -1
    for i in A:
        tmp_cont = 0
        tmp = i
        while True:
            if tmp % 2 != 0:
                break
            tmp = tmp // 2
            tmp_cont += 1
        #print("{}--{}".format(i, tmp_cont))
        if ans == -1 or ans > tmp_cont:
            ans = tmp_cont
        
    print(ans)
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38512
from collections import defaultdict

class UnionFind :
    def __init__(self, size) :
        """
        Parameters
        ---
        size : int
            頂点数
        """
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        """
        親のインデックスの取得

        Parameters
        ---
        index : int
            取得する頂点のインデックス

        Returns
        ---
        rootIndex : int
            指定した頂点の根のインデックス
        """
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        """
        木の結合

        Parameters
        ---
        index1 : int
        index2 : int
            結合する頂点のインデックス
        """
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        """
        同じ木に属するかを判定する

        Parameters
        ---
        index1 : int
        index2 : int

        Returns
        ---
        boolean
        """
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        """
        指定した頂点の属する木の大きさを取得する
        """
        return self.size[self.root(index)]

    def getComponent(self) :
        """
        連結成分数を取得する
        """
        return self.component

N, K, L = map(int, input().split())

train = UnionFind(N)
road = UnionFind(N)

for _ in range(K):
    p, q = map(int, input().split())
    road.union(p - 1, q - 1)

for _ in range(L):
    p, q = map(int, input().split())
    train.union(p - 1, q - 1)

cnt = defaultdict(int)

for i in range(N):
    cnt[(road.root(i), train.root(i))] += 1

ans = []
for i in range(N):
    ans.append(cnt[(road.root(i), train.root(i))])

print(*ans)

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

int main() {
     char L[100100];
     fgets(L, sizeof(L), stdin);

     long long result = 1;
     long long t = 1;
     for(int i = strlen(L) - 2; i >= 0; i--) {
         if (L[i] == '1') {
             result = result * 2 + t;
             result %= 1000000007;
         }
         t *= 3;
         t %= 1000000007;
     }
     printf("%lld\n", result);
}


Measured memory_bytes: 256
# 2020-08-27, Thu

n = int(input())
lis = list(map(int, input().split()))
ans = 0

while (1):
    count = 0
    for i in range(n):
        if lis[i] % 2 == 0:
            lis[i] //= 2
            count += 1
    if count == n:
        ans += 1
    else:
        break

print(ans)

Measured memory_bytes: 9104
#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;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	int n,flag=0;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		int x;
		cin>>x;
		if(x%2==0)
		{
			if(x%3==0 || x%5==0)
			{
				continue;
			}
			else
			{
				flag=1;
			}
		}
	}
	if(flag==0)
	{
		cout<<"APPROVED";
	}
	else
	{
		cout<<"DENIED";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>

using namespace std;
long long n,k;
unsigned long long ans;
int a[200001]; // 10^5
long long ssum[200001];
long long t[200001];
int fenwick[200001];
size_t uniq;

void build() {  // build the tree
  for (int i = n - 1; i > 0; --i) {
    t[i] = t[i<<1] + t[i<<1|1];
  }
}

size_t uniquize() {
  int pos = 1;
  for (int i = 1; i < n; i++) {
    if (t[i] != t[i-1]) {
      t[pos++] =t[i];
    }
  }

  return pos;
}

int sum_fenwick(long long id) {
  int sum = 0;

  for (id++; id > 0; id -= id & -id) {
    sum += fenwick[id];
  }

  return sum;
}

void add_fenwick(long long id, int value) {
  if (value == 0 || id < 0) {
    return;
  }

  for(id++; id < 200001; id += id & -id) {
    fenwick[id] += value;
  }
}


int binary_search(long long v) {
  int l = -1;
  int r = uniq;
  int mid;
  while (r-l > 1) {
    mid = (l+r) >> 1;
    if (t[mid] < v) {
      l = mid;
    } else {
      r = mid;
    }
  }

  return r;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> n >> k;

  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    t[i-1] = ssum[i] = ssum[i-1] + a[i] - k;
  }
  sort(t, t+n);
  uniq = uniquize();
  long long id;

  for (int i = 0; i <= n; i++) {
    id = binary_search(ssum[i]);
    ans += sum_fenwick(id);
    add_fenwick(id, 1);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <cstdlib>
#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() { 
  set<int> p;
  int x, n, ans;
  cin >> x >> n;
  int copy_x = x;
  int true_x = x;
  rep(i, n){
    int a;
    cin >> a;
    p.insert(a);
  }
  bool p_end = true;
  bool m_end = true;
  int plus_x, minus_x;
  while(p_end){
    if(p.count(x)){x++;}
    else{
      plus_x = x;
      p_end = false;
    }
  }
  while(m_end){
    if(p.count(copy_x)){copy_x--;}
    else{
      minus_x = copy_x;
      m_end = false;
    }
  }
  int m_v = abs(minus_x - true_x);
  int p_v = abs(plus_x - true_x);
  if(m_v < p_v){
    cout << minus_x << endl;
  }else if(m_v == p_v){
    cout << min(plus_x, minus_x)<< endl;
  }else{
    cout << plus_x << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
from collections import Counter
N = int(input())
v = [int(i) for i in input().split()]
v_even = [v[i] for i in range(len(v)) if i % 2 == 0]
v_odd = [v[i] for i in range(len(v)) if i % 2 == 1]

even_c = Counter(v_even)
odd_c = Counter(v_odd)
#print(odd_c.most_common(), even_c.most_common())

if odd_c.most_common()[0][0] != even_c.most_common()[0][0]:  # 最頻値の値が違うなら
    output = N-(odd_c.most_common()[0][1] + even_c.most_common()[0][1])
elif N - (odd_c.most_common()[0][1] + even_c.most_common()[0][1]) == 0:  # すべてのvが同じ
    output = N // 2
else:
    if len(even_c) != even_c.most_common()[0][1]:
        frag1 = True
        output1 = N - (odd_c.most_common()[0][1] + even_c.most_common()[1][1])
    else:
        frag1 = False
    if len(odd_c) != odd_c.most_common()[0][1]:
        frag2 = True
        output2 = N - (odd_c.most_common()[1][1] + even_c.most_common()[0][1])
    else:
        frag2 = False
    if frag1 and frag2:
        output = min(output1, output2)
    elif frag1:
        output = output1
    elif frag2:
        output = output2
print(output)


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

using namespace std;

#define FOR(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define lli long long int
#define all(c) (c.begin(),c.end())
#define sz(s) (int)(s).size()
const int MOD = 1000000007;
const int MX = 2e5 + 5;
const lli INF = 1e18;


void solve() {
    string s, k;
    cin >> s >> k;
    int n = sz(s), x = sz(k), ans = 0, temp = 0;
    for (int i = 0; i <= n - x; ++i ) {
        temp = 0;
        string m = s.substr(i, x);
        for (int i = 0; i < x; i++) {
            if (m[i] == k[i])temp++;
            // else break;
        }
        ans = max(ans, temp);
    }
    cout << sz(k) - ans << endl;
}

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

#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    solve();




    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }





int A, B, C;

int main() {
	while (cin >> A >> B >> C) {
		if (A + B >= C) puts("Yes");
		else puts("No");
	}
}



















Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int x, y, z, w;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define ll long long
    #define db double
    #define mod 1000000007
    #define pb push_back
    #define pp pair<ll,ll>
    #define rep(i,a,b) for(ll i=a;i<b;i++)
    #define repe(i,a,b) for(ll i=a;i<=b;i++)
    #define repr(i,a,b) for(ll i=b;i>=a;i--)
    #define maxn 100005
    #define ss second
    #define ff first
    #define lb lower_bound
    using namespace std;
    vector<ll> adj[maxn];
    ll arr[maxn],n,m;
    void solve()
    {
        cin >> n >> m;
        repe(i,1,n)
            cin >> arr[i];
        rep(i,0,m)
        {
            ll x,y;
            cin >> x >> y;
            adj[x].pb(y);
            adj[y].pb(x);
        }
        ll ans=0;
        repe(i,1,n)
        {
            ll cnt=0;
            for(auto x:adj[i])
            {
                if(arr[x] >= arr[i])
                    break;
                cnt++;
            }
            if(cnt == adj[i].size())
            {
                ans++;
            }
        }
        cout << ans;
    }
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll t=1;
        //cin >> t;
        while(t--)
        solve();
        return 0;
    }

Measured memory_bytes: 10276
#include <stdio.h>
 
 
int main(void)
{
 int a,b,i;
 
 scanf("%d%d",&a,&b);
 if(a>b){
 for(i=0;i<a;i++){
  printf("%d",b);
  }
 }
 else{
  for(i=0;i<b;i++){
  printf("%d",a);
  }
 }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,k,q,x,y,l,r,z,n,m;
    cin>>n>>m;
    cout<< ((n)*(n-1))/2 + ((m)*(m-1))/2;
}

Measured memory_bytes: 256