akhauriyash/Code-Regression huggingface dataset:
N,K,Q = map(int,input().split())

#n人にｋ点を配った情報を作成
point = [K] * N

#各クイズごとに正解者に+1点を与える
for i in range(Q):
    score = int(input())
    score = score -1
    point[score] += 1

#クイズが終わった後の得点を調べて結果を出力していく
for i in range(N):
    if point[i] <= Q:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 11748
#include <bits/stdc++.h>
using namespace std; 
#define rep(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int INF = 1<<29;
const int MOD=1073741824;
#define pp pair<ll,ll>
#define ppi pair<int,int>
typedef long long int ll;
bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
////////////////////////////////////////////////////////////////////

int main(){
    int tc=1;
    // cin>>tc;
    while(tc--){
        ll n,k;
        cin>>n>>k;
        ll f[n];
        ll a[n];
        ll mult=1;
        rep(i,n){
            cin>>a[i];
            f[i]=a[i];
        }
        for(ll i=k;i<n;i++){
            if(a[i]>a[i-k])cout<<"Yes";
            else cout<<"No";
            cout<<"\n";
        }
    }
}

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

int main()
{
    std::ios_base::sync_with_stdio (false);
    int n;
    cin >> n;
    int pre_previous_height, previous_height, height;
    cin >> pre_previous_height;
    if (n == 1){
        cout << 0;
        return 0;
    }
    
    cin >> previous_height;
    if (n == 2){
        cout << abs(previous_height - pre_previous_height);
        return 0;
    }
    int pre_previous_cost, previous_cost, cost;
    pre_previous_cost = 0;
    previous_cost = abs(previous_height - pre_previous_height);
    for (int i = 3; i<= n; i++){
        cin >> height;
        cost = min(abs(pre_previous_height - height) + pre_previous_cost,
        abs(previous_height - height) + previous_cost);
        pre_previous_cost = previous_cost;
        previous_cost = cost;
        pre_previous_height = previous_height;
        previous_height = height;
    }
    cout << cost;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int f(int check[][3]) {
	if (check[0][0] && check[1][1] && check[2][2]) return 1;
	if (check[0][2] && check[1][1] && check[2][0]) return 1;
	for (int i = 0; i <= 2; i++) {
		int flag = 1;
		for (int j = 0; j <= 2; j++) {
			if (check[i][j] == 0) flag = 0;
		}
		if (flag) return 1;
	}
	for (int i = 0; i <= 2; i++) {
		int flag = 1;
		for (int j = 0; j <= 2; j++) {
			if (check[j][i] == 0) flag = 0;
		}
		if (flag) return 1;
	}
	return 0;
}

int main(void) {
	int data[3][3];
	int check[3][3] = { 0, };
	for (int i = 0; i <= 2; i++) {
		for (int j = 0; j <= 2; j++) {
			scanf("%d", &data[i][j]);
		}
	}
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int t;
		scanf("%d", &t);
		for (int j = 0; j <= 2; j++) {
			for (int k = 0; k <= 2; k++) {
				if (data[j][k] == t) {
					check[j][k] = 1;
					if (f(check)) {
						printf("Yes");
						return 0;
					}
				}
			}
		}
	}
	printf("No");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int lcm(int a, int b) {
    int d = __gcd(a, b);
    return a / d * (b / d) * d;
}

signed main() {
    int n;
    cin >> n;
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }
    int l = 1LL;
    for (int i = 0; i < n; i++) {
        l = lcm(l, t[i]);
    }
    cout << l << "\n";
}

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

int main()
{
    string s,t;
    cin >> s >> t;
    int len = s.size();
    int ans = 0;
    for (int i = 0; i < len; i++)
    {
        if(s[i] != t[i])ans ++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
int StringCount( int x ){
/*  int Sum = 1;
  if ( x == 1 || x == 0 ){
    return Sum;
  }
  for ( int i = 1; i < x; i++ )
    Sum += StringCount( i );
  return Sum; */
  if ( x == 0 || x == 1 ){
    return 1;
  }
  else
    return pow( 2, x - 1 );
}
 
int main() {
  string S;
  long SumEq = 0;
  cin >> S;
  int N = S.size();
  int RightS, LeftS;

  for ( int i = 0; i < N; i++ ){
    for ( int j = 1; j <= N - i; j++ ){
      RightS = N - i - j;
      // R + j + L = N
      LeftS = N - RightS - j;
      //cout << atol(S.substr(i,j).c_str()) << " " << LeftS << " " << RightS << endl;
      SumEq += atol(S.substr(i,j).c_str()) * StringCount( RightS ) * StringCount( LeftS ) ;
      //cout << SumEq << endl;
    }
  }
  cout << SumEq << endl;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int N;
    cin >> N;
    vi t;
    rep(i,N) {
        int a;
        cin >> a;
        t.push_back(a);
    }

    int M;
    cin >> M;
    rep(i, M) {
        int p, x;
        cin >> p >> x;
        vi tmp = t;
        tmp[p-1] = x;
        P(accumulate(ALL(tmp), 0));
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[10005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){cin>>a[i];}
    bool b=0;
    for(int i=0;i<n;i++){
        if(a[i]%2==0){
            if(a[i]%3!=0){
                    if(a[i]%5!=0){b=1;}
            }
        }
    }
    if(b==0){cout<<"APPROVED";}
    else {cout<<"DENIED";}
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int l;
  cin>>l;
  cout<<fixed<<setprecision(12)<<(double)l*l*l/27<<endl;
}

Measured memory_bytes: 256
uses math;
var
	ans,n,Ma,Mb,i,j,a,b,c,x,mp,mm:Longint;
	p,m:array[0..300]of Longint;
begin
	read(n,Ma,Mb);
	ans:=10000;
	for i:=1 to 300 do begin
		p[i]:=ans;
		m[i]:=ans;
	end;
	for i:=1 to n do begin
		read(a,b,c);
		x:=Ma*b-Mb*a;
		if x>0 then begin
			for j:=mp downto 0 do p[j+x]:=min(p[j+x],p[j]+c);
			mp:=min(mp+x,300);
		end else if x<0 then begin
			for j:=mm downto 0 do m[j-x]:=min(m[j-x],m[j]+c);
			mm:=min(mm-x,300);
		end else ans:=min(ans,c);
	end;
	for i:=1 to 200 do ans:=min(ans,p[i]+m[i]);
	if ans<10000 then writeln(ans)else writeln(-1);
end.

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

ll MOD=1000000007;

using namespace std;

int main()
{
    ll n, k, ans=0;
    cin >> n >> k;
    ll dp[200002];
    dp[0]=0;
    for(ll i=1; i<=200001; i++)
        dp[i]=dp[i-1]+i;
    for(ll i=k; i<=n; i++){
        ll mi=dp[i-1];
        ll mx=dp[n]-dp[n-i];
        ans=(ans+(mx-mi+1))%MOD;
    }
    ans+=(ll)1;
    cout << ans%MOD << endl;
	return 0;
}


Measured memory_bytes: 5176
#include <stdio.h>
#include <iostream>
#include <string>
int main(void){
        int n,m;
        std::string s;
        long long int ans=0;
        std::cin >> n >> m;
        for(int i=n;i<=m;i++){
                s = std::to_string(i);
                if(s[0] == s[4] && s[1] == s[3]){
                        ans++;
                }
        }
        printf("%d",ans);
        return 0;
}

Measured memory_bytes: 256
var print = console.log;

function read_input(_input) {
    var lines = _input.split("\n");
    return function () {
        return lines.shift();
    };
}

String.prototype.dot = function dot(x) {
    var res = "";
    for (var i = 0; i < x; i++) {
        res += this.toString();
    }
    return res;
};

function IL(line, min1Flg) {
    var s = line.split(' ');
    var offset = min1Flg ? -1 : 0;
    var res = [];
    for (var i = 0; i < s.length; i++) {
        res.push(parseInt(s[i]));
    }
    return res;
}

function range(i, n) {
    var res = [];
    for (; i < n; i++) {
        res.push(i);
    }
    return res;
}

function IMAX(x, y) {
    return x > y ? x : y;
}

function IMIN(x, y) {
    return x < y ? x : y;
}

function item_getter_key(x) {
    return function (a, b) {
        if (a[x] < b[x]) return -1;
        else if (a[x] > b[x]) return 1;
        return 0;
    };
}

var Counter = function Counter() {
    this.dic = {};
    var that = this;
    this.add = function (key, val) {
        if (that.dic.hasOwnProperty(key)) {
            that.dic[key] += val;
        } else {
            that.dic[key] = val;
        }
    };
    this.get = function (key) {
        if (that.dic.hasOwnProperty(key)) {
            return that.dic[key];
        }
        return 0;
    };


    // this.values = function(){
    //     var keys = Object.keys(that.dic);
    //     var res = [];
    //     for(var i =0;i<keys.length;i++){
    //         res.push([])

    //     }
    //}
};

/**
 * @return {number}
 */
Array.prototype.SUM = function SUM() {
    var sum = 0;
    this.forEach(function (elm) {
        sum += elm;
    });
    return sum;
};

Array.prototype.Print = function Print(split) {
    if (split === undefined) {
        split = " ";
    }
    console.log(this.join(split));
};


/*

(((???????????)??? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

*/


// input?????\??????????????¨????????\???
function Main(_input) {
    var input = read_input(_input);
    var N = parseInt(input());
    while (N !== 0) {
        var keys =[];
        var counter = new Counter();
        for (var i = 0; i < N; i++) {
            var tmp = IL(input());
            counter.add(tmp[0], tmp[1] * tmp[2]);

            if(keys.indexOf(tmp[0])<0){
                keys.push(tmp[0]);
            }
        }
        var flg = false;
        for (var i = 0; i < keys.length; i++) {
            if (counter.get(keys[i]) >= 1000000) {
                print(keys[i]);
                flg = true;
            }
        }
        if (!flg) {
            print('NA');
        }
        N = parseInt(input());
    }
}

//*???????????\????????¨??????????????§????????????????¨??????\????????????????????????????????????Main????????????????????????
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//Main(require("fs").readFileSync("input.txt", "utf8"));

Measured memory_bytes: 18168
#include<stdio.h>
int main(void)
{
	int n, i, j, k;
	int a[50], co = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 1; i <= n; i++) {
		if (a[i - 1] != i) {
			co++;
		}
	}
	if (co > 2) {
		printf("NO\n");
	}
	else {
		printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 128
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n = I()
a = LI()
d = [0,0]
for i in a:
    if i%2:
        d[0] += 1
    if i%4 == 0:
        d[1] += 1
if n % 2:
    d[0] -= 1
d[0] -= d[1]
if d[0] <= 0:
    print("Yes")
else:
    print("No")
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 59248
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <string.h>
#include <math.h>

using namespace std;

int main(){
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	
	double ans = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
	
	printf("%.8lf\n", ans);
	
	
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    //解説
    ll n;
    cin >> n;
    cout << (n*(n-1))/2 << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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;

int main() {
  string s;
  cin >> s;
  vector<int> v(26, 0);
  rep(i, s.size()) {
    v[s.at(i) - 'a']++;
  }
  bool ok = true;
  rep(i, v.size()) {
    if (v[i] % 2 != 0) {
      ok = false;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using ulint = unsigned long long;
using lint = long long ;
using ldouble = long double;

void err(istream_iterator<string> _it) {}
template<typename T,typename... Args>
void err(istream_iterator<string> _it, T a,Args... args) {cerr<<"\e[91m"<<*_it<<" is "<<a<<"\e[39m"<<endl;err(++_it,args...);}

//#define __debug true; // c++17
const bool _debug = true;
#define cerr if(_debug)cerr
#define eb emplace_back
#define watch(args...) if(_debug){string _s = #args; replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);cerr<<"\n";istream_iterator<string> _itt(_ss);err(_itt,args);} 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string a, b;
    cin >> a >> b;
    int lenb = b.size();
    int ans = 1e6;
    for (int i = 0; i <= a.size() - b.size(); ++i) {
        int temp = 0;
        for (int j = 0; j < lenb; ++j) { if (a[i + j] != b[j]) temp++; }
        ans = min(ans, temp);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3636
/*
    ٭٭UWW٭٭OWO٭٭
    Auto-generated by VS Code's Code Snippet
    «I'm just a starter-coder»
    ▶zyck2002◀
    ٭٭UWW٭٭OWO٭٭
*/

// Includes
#include <bits/stdc++.h>
using namespace std;

#define fup(i,l,h) for (int i = l; i < h; i++)

// Debug tool, f = open input file, D = debug mode
//#define f
//#define debug

// Main function
int main()
{
    #ifdef f
    freopen("a.inp","r",stdin);
    #endif
    int n, k; cin >> n >> k;
    char *s = new char[n];
    fup(i,0,n) cin >> s[i];
    s[k - 1] += 32;
    fup(i,0,n) cout << s[i];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define f first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
typedef long long ll ;
typedef long double ld ;
typedef long long int lli;

using namespace std;
//reference: geeks
ll mult(ll a,ll b, ll p=mod){	return ((a%p)*(b%p))%p;	}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll sub(ll a, ll b, ll p=mod){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
#define INF 10000000000

int main()
{	
	ios
	int n;
	cin>>n;
	int a[n];
	int dp[n];
	for(int i=0;i<n;i++)	cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	
	for(int i=2;i<n;i++)
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	cout<<dp[n-1];
}



Measured memory_bytes: 1024
#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>;

class UnionFind {
    private:
        vector<int>par;
    public:
        UnionFind(int n) {
            for (int i = 0; i < n; i++) par.push_back(-1);
        }
        int root(int x) {
            if (par[x] < 0) return x;
            else return par[x] = root(par[x]);
        }
        bool same(int x, int y) { return root(x) == root(y);}
        void unite(int x, int y) {
            x = root(x), y = root(y);
            if (x == y) return;
            if (par[x] > par[y]) swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return;
        }
        int size(int x) { return -par[root(x)];}
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i, n) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4316
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cmath>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int now;
    int flag=1;
    for(int i=1;i<=n;i++)
    {
        cin>>now;
        if((now&1)==0){
            if(now%3==0||now%5==0)continue;
            else flag=0;
        }
    }
    if(flag)cout<<"APPROVED";
    else cout<<"DENIED";
    return 0;
}

Measured memory_bytes: 256
S=gets.chomp
T=gets.chomp
r=nil
(S.size-T.size+1).times{|i|
    f=true
    T.size.times{|j|
        next if S[i+j]=="?"
        if S[i+j]!=T[j]
            f=false
            break
        end
    }
    if f
        s=S.tr("?","a")
        s[i,T.size]=T
        #warn s
        if !r||s<r
            r=s
        end
    end
}
if r
    puts r
else
    puts "UNRESTORABLE"
end


Measured memory_bytes: 14340
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, sum, k, ans[N];

int power(int a, int b, int m = mod){a %= m; if(b < 0)b += m-1; int r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

int32_t main(){_
   
   cin >> n >> k;

   for (int i = k; i >= 1; --i)
   {
      int choose = power((k/i), n);
      ans[i] = choose;
      for (int j = 2*i; j <= k; j+=i)
      {
         ans[i] -= ans[j];
         ans[i] %= mod;
      }
   }
   
   for (int i = 1; i <= k; ++i)
   {
      sum += i * ans[i];
      sum %= mod;   
   }
      
   cout<<sum;

   return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S,T;
    cin>>S>>T;
    int x=S.size();
    int y=T.size();
    string ans="UNRESTORABLE";
    for(int i=x-y;i>=0;i--){
        string s=S.substr(i,y);
        bool z=true;
        rep(j,y){
            if(s[j]=='?') continue;
            if(s[j]!=T[j]) {
                z=false;
                break;
            }
        }
        if(z){
            string b=S.substr(0,i);
            rep(k,b.size()){
                if(b[k]=='?') cout << 'a';
                else cout << b[k];
            }
            cout << T;
            b=S.substr(i+y);
            rep(k,b.size()){
                    if(b[k]=='?') cout << 'a';
                    else cout << b[k];
                }
            cout << endl;
            return 0;
        }
    }
    cout << ans << endl;


}


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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n;
	cin >> n;
	
	if(n % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}
	
	n /= 2;
	ll ans = 0;
	//$ f(n) = (n/2)! * 2 ^ (n/2)
	
	for(ll x = 5; n / x >= 1; x *= 5) {
		ans += n / x;
	}
	
	cout << ans << endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <sstream>
using namespace std;

int v[102][102];
int dp[102][102];

int main() {
    memset(v, 1, sizeof v);
    memset(dp, 0, sizeof dp);

    int height = 0;
    string s;
    for (int i=1; ; ++i) {
        if ( ! getline(cin, s)) break;
        stringstream ss(s);
        char c;
        for (int j=1; ; ++j) {
            if (1 < j && ! (ss >> c)) break;
            ss >> v[i][j];
        }
        ++ height;
    }

    for (int i=1; i<=height; ++i) {
        for (int j=1, l=min(i,height-i+1); j<=l; ++j) {
            if (i <= height-i+1) {
                dp[i][j] = v[i][j] + max(dp[i-1][j], dp[i-1][j-1]);
            } else {
                dp[i][j] = v[i][j] + max(dp[i-1][j], dp[i-1][j+1]);
            }
        }
    }
    cout << dp[height][1] << endl;
    return 0;
}

Measured memory_bytes: 1312
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	ll n, m;
	cin >> n >> m;

	vl a(n);
	rep(i, n) cin >> a[i];

	map<ll, ll> c;
	ll sum = 0;
	c[sum]++;
	rep(i, n) {
		sum += a[i];
		c[sum % m]++;
	}

	ll res = 0;
	REP(itr, c) {
		res += itr->second * (itr->second - 1) / 2;
	}
	cout << res << endl;
}

Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int main() {
	long long int A, B, C, X, Y;
	long long int a, b, ab, min = 999999999999, sum, max;

	cin >> A >> B >> C >> X >> Y;
	
	if (X > Y) {
		max = X;
	}
	else {
		max = Y;
	}

	for (int i = 0; i <= max*2; i += 2) {
		ab = i;
		a = X - ab / 2;
		b = Y - ab / 2;
		if (a < 0) {
			a = 0;
		}
		if (b < 0) {
			b = 0;
		}
		sum = a * A + b * B + ab * C;
		if (min > sum) {
			min = sum;
		}
	}
	cout << min << endl;

	return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    
        int a = Integer.parseInt(br.readLine());
         
        out.println(a + a * a + a * a * a);
        out.close();
        
    }
}

Measured memory_bytes: 32764
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

const int MAX_V=1e5;

vector<pint> G[MAX_V];
int V;
vi color;
vector<bool> visited;

void dfs(int v,int c){
    visited[v]=true;
    if(c&1) color[v]=1;
    rep(i,G[v].size()){
        if(!visited[G[v][i].fs]){
            dfs(G[v][i].fs,c+G[v][i].sc);
        }
    }
}

signed main(){

    in(V);
    visited.resize(V,false);
    color.resize(V);
    rep(i,V-1){
        int u,v,w;
        in(u,v,w);
        u--;v--;
        G[u].pb({v,w});
        G[v].pb({u,w});
    }
    dfs(0,0);
    for(auto e:color){
        out(e);
    }

    return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    string s; cin >> s;
    vector<int> a(26,0);
    REP(i, 4) a[s[i]-65] ++;
    int ans = 0;
    REP(i,26) ans += (a[i]==2);
    cout << (ans==2 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int k, n; cin >> k >> n;
  vector<int> hoge(n);
  rep_i(i, n){
    cin >> hoge[i];
  }
  vector<int> sa(n);
  rep_i(i, n){
    if(i == n - 1){
      sa[i] = abs(k - hoge[i]) + hoge[0];
    }else{
      sa[i] = abs(hoge[i] - hoge[i + 1]);
    }
  }
  sort_v(sa);
  cout << k - sa[n - 1] << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<string> W(N);
  set<string> V;
  for(int i=0; i<N; i++){
    cin >> W.at(i);
    V.insert(W.at(i));
  }
  int Ans=1;
  if(V.size()!=N){
    Ans=0;
  }
  for(int i=0; i<N-1; i++){
    if(W.at(i).at(W.at(i).size()-1)!=W.at(i+1).at(0)){
      Ans=0;
    }
  }
  if(Ans==0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n, m;
    cin>>n>>m;
    vector<int> as(n);
    int a = 0;
    rep(i, n) {
        cin>>as[i];
        a += as[i];
    }
    int cnt = 0;
    rep(i, n) {
        if (as[i] * 4 * m >= a) cnt++;
    }
    if (cnt >= m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define R(_x, _y) (0 <= _x && _x <= M - 1 && 0 <= _y && _y <= N - 1)
#define A(a) (!(R(x + dx[a], y + dy[a]) && b[y + dy[a]][x + dx[a]]))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
ll table[2019], t2[2019];
int main() {
	string S;
	cin >> S;
	ll num, C = 0, t;
	rep(i, 0, S.size() - 1) {
		table[S[i] - '0']++;
		rep(i2, 0, 2019)t2[i2] = 0;
		rep(i2, 0, 2019) {
			t2[(i2 * 10 + S[i + 1] - '0') % 2019] += table[i2];
			//printf("%d\n", (i2 * 10 + S[i + 1] - '0') % 2019);
			if ((i2 * 10 + S[i + 1] - '0') % 2019 == 0)C += table[i2];
		}
		rep(i2, 0, 2019)table[i2] = t2[i2];
	}
	printf("%lld\n", C);
	return 0;
}

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  cin>>N;

  vector<int> p(N-1),q(N);
  for(int i=0;i<N-1;i++) cin>>p.at(i);

  q.at(0)=p.at(0);
  q.at(1)=p.at(0);
  for(int i=1;i<N-1;i++){
    if(q.at(i)>p.at(i)) q.at(i)=p.at(i);
    q.at(i+1)=p.at(i);
  }
  int sum;
  sum = accumulate(q.begin(),q.end(),0);
  cout<<sum<<endl;
}

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()  
{ 
    FAST_INP;
    int n,k;
    cin >> n >> k;
    vector<long long> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n-k;i++){
    	if(a[i]<a[i+k]) cout <<"Yes\n";
    	else cout <<"No\n";
	}
	
    return 0;
} 


Measured memory_bytes: 4772
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c;
    while(~scanf("%d %d %d",&a,&b,&c))
    {
        if(c>=a&&c<=b)
        printf("Yes\n");
        else
        printf("No\n");

    }return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	char tab[55]={0};
	char *ptr;
	int N,temp=0;
	cin>>N;
	cin>>tab;
	ptr=tab;
	while(ptr-tab<N) {
		if (strstr(ptr,"ABC")) {
			temp++;
			ptr=strstr(ptr,"ABC")+3;
		}
		else break;
	}
	cout<<temp;
	return 0;
}


Measured memory_bytes: 256
import itertools

n = int(input())
l_list = list(map(int, input().split()))
ans = 0
for l1, l2, l3 in itertools.combinations(l_list, 3):
    li = [l1, l2, l3]
    if len(set(li)) != 3:
        continue
    if max(li) < sum(li) - max(li):
        ans += 1

print(ans)

Measured memory_bytes: 9100
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define pii pair<int,int>
using namespace std;



int main() {

	string s, t;

	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    int D, X;
    cin >> D >> X;
    int n = 0;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        int d = 1;
        while (d <= D) {
            ++n;
            d += A;
        }
    }
    cout << n + X << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main()
{
	int n, m, l, i, j, k;
	cin >> n >> m >> l;

	int Anm[101][101] = {};
	int Bml[101][101] = {};
	long Cnl[101][101] = {};
	for (i = 0; i<n; i++)
	{
		for (k = 0; k<m; k++)
		{
			cin >> Anm[i][k];
		}
	}
	for (k = 0; k<m; k++)
	{
		for (j = 0; j<l; j++)
		{
			cin >> Bml[k][j];
		}
	}

	for (i = 0; i<n; i++)
	{
		for (j = 0; j<l; j++)
		{
			for (k = 0; k<m; k++)
			{
				Cnl[i][j] += Anm[i][k] * Bml[k][j];
			}
		}
	}

	for (i = 0; i<n; i++)
	{
		for (j = 0, k = 0; j<l; j++, k++)
		{
			if (k != 0){
				cout << " ";
			}
			cout << Cnl[i][j];
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1328
#include <cstdio>
int main()
{
        int a,b,c;
        while(scanf("%d",&a)!=EOF)
        {
                scanf(" %d",&b);
                c=a+b;
                int cnt,i;
                i=1;
                for(cnt=0;;cnt++)
                {       
                        if(c/i==0)break;
                        i=i*10;
                }
                printf("%d\n",cnt);
        }
         
        return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); ++i )
using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  
  priority_queue<int> price;
  rep(i,N) {
    int a;
    cin >> a;
    price.push(a);
  }
  
  rep(i,M) {
    int a = price.top(); price.pop();
    price.push( a/2 );
  }
  
  long long sum = 0;
  rep(i,N) {
    sum += price.top(); price.pop();
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 892
from collections import Counter
from functools import reduce
#import numpy as np
N = int(input())
S = [[0]] * N
for n in range(N):
    S[n] = Counter(map(ord, input()))
#S = np.array(S)
#print(S)

def get_inter(counter1, counter2):
    dic = {}
    keys = counter1.keys() & counter2.keys()
    for key in keys:
        dic[key] = min(counter1[key], counter2[key])
    return dic

ans = ''
for key, value in reduce(get_inter, S).items():
    ans += chr(key) * value
print(ans)

Measured memory_bytes: 3684
#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 FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#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()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200;

int N;
vi L;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> N;

	F0R(i, 2 * N) {
		int x;
		cin >> x;
		L.pb(x);
	}
	sort(all(L));

	int ans = 0;
	for (int i = 0; i < 2 * N; i += 2) {
		ans += L.at(i);
	}

	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char **argv)
{
    int w,h,x,y,r;

    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if ((x >= r) && (x+r <= w) &&
        (y >= r) && (y+r <= h)) {
        printf("Yes\n");
    } else printf("No\n");

    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
long long n,k,inv[200005],fac=1,po[35],ans,f[200005];
int main(){
    scanf("%lld %lld",&n,&k);
    f[0]=1;
    for(long long i=1;i<=200000;i++)f[i]=(f[i-1]*i)%MOD;
    fac=f[200000];
    po[0]=fac;
    for(int i=1;i<=30;i++)po[i]=(po[i-1]*po[i-1])%MOD;
    long long x=MOD-2LL;
    inv[200000]=1;
    for(int i=0;i<=30;i++){
        if(x%2LL)inv[200000]=(inv[200000]*po[i])%MOD;
        x/=2LL;
        if(!x)break;
    }
    for(long long i=199999;i>=0;i--)inv[i]=(inv[i+1]*(i+1))%MOD;
    for(long long i=0;i<=min(n-1,k);i++){
        long long s=1,t=1;
        s=f[n],t=f[n-1];
        s=(s*inv[i])%MOD,t=(t*inv[i])%MOD;
        s=(s*inv[n-i])%MOD,t=(t*inv[n-i-1])%MOD;
        s=(s*t)%MOD;
        ans=(ans+s)%MOD;
    }
    printf("%lld",ans);
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String pattern = sc.next();
        
        str += str;
        if(str.contains(pattern)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26276
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; 
    int l;
    cin >> n >> l;

    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
        sum += l + i - 1;
    }

    pair<long long, long long> res(1 << 28, -1);

    for (int i = 1; i <= n; ++i) {
        long long N = sum - (l + i - 1);
        // cout << i << " " << N << " " << sum << endl;
        res = min(res, make_pair(abs(N - sum), N));
    }

    cout << res.second << "\n";


    return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, n * a) << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
const int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
queue< pair<int,int> > q;
int n,m,ans,dis[1005][1005];
char s[1005][1005];
int main() {
	n=_; m=_;
	memset(dis,127,sizeof(dis));
	for( int i=1;i<=n;i++ ) scanf("%s",s[i]+1);
	for( int i=1;i<=n;i++ ) 
		for( int j=1;j<=m;j++ ) if(s[i][j]=='#') dis[i][j]=0,q.push(make_pair(i,j));
	while(!q.empty()) {
		pair<int,int> now = q.front(); q.pop();
		for( int k=0;k<4;k++ ) {
			int nx=now.first+dx[k],ny=now.second+dy[k];
			if(nx<1||nx>n||ny<1||ny>m) continue;
			if(dis[nx][ny]>dis[now.first][now.second]+1) 
				q.push(make_pair(nx,ny)),chkmin(dis[nx][ny],dis[now.first][now.second]+1);
		}
	}
	for( int i=1;i<=n;i++,putchar('\n') ) 
		for( int j=1;j<=m;j++,putchar(' ') ) chkmax(ans,dis[i][j]);
	cout<<ans;
}	

Measured memory_bytes: 14352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[m + 1] = {}, b[] = {}, c[] = {};
        vll v;
        rep(i, n){
            cin >> x;
            rep(j, x){
                cin >> y;
                a[y]++;
            }
        }
        each(i, a){
            if(i == n){
                ans++;
            }
        }
        print(ans);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int k, x;
    cin >> k >> x;
    if(500 * k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
from collections import Counter

n = int(input())
V = list(map(int, input().split()))

even = V[0::2]
odd = V[1::2]
even_counter = Counter(even).most_common(2)
odd_counter = Counter(odd).most_common(2)

# if even_max_cnt[0][0] != odd_max_cnt[0][0]:
#     ans = len(V) - even_max_cnt[0][1] - odd_max_cnt[0][1]
# else:
#     if len(even_max_cnt) == 1 or len(odd_max_cnt) == 1:
#         ans = len(V) // 2
#     else:
#         ans = len(V) - max(even_max_cnt[0][1]+odd_max_cnt[1][1],
#                            even_max_cnt[1][1]+odd_max_cnt[0][1])
#
# print(ans)

if even_counter[0][0] != odd_counter[0][0]:
    ans = len(V) - even_counter[0][1] - odd_counter[0][1]
else:
    if len(even_counter) == 1 and len(odd_counter) == 1:
        ans = len(V) // 2
    else:
        ans = len(V) - max(even_counter[0][1]+odd_counter[1][1],
                           even_counter[1][1]+odd_counter[0][1])

print(ans)

Measured memory_bytes: 15972