akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define repi(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(v) begin(v), end(v)

using ll = long long;

int main() {
  // freopen("1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;

  vector<int> f(N);
  for (int i = 1; i < N; ++i) {
    for (int j = 1; 1LL * j * i < N; ++j) {
      ++f[i * j];
    }
  }

  ll sum = 0;
  for (int a : f) {
    sum += a;
  }
  cout << sum << '\n';

  return 0;
}


Measured memory_bytes: 7060
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#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
 
long long binpow(long long a,long long b)
{
    if (b == 1) return a;
    long long res = binpow(a, b/2)%MOD;
    if (b % 2) return (res*((res*a)%MOD))%MOD;
    else return (res * res)%MOD;
}

long long int fact(long long int a)
{
    if(a==0||a==1)
        return 1;
    long long int ans = 1;
    for(int i=a;i>=1;i--)
        ans = (ans * i);
    return ans;
}

long long int ivmod(long long int a)
{
    return binpow(a,MOD-2);
}

long long int ncr(long long int a,long long int b)
{
    long long int pans=1;
    for(int i =a;i>max(b,a-b);i--)
        pans=pans*i;
    long long int div = fact(min(b,a-b));
    // cout<<ans<<"            "<<div<<endl;
    pans = pans/div;
    return pans;
}
 
map<long long int ,long long int >mm,cc;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen ("output.txt","w",stdout);
    // #endif
    int n;
    cin>>n; 
    n = n*3;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long int ans = 0;
    bool flag[n]={0};
    int k = n;
    for(int i=0;i<n;i++)
    {
        if(flag[i]==0&&flag[k-1]==0&&flag[k-2]==0)
        {
            ans+=a[k-2];
            flag[i]=1;
            flag[k-1]=1;
            flag[k-2]=1;
            k-=2;
        }
        else
        {
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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


#----------
H,W = list(map(int, input().rstrip().split()))
all_S_list = [ list(input().strip()) for _ in range(H) ]
#----------
new_S_list = [["_"]*W for i in range(H)]

for i in range(H):
    for j in range(W):
        if all_S_list[i][j] == "#":
            new_S_list[i][j] = "#"
        
        if all_S_list[i][j] == ".":
            d_i_list = [(-1)*(i>0) , 0 , 1*(i<(H-1)) ]
            d_j_list = [(-1)*(j>0) , 0 , 1*(j<(W-1)) ]
        
            count=0
            for d_i in set(d_i_list):
               for d_j in set(d_j_list):
                   if all_S_list[i + d_i][j + d_j] == "#":
                       count += 1
            
            new_S_list[i][j] = str(count)
            
for line in new_S_list:
    print("".join(line))


Measured memory_bytes: 3188
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	int L[]=new int[N];
	int sum=0;
	int max=0;
	for(int i=0;i<N;i++) {
		L[i]=sc.nextInt();
		sum+=L[i];
		if(max<L[i]) {
			max=L[i];
		}
	}
	if(max>=(sum-max)) {
		System.out.println("No");
	}else {
		System.out.println("Yes");
	}

}
}


Measured memory_bytes: 23380
function main(input) {
  var args = input.split('\n');
  var target = args[0].split(' ')[0];
  var i = target;
  var j = target;
  var forbiddenList = args[1].split(' ');
  while (forbiddenList.indexOf(i + '') >= 0) {
    i--;
  }
  while (forbiddenList.indexOf(j + '') >= 0) {
    j++;
  }
  if (Math.abs(target - i) > Math.abs(target - j)) {
    console.log(j);
  } else {
    console.log(i);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29532
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def popcount(n):
    if n == 0:
        return 0
    return 1 + popcount(n % bin(n).count("1"))


def main():
    N = int(input())
    X = input().strip()

    x1 = 0
    xc = bin(int(X, 2)).count("1")
    if xc == 1:
        x2 = -1
    else:
        x2 = 0
    for i in range(N):
        if X[-1 - i] == '1':
            x1 += pow(2, i, xc + 1)
            if x2 != -1:
                x2 += pow(2, i, xc - 1)
    for i in range(N):
        if X[i] == '0':
            print(1 + popcount((x1 + pow(2, N - i - 1, xc + 1)) % (xc + 1)))
        else:
            if x2 == -1:
                print(0)
            else:
                print(1 + popcount((x2 - pow(2, N - i - 1, xc - 1) + xc - 1) % (xc - 1)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9548
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n,a;
int t[SIZE];

int main(){
  cin >> n;
  rep(i,2,n+1){
    cin >> a;
    t[a]++;
  }
  rep(i,1,n+1) cout << t[i] << endl;

  return 0;
}


Measured memory_bytes: 4324
import sys
import copy
input = sys.stdin.readline

N, M = [int(x) for x in input().strip().split()]
sides = [tuple([int(x) - 1 for x in input().strip().split()]) for _ in range(M)]

ans = 0
for i in range(M):
    node_N = [0] * N
    MAP = [[0] * N for _ in range(N)]
    sub_sides = [side for j, side in enumerate(sides) if j != i]
    for a, b in sub_sides:
        MAP[a][b] = 1
        MAP[b][a] = 1
    queue = [i for i, b in enumerate(MAP[0]) if b == 1]
    node_N[0] = 1
    while len(queue):
        p = queue.pop(0)
        if node_N[p] == 1:
            continue
        node_N[p] = 1
        queue.extend([i for i, b in enumerate(MAP[p]) if b == 1 and node_N[i] == 0])
    if 0 in node_N:
        ans += 1

print(ans)


Measured memory_bytes: 3540
from heapq import heappop,heappush

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = map(lambda x:-1*x,a)
a = sorted(a)

for i in range(m):
    x = heappop(a)
    heappush(a,-(-x//2))

print(-sum(a))

Measured memory_bytes: 64356
import math
import bisect
import collections
import itertools
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


N,x = imn()
a = iln()

cnt = 0
for i in range(N-1):
    tmp = a[i] + a[i+1]
    t_a = a[i+1]
    if tmp > x:
        a[i+1] = max(0, x - a[i])
        cnt += (t_a - a[i+1])
    tmp = a[i] + a[i+1]
    t_a = a[i]
    if tmp > x:
        a[i] = max(0, x-a[i+1])
        cnt += (t_a - a[i])
print(cnt)
    
        


Measured memory_bytes: 14788
#include <bits/stdc++.h>
#include <stdio.h>
#include <string>
#include <stdexcept>
using namespace std;

int main(){
  string S;
  string Month;
  int a = 0;
  cin >> S;
  if (S.at(5) == '1'){
    cout << "TBD" << endl;
    a = 1;
  }
   if (S.at(6) == '5'){
     a=1;
     cout << "TBD" << endl;
   }
  else{
    for(int i=5; i<10; i++){
      if(S.at(6) == 'i'){
        a = 1;
        cout << "TBD" << endl;
      }
    }
  }
  if (a == 0){
    cout << "Heisei" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
    int n,a,b;
    cin>>n;
    vector<int> p(n),q(n),number(n);
   // a=0;
   // b=0;
   
    
    rep(i,n){
        cin>>p.at(i);
    }
    rep(i,n){
        cin>>q.at(i);
    }
     rep(i,n){
        number.at(i)=i+1;
    }
    
    int i=0;
    do{
       
        if(number==p)a=i;
        if(number==q)b=i;
        i++;
    }while(next_permutation(number.begin(),number.end()));
    
    cout<<abs(a-b)<<endl;
    
}

Measured memory_bytes: 256
import sys

A, B, M = map(int, sys.stdin.readline().rstrip().split())
a = list(map(int, sys.stdin.readline().rstrip().split()))
b = list(map(int, sys.stdin.readline().rstrip().split()))
xyc = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(M)]
ans = min(a) + min(b)

for xyci in xyc:
    x, y, c = xyci
    tmp = a[x - 1] + b[y - 1] - c
    if ans > tmp:
        ans = tmp

print(ans)

Measured memory_bytes: 38692
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn collatz(n: u64) -> u64 {
    if n % 2 == 0 {
        n / 2
    } else {
        3 * n + 1
    }
}

use std::collections::HashSet;

fn main() {
    input! {
        s: u64
    }
    let mut s = s;
    let mut set = HashSet::new();
    set.insert(s);
    let mut cnt = 1;
    loop {
        s = collatz(s);
        cnt += 1;
        if set.contains(&s) {
            break;
        }
        set.insert(s);
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int c[a];
	for(int i=0;i<a;i++){
		cin>>c[i];
	}
	for(int i=1;i<=b;i++){
		for(int j=0;j<a-1;j++){
			if(c[j]%i>c[j+1]%i){
				int d=c[j];
				c[j]=c[j+1];
				c[j+1]=d;
			}
		}
	}
	for(int i=0;i<a;i++){
		cout<<c[i]<<endl;
	}
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
int main() {
	char ch;
	cin >> ch;
	if(ch >='a' && ch <='z') {
		cout<<'a';
	} else cout<<"A";
}


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

int main() {
	int N;
	cin >> N;
	vector<vector<int>>A(2, vector<int>(N));
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A.at(i).at(j);
		}
	}
	vector<vector<int>>DP(2, vector<int>(N));
	DP.at(0).at(0) = A.at(0).at(0);
	for (int i = 1; i < N; i++) {
		DP.at(0).at(i) = DP.at(0).at(i - 1) + A.at(0).at(i);
	}
	DP.at(1).at(0) = DP.at(0).at(0) + A.at(1).at(0);
	for (int i = 1; i < N; i++) {
		DP.at(1).at(i) = max(DP.at(0).at(i) + A.at(1).at(i), DP.at(1).at(i - 1) + A.at(1).at(i));
	}
	cout << DP.at(1).at(N - 1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    
    public static void main(String[] args){
        
        Scanner sc =new Scanner(System.in);
    
        int n=sc.nextInt();
        int m=sc.nextInt();
        int count=1;
        int a[][]=new int[n+1][m+1];
        int b[]=new int[m+1];
        int sum=0;
     
        for(int i=1;i<=n;i++)
         for(int j=1;j<=m;j++)
           a[i][j]=sc.nextInt();
        
        for(int i=1;i<=m;i++)
         b[i]=sc.nextInt();
        
        for(int i=1;i<=n;i++) {
         for(int j=1;j<=m;j++)
          sum+=a[i][j]*b[j];
         System.out.println(sum);
         sum=0;
        }
  }
  
}


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

using namespace std;

typedef long long ll;

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans;
    ans=max(a*c,max(a*d,max(b*c,b*d)));
    cout << ans << endl;
}


Measured memory_bytes: 3592
S = input()
buf = 0
for i in range(len(S)) :
    if i % 2 == 0 :
        if S[i] == "L" :
            buf += 1
    else :
        if S[i] == "R" :
            buf += 1

if buf != 0 :
    print("No")
else :
    print("Yes")

Measured memory_bytes: 2940
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	int a,b;
	cin>>a>>b;
	if(a>9||b>9)
		puts("-1");
	else
		printf("%d\n",a*b);
	return 0;
}



Measured memory_bytes: 256
from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

a,v = map(int,stdin.readline().rstrip().split())
b,w = map(int,stdin.readline().rstrip().split())
t = int(stdin.readline().rstrip())

if v < w or v-w == 0:
    print("NO")
    exit()

if abs(a-b)/abs(v-w) <= t:
    print("YES")
else:
    print("NO")

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

int main() {
  string s, t;

  cin >> s;
  cin >> t;

  int cnt = (int)t.size();
  for(int i = 0; i < s.size() - t.length() + 1; i++) {
    int tmp = 0;
    for(int j = i; j < i + (int)t.size(); j++)
      if(s[j] != t[j-i])
        tmp++;

    cnt = min(cnt, tmp);
  }

  cout << cnt;
  return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        str = str.replaceAll("eraser", "-");
        str = str.replaceAll("erase", "-");
        str = str.replaceAll("dreamer", "-");
        str = str.replaceAll("dream", "-");
        str = str.replaceAll("-", "");
        if (str.length() == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 29048
#include<bits/stdc++.h>
using namespace std;
int n, m, w, h, v;
int main()
{
	cin >> n >> m >> w >> h;
	if (n % w == 0 && m % h == 0)printf("No\n");
	else
	{
		printf("Yes\n");
		v = (w * h - 1) * 500 + 1;
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= m; j++)
				if (i % w == 0 && j % h == 0)
					printf("%d ", -v);
				else printf("500 ");
			printf("\n");
		}
	}
	return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "

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

  string S;
  cin >> S;

  int l = 0, r = 0, cnt;
  cnt = 0;
  rep0(i, N) {
    if (S[i] == '(') cnt++;
    else if (cnt > 0) cnt --;
    else l++;
  }

  cnt = 0;
  repR0(i, N) {
    if (S[i] == ')') cnt++;
    else if (cnt > 0) cnt --;
    else r++;
  }

  rep0(i, l) cout << "(";
  rep0(i, N) cout << S[i];
  rep0(i, r) cout << ")";

  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	if(N%2==1) {
		for(i=1;i<=M;i++) cout<<i<<" "<<N-i<<endl;
	}
	else {
		for(i=1;i<=M;i++) {
			if(N-i-i>N/2) cout<<i<<" "<<N-i<<endl;
			else cout<<i<<" "<<N-i-1<<endl;
		}
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ll long long int
#define f(i,a,n) for(i=a;i<n;i++)
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define test() ll tc;cin>>tc;while(tc--)

using namespace std;

const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const ll INF = 1e13;


/*ll fact(ll n);

ll comb(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = ((res%mod * i%mod)%mod)%mod;
    return res;
}


ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

*/



int main()
{
        fast();
        ll n;
        cin>>n;
        long double p[n];
        for(ll i=0;i<n;i++)
        {
            cin>>p[i];
        }
        long double dp[n+1][n+1];
        for(ll i=0;i<=n;i++)
        {
            for(ll j=0;j<=n;j++)
            {
                dp[i][j]=0.0;
            }

        }
        dp[0][0]=1.0;
        for(ll i=1;i<=n;i++)
        {
            for(ll j=0;j<=n;j++)
            {
                if(j==0)
                {
                    dp[i][j]=(1.0-p[i-1])*dp[i-1][j];
                }
                else{
                    dp[i][j] = p[i-1]*dp[i-1][j-1] + (1.0-p[i-1])*dp[i-1][j];
                }
            }
        }
        long double res=0.0;

        for(ll i=n/2+1;i<=n;i++)
        {
            res+= dp[n][i];
        }
        cout<<fixed<<setprecision(10)<<res;

        return 0;
}


Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

map<ll,ll> prime(ll n){  
    map<ll,ll> mp;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n/=i;
        }
    }
    if(n!=1)mp[n]++;
    return mp;
}

//上で素因数分解した数から、値を再構成する関数 .first .second を引き値として、int で値を返す

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1)res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll pow_mod(ll n,ll p,ll m){
    ll res = 1;
    while(p>0){
        if(p%2==1) res = (res * n) % m;
        n = (n * n) % m;
        p /= 2;
    }
    return res;
}

ll inv_mod(ll n,ll mod){
    return pow_mod(n,mod-2,mod);
}

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

    vector<map<ll,ll>> v(n);
    rep(i,n){
        v[i] = prime(a[i]);
    }
    map<ll,ll> P;
    rep(i,n){
        for(auto t : v[i]){
            if(P[t.first] < t.second) P[t.first] = t.second;
        }
    }

    ll all = 1;
    for(auto t : P){
        all *= modpow(t.first, t.second);
        all %= MOD;
    }

    ll sum = 0;
    rep(i,n){
        sum += all * inv_mod(a[i], MOD);
        sum %= MOD;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3840
#include <stdio.h>
#include <stdlib.h>

#define N 100000

int main()
{
  int i, n, q, v, x, y, z, dx, dy, x0, y0, ex, rx, sx, tmp;
  char *p, buf[32];
  buf[31]=0;
  buf[30]='\n';
  int *s = (int*)malloc(sizeof(int)*N);
  int *d = (int*)malloc(sizeof(int)*N);
  while (fgets(buf, 32, stdin)) {
    for (n=0,p=buf; *p!=' '; n=n*10+*(p++)-'0'); 
    for (q=0,p++; *p!='\n'; q=q*10+*(p++)-'0'); 
    if (n==0 && q==0) break;
    for (i=1; i<=n; s[i]=i,d[i++]=0);
    for (int t=0; t<q; t++) {
      fgets(buf, 32, stdin);
      for (x=0,p=buf+2; *p!=' '; x=x*10+*(p++)-'0');
      for (y=0,p++; *p>='0'; y=y*10+*(p++)-'0');

      if (buf[0]=='!') { // relate x y z
	for (z=0,p++; *p!='\n'; z=z*10+*(p++)-'0');
	for (x0=x,dx=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (y0=y,dy=0; s[y]!=y; dy+=d[y], y=s[y]);
	s[x0]=x;
	d[x0]=dx;
	s[y0]=y;
	d[y0]=dy;
	if (x<y) {
	  s[y] = x;
	  d[y] = z + dx - dy;
	} else if (x>y) {
	  s[x] = y;
	  d[x] = -z - dx + dy;
	} else continue;
	
      } else { // diff

	for (x0=x,dx=dy=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (rx=x, x=x0, ex=dx; s[x]!=x; x=sx) {
	  sx=s[x];
	  s[x]=rx;
	  tmp=d[x];
	  d[x]=ex;
	  ex-=tmp;
	}
	for (y0=y; s[y]!=y; dy+=d[y], y=s[y]);
	v=-dx+dy;
	if (x!=y) {
	  fputs("UNKNOWN\n", stdout);
	} else {
	  i=30;
	  if (v>0)  for (; v>0; buf[--i]='0'+v%10,v/=10);
	  else if (v<0) {
	    for (; v<0; buf[--i]='0'-v%10,v/=10);
	    buf[--i] = '-';
	  } else  buf[--i] = '0';
	  fputs(buf+i, stdout);
	}
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2352
#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 speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


ll mod=1000000007;
ll vis[212345]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}





int main()
{
speed

string s;
cin>>s;
ll c=0;
rep(i,0,3) if(s[i]=='R') c++;
if(c==3) cout<<"3\n";
else if(c==2&&s[1]=='R') cout<<"2\n";
else if(c==0) cout<<"0\n";
else cout<<"1\n";
}


Measured memory_bytes: 8056
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
int main(void)
{
    string S;
    int count=0, i, k;

    cin >> S;
    
    k = S.size();

    for(i=0; i<k; i++){
        if(S[i] == 'o'){
            count++;
        }
    }

    if(count+(15-k) >= 8){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
M = 10**5+1
p = [1]*M
p[0] = p[1] = 0
for i in range(2, 10**3):
    if p[i]:
        for j in range(i*i, M, i):
            p[j] = 0
C = [0]*M
for i in range(2, M):
    if p[i] and p[(i+1)//2]:
        C[i] = C[i-1] + 1
    else:
        C[i] = C[i-1]
q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(C[r] - C[l-1])

Measured memory_bytes: 51416
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            boolean ok = true;
            Integer[][] AB = new Integer[n][2];
            for (int i = 0; i < n; i++) {
                AB[i][0] = Integer.parseInt(in.next());
                AB[i][1] = Integer.parseInt(in.next());
            }
            Arrays.sort(AB, (x, y) -> {
                if (x[1] != y[1]) return (x[1] - y[1]);
                return (x[0] - y[0]);
            });
            long tot = 0;
            for (int i = 0; i < n; i++) {
                tot += AB[i][0];
                if (tot > AB[i][1]) ok = false;
            }

            out.println(ok ? "Yes" : "No");

        }

    }
}



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

int main() {
	int n;
	cin >> n;
	while (1) {
		char a;
		cin >> a;

		if (a == '+') {
			int b;
			cin >> b;
			n += b;
		}
		else if (a == '-') {
			int b;
			cin >> b;
			n -= b;
		}
		else if (a == '*') {
			int b;
			cin >> b;
			n *= b;
		}
		else if (a == '/') {
			int b;
			cin >> b;
			n /= b;
		}
		else break;
	}
	cout << n << endl;
	return 0;
}

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

int main(){
  ll n;cin>>n;
  ll sum[10000005] ;
  fill_n(sum,10000005,1);
  for (ll i = 2; i <= n; i++) {
    for (ll j = 1; j * i <= 10000000; j++) {
      sum[i*j]++;
    }
  }

  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    ans += i * sum[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 81696
#include<bits/stdc++.h>
using namespace std;
int f[109][109];

main()
{
   int a,b;
   string s;
   cin>>a>>b;
   cin>>s;
   int fl=1;
   for(int i=0; i<s.size(); i++)
   {
       if(i==a && s[i]!='-' || i!=a && s[i]=='-') {fl=0;}
   }
   if(fl) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

}


Measured memory_bytes: 256
H, W = gets.chop.split.map(&:to_i)

@size = H * W

@gap_list = []

@h = H
@w = W

def calculate_gap
  i_list = [(@size.to_f / 3).ceil, (@size.to_f / 3).floor]
end


def calculate_gap
  i_list = [(@h.to_f / 3).ceil, (@h.to_f / 3).floor]
  i_list.each do |i|
    first_piece = i * @w
    if @h - i > 0
      (@h-i).times do |j|
        second_piece = j * @w
        third_piece = @size - first_piece - second_piece
        pieces = [first_piece, second_piece, third_piece]
        @gap_list << pieces.max - pieces.min
      end
      @w.times do |j|
        second_piece = (@h-i) * j
        third_piece = @size - first_piece - second_piece
        pieces = [first_piece, second_piece, third_piece]
        @gap_list << pieces.max - pieces.min
      end
    end
  end
end

@h = H
@w = W
calculate_gap

@h = W
@w = H
calculate_gap

puts @gap_list.min

Measured memory_bytes: 9084
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
struct edge
{
	int to;
	int no;
	int next;
}e[333333];
int pe=111111;
void insert(int a,int to,int no)
{
	e[pe]=(edge){to,no,e[a].next};
	e[a].next=pe++;
}
int siz[111111];
long long s[111111];
long long ans[111111];
int fa[111111];
void dfs(int o)
{
	siz[o]=1;
	for(register int p=e[o].next;p;p=e[p].next)
		if(e[p].to!=fa[o])
			fa[e[p].to]=o,dfs(e[p].to),siz[o]+=siz[e[p].to];
}
long long ss;
int main()
{
	int n=io::F();
	for(register int i=1;i<n;++i)
	{
		int a=io::F(),b=io::F();
		insert(a,b,i);
		insert(b,a,i);
	}
	for(register int i=1;i<=n;++i)s[i]=io::G();
	dfs(1);
	for(register int i=2;i<=n;++i)
		for(register int p=e[i].next;p;p=e[p].next)
			if(e[p].to==fa[i])
			{
				int o=i;
				if(siz[o]!=n-siz[o])ans[e[p].no]=(s[o]-s[fa[o]])/(n-siz[o]-siz[o]),ss+=siz[o]*ans[e[p].no];
			}
	for(register int i=2;i<=n;++i)
		for(register int p=e[i].next;p;p=e[p].next)
			if(e[p].to==fa[i])
			{
				int o=i;
				if(siz[o]==n-siz[o])ans[e[p].no]=(s[1]-ss)/siz[o];
			}
	for(register int i=1;i<n;++i)
		printf("%lld\n",ans[i]);
	return 0;
}




Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { };
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));

typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
std::vector<ll> aa;
ll x,y,z;
bool cn(const std::vector<ll>&c,ll k,ll mi) {//下のルーチンと併せてめぐる式二分探索
    int cnt=0;
    rep(i,z){
        cnt+=int(aa.size()-(ub(all(aa),mi-c[i])-aa.begin()));
    }
    //std::cout << cnt << std::endl;
    if(cnt<k)return false;
    else return true;
}
// 汎用的な二分探索のテンプレ
ll binary_search(const std::vector<ll>&c,ll key) {
    ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok = INF64; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (cn(c,key,mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    ll k;
    std::cin >> x>>y>>z>>k;
    VEC(ll,a,x);
    VEC(ll,b,y);
    VEC(ll,c,z);
    
    rep(i,x)rep(j,y){
        aa.pb(a[i]+b[j]);
    }
    sort(all(aa));
    ll in=binary_search(c,k);
   // std::cout << in << std::endl;
    //std::cout << 123 << std::endl;
    std::vector<ll> ans;
    sort(all(aa),greater<ll>());
    rep(i,z){
        rep(j,aa.size()){
            if(c[i]+aa[j]>=in)ans.pb(c[i]+aa[j]);
            else break;
        }
    }
  //  std::cout << ans.size() << std::endl;
    sort(all(ans),greater<ll>());
    
    rep(i,k){
        std::cout << ans[i] << std::endl;
    }
    
    
}

Measured memory_bytes: 271196
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int result1 = a/b;
        int result2 = a%b;
        double result3 = (double)a/b;

        System.out.println(result1 + " " + result2 + " " + String.format("%.5f", result3));

    }
}


Measured memory_bytes: 26424
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,A,B;
int main(){
    cin>>N>>A>>B;
    cout<<N/(A+B)*A+min(A,N%(A+B))<<endl;

    return 0;
}

Measured memory_bytes: 256
line = gets.chomp.split("").map(&:to_i);

line2 = line.reverse

if line2[0] == 3 then
	puts "bon"
elsif
	line2[0] == 0 || line2[0] == 1 || line2[0] == 6 || line2[0] == 8 then
	puts "pon"
else
	puts "hon"
end




Measured memory_bytes: 14280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String InStr = scan.nextLine();
		String[] AryStr = InStr.split(" ");

		int A;
		int B;

		A = Integer.parseInt(AryStr[0]);
		B = Integer.parseInt(AryStr[1]);

		if (A > B) {
            B = A--;
		} else if (A < B) {
			A = B--;
        }

        System.out.println(A + B);

	}

}


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int array[n];
  for (int i = 0; i < n; i++) {
    cin >> array[i];
  }
  sort(array, array + n);
  int result = 0;
  for (int i = 0; i < k; i++) {
    result += array[i];
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    map<int, int> M;
    rep(i,n){
        int num; cin >> num;
        M[num]++;
    }
    int m; cin >> m;
    rep(i,m){
        int num; cin >> num;
        if(M[num]>=1) M[num]--;
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N; cin >> N;
  vector<ll> H(N); 
  for(ll i = 0; i < N; i++){ cin >> H[i];}
  
  ll ans = 0;
  
   ll right = 0;     
  
for (ll left = 0; left < N-1; ++left) {
  ll res = 1;
    while (right < N-1 && H[right] >= H[right+1]) {
       
       right++; res++;
    }

     ans = max(ans, res-1);
     if (right == left) ++right;
    
}
  
  cout << ans << endl; return 0;}



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

using namespace std;
int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	string t;
	cin >> t;
	
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i]) {
			ans += 1;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#define MAXN 200000
using namespace std;
typedef pair<int,int> PII;
map<PII,int> mp;
int setfa[2][MAXN+5];
void Init()
{
	for(int i=0;i<=MAXN+3;i++)
		setfa[0][i]=setfa[1][i]=i;
}
int Findfa(int x,int typ)
{
	if(setfa[typ][x]==x)
		return x;
	return setfa[typ][x]=Findfa(setfa[typ][x],typ);
}
void Union(int x,int y,int typ)
{
	int fx=Findfa(x,typ),fy=Findfa(y,typ);
	if(fx==fy)
		return;
	setfa[typ][fx]=fy;
}
int main()
{
	Init();
	int N,K,L;
	scanf("%d %d %d",&N,&K,&L);
	int x,y;
	for(int i=1;i<=K;i++)
	{
		scanf("%d %d",&x,&y);
		Union(x,y,0);
	}
	for(int i=1;i<=L;i++)
	{
		scanf("%d %d",&x,&y);
		Union(x,y,1);
	}
	for(int i=1;i<=N;i++)
	{
		int a=Findfa(i,0),b=Findfa(i,1);
		mp[PII(a,b)]++;
	}
	int Ans;
	for(int i=1;i<=N;i++)
	{
		int a=Findfa(i,0),b=Findfa(i,1);
		Ans=mp[PII(a,b)];
		if(i==1)
			printf("%d",Ans);
		else
			printf(" %d",Ans);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 13696
N = int(input())
R = [list(map(int, input().split())) for _ in range(N)]
B = [list(map(int, input().split())) for _ in range(N)]

R.sort(key=lambda x: -x[1])
B.sort(key=lambda x: x[0])

idx = 0
ans = 0
for xr, yr in R:
    for xb, yb in B:
        if xr < xb and yr < yb:
            ans += 1
            B.remove([xb, yb])
            break
            
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    string a;
    cin >>a;
    int ans=0;
    for(int i=0;i<4;i++){
        if(a[i]=='+'){
            ans++;
        }else{
            ans--;
        }
    }

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

Measured memory_bytes: 256
# solution
import io
import math

MOD = 10 ** 9 + 7

nim, mike = map(int, input().split())

m = 2 * nim - mike
n = 2 * mike - nim

if m % 3 or n % 3 or m < 0 or n < 0:
    print(0)
    quit()

m //= 3
n //= 3

factorial = [1] * (n + m + 1)
for i in range(n + m):
    factorial[i + 1] = factorial[i] * (i + 1) % MOD

print(factorial[m + n] * pow(factorial[m], MOD - 2, MOD) * pow(factorial[n], MOD - 2, MOD) % MOD)

Measured memory_bytes: 29300
A= []
for i in range(3):
    array = list(map(int, input().strip().split()))
    A.append(array)
n=int(input())
b = []
for _ in range(n):
    b.append(int(input()))
ans="No"
for i in range(3):
    count=0
    for j in range(3):
        for k in range(n):
            if A[i][j]==b[k]:
                count=count+1
    if count==3:
        ans='Yes'
    
for i in range(3):
    count=0
    for j in range(3):
        for k in range(n):
            if A[j][i]==b[k]:
                count=count+1
    if count==3:
        ans='Yes'

count=0
for i in range(3):
        for k in range(n):
            if A[i][i]==b[k]:
               count=count+1
if count==3:
    ans='Yes'
count=0
for i in range(3):
        for k in range(n):
            if A[i][2-i]==b[k]:
                count=count+1
if count==3:
    ans='Yes'
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W + 1));
    for(int i = 0; i < H; ++i)
        for(int j = 0; j < W; ++j)
            cin >> s[i][j];

    bool ok;
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    for(int y = 0; y < H; ++y) {
        for(int x = 0; x < W; ++x) {
            if(s[y][x] == '.')
                continue;
            ok = false;
            for(int i = 0; i < 4; ++i) {
                int nx = x + dx[i], ny = y + dy[i];
                if(nx >= 0 && nx < W && ny >= 0 && ny < H && s[ny][nx] == '#') {
                    ok = true;
                    break;
                }
            }
            if(!ok)
                break;
        }
        if(!ok)
            break;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

#define FOR(i, l, r) for (size_t i = (l); i < (r); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main(void)
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    long long ac, ad, bc, bd;
    ac = a * c;
    ad = a * d;
    bc = b * c;
    bd = b * d;

    long long ans;
    ans = max(ac, ad);
    ans = max(ans, bc);
    ans = max(ans, bd);

    cout << ans << "\n";
}


Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<stack>
// #include<string.h>

using namespace std;

int main(){
	
	
	while(1){
		
		int  i ,a=0;
		
		string str;
		stack<char> strstack;
		
		getline(cin , str);
		
		if(str[0] == '.') return 0;
		
		for(i=0 ; i<100  ; i++){
			
// 		cout << str[i] << endl;
			
			if (str[i] == '.') break;
			
			else if (str[i] == '['){
				
//				printf("[の読み込み\n");
					
				strstack.push(str[i]);
				
			}
					
			else if (str[i] == '('){
				
//				printf("(の読み込み\n");
				strstack.push(str[i]);
				
			}
			
			else if (str[i] == ']'){
//				printf("]の読み込み\n");
				if( strstack.empty() ) {
					a = 1;
					break;
					
				}
				else {
					
					if(strstack.top() == '['){
						strstack.pop();
					}
					else {
						a = 1;
						break;
					}
				}
			
			}
			
			else if (str[i] == ')'){
//				printf(")の読み込み\n");
				if( strstack.empty() ){
					a = 1;
					 break;
				}
				else {
					
					if(strstack.top() == '('){
						strstack.pop();
					}
					else {
						a = 1;
						break;
					}
				}
			
			}
	
		}
		

		
		if(a==0 && strstack.empty() == 1)  {
			
			printf("yes\n");
			
		}
		else printf("no\n");
			 
	}
	
	
	return 0;
			
	
	

	
}

Measured memory_bytes: 888
n = int(input())
a = {}
cnt = 0
for i in range(n):
    tmp = int(input())
    if tmp not in a:
        a[tmp] = 1
    else:
        a[tmp] += 1

for v in a.values():
    if v % 2 != 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 15076
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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 T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int n,k,q; cin >> n >> k >> q;
    VI menber(n,k-q);
    REP(i,q){
        int x; cin >> x;
        menber[x-1]++;
    }
    REP(i,n) Yn(menber[i]>0);

    return 0;
}

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


int main()
{
    //freopen("in.txt","r",stdin);
//string ss;
	int n;
	cin>>n;
	int arr[10000];

	int cnt=0;
	for(int i=1;i<=n;i++)
    {
        cin>>arr[i];

    }
    sort(arr+1,arr+1+n);
    for(int i=1;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)

            for(int k=j+1;k<=n;k++)
            {
                if(arr[i]+arr[j]>arr[k]   && arr[j]+arr[k]>arr[i] && arr[i]+arr[k]>arr[j] )
                  cnt++;
                else
                    break;

            }
    }
    cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int c[3][3];
  rep(i,3){
    rep(j,3){
      cin >> c[i][j];
    }
  }
  rep(i,3){
    rep(j,2){
      c[i][j+1]-=c[i][0];
    }
  }
  bool ok=true;
  rep(j,2){
    rep(i,2){
      if(c[i][j+1]!=c[i+1][j+1])ok=false;
    }
  }
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256