akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
const int N = 204721;
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

int main()
{
#ifndef ONLINE_JUDGE  
  //  freopen("in.txt","r" ,stdin);
    // freopen("out.txt", "w", stdout);
#endif 
    ll n, m;
    while (cin >> n >> m)
    {
        ll c = n - m;
        if (c < 0)
            c = -c;
        printf("%s\n", c <= 1?"Brown":"Alice");

    }
    return 0;
}

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

using namespace std;

typedef long long  ll;

struct Data {
    int key;
    Data *prev, *nxt;
    Data() { key = -1, prev = nullptr, nxt = nullptr; }
    Data(int key, Data *prev, Data *nxt) : key(key), prev(prev) , nxt(nxt) {}
};

Data head, last;
int size = 0;

Data* Find(int key)
{
    for (auto it = head.nxt; it != &last; it = it->nxt)
        if (it->key == key)
            return it;
    return nullptr;
}

void Insert(int key)
{
    ++size;
    auto now = new Data;
    now->key = key;
    now->nxt = head.nxt;
    now->prev = &head;
    (*(head.nxt)).prev = now;
    head.nxt = now;
}

void Delete(Data *it)
{
    --size;
    (*(it->prev)).nxt = it->nxt;
    (*(it->nxt)).prev = it->prev;
    delete it;
}

void Delete(int key)
{
    auto it = Find(key);
    if (it != nullptr)
        Delete(it);
}

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

    int n, x;
    string s;

    head.prev = head.nxt = &last;
    last.prev = last.nxt = &head;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;

        if (s == "insert") {
            cin >> x;
            Insert(x);
        }
        else if (s == "delete") {
            cin >> x;
            Delete(x);
        }
        else if (s == "deleteFirst" && size != 0)
            Delete(head.nxt);
        else if (s == "deleteLast" && size != 0)
            Delete(last.prev);
    }

    for (auto it = head.nxt; it != &last; it = it->nxt, --size)
        cout << it->key << (size == 1 ? '\n' : ' ');

    return 0;
}

Measured memory_bytes: 32476
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    db = [a]
    cnt = 1
    while 2**cnt <= k:
        temp = [0]*n
        for i in range(n):
            temp[i] = db[cnt-1][db[cnt-1][i]-1]
        db.append(temp)
        cnt += 1

    res = 1
    for i in range(cnt):
        if (k>>i) & 1:
            res = db[i][res-1]
    print(res)

if __name__ == '__main__':
    main()

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

struct ModInt {
  using M = ModInt;
  long long MOD;
  long long v;
  ModInt(long long _v = 0, long long _MOD = 1e9 + 7) : MOD(_MOD), v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v, MOD); }
  M operator-(const M& x) const { return M(v + MOD - x.v, MOD); }
  M operator*(const M& x) const { return M(v * x.v % MOD, MOD); }
  M operator/(const M& x) const { return M(v * x.inv().v, MOD); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v, MOD), res(1, MOD);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }

  static vector<M> fact, finv;
  static void build(int n, long long p) {
    fact.assign(n + 1, M(1, p));
    finv.assign(n + 1, M(1, p));
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i, p);
    for (int i = 0; i < n + 1; i++) finv[i] = fact[i].inv();
  }
  static M comb(int n, int k, long long p) {
    if (n < k || k < 0) return M(0, p);
    return fact[n] * finv[n - k] * finv[k];
  }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
using mint = ModInt;

int main() {
  int p;
  cin >> p;
  vector<int> a(p);
  for (int i = 0; i < p; i++) cin >> a[i];
  mint::build(p, p);
  vector<mint> b(p, mint(0, p));
  for (int i = 0; i < p; i++) {
    if (a[i] == 0) continue;
    b[0] += mint(1, p);
    mint pw = mint(1, p);
    for (int j = p - 1; j >= 0; j--) {
      b[j] -= pw * mint::comb(p - 1, j, p);
      pw *= mint(-i, p);
    }
  }
  for (auto x : b) {
    cout << x << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pl;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

int main(){

  int a,b,h;
  cin >> a>>b>>h;

  cout << (a+b)*h/2 <<endl;
  return 0;
}


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

using namespace std;

int main(void){
    int n;
    vector<string> s;
    string temp;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>temp;
        s.emplace_back(temp);
    }

    std::sort(s.begin(), s.end());
    s.erase(std::unique(s.begin(), s.end()), s.end());

    cout<<s.size();

    return 0;
}

Measured memory_bytes: 11660
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long c = sc.nextLong();
        long[] x = new long[n+2];
        long[] v = new long[n+2];
        long[] vx = new long[n+2];
        long[] vy = new long[n+2];
        long[] ax = new long[n+2];
        long[] bx = new long[n+2];
        long[] al = new long[n+2];
        long[] bl = new long[n+2];
        x[0] = v[0] = v[n+1] = vx[0] = vy[0] = ax[0] = bx[0] = al[0] = bl[0]= 0;
        x[n+1] = c;
        for(int i = 1; i < n+1; i++){
            x[i] = sc.nextLong();
            v[i] = sc.nextLong();
        }
        for(int i = 1; i < n+2; i++){
            vx[i] = vx[i-1] + v[i];
            ax[i] = Math.max(ax[i-1], vx[i] - x[i]);
            al[i] = ax[i] == ax[i-1] ? al[i-1] : x[i];
            vy[i] =  vy[i-1] + v[n + 1 - i];
            bx[i] = Math.max(bx[i-1], vy[i] - (c - x[n + 1 - i]));
            bl[i] = bx[i] == bx[i-1] ? bl[i-1] : c - x[n + 1 - i];
        }
        long ans = 0;
        for(int i = 0; i < n+1; i++){
            ans = Math.max(ans, Math.max(ax[i] + bx[n - i] - al[i], ax[i] + bx[n - i] - bl[n - i]));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 100120
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] cin = Console.ReadLine().Split();
        int n = int.Parse(cin[0]);
        int m = int.Parse(cin[1]);
        int X = int.Parse(cin[2]);
        int Y = int.Parse(cin[3]);
        cin = Console.ReadLine().Split();
        int XMAX = X;
        for (int i = 0; i < n; i++)
        {
            XMAX = Math.Max(XMAX, int.Parse(cin[i]));
        }
        cin = Console.ReadLine().Split();
        int YMIN = Y;
        for (int i = 0; i < m; i++)
        {
            YMIN = Math.Min(YMIN, int.Parse(cin[i]));
        }

        if (XMAX < YMIN) Console.WriteLine("No War");
        else Console.WriteLine("War");
    }
}

Measured memory_bytes: 11092
/*
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C&lang=jp
?????????: Getting Started - Prime Numbers
?????°
7/5
14:08 Online Programming Lesson???????????¢????????????????????£????????????
14:12 ????????????
14:13 ?????????????????????????????????
14:14 TLE???????????????????????§????????????
*/
#include <cstdio>

bool isPrime(int n)
{
	if(n <= 1) return false;
	for(int i=2;i*i<=n;i++){
		if(n%i == 0) return false;
	}
	return true;
}

int main()
{
	int n;
	scanf("%d",&n);
	int ans = 0;
	for(int i=0;i<n;i++){
		int m;
		scanf("%d",&m);
		if(isPrime(m)) {ans++;}
	}
	printf("%d\n",ans);
}

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

int		main(void)
{
	int knum;
	string str;

	cin >> knum >> str;
	for (int i = 0; i < knum && str.length() > i ; i++)
	{
		cout << str[i];
	}
	if (str.length() > knum)
	{
		cout << "...";
	}
	cout << endl;



	return (0);
}

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

#define st first
#define nd second
typedef long long LL;
typedef long double LLD;
typedef pair <int, int> PII;
typedef pair <LL, LL> PLL;

bool Equals (string s, int it, string t)
{
    int n = (int)s.size();

    for (int i = 0; i < n; ++i)
        if (s[(i + it) % n] != t[i])
            return false;

    return true;
}

bool Check (string s, string t)
{
    int n = (int)s.size();

    for (int i = 0; i < n; ++i)
        if (Equals(s, i, t))
            return true;

    return false;
}

int main()
{       
    ios_base::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;

    if (s.size() != t.size() || !Check(s, t))
        cout << "No";
    else    
        cout << "Yes";
    
    return 0;
}

Measured memory_bytes: 256
def c_ManyFormulas(S):
    import itertools
    d = len(S)  # Sの桁数
    # 桁数-1個の演算子の列と解釈(1は'+',0は空文字)
    comb = itertools.product('01', repeat=d - 1)
    ans = 0
    for c in comb:
        c = ['+' if x == '1' else '' for x in c]
        tmp = ''  # 数字の間に演算子を入れた文字列(数式と解釈する)
        for i in range(d):
            if i == d - 1:
                # 末尾に演算子は付かない
                tmp += S[d - 1]
            else:
                tmp += S[i] + c[i]
        ans += eval(tmp)
    return ans

S = input().strip()
print(c_ManyFormulas(S))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M,C,a,b;
    int count=0;
    cin>>N>>M>>C;
    vector<int>B;
    for(int i=0;i<M;i++){
        cin>>b;
        B.push_back(b);
    }
    for(int i=0;i<N;i++){
        vector<int>A;
        for(int j=0;j<M;j++){
            cin>>a;
            A.push_back(a);
        }
        long long D=inner_product(A.begin(),A.end(),B.begin(),C);
        if(D>0){count++;}
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
V = rl()
C = rl()

def get_score(b):
	X = 0
	Y = 0
	for i, v in enumerate(b):
		if v:
			X += V[i]
			Y += C[i]
	return X-Y
ans = -float('inf')
for b in product([0, 1], repeat=N):
	s = get_score(b)
	ans = max(ans, s)
print(ans)



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

int main (){
    int a, b, c;
    cin >> a >> b >> c;
    if (a >= b && a >= c){
        cout << b*c/2 << endl;
    } else if (b >= a && b>= c){
        cout << a*c/2 << endl;
    } else {
        cout << a*b/2 << endl;
    }
    return 0;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{

    string ss;
    cin >> ss;
    ll x = (ss[0] - '0')*10 + (ss[1]-'0');
    ll y = (ss[2] - '0')*10 + (ss[3] - '0');
    if(x >= 1 && x <= 12)
    {

        if(y >= 1 && y <= 12)
            cout << "AMBIGUOUS";
        else cout << "MMYY";
    }
    else
    {

        if(y >= 1 && y <= 12)
            cout << "YYMM";
        else cout << "NA";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n;
long long ans,m,a[500005];
int main()
{
	scanf("%d%lld",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%lld",&a[i]),a[i]=a[i-1]+a[i];
	ans=1000000000000000000ll;
	for (int i=1;i<=n;i++)
	{
		long long s=0;
		for (int j=n,x=1;j>=1;j-=i,x++)
		{
			int k=max(j-i+1,1);
			if (j==n) s=min(s+2ll*(a[j]-a[k-1]),1000000000000000000ll);
			s=min(s+(long long)(x+x+1)*(a[j]-a[k-1]),1000000000000000000ll);
		}
		s=min(s+m*(i+n),1000000000000000000ll);
		ans=min(ans,s);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
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; }


int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    int k,s;
    vector<int> S(N);
    REP(i,M){
        cin >> k;
        REP(j,k){
            cin >> s;
            s--;
            S[s] |= (1 << i);
        }
    }
    int P = 0;
    REP(i,M){
        int x;
        cin >> x;
        P |= x << i;
    }

    int ans = 0;
    REP(i,(1<<N)){
        int t= 0;
        REP(j,N){
            if((i>>j)&1){
                t ^= S[j];
            }
        }
        if(t == P){
            ans++;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int order(int x)
{
    return (x + 9) / 10 * 10;
}

int remtime(int x)
{
    return order(x) - x;
}

int main()
{
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;

    int sum = order(A) + order(B) + order(C) + order(D) + order(E);
    sum -= max({remtime(A), remtime(B), remtime(C), remtime(D), remtime(E)});
    cout << sum << endl;
}


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

 int main() {
 int N;
 cin >> N;
 vector<int> a(N);
 int sum = 0;

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

 int mini = sum;
 int prefix_sum = 0;
 for (int i = 0; i < N; ++i) {
 	cin >> a[i];
 prefix_sum += a[i];
 mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
 }

 cout << mini << endl;
 return 0;
 }

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
    int n, minv, maxv = INT_MIN;
    int r[200001];
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> r[i];
    }
    minv = r[0];
    for(int i = 1; i < n; i++) {
        maxv = max(maxv, r[i] - minv);
        minv = min(minv, r[i]);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
vector<ar<int, 3>> a;
vector<string> ans;
int dignum(int x) {
  int num = 0;
  while (x) {
    num++;
    x /= 10;
  }
  return num;
}
void fun(int j, int cnt) {
  string t;
  int siz = dignum(a[j][0]);
  if (siz != 6)
    t += string(6 - siz, '0');
  t += to_string(a[j][0]);
  if (dignum(cnt) != 6)
    t += string(6 - dignum(cnt), '0');
  t += to_string(cnt);
  ans[a[j][2]] = t;
}
void init() {
  int n, m;
  cin >> n >> m;
  a = vector<ar<int, 3>>(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i][0] >> a[i][1];
    a[i][2] = i;
  }
  ans = vector<string>(m);
  sort(all(a), [&](const ar<int, 3> &a, const ar<int, 3> &b) {
    if (a[0] == b[0])
      return a[1] < b[1];
    return a[0] < b[0];
  });
  for (int i = 0; i < m;) {
    int j = i;
    int cnt = 1;
    while (j + 1 < m and a[j][0] == a[j + 1][0]) {
      fun(j, cnt);
      ++cnt;
      ++j;
    }
    fun(j, cnt);
    i = j + 1;
  }
  for (auto &x : ans)
    cout << x << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 8704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer in=new StringTokenizer(br.readLine());
        int N =Integer.parseInt(in.nextToken());
        int K =Integer.parseInt(in.nextToken());
        in = null;
        br = null;
        double ans = 0.0;

        for (int i = 1; i <= N; i++) {
        	int tmp = i;
        	double d = 1.0 / N;
        	while (K > tmp) {
        		tmp *= 2;
        		d /= 2;
        	}
        	ans += d;
        }

        System.out.println(ans);

	}

}


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

long long gcd(long long x, long long y){
  if(x < y) swap(x,y);
  if(!y) return x;
  return gcd(y,x%y);
}

int main(){
  int T;
  cin >> T;
  for(int i = 0; i < T; ++i){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A < B){
      cout << "No" << endl;
      continue;
    }
    if(A-B <= C && A-B+D < B){
      cout << "No" << endl;
      continue;
    }
    if(C >= B){
      if(D >= B) cout << "Yes" << endl;
      else cout << "No" << endl;
      continue;
    }
    if(!(D%B)){
      if(A%B <= C) cout << "Yes" << endl;
      else cout << "No" << endl;
      continue;
    }
    //long long d = D%B;
    long long d = gcd(D,B);
    //cout << ((A%B)%d+C-C%B)/d*d + C-C%B << endl;
    //cout << (C - A%B)/d << " " <<  (B-A%B-1)/d << endl;
    if((C - A%B)/d >= (B-A%B-1)/d &&
       (A%B)%d + D >= B) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
mod = 10**9+7
count = [0]*(2*10**5+1)
l = [0]+[int(input()) for i in range(n)]
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1):
    if l[i] == l[i-1]:
        dp[i] = dp[i-1]
        continue
    dp[i] = (dp[i-1]+count[l[i]])%mod
    count[l[i]] = dp[i]
print(dp[-1])

Measured memory_bytes: 26252
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll inf=1e18+7;

/*
AC
*/

ll q,h,s,d,n,a[3],ans=0;

int main(void){
	cin>>q>>h>>s>>d>>n;
	a[0]=4*q;
	a[1]=2*h;
	a[2]=s;
	sort(a,a+3);
	s=a[0];
	if(s*2>d){
		ans+=n/2*d;
		ans+=(n%2)*s;
	}else{
		ans+=n*s;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll k,n,i;
    cin>>k>>n;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    ll mini=hell;
    for(i=1;i<n;i++)
        mini=min(mini,k-a[i]+a[i-1]);
    mini=min(mini,(a[n-1]-a[0]));
    cout<<mini;
    return 0;
}



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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == '1') cout << '9';
    else cout << '1';
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
000010 IDENTIFICATION  DIVISION.
000020 PROGRAM-ID.     MAIN.
000030 ENVIRONMENT     DIVISION.
000040 DATA            DIVISION.
000050 WORKING-STORAGE  SECTION.
000060 01 STR        PIC 99.
000070 01 ANS		  PIC 99.
000080 *     
000090 PROCEDURE DIVISION.
000100 * 
000110 ACCEPT STR.
000120 COMPUTE ANS = 48 - STR.
000130 DISPLAY ANS.
000140 STOP RUN.

Measured memory_bytes: 384
#include<bits/stdc++.h> 
using namespace std;int main(){
	int n;	cin >> n;
	int arr[n];	for(int i=0; i<n; i++)	cin >> arr[i];
	int fmax=max(arr[0],arr[1]); int index;if(fmax==arr[0])	index=0;	else	index=1;
	int smax=min(arr[0],arr[1]); 
	for(int i=2; i<n; i++){
		if(arr[i]>=fmax){
			smax=fmax;	fmax=arr[i];	index=i;
		}
		else if(arr[i]<fmax && arr[i]>smax){
			smax=arr[i];
		}
	}
	for(int i=0; i<n; i++){
		if(i==index)	cout<<smax<<endl;
		else	cout<<fmax<<endl;
	}
	return 0;
}

Measured memory_bytes: 2432
//https://vjudge.net/contest/331523#problem/D
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 100005;
MPII m;

int main(){
    io;
    //freopen("input.txt", "r", stdin);
    int n; cin >> n;
    rep(i, 1, n){
        int x; cin >> x;
        if(m.find(x) == m.end()){
            m.insert(mp(x, 1));
        }else{
            m[x]++;
        }
    }
    int total = 0;
    foreach(a, m){
        if(a.ff <= a.ss){
            total += a.ss - a.ff;
        }else{
            total += a.ss;
        }
    }
    cout << total;
    return 0;
}


Measured memory_bytes: 4736
import java.io.*;
public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String wline = reader.readLine();
            String nline = reader.readLine();
            int w = Integer.parseInt(wline);
            int n = Integer.parseInt(nline);
            int i,a,b,x;
            int[] num = new int[w];

            for(i=0;i<w;i++){
                num[i] = i+1;
            }
            

            for(i=0;i<n;i++){ 
                String line = reader.readLine();
                String[] lines = line.split(",");
                a = Integer.parseInt(lines[0]);
                b = Integer.parseInt(lines[1]);
                x = num[a-1];
                num[a-1] = num[b-1];
                num[b-1] = x;
            }       
            for(i=0;i<w;i++){
                System.out.println(num[i]+"");
            }     
            
           
        } catch (FileNotFoundException e) {
            System.out.println("ファイルが存在しません。");
        } catch (IOException e) {
            System.out.println("エラーが発生しました。");
        }
        
    
    }
}


Measured memory_bytes: 24144
n = int(input())
Xl = [ list(map(int, input().split())) for _ in range(n) ]
Xl.sort()
cnt, prv = 0, sum(Xl[0])
for i in range(n-1):
    x, l = Xl[i+1][0], Xl[i+1][1]
    if prv <= x-l:
        prv = x+l
        continue
    else:
        prv = min(prv, x+l)
        cnt += 1
print(n-cnt)

Measured memory_bytes: 63448
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<int, int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int, int>
#define mii         map<pii, int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
int mult(int a,int b, int p=MOD){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p=MOD){return (a + b + p)%p;}
int fpow(int n, int k, int p = MOD) {int r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve(){
    string s;
    cin>>s;
    if(s == "ABC")
        cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;

}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

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

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


























int main(){
    string s;
    cin >> s;
    ll n = s.size();
    REP(i, n){
        if(s[i] == '?') s[i] = 'D';
    }
    cout << s << endl;
}


Measured memory_bytes: 3756
import std.stdio, std.conv, std.algorithm, std.array, std.string;

void main(){
	int n = to!int(readln.chomp);
	foreach(_; 0..n){
		auto ns = array(map!(to!int)(readln.chomp.split));
		writeln(solve(ns) ? "YES" : "NO");
	}
}

bool solve(int[] ns){
	foreach(bit; 0..1<<ns.length){
		int[2] prev;
		bool ok = true;
		foreach(i; 0..ns.length){
			if(prev[(bit>>i)&1] < ns[i]){
				prev[(bit>>i)&1] = ns[i];
			}
			else{
				ok = false;
				break;
			}
		}
		if(ok){
			return true;
		}
	}
	return false;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
const int maxn=1e5+10;
const LL inf=1e18;
LL a[maxn];
map<LL,int> mp;
void bfs()
{
    int ans=0;
    queue<LL> q;
    for(LL i=1;i<=9;i++){
        q.push(i);
        mp[i]=1;
        a[++ans]=i;
    }
    while(!q.empty()){
        if(ans>=maxn-5)break;
        LL pre=q.front();
        //LL pre1=pre;
        q.pop();
        LL ko=pre%10;
        for(LL i=0;i<=9;i++){
            if(abs(i-ko)<=1){
                LL nxt=pre*10+i;
                if(mp[nxt]==0){
                    q.push(nxt);
                    mp[nxt]=1;
                    a[++ans]=nxt;
                }
            }
        }
    }
}
int main()
{
    bfs();
    /*for(int i=1;i<=100000;i++){
        printf("%lld ",a[i]);
    }*/
    int k;
    scanf("%d",&k);
    printf("%lld\n",a[k]);
    return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
	int a = 0;
	string W, T;
	cin >> W;
	transform(W.begin(), W.end(), W.begin(), ::toupper);

	while (1){
		cin >> T;
		if (T == "END_OF_TEXT")
		{
			break;
		}
		transform(T.begin(), T.end(), T.begin(), ::toupper);

		if (T == W)
		{
			a++;
		}
	}
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    int fact[1000005];
    bool ok=false;
 
    void f(int x){
        if(ok==true)
            return;
        for(int i=1;i*i<=x;i++){
            if(x%i==0){
                int a=i;
                int b=x/i;
                if(a==b){
                    a=i;
                    b=1;
                }
                if(a!=1){
                    if(fact[a]){
                        ok=true;
                        return;
                    }
                    fact[a]++;
                }
                if(b!=1){
                    if(fact[b]){
                        ok=true;
                        return;
                    }
                    fact[b]++;
                }
            }
        }
    }
 
    void solve(){  
        int n;
        cin>>n;
        vector<int>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        int gcd=a[0];
        // cout<<"in "<<ok<<"\n";
        f(a[0]);
        // cout<<"in "<<ok<<"\n";
        for(int i=1;i<n;i++){
            f(a[i]);
            gcd=__gcd(gcd,a[i]);
            // cout<<"in "<<ok<<"\n";
        }
        if(!ok){
            cout<<"pairwise coprime";
        }
        else if(gcd==1){
            cout<<"setwise coprime";
        }
        else{
            cout<<"not coprime";
        }
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

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

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

template <long long Modulus> class mint {
    long long a;
public:

    constexpr mint(const long long a = 0) noexcept : a((a % Modulus + Modulus) % Modulus) {}

    constexpr long long& value() noexcept {
        return a;
    }

    constexpr mint& operator +=(const mint& rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) a -= Modulus;
        return *this;
    }

    constexpr mint& operator -=(const mint& rhs) noexcept {
        a += Modulus - rhs.a;
        if (a >= Modulus) a -= Modulus;
        return *this;
    }

    constexpr mint& operator *=(const mint& rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }

    constexpr mint operator +(const mint rhs) const noexcept {
        return mint(*this) += rhs;
    }

    constexpr mint operator -(const mint rhs) const noexcept {
        return mint(*this) -= rhs;
    }

    constexpr mint operator *(const mint &rhs) const noexcept {
        return mint(*this) *= rhs;
    }

    constexpr mint pow(long long t) const noexcept {
        if (!t) return 1;
        mint<Modulus> ret = pow(t >> 1u);
        ret *= ret;
        if (t & 1) ret *= *this;
        return ret;
    }

    constexpr mint inv() const noexcept {
        return pow(Modulus - 2);
    }

    constexpr mint operator /=(const mint rhs) {
        return (*this) *= rhs.inv();
    }

    constexpr mint operator /(const mint &rhs) const noexcept {
        return mint(*this) /= rhs;
    }
};

using mi = mint<MOD>;

mi powmod(mi a, ll p) {
    mi ans = 1;
    mi mul = a;
    for (; p > 0; p >>= 1, mul = mul * mul) {
        if (p & 1) ans *= mul;
    }
    return ans;
}

mi fact[100005];
mi rev[100005];

mi nCk(ll n, ll k) {
    if (n < 0 || k < 0) return 0;
    if (n < k) return 0;
    return fact[n] * rev[n-k] * rev[k];
}

signed main() {
    fact[0] = 1;
    for (int i = 0; i < 100000; i++) fact[i+1] = fact[i] * (i + 1);
    rev[100000] = powmod(fact[100000], MOD-2);
    for (int i = 100000-1; i >= 0; i--) rev[i] = rev[i+1] * (i+1);

    int N, K;
    cin >> N >> K;

    if (K == 1) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    mi tmp1 = 0;
    mi tmp2 = 0;

    for (int i = K-1; i < N; i++) {
        tmp1 += nCk(i, K-1) * A[i];
    }

    /*
    for (int i = N - K; i >= 0; i--) {
        tmp2 += nCk(N-i-1, K-1) * A[i];
    }
     */

    sort(A.begin(), A.end(), greater<ll>());
    for (int i = K-1; i < N; i++) {
        tmp2 += nCk(i, K-1) * A[i];
    }

    cout << (tmp1 - tmp2).value() << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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; }

int main () {
  vi x(5);
  rep(i,5) x[i] = in();
  auto maxtime = [&](int x) {
    return dup(x,10)*10;
  };
  auto remtime = [&](int x) {
    return maxtime(x) - x;
  };
  int sum = 0;
  rep(i,5) sum += maxtime(x[i]);
  int ma = 0;
  rep(i,5) chmax(ma, remtime(x[i]));
  int ans = sum - ma;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());

        int d = a / b;
        int r = a % b;
        double f = (double) a / (double) b;

        System.out.println(d + " " + r + " " + String.format("%.5f", f));
    }
}

Measured memory_bytes: 26344
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline long long in(){long long x=0;cin>>x;return x;}
inline void out(long long x){if(x<0) putchar('-'),x=-x;if(x>9) out(x/10);putchar(x%10+'0');}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "R"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define _ putchar(' ')
#define __ putchar('\n')
const int N=1e9+7;
int n,k,kq;
struct M{int m[50][50];}a;
M operator*(M a,M b)
{
    M c;
    forinc(i,0,n-1) forinc(j,0,n-1) c.m[i][j]=0;
    forinc(t,0,n-1) forinc(i,0,n-1) forinc(j,0,n-1) c.m[i][j]=(c.m[i][j] + a.m[i][t]*b.m[t][j]%N)%N;
    return c;
}
M pw(M a,int i)
{
    M b=a;i--;
    for(;i;i>>=1,a=a*a) if(i&1) b=b*a;
    return b;
}
main()
{
    fasty;
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    n=in(),k=in();
    forinc(i,1,n) forinc(j,1,n) a.m[i-1][j-1]=in();
    a=pw(a,k);
    forinc(i,0,n-1) forinc(j,0,n-1) kq=(kq+a.m[i][j])%N;
    cout<<kq;
}


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

const int maxn = 500009;
struct point{
	double v, t;
} u, q[maxn];
int n, L, l = 1, r;
double X, Y;

int main(){
	scanf("%d%d", &n, &L);
	for (int i=1; i<=n; i++){
		scanf("%lf%lf", &u.t, &u.v);
		X += u.v; Y += u.v*u.t;
		while (L < X){
			if (X-L >= q[l].v){ Y -= q[l].v * q[l].t; X -= q[l++].v; }
			else { Y -= q[l].t*(X-L); q[l].v -= X-L; X = L; }
		}
		printf("%.8lf\n", Y/X);
		while (l <= r && q[r].t >= u.t){
			u.t = (q[r].t*q[r].v + u.t*u.v) / (q[r].v+u.v);
			u.v += q[r--].v;
		}
		q[++r] = u;
	}
	return 0;
}

Measured memory_bytes: 17280
N,M = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]

import heapq
h = []
ans = 0
L.sort()
m = 1
i = 0
while i < N and L[i][0] <= M:
    if L[i][0] == m:
        heapq.heappush(h, -L[i][1])
        i += 1
    else:
        m += 1
        if h:
            ans -= heapq.heappop(h)
while m <= M and h:
    ans -= heapq.heappop(h)
    m += 1
print(ans)

Measured memory_bytes: 25452
#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>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

    int main(){
      string S,T;
      cin >> S >> T;
      int cnt1[26]={},cnt2[26]={};
      for(int i=0;i<=25;i++){
       for(int j=0;j<S.size();j++){
        if(S[j]=='a'+i){
          cnt1[i]++;
        }
       }
        for(int j=0;j<T.size();j++){
         if(T[j]=='a'+i) cnt2[i]++; 
        }
      }
      
     for(int i=0;i<26;i++){
     }
      sort(cnt1,cnt1+26);
      sort(cnt2,cnt2+26);
      bool flag=true;
      for(int i=0;i<26;i++){
       if(cnt1[i]!=cnt2[i]){
        flag=false; 
       }
      }
      if(flag){
       cout << "Yes" << endl; 
      }else{
       cout << "No" << endl; 
      }
      return 0;}

Measured memory_bytes: 776
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

N = int(input())
ans = 0
for i in range(N):
	l,r = inpl()
	ans += r-l+1

print(ans)


Measured memory_bytes: 4212
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <string>
#define SIZE 100005
#define MOD 1000000007
#define MX 5

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

struct Matrix
{
	int n;
	ll A[MX][MX];
	
	ll mpow(ll x,ll t)
	{
		if(t==0) return 1;
		ll ret=mpow(x,t/2);
		ret=ret*ret%MOD;
		if(t%2==1) ret=ret*x%MOD;
		return ret;
	}
	ll inv(ll x)
	{
		return mpow(x,MOD-2);//if MOD is a prime number
	}
	void init(int m)
	{
		n=m;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				A[i][j]=0;
			}
		}
	}
	void add(int a,int b,ll x)
	{
		A[a][b]+=x;
		if(A[a][b]>=MOD) A[a][b]-=MOD;
	}
};
Matrix SUM_mat,PR_mat;
void product(Matrix&A,Matrix&B)
{
	int n=A.n;
	PR_mat.init(n);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			PR_mat.A[i][j]=0;
			for(int k=0;k<n;k++)
			{
				PR_mat.A[i][j]+=A.A[i][k]*B.A[k][j]%MOD;
				if(PR_mat.A[i][j]>=MOD) PR_mat.A[i][j]-=MOD;
			}
		}
	}
}
void sumsum(Matrix&A,Matrix&B)
{
	int n=A.n;
	SUM_mat.init(n);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			SUM_mat.A[i][j]=0;
			for(int k=0;k<n;k++)
			{
				SUM_mat.A[i][j]+=(A.A[i][k]+B.A[k][j])%MOD;
				if(SUM_mat.A[i][j]>=MOD) SUM_mat.A[i][j]-=MOD;
			}
		}
	}
}
Matrix mt[1000];
void mpow(Matrix&M,ll t,int dep)
{
	if(t==1)
	{
		mt[dep]=M;
		return;
	}
	mpow(M,t/2,dep+1);
	product(mt[dep+1],mt[dep+1]);
	mt[dep]=PR_mat;
	if(t%2==1)
	{
		product(mt[dep],M);
		mt[dep]=PR_mat;
	}
}

int main()
{
	ll eA=0,eB=1,eC=3;
	ll oA=0,oB=0,oC=0;
	Matrix M;
	M.init(3);
	M.add(0,0,4);
	M.add(0,1,MOD-2);
	M.add(0,2,1);
	M.add(1,0,1);
	M.add(1,1,0);
	M.add(1,2,0);
	M.add(2,0,0);
	M.add(2,1,1);
	M.add(2,2,0);
	int n,m;
	scanf("%d %d",&n,&m);
	int bef=0;
	for(int i=0;i<m;i++)
	{
		int x;
		scanf("%d",&x);
		mpow(M,x-bef,0);
		ll na=(mt[0].A[0][0]*eA%MOD+mt[0].A[0][1]*eB%MOD+mt[0].A[0][2]*eC%MOD)%MOD;
		ll nb=(mt[0].A[1][0]*eA%MOD+mt[0].A[1][1]*eB%MOD+mt[0].A[1][2]*eC%MOD)%MOD;
		ll nc=(mt[0].A[2][0]*eA%MOD+mt[0].A[2][1]*eB%MOD+mt[0].A[2][2]*eC%MOD)%MOD;
		
		ll ma=(mt[0].A[0][0]*oA%MOD+mt[0].A[0][1]*oB%MOD+mt[0].A[0][2]*oC%MOD)%MOD;
		ll mb=(mt[0].A[1][0]*oA%MOD+mt[0].A[1][1]*oB%MOD+mt[0].A[1][2]*oC%MOD)%MOD;
		ll mc=(mt[0].A[2][0]*oA%MOD+mt[0].A[2][1]*oB%MOD+mt[0].A[2][2]*oC%MOD)%MOD;
		
		eA=na,eB=(nb+ma)%MOD,eC=(nc+3LL*ma)%MOD;
		oA=ma,oB=(mb+na)%MOD,oC=(mc+3LL*na)%MOD;
		
		bef=x;
	}
	mpow(M,n-bef,0);
	ll na=(mt[0].A[0][0]*eA%MOD+mt[0].A[0][1]*eB%MOD+mt[0].A[0][2]*eC%MOD)%MOD;
	ll ma=(mt[0].A[0][0]*oA%MOD+mt[0].A[0][1]*oB%MOD+mt[0].A[0][2]*oC%MOD)%MOD;
	printf("%lld\n",(na-ma+MOD)%MOD);
	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  string s;
  while (cin >> s, s != "#") {
    int h = 1, w = 0, flag = 0;
    for (int i = 0; i < s.size(); i++) {
      h += s[i] == '/';
      if (s[i] == '/') flag = 1;
      if (!flag) w += (s[i] == 'b' ? 1 : s[i] - '0');
    }

    vector<vector<bool>> ball(h, vector<bool>(w, false));
    int y = 0, x = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '/') {
        y++; x = 0;
        continue;
      }
      if (s[i] == 'b') ball[y][x] = true, x++;
      else x += s[i] - '0';
    }

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    ball[a - 1][b - 1] = false;
    ball[c - 1][d - 1] = true;

    string ans = "";
    for (int i = 0; i < h; i++) {
      int l = 0, r = 0;
      while (l < w) {
        if (ball[i][l]) {
          ans += 'b';
        } else {
          while (r + 1 < w && !ball[i][r + 1]) r++;
          ans += r - l + 1 + '0';
        }
        l = ++r;
      }
      if (i + 1 != h) ans += "/";
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3160
n=int(input())
from collections import Counter as co
l=co(map(int,input().split()))
ans=set()
for k in l:
    if l[k]>=2:ans.add(k)
    for j in range(2*k,10**6+1,k):
        if j in l:
            ans.add(j)
        
        
print(len(l)-len(ans))

Measured memory_bytes: 135736