akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc169_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var A = CIn.ReadLongArray(N);

      if (A.Contains(0))
      {
        Console.WriteLine(0);
        return;
      }

      var m = 1L;

      for (int i = 0; i < N; i++)
      {
        try
        {
          m = checked(m * A[i]);
        }
        catch
        {
          Console.WriteLine(-1);
          return;
        }
        if (m > (long)1e18)
        {
          Console.WriteLine(-1);
          return;
        }
      }

      Console.WriteLine(m);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 44544
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if((c-a-b)*(c-a-b)>4*a*b&&c-a-b>=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main() {
	char s[3];
	int k[3];
	for(int i=0;i<3;i++){
	cin>>s[i];
	k[i]=0;

	}
	for(int i=0;i<3;i++){
		if(s[i]=='a')k[0]=1;
		if(s[i]=='b')k[1]=1;
		if(s[i]=='c')k[2]=1;
	}
	if(k[0]*k[1]*k[2]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}


	return 0;
}


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

int fairfiled(int y,int m,int d){
	if(m<3){
		--y;
		m+=12;
	}
	return 365*y+(y/4)-(y/100)+(y/400)+(306*(m+1)/10)+d-428;
}

int main(){
	int y1,m1,d1;
	int y2,m2,d2;
	int sum;
	while(cin>>y1>>m1>>d1>>y2>>m2>>d2,y1>0){
		cout<<fairfiled(y2,m2,d2)-fairfiled(y1,m1,d1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;

    cout << max(max(A*10+B+C, A+B*10+C), A+B+C*10 )<< endl;
    // if(A==12)
    // 	cout << 1<<endl;
    // else
    // 	cout << A+1<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;

    // if(A%2==1 && B%2==1)
    // 	puts("Yes");
    // else
    // 	puts("No");
	
}


Measured memory_bytes: 256
const main = (input) => {
  const N = Number(input);

  console.log(calc(N, "", 0));
}

var map = {}; // 最後の4文字+文字数
var w = ['A','C','G','T'];
function calc(N, lst4, cnt){
  var key = lst4 + "_" + cnt;
  if(map[key]) return map[key];
  if(cnt == N) {
//    console.log(lst4);
    return 1;
  }
  var ans = 0;
  for(var i=0;i<4;i++){
    var next = lst4+w[i];
    var next3 = (next).slice(-3);
    var next4 = (next).slice(-4);
    if(
      next3[0]+next3[1]+next3[2] != 'AGC' &&
      next3[0]+next3[2]+next3[1] != 'AGC' &&
      next3[1]+next3[0]+next3[2] != 'AGC' &&

      next4[0]+next4[1]+next4[3] != 'AGC' &&
      next4[0]+next4[2]+next4[3] != 'AGC'
    ){
      ans += calc(N, next.slice(-4), cnt+1);
      ans %= 1000000007;
    }
  }
  map[key] = ans;
  return ans;
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 13780
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    let answer = 0;
    
    if(K === 0) {
        console.log(N * N);
        return;
    }
    
    for(let b=1; b<=N; b++) {
        answer += Math.floor(N / b) * Math.max(0, b - K);
        
        if(N % b > 0) {
            answer += Math.max(0, (N % b) - K + 1);
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 10

string S;

int main() {
	cin >> S;

	int sz = S.size();
	long long ans = 0;
	for( int i = 0; i < 1 << (sz - 1); i++ ) {
		long long acc = 0;
		for( int j = 0; j < sz; j++ ) {
			acc = acc * 10 + S[j] - '0';
			if( i & 1 << j ) {
				ans += acc;
				acc = 0;
			}
		}
		ans += acc;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

ll a[201100], b[201100];

ll Combination(ll n, int m)
{
 int ans = 1;
 for(int i=n; i>=(n-m+1); --i)
  ans *= i;
 while(m)
  ans /= m--;
 return ans;
}

int main()
{
        ll n, sum = 0, temp;
        cin >> n;
        for(int i = 0; i < n; i++)
        {
                cin >> b[i];
                a[b[i]]++;
        }
        for(int i = 1; i <= n; i++)
        {
                if(a[i] <= 1) continue;
                sum += (a[i] * (a[i] - 1) ) / 2;
        }
        for(int i = 0; i < n; i++)
        {
                temp = sum;
                if(a[b[i]]) temp -= (a[b[i]] * ( a[b[i]] - 1) - (a[b[i]] - 1) * (a[b[i]] - 2)) / 2;
                cout << temp << endl;
        }
        return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<string>

class Card{
protected:
    int value;
    std::string pattern;
public:
    Card(std::string pattern,int value);
    Card(std::string card);
    int getValue();
    std::string getPattern();
    std::string getCard();
};

Card::Card(std::string pattern,int value){
    this->pattern = pattern;
    this->value = value;
}

Card::Card(std::string card){
    this->pattern = card.substr(0,1);
    this->value = std::stoi(card.substr(1,1));
}

int Card::getValue(){
    return value;
}

std::string Card::getPattern(){
    return pattern;
}

std::string Card::getCard(){
    return pattern + std::to_string(value);
}

class CardSort{
protected:
    std::vector<Card> cardSet;
public:
    CardSort(std::vector<Card> cardSet);
    std::vector<Card> getCardSet();
    void showCardSet();
    void startBubbleSort();
    void startSelectSort();
};

CardSort::CardSort(std::vector<Card> cardSet){
    this->cardSet = cardSet;
}

std::vector<Card> CardSort::getCardSet(){
    return this->cardSet;
}

void CardSort::showCardSet(){
    for(int i = 0;i < cardSet.size();i++){
        std::cout << (i ? " " : "") << cardSet[i].getCard();
    }
    std::cout << std::endl;
}

void CardSort::startBubbleSort(){
    for(int i = 0;i < cardSet.size() - 1;i++){
        for(int j = cardSet.size() - 1;j >= i + 1;j--){
            if(cardSet[j].getValue() < cardSet[j-1].getValue()){
                Card tmp = cardSet[j];
                cardSet[j] = cardSet[j-1];
                cardSet[j-1] = tmp;
            }
        }
    }
}

void CardSort::startSelectSort(){
    for(int i = 0;i < cardSet.size();i++){
        int minj = i;
        for(int j = i;j < cardSet.size();j++){
            if(cardSet[j].getValue() < cardSet[minj].getValue()){
                minj = j;
            }
        }
        if(i != minj){
            Card tmp = cardSet[minj];
            cardSet[minj] = cardSet[i];
            cardSet[i] = tmp;
        }
    }
}

bool isStable(std::vector<Card> bubble,std::vector<Card> select){
    for(int i = 0;i < bubble.size();i++){
        if( (bubble[i].getPattern() != select[i].getPattern() || bubble[i].getValue() != select[i].getValue()) ){
            return false;
        }
    }
    return true;
}

int main(){
    
    int content;
    std::cin >> content;

    std::vector<Card> vec;

    int i = 0;
    std::string input;

    while(std::cin >> input){
        
        Card c = Card(input);
        vec.push_back(input);

        i++;
        if(i >= content){
            break;
        }
    }

    CardSort bs = CardSort(vec);
    CardSort ss = CardSort(vec);

    bs.startBubbleSort();
    bs.showCardSet();
    std::cout << "Stable" << std::endl;

    ss.startSelectSort();
    ss.showCardSet();
    if( isStable(bs.getCardSet(),ss.getCardSet()) ){
        std::cout << "Stable";    
    }else{
        std::cout << "Not stable";
    }
    std::cout << std::endl;
    
    return 0;
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, B;
  cin >> A >> B;

  if((A <= 8) && (B <= 8))
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
  
  return 0;
}


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

using namespace std;

typedef long long ll;

const int maxn = 10010;
const int mod = 998244353;
const int g = 3;

int n, c1, c2, c3, fac[maxn], ifac[maxn];
char A[maxn], B[maxn];

int qpow(int x, int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = 1ll * ret * x % mod;
		x = 1ll * x * x % mod;
		y >>= 1;
	}
	return ret;
}

struct poly {
	int *a, len;
	poly(int l) {
		len = l;
		a = new int[len];
		for (int i = 0; i < len; i++) {
			a[i] = 0;
		}
	}
};

int wa[maxn<<2], wb[maxn<<2], wc[maxn<<2], rev[maxn<<2];

void ntt(int *a, int _l, int ty) {
	int len = (1 << _l);
	for (int i = 1; i < len; i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (_l - 1));
	for (int i = 0; i < len; i++) if (i < rev[i]) swap(a[i], a[rev[i]]);
	for (int l = 2; l <= len; l <<= 1) {
		int wl = qpow(g, (mod - 1) / l);
		for (int s = 0; s < len; s += l) {
			int w = 1;
			for (int i = 0; i < (l >> 1); i++) {
				int v1 = a[s + i], v2 = 1LL * w * a[s + i + (l >> 1)] % mod;
				a[s + i] = (v1 + v2) % mod;
				a[s + i + (l >> 1)] = (v1 + mod - v2) % mod;
				w = 1LL * w * wl % mod;
			}
		}
	}
	if (ty == -1) {
		int inv = qpow(len, mod-2);
		for (int i = 0; i < len; i++) a[i] = 1LL * a[i] * inv % mod;
		for (int i = 1; i < len - i; i++) swap(a[i], a[len - i]);
	}
}

poly operator*(const poly &p1, const poly &p2) {
	poly ret(p1.len + p2.len - 1);
	int l = 0; while ((1 << l) < ret.len) ++ l;
	for (int i = 0; i < (1 << l); i++) wa[i] = wb[i] = 0;
	for (int i = 0; i < p1.len; i++) wa[i] = p1.a[i];
	for (int i = 0; i < p2.len; i++) wb[i] = p2.a[i];
	ntt(wa, l, 1), ntt(wb, l, 1);
	for (int i = 0; i < (1 << l); i++) wc[i] = 1LL * wa[i] * wb[i] % mod;
	ntt(wc, l, -1);
	for (int i = 0; i < ret.len; i++) ret.a[i] = wc[i];
	ret.len = min(ret.len, c2+1);
	return ret;
}

poly qpow(poly p, int k) {
	poly ret(1); ret.a[0] = 1;
	while (k) {
		if (k & 1) ret = ret * p;
		p = p * p;
		k >>= 1;
	}
	return ret;
}

int main() {
	scanf("%s", A+1);
	scanf("%s", B+1);
	n = int (strlen (A+1));
	for (int i = 1; i <= n; i++) {
		if (A[i] == '1' && B[i] == '0') ++ c1;
		if (A[i] == '1' && B[i] == '1') ++ c2;
		if (A[i] == '0' && B[i] == '1') ++ c3;
	}
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = 1LL * fac[i-1] * i % mod;
		ifac[i] = qpow(fac[i], mod-2);
	}
	poly C(c2+1), P(c2+1);
	for (int i = 0; i <= c2; i++) C.a[i] = 1;
	for (int i = 0; i <= c2; i++) P.a[i] = ifac[i+1];
	poly res = qpow(P, c1) * C;
	printf("%d\n", int (1LL * fac[c1] * fac[c2] % mod * fac[c1 + c2] % mod * res.a[c2] % mod));
	return 0;
}

Measured memory_bytes: 2176
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
	int main() {
		int a, c;
		std::cin >> a;
		std::vector<int>T(a);
		
		for (int i = 0;i < a;++i) {
			std::cin >> T[i];
		}
		std::cin >> c;
		std::vector<int>P(c), X(c);
		for (int j = 0;j < c;++j) {
			std::cin >> P[j] >> X[j];
		}
		for (int j = 0;j < c;++j) {
			int D = 0;
			for (int i = 0;i < a;++i) {
				if (i == P[j] - 1)
					D += X[j];
				else
					D += T[i];
			}
			std::cout << D << std::endl;
		}
		return 0;
	}

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

/*----------------------------- DEFINES ------------------------------*/

#define eps 1e-9
#define mod 1000000007
#define ump unordered_map // operations take less time compared to map
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define mp make_pair
#define ps(x) push(x) // for stack and queue
#define T top() //  for stack
#define FR front()// for queue
#define BA back()// for queue
#define PP pop()// for queue and stack
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define MAE max_element
#define MIE min_element
#define cnt(x) count(x)
#define lb(x) lower_bound(x) // returns an it ptng to the element >=x if no such returns end
#define ub(x) upper_bound(x) // returns an it ptng to the element >x if no such returns end
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define reps(i,x,y,k) for(int i=x;i<y;i+=k)
#define sper(i,x,y,k) for(int i=x;i>y;i-=k) 
#define all(x) ((x.B),(x.E))
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x) // easy method to iterate through a ds
#define sq(a) (a)*(a)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)// compute fib(n) in O(1)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}// fast i/o
#define dig(n) (int)(log10(n)+1) // num of digits
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define f(x) find(x)
#define set(x,k) memset(x,k,sizeof x)

/*------------------------------ TYPEDEFS-----------------------------*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef ump<int,int> umpii;

/*-----------------------------START FROM HERE -----------------------*/

int main(){
	FIO
	
	int n;cin>>n;
  	map<int,int> m;
  	int a[n];rep(i,0,n){cin>>a[i];m[a[i]]++;}
  	if(!(n%2)){
      	ll ans=1;
      	int c=0;
      	for(int i=1;i<n;i+=2){
        	if(m[i]!=2){cout<<0;return 0;}
          	else c++;
        }
      	rep(i,0,c)ans=(ans%mod*2%mod)%mod;
      	cout<<ans;
    }
  	else{
      	ll ans=1;
      	int c=0;
      	for(int i=0;i<n;i+=2){
          	if(i==0){
              	if(m[i]==1);
              	else {cout<<0;return 0;}
            }
        	else if(m[i]!=2){cout<<0;return 0;}
          	else c++;
        }
      	rep(i,0,c)ans=(ans%mod*2%mod)%mod;
      	cout<<ans;
    }
    return 0;
}


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

using namespace std;

using button_t = std::pair<int, int>;

int64_t solve(const std::vector<button_t>& buttons) {
  int64_t ret = 0;
  for (auto itr = buttons.crbegin(); itr != buttons.crend(); itr++) {
    const auto& button = *itr;
    ret +=
        (button.second - (button.first + ret) % button.second) % button.second;
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<button_t> buttons(n);
  for (auto& button : buttons) {
    std::cin >> button.first >> button.second;
  }
  std::cout << solve(buttons) << std::endl;
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<long> D,T;
  for(int i=0;i<N;i++){
    long d;
    cin>>d;
    D.push_back(d);
  }
  sort(D.begin(),D.end());

  int M;
  cin>>M;
  for(int i=0;i<M;i++){
    long t;
    cin>>t;
    T.push_back(t);
  }
  sort(T.begin(),T.end());
  int k=0;
  for(int i=0;i<T.size();i++){
    bool jdg=false;
    while(k<D.size()){
      if(T[i]==D[k]){
        jdg=true;
        k+=1;
        break;
      }
      k+=1;
    }
    if(!jdg){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B,val;
	cin>>A;
	cin>>B;
	if(A>=B){
		val=A;
		A--;
		if(A>=B){
			val=val+A;
			cout<<val;
			return 0;
		}
		else{
			val=val+B;
			cout<<val;
			return 0;
		}
	}
	else{
		val=B;
		B--;
		if(A>=B){
			val=val+A;
			cout<<val;
			return 0;
		}
		else{
			val=val+B;
			cout<<val;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool vis[104];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k;
	cin>>n>>k;
	memset(vis, 0, sizeof vis);
	for(int i=0;i<k;i++){
		int d;
		cin>>d;
		for(int j=0;j<d;j++){
			int x;
			cin>>x;
			vis[x]=true;
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]) cnt++;
	}
	cout<<cnt;
}

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

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

    int res = 0;
    if(N<10){
        res = N;
    }else if(N<100){
        res = 9;
    }else if(N<1000){
        res += 9;
        res += N-100+1;
    }else if(N<10000){
        res = 9 + 900;
    }else if(N<100000){
        res += 9 + 900;
        res += N-10000+1;
    }else{
        res += 9 + 900 + 90000;
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)	   for(int i = 0; i < (n); ++i)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define SZ(a)		   ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;


int main(){
	ll N;
	cin >> N;
	ll tmp;
	tmp=N;
	int count=0;
	while(tmp>0){
		tmp=tmp/10;
		count++;
	}
	ll a;
	a=N/pow(10,count-1);
	ll b=0;
	rep(i,count-1){
		b +=  9*pow(10,i);
	}
	b += a*pow(10,count-1);
	if(b==N) cout << a+(count-1)*9;
	else cout << a-1+(count-1)*9;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
lint powerMod(lint b,lint p,lint m){ /// b^p %m
    if(!p)
        return 1%m;
    lint d=powerMod(b,p/2,m);
    if(p%2)
        return ((d*d)%m*b)%m;
    else
        return (d*d)%m;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint n,m;
    cin>>n;
    cout<<((powerMod(10,n,mod)+powerMod(8,n,mod)-2*powerMod(9,n,mod))%mod+mod)%mod;
    return 0;
}


Measured memory_bytes: 3644
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

vector<int> prime_factorize(int n) {
    vector<int> res;
    while (n % 2 == 0) {
        res.push_back(2);
        n /= 2;
    }
    for (int i=3; i*i<=n; i+=2) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

int main() {
    ll n; cin >> n;
    ll mod = 1000000007;
    if (n == 1) {
        cout << 1 << endl;
    } else {
        map<int, int> mp;
        FOR(i, 2, n) {
            for (auto e:prime_factorize(i)) {
                mp[e]++;
            }
        }
        ll res = 1;
        for (auto e:mp) {
            res *= (e.second + 1) % mod;
            res %= mod;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main()
{
  int a=0;
  int b=0;
  int ans=0;
  cin >> a;
  cin >> b;
  if (a>=b)
  {
    ans = ans + a;
    a=a-1;
  }
  else
  {
    ans = ans + b;
    b=b-1;
  }
    if (a>=b)
  {
    ans = ans + a;
    a=a-1;
  }
  else
  {
    ans = ans + b;
    b=b-1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a, b;


	for (a = 1; a < 10; a++) {
		for (b = 1; b < 10; b++) {
			printf("%dx%d=%d\n", a, b, a*b);
		}
	}
	return 0;
}



Measured memory_bytes: 2036
class FenwickTree:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(n+1)
    
    def build(self, lis):
        self.value = lis
        for i, x in enumerate(lis):
            self.add(i+1, x)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s
    
    def add(self, i, x):
        while i <= self.n:
            self.bit[i] += x
            i += i & -i
    
    def get_sum(self, i, j):
        return self.sum(j) - self.sum(i)


def main():
    n, q = map(int, input().split())
    a = list(map(int, input().split()))
    
    bit = FenwickTree(n)
    bit.build(a)
    
    for i in range(q):
        query = list(map(int, input().split()))
        if query[0] == 0:
            bit.add(query[1]+1, query[2])
        else:
            print(bit.get_sum(query[1], query[2]))
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 132564
N,M = gets.split.map &:to_i
as = M.times.map {gets.split.map(&:to_i)}
cnt=0
(2..N).to_a.permutation(N-1) do |p|
  if N>=3
    cnt+=1 if as.include?([1,p[0]]) && (0..N-3).to_a.map{|i|as.include?([p[i],p[i+1]].sort)}.inject(:&)
  else
    cnt+=1
  end
end
puts cnt


Measured memory_bytes: 1916
h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
def check(x,y):
  if s[x][y] == '.':
    return 1
  else:
    return 0
def check_ans(i,j):
  if s[i][j] == '.':
    pass
  else:
    cnt = 0
    cnt2 = 0
    if i - 1 >= 0:
      cnt += check(i-1,j)
      cnt2 += 1
    if i + 1 <= h-1:
      cnt += check(i+1,j)
      cnt2 += 1
    if j - 1 >= 0:
      cnt += check(i,j-1)
      cnt2 += 1
    if j + 1 <= w-1:
      cnt += check(i,j+1)
      cnt2 += 1
    if cnt == cnt2:
      print('No')
      exit()
    return 0

for i in range(h):
  for j in range(w):
    if check_ans(i,j) == 0:
      pass
print('Yes')

Measured memory_bytes: 3064
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#include <math.h>
#include <bits/stdc++.h>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	int M;
	cin >> M;
	cout << 48-M << endl;
}


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

int main(){
    string N;
    bool flag = false;
    cin >> N;
    for(int i=0; i<3; i++){
        if(N.at(i)=='7'){
            flag = true;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


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

int main(){
	int N;
	cin >> N;
	vector<pair<int,int>> A(N);
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		A[i]=make_pair(a,i);
	}
	sort(A.begin(),A.end());
	int c=0;
	for(int i=0;i<N;i++){
		if(A[i].second%2!=i%2)c++;
	}
	cout << c/2 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(){
string a[3];
cin >> a[0] >> a[1] >> a[2];
char b = a[0].back();
char c = a[1].front();
char d = a[1].back();
char e = a[2].front();
if (b==c&&d==e){
cout << "YES";
}else{
cout << "NO";
}
return 0;
}

Measured memory_bytes: 256
H, N = map(int, input().split())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    
A, B = zip(*sorted(zip(A, B)))

dp = [[0] * (10000 + 1)] * (N + 1)

for dmg in range(1, 10000 + 1):
    dp[1][dmg] = -(-dmg // A[0]) * B[0]

for index in range(1, N + 1):
    a, b = A[index-1], B[index-1]
    for dmg in range(1, 10000 + 1):
        ahead = dp[index-1][dmg] #前回
        if dmg - a < 0:
            only = -(-dmg // a) * b
        else:
            only = dp[index][dmg - a] + b #自分だけ
        dp[index][dmg] = min(ahead, only)
print(min(dp[N][H:]))

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

int main() {
  int n; cin >> n;
  vector<vector<ll>> dp(n, vector<ll> (n));
  vector<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i], dp[i][i] = a[i];
  for (int i = 1; i < n; i++) {
    for (int j = 0; j+i < n; j++) 
      dp[j][i+j] = max(a[j] - dp[j+1][i+j], a[i+j] - dp[j][i+j-1]);
  }
  cout << dp[0][n-1];
  return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL; 
typedef long double dd; 
#define endl "\n"
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
//LL dp[2000001];
LL mod=1e9+7;
bool vis[100000];
using namespace std;
bool isPrime(LL n) {
  LL j; 
  for( j=2;j<=sqrt(n);j++){
    if(n%j==0){
      break;  
    } 
  }
  if(j>sqrt(n)){
    return 1; 
  }
  else{
    return 0; }
}
LL modexpo(LL a, LL b) {
  LL ans=1;
  a=a%mod;
  while(b>0){
    if((b&1)==1){
      ans=((ans%mod)*(a%mod))%mod;
    }
    b=b>>1;
    a=((a%mod)*(a%mod))%mod;
  }
  return ans; 
}
LL invmod(LL n){
  return modexpo(n,mod-2);
}

LL comb(LL n,LL r){
  if(r==0){
    return 1;
  }
  LL fact[n+1];
  fact[0] = 1; 
    for (LL i = 1; i <= n; i++){
       fact[i] = (fact[i - 1] * i) %mod;}
    return (fact[n] * invmod(fact[r]) % mod * invmod(fact[n - r]) % mod) %mod; 
}
LL gcd(LL a, LL b) {
  if (a == 0){
       return b;
       }  
    return gcd(b % a, a);  
}
LL lcm(LL a, LL b) {
  return (a*b)/gcd(a,b);
}
void dfs(LL i,vector<LL>adj[],bool visited[]){
  visited[i]=1;
  for(auto j:adj[i]){
    if(visited[j]==0){
      dfs(j,adj,visited);
    }
  }
}
void solve(LL k){
LL n, m; 
cin>>n>>m; 
vector<LL>adj[n+1];
bool visited[n+1];
memset(visited,0,sizeof(visited));
while(m--){
  LL a, b;
  cin>>a>>b; 
  adj[a].push_back(b);
  adj[b].push_back(a);
}
LL c=0;
for(LL i=1;i<=n; i++){
  if(visited[i]==0){
    c++;
    dfs(i,adj,visited);
  }
}
cout<<c-1<<endl; 
}
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
 LL t=1;
//cin>>t;
 LL k=1;
while(k<=t){
   solve(k);
  k++;
  }
   return 0;
   }

Measured memory_bytes: 10808
import heapq

def main():
  n = int(input())
  abs = [tuple(map(int, input().split())) for _ in range(n)]

  pq = []

  for ab in abs:
    a,b = ab[0],ab[1]
    heapq.heappush(pq, tuple([b,a]))

  dl = 0
  tc = 0

  ans = "Yes"

  for i in range(n):
    ba = heapq.heappop(pq)
    dl = ba[0]
    tc += ba[1]
    if dl < tc:
      ans = "No"
      break
  print(ans)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 43100
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
		
  		int[] h=new int[n];
		for(int c=0;c<n;c++){
    		h[c]=sc.nextInt();
    	}
  		int[] c=new int[n];
  		int[] a=new int[m];
  		int[] b=new int[m];
  		for(int d=0;d<m;d++){
    		a[d]=sc.nextInt();
          	b[d]=sc.nextInt();
          if(h[a[d]-1]<h[b[d]-1]){
          c[a[d]-1]++;
          }else if(h[a[d]-1]==h[b[d]-1]){
           c[a[d]-1]++;
           c[b[d]-1]++;
          }else{
          c[b[d]-1]++;
          }
    	}
  	int ans=0;
    for(int e=0;e<n;e++){
    if(c[e]==0){
    ans++;
    }
    }
 	

    	System.out.println(ans);
    }
}

Measured memory_bytes: 61420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];

	int ans = h[0];
	for (int i = 1; i < n; i++) {
		if (h[i - 1] < h[i]) {
			ans += h[i] - h[i - 1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
        var line = ReadLongs();
        var n = line[0];
        var x = line[1];
        long[] xs = ReadLongs();
        //WriteArr(xs);
        long[] wa = new long[n];
        wa[0]=xs[n-1];
        for(long i=1; i<n; i++){
            wa[i]=wa[i-1]+xs[n-i-1];
        }        
        //WriteArr(wa);
        long r = long.MaxValue;
        for(long k=1; k<=n; k++){
            long s = 0;
            bool f = false;
            for(long j=1; j<=(n+k-1)/k; j++){
                f=true;
                if(j*k>n){
                    s += Energy(j,wa[n-1]-((j==1)? 0: wa[k*(j-1)-1]));
                }else{
                    s += Energy(j,wa[k*j-1]-((j==1)? 0: wa[k*(j-1)-1]));
                }
                if(s>r){
                    f=false;
                    break;
                }
            }
            if(!f)continue;
            s += (n+k)*x;
            r = Min(s,r);
        }
        Writeln(r);
    }
    
    static long Energy(long i, long x){
        return ((i==1)? 5*x: (2*i+1)*x);
    }
  
    static int Max(params int[] args){
        var m = args[0];
        for(int i=1; i<args.Length; i++){
            m = (m>args[i])? m: args[i];
        }
        return m;
    }
    static long Max(params long[] args){
        var m = args[0];
        for(int i=1; i<args.Length; i++){
            m = (m>args[i])? m: args[i];
        }
        return m;
    }
    static int Min(params int[] args){
        var m = args[0];
        for(int i=1; i<args.Length; i++){
            m = (m<args[i])? m: args[i];
        }
        return m;
    }
    static long Min(params long[] args){
        var m = args[0];
        for(int i=1; i<args.Length; i++){
            m = (m<args[i])? m: args[i];
        }
        return m;
    }
    static string[] ReadStrs(char delimiter = ' '){
        return System.Console.ReadLine().Split(delimiter);
    }
    static long[] ReadLongs(char delimiter = ' '){
        var line = ReadStrs(delimiter);
        var r = new long[line.Length];
        for(int i=0; i<line.Length; i++){
            r[i] = long.Parse(line[i]);
        }
        return r;
    }
    static void Writeln<T>(T x){
        System.Console.WriteLine(x);
    }
    static void WriteParms(params string[] args){
        WriteArr(args);
    }
    static void WriteParms(params int[] args){
        WriteArr(args);
    }
    static void WriteParms(params long[] args){
        WriteArr(args);
    }
    static void WriteArr<T>(T[] x, string delimiter = " "){
        for(int i=0; i<x.Length-1; i++){
            System.Console.Write(x[i]+delimiter);
        }
        System.Console.WriteLine(x[x.Length-1]);
    }
}


Measured memory_bytes: 34524
#include <iostream>
using namespace std;
int main(){
	int n,k,sum,max,a,i;
	int *data;
	while(cin>>n>>k){
		if(n==0 && k==0){break;}
		data=new int[n];
		sum=0;
		for(i=0;i<k;i++){
			cin>>data[i];
			sum+=data[i];
		}
		max=0;
		for(i=k;i<n;i++){
			cin>>data[i];
			sum-=data[i-k];
			sum+=data[i];
			if(sum>max){
				max=sum;
			}
		}
		cout<<max<<endl;
	}
	return 0;
}

Measured memory_bytes: 1580
def main():
    S = input()
    # 0から始まる文字列
    s1 = list(map(lambda x: str(x % 2), range(len(S))))
    ans1 = 0
    ans2 = 0
    for i, s in enumerate(S):
        if s1[i] != s:
            ans1 += 1
        else:
            ans2 += 1
    print(min([ans1, ans2]))


if __name__ == "__main__":
    main()


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

typedef struct{
	string s;
	int dot;
}data;

int n;
string s;
data d;
vector<data> vec;

int dotcount(string s){
	int count = 0;
	for(int i = 0;i < s.size();i++){
		if(s[i] != '.')break;
		count++;
	}
	return count;
}

void check(int dot,int bgn,int ed){
	bool ccount = true;
	for(int i = bgn + 1;i < ed;i++){
		if(vec[i].dot == dot){
			for(int j = bgn + 1;j < i;j++){
				vec[j].s[dot-1] = '|';
			}
			check(dot+1,bgn + 1,i);
			check(dot,i,ed);
			ccount = false;
			break;
		}
	}
	if(ccount && bgn + 1 < ed)check(dot+1,bgn+1,ed);
}

int main(){
	while(1){
		cin >> n;
		if(n == 0)break;
		vec.clear();
		cin >> s;
		cout << s << endl;
		for(int i = 1;i < n;i++){
			cin >> d.s;
			d.dot = dotcount(d.s);
			vec.push_back(d);
		}

		check(1,0,vec.size());

		for(int i = 0;i < vec.size();i++){
			vec[i].s[vec[i].dot-1] = '+';
		}

		for(int i = 0;i < vec.size();i++){
			for(int j = 0;j < vec[i].dot;j++){
				if(vec[i].s[j] == '.'){
					vec[i].s[j] = ' ';
				}
			}
		}

		for(int i = 0;i < vec.size();i++){
			cout << vec[i].s << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
  int n;
  string s,a,b;
  cin >> n >> s;
  if(n%2 != 0){
    cout << "No" << endl;
    return 0;
  }
  a = s.substr(0,n/2);
  b = s.substr(n/2);
  if(a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

bool func(ll a , ll b){
    return abs(a) < abs(b);
}

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

    ll N , K ;
    cin >> N >> K ;
    vector<ll> a ;
    rep(i, N){
        a.pb(K + (i));
    }
    sort(all(a), func);

    ll ans = 0;
    rep(i, a.size()){
        if(i == 0) continue;
        ans += a[i] ;
    }
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
ans = [1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717,
       1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]
K = int(input())
print(ans[K-1])


Measured memory_bytes: 9304
// Problem : B - Substring
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	string s,t;
	cin>>s>>t;
	int mn=sz(s);
	//cout<<sz(s)-sz(t)<<nl;
	loop(i,sz(s)-sz(t)+1)
	{
		int changes=0;
		l00p(j,i,i+sz(t))
		{
			if(s[j]!=t[j-i])
			changes++;
			//cout<<s[j]<<t[j-i]<<" ";
		}
		//cout<<nl;
		ckmin(mn,changes);
	}
	cout<<mn;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3644
#!/usr/bin/env python3

from functools import reduce


def main():
    N, M = [int(x) for x in input().split()]
    A = [[int(x) for x in input().split()[1:]] for _ in range(N)]
    print(len(reduce(lambda a, b: a & b, map(lambda a: set(a), A))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<stdio.h>

int main(void){
  int d=3,a[6],i=0,j,cnt=0;
  while(d>0){
    scanf("%d %d",&a[i],&a[i+1]);
    i+=2;
    d--;
  }
  for(i=0;i<6;i++){
    for(j=0;j<6;j++){
      if(a[i]==a[j]) cnt++;
    }
  }
  //for(i=0;i<6;i++) printf("%d ",a[i]);
  if(cnt==10) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18
int INF = 1 << 30;



int main(void){
    int N;
    cin >> N;
    vector<int> a(N),b(N),c(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
        cin >> b.at(i);
        cin >> c.at(i);
    }
    
    int dp[N+1][3];//i日めjをした
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    for(int i = 1; i <= N; i++){
        dp[i][0] = max(dp[i-1][1] + a.at(i-1), dp[i-1][2] + a.at(i-1));
        dp[i][1] = max(dp[i-1][0] + b.at(i-1), dp[i-1][2] + b.at(i-1));
        dp[i][2] = max(dp[i-1][0] + c.at(i-1), dp[i-1][1] + c.at(i-1));
    }
    
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}


Measured memory_bytes: 2560
#include <stdio.h>

const char *jinkoki[] = {
    "", "Man", "Oku", "Cho", "Kei",
    "Gai", "Jo", "Jou", "Ko", "Kan",
    "Sei", "Sai", "Gok", "Ggs", "Asg",
    "Nyt", "Fks", "Mts",
};

int main(void)
{
    int m, n;

    while (scanf("%d %d", &m, &n), m){
        int digit[32] = {0};
        int i, j;

        digit[0] = 1;
        for (i = 0; i < n; i++){
            int tmp[32] = {0};

            for (j = 0; j < 18; j++){
                tmp[j] += digit[j] * m;
                tmp[j + 1] += tmp[j] / 10000;
                tmp[j] %= 10000;
            }
            for (j = 0; j < 18; j++) digit[j] = tmp[j];
        }
        for (j = 18; digit[j] == 0; j--);
        for (; j >= 0; j--){
            if (digit[j] == 0) continue;
            printf("%d%s", digit[j], jinkoki[j]);
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, l, r, sa, ans = 0;

    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> l >> r;
        sa = r - l;
        ans += (sa+1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    for(int i=1; i<=5; i++){
        int a;
        cin >> a;
        if(a==0){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3584
/* ex_4-3. nknm */

#include <stdio.h>
#include <math.h>

//関数を宣言
double length(int height_w, int height_e);

int main(void){

    int height_w, height_e, ans;
    scanf("%d%d", &height_w, &height_e);

    //関数の計算結果を出力
    ans = length(height_w, height_e);
    printf("%d\n", ans);
    
    return 0;
}

double length(int height_w, int height_e){

    //高低差より高いほうの塔の高さを求め見えてる部分を引く
    int dif,result;
    dif = height_e - height_w;
    result = (1 + dif) * dif / 2 - height_e;

    return result;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int n,a[2000000];
	int map[2000000]={0};
	int i,j;
	int h,flg,tmp;
	int sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	h=n;flg=1;
	while(h>1||flg){
		if(h>1) h=h/1.3;
		if(h==10||h==9) h=11;
		flg=0;
		for(i=0;i<n-h;i++){
			if(a[i]>a[i+h]){
				tmp=a[i];
				a[i]=a[i+h];
				a[i+h]=tmp;
				flg=1;
			}
		}
	}
	for(i=0;i<n;i++){
		if(a[i]!=a[i+1]&&map[a[i]]==0) sum++;
		if(map[a[i]]==0){
			for(j=a[i];j<2000000;j+=a[i]){
				map[j]=1;
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}


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

int main() {

    int uMax, vMax;
    cin >> uMax >> vMax;
    vector<vector<bool>> isWhite(uMax);
    for (int u = 0; u < uMax; u++) {
        string s;
        cin >> s;
        isWhite[u] = vector<bool>(vMax);
        for (int v = 0; v < vMax; v++) {
            isWhite[u][v] = (s[v] == '.');
        }
    }
    vector<vector<int>> minOperation(uMax);
    for (int u = 0; u < uMax; u++) minOperation[u] = vector<int>(vMax);
    minOperation[0][0] = ((isWhite[0][0]) ? 0 : 1);
    for (int indexSum = 1; indexSum < uMax + vMax - 1; indexSum++) {
        for (int u = 0; u < uMax; u++) {
            int v = indexSum - u;
            if (v < 0 || v >= vMax) continue;
            int minOpe = 100000000;
            // 上からくる場合の操作最小を求める。
            if (u != 0) {
                int ope = minOperation[u - 1][v];
                if (isWhite[u - 1][v] && !isWhite[u][v]) ope++;
                minOpe = ope;
            }
            // 左からくる場合の最小操作を求める。
            if (v != 0) {
                int ope = minOperation[u][v - 1];
                if (isWhite[u][v - 1] && !isWhite[u][v]) ope++;
                minOpe = std::min(minOpe, ope);
            }
            minOperation[u][v] = minOpe;
        }
    }

    cout << minOperation[uMax - 1][vMax - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int sum(int n) {
  int ans = 0;
  while(n > 0) {
    ans += n % 10;
    n /= 10;
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  int mn = 1e9;
  rep(i, 1, N) {
    int res = sum(i) + sum(N - i);
    mn = min(mn, res);
  }
  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main() {
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    if(a==b){
        cout << "YES" << "\n";
        return 0;
    }else{
        if(abs(a-b)<=t*(v-w)){
            cout << "YES" << "\n";
            return 0;
        }else{
            cout << "NO" << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
max1=0;max2=0
count=0
for i in range(n-3):
  if a[i]==a[i+1]:
    max1=a[i]
    a[i+1]=0
    count=i+1
    break
if count==0:
  print(0)
  exit()
for j in range(count,n-1):
  if a[j]==a[j+1]:
    max2=a[j]
    break
print(max1*max2)

Measured memory_bytes: 14244