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

using namespace std;

typedef long long int ll;

#define mod (int ) (1e9+7)



ll gcd(ll a, ll b){
	
	if(b==0){
		return a;
	}
	
	return gcd(b, a%b);
	
}


 
 ll ncr(ll x, ll y){
 	ll ans=1;
 	
 	y=(y > x-y? x-y: y);
 	
 	for(ll i=0; i<y; i++){
 		ans=ans*(x-i);
 		ans=ans/(i+1);
 		ans=ans%mod;
 	}
 
 	
 	return ans;
 }

ll power(ll x, ll y){
    ll ans=1;
    while(y){
        if(y&1){
            ans=ans*x;
            ans=ans%mod;
        }
        
        x=x*x;
        x=x%mod;
        y=y>>1;
    }
    
    return ans;
    
}
 
void solve(){
	
  ll n,k,t; cin>>n>>k>>t;
  
  ll ans=(n+k-1)/k;
  
  ans=ans*t;
  
  cout<<ans<<"\n";

  
   return ;
	
}

int main(){
    ios_base::sync_with_stdio(0);
    
    cin.tie(0);
    
    int t=1,h=0; //cin>>t;
    
    
    // clock_t begin, end;
    
    // double time_spent;
    
    // begin = clock(); // Time taken till now.
    
    
    while(t--){
    
	  solve();
        
    }
   
   //end= clock(); // Total  Time taken till now.
   
   //time_spent= (end- begin) / CLOCKS_PER_SEC;
   
   //cout<<time_spent<<"\n";
	
	return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int N;
  string S, T;
  cin >> N >> S >> T;
  REP(i, N) {
    cout << S[i] << T[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())

DP=[[0,0] for _ in range(f+3000)]
DP[a*100][0]=a*100
DP[b*100][0]=b*100

for i in range(f+1):
    if DP[i][0]==0:continue
    for j in a,b:
        if i+j*100<=f:
            j *=100
            if DP[i][1]*100/(i+j)>=DP[i+j][1]*100/(i+j):
                DP[i+j]=[i+j,DP[i][1]]
    for j in c,d:
        if i+j<=f:
            if 100*(DP[i][1]+j)/(i+j)<=100*e/(100+e):
                if 100*(DP[i][1]+j)/(i+j)>=100*(DP[i+j][1])/(i+j):
                    DP[i+j]=[i+j,DP[i][1]+j]

ans,water=0,[a*100,0]
for x,y in DP:
    if x==0:continue
    if 100*y/x>ans:
        ans=100*y/x
        water=[x,y]
print(*water)

Measured memory_bytes: 74724
#include<stdio.h>

struct test{
    signed short mid;
    signed short fin;
    signed short re;
    unsigned char eval;
};

unsigned char evaluate(signed short mid, signed short fin, signed short re);

int main(){
    struct test test[50];
    unsigned short usW_C_i;
    unsigned short usW_C_count = 0;

    for(usW_C_i = 0;usW_C_i < 50;usW_C_i++){
        scanf("%d %d %d", &test[usW_C_i].mid, &test[usW_C_i].fin, &test[usW_C_i].re);
        if(test[usW_C_i].mid == -1 && test[usW_C_i].fin == -1 && test[usW_C_i].re == -1){
            break;
        }
        test[usW_C_i].eval = evaluate(test[usW_C_i].mid, test[usW_C_i].fin, test[usW_C_i].re);
        usW_C_count++;
    }

    for(usW_C_i = 0;usW_C_i < usW_C_count;usW_C_i++){
        printf("%c\n", test[usW_C_i].eval);
    }

    return 0;
}

unsigned char evaluate(signed short mid, signed short fin, signed short re){
    signed short ssW_D_sum;
    unsigned char ubW_D_result;

    ssW_D_sum = mid + fin;

    if(mid == -1 || fin == -1){
        ubW_D_result = 'F';
    }
    else if(ssW_D_sum >= 80){
        ubW_D_result = 'A';
    }
    else if(ssW_D_sum >= 65){
        ubW_D_result = 'B';
    }
    else if(ssW_D_sum >= 50){
        ubW_D_result = 'C';
    }
    else if(ssW_D_sum >= 30){
        if(re >= 50){
            ubW_D_result = 'C';
        }
        else{
            ubW_D_result = 'D';
        }
    }
    else{
        ubW_D_result = 'F';
    }

    return ubW_D_result;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 998244353;

void solve() {
    ll x, y;
    cin >> x >> y;
    if((y & 1) || y > 4 * x || y < 2 * x) cout << "No";
    else cout << "Yes";
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;   
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using i64 = long long;

long long *fact, *inv;

template <class T>
T pow(T x, T n, T mod) {
    T ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <class T>
T inverse(T x, T p) { return pow(x, p - 2, p); }

void init_factorial(int n, long long mod) {
    fact = new long long[n + 1];
    inv = new long long[n + 1];
    fact[0] = 1;
    for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    inv[n] = inverse(fact[n], mod);
    for (long long i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

int main() {
    constexpr i64 mod = 1000000007;
    constexpr int inf = std::numeric_limits<int>::max();
    int n, x, y;
    std::cin >> n >> x >> y;
    init_factorial(n, mod);

    std::vector<std::deque<int>> v(n);
    int min = inf, minc = -1;
    for (int i = 0; i < n; i++) {
        int c, w;
        std::cin >> c >> w;
        --c;
        v[c].push_back(w);
        if (min > w) {
            min = w;
            minc = c;
        }
    }

    for (int i = 0; i < n; i++) {
        if (v[i].empty()) continue;
        std::sort(v[i].begin(), v[i].end());
    }

    int min2 = inf;
    std::deque<int> a;
    for (int i = 0; i < n; i++) {
        if (v[i].empty() || (i != minc && v[i].front() + min > y)) continue;
        if (i == minc) continue;
        int c1 = std::upper_bound(v[i].begin() + 1, v[i].end(), x - v[i].front()) - v[i].begin();
        int c2 = std::upper_bound(v[i].begin(), v[i].end(), y - min) - v[i].begin();
        a.push_back(std::max(c1, c2));
        min2 = std::min(min2, v[i].front());
    }

    int c1 = std::upper_bound(v[minc].begin() + 1, v[minc].end(), x - v[minc].front()) - v[minc].begin();
    int c2 = minc < inf ? std::upper_bound(v[minc].begin(), v[minc].end(), y - min2) - v[minc].begin() : 0;
    a.push_back(std::max(c1, c2));

    i64 ret = fact[std::accumulate(a.begin(), a.end(), 0)];
    for (auto &e : a) ret = ret * inv[e] % mod;
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 138624
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string a,b,c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
MOD=10**9+7
p,q,n=0,1,1
for _ in range(M):
    a=int(input())
    while n<=a:
        p,q=q,p+q
        n+=1
    q=0
while n<=N:
    p,q=q,p+q
    n+=1

print(q%MOD)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
vector<int> ans;
void dfs (int m, int n) {
	if (ans.size() == n) {
		for (int i = 0; i < n; i++)
			cout << char(ans[i] + 'a');
		cout << "\n";
		return;
	}
	for (int i = 0; i <= min(m, 25); i++) {
		ans.pb(i);
		dfs(max(i + 1, m), n);
		ans.pop_back();
	}
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	dfs(0, n);	
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;

    int cnt = 0;
    rep(i, n){
        int h;
        cin >> h;
        if(h >= k) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int a,b; cin >> a >> b;
  if (a <= 9 && b <= 9) {cout << a*b << endl;}
  else {cout << "-1" << endl;}

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(){
    int A = 0;
    int B = 0;
    int X = 0;
    int temp = 0;

    scanf("%d%d%d", &A, &B, &X);

    temp = A + B;
    if ((1 > A) || (100 < A) || (1 > B) || (100 < B) || (1 > X) || (200 < X)){
        printf("NO\n");
    }
    else if ((X <= temp) && (X >= A)){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second

template <class T>
void print(vector<T>& v){
    for(T x:v) cout<<x<<" ";
    cout<<"\n";
}
void inp(vector<int>& v, int n){
    for (int i=0; i<n; ++i) scanf("%d", &v[i]);
}


void sol(){
    int n, m, bomb;
    cin>>n>>m>>bomb;
    set<pair<int, int>> ms;
    int x, y;
    vector<int> r(n+1), c(m+1);
    for (int i=0; i<bomb; ++i){
        scanf(" %d %d", &x, &y);
        r[x]++, c[y]++;
        ms.insert({x, y});
    }
    int a=0, b=0, xi=0, yi=0;
    x=0, y=0;
    vector<int> xa(n+1), xb(m+1);
    for (int i=1; i<=n; i++){
        if (r[i]>a){
            xi=0;
            xa[xi]=i;
            a=r[i];
            xi++;
        }
        else if (a==r[i]){
            xa[xi]=i;
            xi++;
        }
    }
    // a=0;
    for (int i=1; i<=m; i++){
        if (c[i]>b){
            yi=0;
            xb[yi]=i;
            b=c[i];
            yi++;
        }
        else if (b==c[i]){
            xb[yi]=i;
            yi++;
        }
    }
    int res=a+b-1;
    for (int i=0; i<xi; ++i){
        for (int j=0; j<yi; ++j){
            if (ms.find({xa[i], xb[j]})==ms.end()){
                printf("%d\n", res+1);
                return;
            }
        }
    }
    printf("%d\n", res);
    return;
}

int main() {
    // int t;
    // cin>>t;
    // t++;
    // for (int i=1; i<t; ++i){
        // cout<<"Case #"<<i<<": ";
        sol();
    // }
    return 0;
}

Measured memory_bytes: 22072
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
    int X, cnt = 1;
    long long Y;
    cin >> X >> Y;
    Y /= X;
    for(int i = 0; i < 10000; i++){
        Y /= 2;
        if(Y != 0){
            cnt += 1;
        }
        else break;
    }
    cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i;
        String T="";
        String S = scan.nextLine();
        for(i=0; i<S.length(); i++){
           T=T+"x";
        }
        System.out.println(T);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
// #define input(X) getline(cin,X)
static const int INF = 1e+9+7;
static const ll INFL = 1e+18+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  vi vec,p;
  cin >> n;
  rep(i,0,n){
    cin >> m;
    p.pb(m);
    vec.pb(m-(i+1));
  }
  sort(all(vec));
  ll ans = 0;
  rep(i,0,vec.sz)ans += abs(p[i]-(vec[vec.sz/2]+i+1));
  print(ans);
  return 0;
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

map<int,int> m;
int n;
int cnt;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>n;

for(int i=0; i<n; i++){
	int a;
	cin>>a;
	if(m[a]==1){
		m[a]=0;
	}else{
		m[a]=1;
	}
}

map<int,int>::iterator it;
  for(it = m.begin(); it!=m.end(); it++){
    int n1=it->first;
    int n2=it->second;
    if(n2==1){
    	cnt++;
    }
}

cout<<cnt<<endl;

}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<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;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll a, b;
    cin >> a >> b;
    rep(i,3){
        if(i == a-1 || i == b-1){
            continue;
        }else{
            cout << i+1 << endl;
        }
    }
    
}


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

using namespace std;

const int N = 200000;

string ss[N];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)
		cin >> ss[i];
	sort(ss, ss + n);
	int ans = 1;
	for (int i = 1; i < n; i++)
		if (ss[i] != ss[i - 1])
			ans++;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 9864
S = list(input())

N = len(S)
index = 0
count = 0
while index < len(S) - 1:
    if S[index] != S[index + 1]:
        del S[index:index + 2]
        index = max(0, index - 1)
        count += 1
    else:
        index += 1

print(2 * count)

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

#define fastIO      ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define asc(s)      sort(s.begin(), s.end())
#define des(s)      sort(s.rbegin(), s.rend())
#define pb(x)       push_back(x)
#define mp(x, y)    make_pair(x, y)
#define all(v)      v.begin(), v.end()
#define rev(v)      reverse(v.begin(), v.end())
#define lower(s)    transform(s.begin(), s.end(), s.begin(), ::tolower);
#define upper(s)    transform(s.begin(), s.end(), s.begin(), ::toupper);
#define MOD         1000000007
#define PI          3.14159265358979

typedef long long ll;

template <typename TH>
void _dbg(const char *sdbg, TH h) { cerr << sdbg << "=" << h << "\n"; }
template <typename TH, typename... TA>
void _dbg(const char *sdbg, TH h, TA... t)
{
    while (*sdbg != ',')
    {
        cerr << *sdbg++;
    }
    cerr << "=" << h << ",";
    _dbg(sdbg + 1, t...);
}

#ifndef ONLINE_JUDGE
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug
#endif

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template <class T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

vector<string> split(string s)
{
    istringstream buf(s);
    istream_iterator<string> beg(buf), end;
    vector<string> list(beg, end);
    return list;
}

bool isvowel(char c)
{
    string s = "aeiouAEIOU";
    if (find(s.begin(), s.end(), c) != s.end())     return true;
    return false;
}

vector <ll> sieve(ll n)
{
    vector<bool> prime(n + 1, true);
    prime[0] = prime[1] = 0;

    for (int i = 2; i * i <= n; i++)
    {
        if (prime[i])
            for (int j = i * i; j <= n; j += i)
            {
                prime[j] = 0;
            }
    }

    vector <ll> p;

    for(int i=2; i<=prime.size();i++)
        if(prime[i])
            p.pb(i);
    
    return p;        
}

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

    return true && (n!=1);
}

int ncr(ll n, ll r) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 

    C[0] = 1; 

    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            // nCj = (n-1)Cj + (n-1)C(j-1); 
            C[j] = (C[j] + C[j-1])%MOD; 
    } 

    return C[r]; 
}

bool special(string s)
{
    for(int i=0;i<s.size();i++)
    {
        if(s[i] == ' ')
            continue;
        
        if(s[i] == '#')
            return true;
        
        else
            return false;
    }
    return false;
}

vector <ll> ans;

bool cmp(string &a, string &b)
{
    return (a.size() < b.size() )|| (a.size() == b.size() && a < b);
}

void solve()
{
    int n,m;
    cin >> n >> m;

    vector <int> v(n);
    int sum = 0;

    for(int i=0;i<n;i++)
    {
        cin >> v[i];
        sum += v[i];
    }
    
    des(v);

    if(4*m*v[m-1] < sum)
    {
        cout << "No";
    }

    else 
    {
        cout << "Yes";
    }
}

int main()
{
    fastIO
  


    int t = 1;
    // cin >> t;

    for(int i=1;i<=t;i++)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a[10000000];
int main()
{
	long long  n,minn=9999999999,maxn=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		minn=min(minn,a[i]);
		maxn=max(maxn,a[i]);
	}
	cout<<maxn-minn<<endl;
 } 

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int, int> pii;
const int mod = (int)1e9 +7;


int n,m;
vector<VI> r;
VI usd;
int rec(int z){
	//if(usd[z] !=0) return 0;
	usd[z] = 1;
	if(count(all(usd),1) ==n){
		usd[z]=0;
		return 1;
	}
	int rtn =0;
	rep(i,n) if(r[z][i]==1 && usd[i]==0) rtn += rec(i);
	usd[z] = 0;
	return rtn;
}


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

	cin >>n >>m;
	usd.assign(n,0);
	r.assign(n, VI(n,0));
	rep(i,m){
		int a,b;
		cin >>a >>b;
		r[a-1][b-1]=r[b-1][a-1]=1;
	}
	
	cout << rec(0) <<endl;
	
	return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < n; ++i)
int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> v(n);
	REP(i, n) {
		int a;
		cin >> a;
		v[i] = {a, i};
	}
	sort(v.begin(), v.end());
	REP(i, n) {
		cout << v[i].second + 1 << " ";
	}
}


Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main()
{
	int tc; cin>>tc;
	while(tc--){
		string s; cin>>s;
		int dsum=0;
		for(char c:s) dsum+=c-'0';
		
		int up=(dsum-9+8)/9;
		if(s.size()+up&1)
			cout<<"Audrey wins."<<endl;
		else
			cout<<"Fabre wins."<<endl;
	}
	
	return 0;
}

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

const int N = 107;
typedef pair<pair<string,int>,int> PSII;

vector<PSII> a(N);

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i].first.first >> a[i].first.second;
        a[i].second = i + 1;
    }
    sort(a.begin(), a.begin() + n,
            [&](PSII &p, PSII &q){
                if(p.first.first == q.first.first) return (p.first.second > q.first.second);
                return (p.first.first < q.first.first) ;//&& (p.first.second > q.first.second)
    });
    for(int i = 0; i < n; ++i){
        cout << a[i].second << endl;
    }
    return 0;
}



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


using namespace std;
#define MAXN 10000001
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
ll pro(int i){
    ll p=1;
    int g=i;
    int k,temp=spf[i];
    int count=0;
    while(i!=1){
        k=spf[i];
        if(k==temp)
        count++;
        else
        {
           
            p*=count+1;
            temp=k;
             count=1;
        }
        i/=k;
    }
    p*=count+1;
    p*=g;
    return p;
}
int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    sieve();
    int n;
    cin>>n;
    ll sum=0;
    rep(i,1,n+1){
        sum+=pro(i);
        //cout<<pro(i);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 42692
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int x,i;
  x = 1;
  i = 0;
  while(1){
    cin >> x;
    i += 1;
    if(x == 0) break;
    cout << "Case " << i << ": " << x << endl;
  }
  return 0;
}



Measured memory_bytes: 2996
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String s = sc.next();
		long wcnt = 0;
		long widx = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'W') {
				wcnt += i - widx;
				widx++;
			}
		}
		System.out.println(wcnt);
	}
}


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

using namespace std;

#define EPS 1e-10
#define equals(a, b) (fabs(a - b) < EPS)

struct Point {
    double x, y;

    Point(){}
    Point(double x, double y) : x(x), y(y) {}
 
    Point operator - (const Point &p) const {  return Point(x - p.x, y - p.y); }
};

typedef Point Vector;

double cross(const Point &a, const Point &b)
{
    return a.x * b.y - b.x * a.y;
}

struct Line {
    Point s, t;
    Line(){}
    Line(Point s, Point t) : s(s), t(t) {}
};

bool isParallelSS(const Line &s1, const Line &s2)
{
    Vector a = s1.t - s1.s;
    Vector b = s2.t - s2.s;
    return equals(cross(a, b), 0);
}

istream &operator >> (istream &is, Point &p)
{
    return is >> p.x >> p.y;
}

int main()
{
    int N;
    Line l[2];
    cin >> N;
    while (N--) {
        for (int i = 0; i < 2; i++) {
            cin >> l[i].s >> l[i].t;
        }
        cout << (isParallelSS(l[0], l[1]) ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 3168
import math
N, M = [int(i) for i in input().split(" ")]
bumbo = 2**M
kakuritu = 0
sum = 0
kakuritu_1 = 0
i = 0
a = 1
while True:
    i += 1
    kakuritu += a* 1/bumbo
    sum += i*(M*1900+(N-M)*100) *a*1/bumbo
    if 1-kakuritu < 0.000000001:
        break
    kakuritu_1 = sum
    a = a*(bumbo-1)/bumbo
print(math.ceil(sum))

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

int main(){
  int n, x;
  cin >> n >> x;
  int l[n+1], d[n+1];
  for ( int i = 1; i <= n; i++){
    cin >> l[i];
  }

  int count = 1;
  d[1] = 0;
  for ( int i = 2; i<=n+1; i++){
    d[i] = d[i-1] + l[i-1];
    if ( d[i] > x){
      break;
    }else {
      count ++;
    }
  }


  cout << count << endl;

  return 0;
}


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

using namespace std;

typedef pair<int,int> P;

int main() {
  int64_t N,K;
  cin>>N>>K;
  if(K%2==1){
    int64_t j = N/K;
    cout<<j*j*j<<endl;
  }else{
    int64_t j1 = N/K;
    int64_t ans1 = j1*j1*j1;
    int64_t j2 = (N+K/2)/K;
    int64_t ans2 = j2*j2*j2;
    cout<<ans1+ans2<<endl;
    
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main{

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int A = fs.nextInt();
        int B = fs.nextInt();
        int C = fs.nextInt();
        int K = fs.nextInt();
        int cnt = 0;
        while(A >= B){
            cnt++;
            B = B*2;
        }
        while(B >= C){
            cnt++;
            C = C*2;
        }
        if(cnt <= K) System.out.println("Yes");
        else  System.out.println("No");
    }

    static void sort(int[] a){
        ArrayList<Integer>l = new ArrayList<>();
        for(int i: a)
            l.add(i);
        Collections.sort(l);
        for(int i = 0; i < a.length; i++)
            a[i] = l.get(i);
    }

    static class FastScanner{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next(){
            while(!st.hasMoreTokens())
                try{
                    st = new StringTokenizer(br.readLine());
                } catch(IOException e){
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt(){
            return Integer.parseInt(next());
        }
        int[] readArray(int n){
            int[] a = new int[n];
            for(int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        long nextLong(){
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32812
N = gets.to_i
r = Hash.new{0}
1.upto(100){|x|
    1.upto(100){|y|
        1.upto(100){|z|
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            r[n] += 1
        }
    }
}
1.upto(N){|n|
    puts r[n]
}


Measured memory_bytes: 16696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, k;
  cin >> n >> k;
  if (k <= ceil(n / 2.0)) YES();
  else NO();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string s;
ll n, len, add_less[200100], add_more[200100], ones_less, ones_more, total_add_less, total_add_more;

void calc_adds();

int reduce(ll sum) {
    int cnt = 0;
    while (sum) {
        cnt++;
       // cout << "#" << sum << ' ' << __builtin_popcount(sum) << '\n';
        sum = sum % __builtin_popcount(sum);
    }
    return cnt;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> n >> s;
    len = s.length();
    calc_adds();

    for (int i = 0; i < len; i++) {
        if (s[i] == '0') {
            /// add more
            ll sum = total_add_more + add_more[i];
            //cout << "@ " << sum << ' ' << '\n';
            if (sum == 0) {
                if (ones_more <= 2)
                    cout << 1 << '\n';
                else
                    cout << 0 << '\n';
            } else
                cout << 1 + reduce(sum % ones_more) << '\n';
        } else {
            ll sum = total_add_less - add_less[i];
            //cout << "# " << sum << '\n';
            if (sum == 0) {
                if (ones_less == 1)
                    cout << 1 << '\n';
                else
                    cout << 0 << '\n';
            } else
                cout << 1 + reduce(sum % ones_less) << '\n';
        }
    }
    return 0;
}

void calc_adds() {
    int ones = 0;
    for (int i = 0; i < len; i++)
        ones += (s[i] == '1');
    ones_less = ones - 1;
    ones_more = ones + 1;

    if (ones != 1) {
        int p_less = 1;
        for (int i = len - 1; i >= 0; i--, p_less = p_less * 2 % ones_less) {
            add_less[i] = p_less;
            if (s[i] == '1')
                total_add_less += p_less;
        }
    }
    int p_more = 1;
    for (int i = len - 1; i >= 0; i--, p_more = p_more * 2 % ones_more) {
        add_more[i] = p_more;
        if (s[i] == '1')
            total_add_more += p_more;
    }
}



Measured memory_bytes: 6816
#include <bits/stdc++.h>
using namespace std;
bool ng[10];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int a;
		cin >> a;
		ng[a] = true;
	}
	auto is_ng = [](int n) {
		while (n)
		{
			if (ng[n % 10])
			{
				return true;
			}
			n /= 10;
		}
		return false;
	};
	while (is_ng(n))
	{
		n++;
	}
	cout << n << endl;
}

Measured memory_bytes: 256
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

read = sys.stdin.buffer.read

a, b, c, k = map(int, read().split())
for i in range(k):
    if a >= b:
        b *= 2
    elif b >= c:
        c *= 2
if a < b and b < c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 65424
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,k;
  cin >> n >> k;
  printf("%lld",POW(k-1,n-1)*k);
}

Measured memory_bytes: 256
// RAM RAM
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define bg begin()
#define ed end()
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55
const int MOD=1000000007;
using namespace std;
     
     
string to3(int n){
    string res="";
    while(n>0){
    	res.pb(n%3 + '0');
    	n/=3;
    }
    res.pb('0');
    reverse(res.bg,res.ed);
    return res;
}
    bool isGood(int n){
     
    	while(true){
    		//cout<<n<<endl;
    		while(n%3==0 && n!=0){
    			n=n/3;
    		}
    		if(n>0){
    			n=n-1;
    		}else if(n==0){
    			break;
    		}else{
    			return false;
    		}
    		if(n%3!=0){
    			return false;
    		}
    	}
    	return true;
    }


int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
    	

    // int t;cin>>t;
    // while(t--){

    // }
     
    char a,b;cin>>a>>b;

    if(a=='H'){
    	if(b=='H'){
    		cout<<"H"<<endl;
    	}else{
    		cout<<"D"<<endl;
    	}
    }else{
    	if(b=='H'){
    		cout<<"D"<<endl;
    	}else{
    		cout<<"H"<<endl;
    	}
    }
  	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    key = a[i]
    j = i - 1
    while j >= 0 and a[j] > key:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = key
    print(" ".join(map(str, a)))



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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m, q;
int a[100005];
int b[200005];
int last[200005];
bool used[200005];
int cnt;

void corr(int *a, int &cnt) {
    memset(last, -1, sizeof last);
    forn(i, cnt) used[i] = true;
    forn(i, cnt) {
        if (last[a[i]] != -1) {
            used[last[a[i]]] = false;
        }
        last[a[i]] = i;
    }
    int ncnt = 0;
    forn(i, cnt) if (used[i]) {
        a[ncnt++] = a[i];
    }
    cnt = ncnt;
    reverse(a, a + cnt);
    forn(i, n) if (last[i] == -1) {
        a[cnt++] = i;
    }
}

int pos[100000] = {};
set<int> where[100000];

int main() {
    //freopen("input.txt", "r", stdin);
    scanf("%d%d%d", &n, &m, &q);
    forn(i, q) scanf("%d", a + i), --a[i];
    forn(i, m) b[i] = m - 1 - i;
    cnt = m;
    forn(i, q) b[cnt++] = a[i];
    corr(b, cnt);
    while (cnt > 1 && b[cnt - 1] > b[cnt - 2]) {
        --cnt;
    }
    --cnt;
    if (cnt == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    reverse(a, a + q);
    forn(i, n) {
        pos[i] = 0;
        where[b[0]].insert(i);
    }
    forn(i, q) {
        int val = a[i];
        if (!where[val].empty()) {
            int ind = *where[val].begin();
            where[val].erase(where[val].begin());
            ++pos[ind];
            if (pos[ind] < cnt) {
                where[b[pos[ind]]].insert(ind);
            }
        }
    }
    forn(i, n) if (pos[i] != cnt) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m;
    cin>>n>>m;
    int cnt=1;
    while(n--)
    {
       if(cnt+cnt<cnt+m)
       {
           cnt+=cnt;
       }
       else
       {
           cnt+=m;
       }
    }
    cout<<cnt<<NL;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  
	public static void main(String[] args) {
      
  		Scanner scanner = new Scanner(System.in);
  
  		int A = scanner.nextInt();
  		int B = scanner.nextInt();
  		int C = scanner.nextInt();
  
  		if( A * B * C == 175 ){
    		System.out.println("YES");
  		} else {
    		System.out.println("NO");
  		}
      
    }  
  
}



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

using namespace std;

int arr[600][600] ;

int main()
{
    int n , m , q ;
    cin>>n>>m>>q ;
    map<int , int>mp ;
    int cnt = 0 ;
    vector<pair<int , int> >vp ;
    for(int i = 0 ; i < m ; ++i)
    {
        int x , y ;
        cin>>x>>y ;
        vp.push_back({y , x});
    }
    sort(vp.begin() , vp.end());
    for(int i = 0 ; i < m ; ++i)
    {
        int x = vp[i].second , y = vp[i].first;
        arr[x][y]++;
        for(int j  = y+1 ; j <= n ; ++j)
            arr[x][j] = arr[x][j-1] + (y == j);
    }
    for(int i = 0 ; i < q ; ++i)
    {
        map<int , int>mp2 ;
        int x , y ;
        cin>>x>>y ;
        int ans = 0 ;
        for(int j = x ; j <= y ; ++j)
        {
            ans += arr[j][y] ;
        }
        cout<<ans<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
ll x,k,d;
ll ans;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> x >> k >> d;
    x = abs(x);
    ll n = min(k, x / d);
    k -= n;
    x -= n * d;
    
    if(k & 1) cout << d - x;
    else cout << x;
  
	return 0;
}


Measured memory_bytes: 3664
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int a = 0;
        int b = 0;

        for(int i=0; i<M; i++){
            if(sc.nextInt()<X){
                a += 1;
            }
            else{
                b += 1;
            }
        }
        if(a<=b){
            System.out.println(a);
        }
        else{
            System.out.println(b);
        }
    } 
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef pair<int,int> P;
//typedef long long int ll;

int ans;
int a[11111],b[11111];

signed main(){

	int n;
	string s[11111];
	cin>>n;
	rep(i,n){
		cin>>s[i];
	}
	rep(i,n){
		if(s[i][0]=='B')b[i]=1;
		if(s[i][s[i].size()-1]=='A')a[i]=1;
		rep(j,s[i].size()){
			if(j==s[i].size()-1)continue;
			if(s[i][j]=='A' && s[i][j+1]=='B')ans++;
		}
	}
	int co=0,co2=0,co3=0;
	rep(i,n){
		if(a[i] && b[i]){co++;}
		else if(a[i])co2++;
		else if(b[i])co3++;
	}
	if(co!=0)cout<<co-1+min(co2,1)+min(co3,1)+min(max(co2-1,0),max(co3-1,0))+ans<<endl;
	else cout<<min(co2,co3)+ans<<endl;
}


Measured memory_bytes: 896
#include <iostream>
 
using namespace std;
typedef long long ll;
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(decltype(n) i=(a); i<(n); i++)

int N;
int a[100010];

int main() {
    cin >> N;
    ll total = 0;
    REP(i, 1, N+1){
        cin >> a[i];
        total += abs(a[i-1] - a[i]);
    }
    total += abs(a[N]);
    REP(i, 1, N+1){
        cout << total - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]) - abs(a[i-1]-a[i+1])) <<endl;
    }
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;
int countFive, countSeven;

void check(int input) {
	if (input == 5) {
		countFive++;
	}
	else if (input == 7) {
		countSeven++;
	}
}

int main() {
	int input = 0;
	cin >> input;
	check(input);
	cin >> input;
	check(input);
	cin >> input;
	check(input);

	if (countFive == 2 && countSeven == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    mod=10**9+7
    stone_last_pos=[-1]*(2*10**5+1)
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(1,n+1):
        c=int(input())
        place=stone_last_pos[c]
        if place==i-1 or place==-1:
            dp[i]=dp[i-1]
        else:
            dp[i]=(dp[i-1]+dp[place])%mod
        stone_last_pos[c]=i
    print(dp[n])


if __name__=='__main__':
    main()

Measured memory_bytes: 12532
n,m=map(int,input().split())

a=list(map(int,input().split()))


s=0
b=1/(4*m)

for i in range(n):

    if a[i]< sum(a)*b:

        pass

    else:
        s+=1

if s >= m:

    print("Yes")

else:
    print('No')


Measured memory_bytes: 2940
R,G,B,n=map(int,input().split())
ans=0
for r in range(((n+1)//R)+1):
    for g in range(((n+1)//G)+1):
        if ((n-r*R - g*G)%B)== 0 and (n-r*R-g*G)>=0:
            ans+=1
print(ans)


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N,K;cin>>N>>K;
    vector<int> S(N),dp(2*N,1500000000);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    dp[0]=0;
    for(int i=0;i<N;i++){
        for(int j=1;j<=K;j++){
        dp[i+j]=min(dp[i]+abs(S[i+j]-S[i]),dp[i+j]);
        }
    }
    cout<<dp[N-1]<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 9e18

ll n,k;
ll x[101],y[101];
ll sum[101][101];

int main(){
	cin>>n>>k;
  vector<ll> xs,ys;
  rep(i,n){
    cin>>x[i]>>y[i];
    xs.push_back(x[i]);
    ys.push_back(y[i]);
  }
  sort(all(xs));
  uni(xs);
  sort(all(ys));
  uni(ys);
  ll xn=xs.size(),yn=ys.size();
  rep(k,n){
    ll i=lower_bound(all(ys),y[k])-ys.begin();
    ll j=lower_bound(all(xs),x[k])-xs.begin();
    sum[i+1][j+1]++;
  }
  rep(i,yn+1)rep(j,xn)sum[i][j+1]+=sum[i][j];
  rep(i,yn)rep(j,xn+1)sum[i+1][j]+=sum[i][j];

  ll res=INF;
  rep(a,yn)rep(b,xn)rep(c,a)rep(d,b){
    if(sum[a+1][b+1]-sum[c][b+1]-sum[a+1][d]+sum[c][d]!=k)continue;
    minch(res,(ys[a]-ys[c])*(xs[b]-xs[d]));
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
m = list(map(int,input().split()))   
ctr = Counter(m)
all = 0
def f(n):
    return n*(n-1)//2

for i in ctr.values():
    all += f(i)

ans = []
for j in m:
    ans.append(all - ctr[j] +1)

print(*ans, sep = '\n')

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

using namespace std;

#define int long long

const int N = 200005;
int n, a[N], ans;

signed main () {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (i > 1 && a[i] - a[i - 1] > 1) return cout << -1, 0;
    }
    if (a[1] > 0) return cout << -1, 0;
    for (int i = n; i; --i) {
        if (i == n || a[i + 1] != a[i] + 1) ans += a[i];
    }

    cout << ans;

    return 0;
}


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

#define MAXN 1299710

bool p[MAXN];

int main() {

int i, j, N;

memset(p, true, sizeof(p));;
for (i=2; i<MAXN; i++) {
   if (p[i] == true) {
		for (j=2*i; j<MAXN; j+=i) {
			p[j] = false;
		}
	}
}

cin >> N;

do {

i = N; while (p[i] == false) i++;
j = N; while (p[j] == false) j--;

cout << i-j << endl;

cin >> N;

} while (N!=0);

return 0;
}

Measured memory_bytes: 2436
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#define all(x) x.begin(), x.end()
#define rep(n) for (int i=0; i<n; ++i)

using namespace std;

int main(void){
  int r, g, b;
  cin >> r >> g >> b;
  int concat = 100*r + 10*g + b;
  if (concat % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

# N,Cを取得
n, c = map(int, input().split())

# x1, v1..xN, vNを取得
xs = []
vs = []
for _i in range(n):
    x, v = map(int, input().split())
    xs.append(x)
    vs.append(v)

r1, r2, l1, l2 = [[], [], [], []]
r_sum, l_sum = [0, 0]
for i in range(n):
    r_sum += vs[i]
    r1.append(r_sum - xs[i])
    r2.append(r_sum - 2 * xs[i])

    i_rev = n - i - 1
    l_sum += vs[i_rev]
    l1.append(l_sum - (c - xs[i_rev]))
    l2.append(l_sum - 2 * (c - xs[i_rev]))

r1_max, r2_max = [0, 0]
l1_max, l2_max = [0, 0]
r1_maxs, r2_maxs = [[0], [0]]
l1_maxs, l2_maxs = [[0], [0]]
for i in range(n):
    r1_max = max(r1_max, r1[i])
    r1_maxs.append(r1_max)
    r2_max = max(r2_max, r2[i])
    r2_maxs.append(r2_max)
    l1_max = max(l1_max, l1[i])
    l1_maxs.append(l1_max)
    l2_max = max(l2_max, l2[i])
    l2_maxs.append(l2_max)

r1_l2_max = 0
l1_r2_max = 0
for i in range(0, n + 1):
    r1_l2_max = max(r1_l2_max, r1_maxs[i] + l2_maxs[n - i])
    l1_r2_max = max(l1_r2_max, l1_maxs[i] + r2_maxs[n - i])

total_max = max(r1_l2_max, l1_r2_max)

# 結果を出力
print("{}".format(total_max))


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

int main() {
  string S, T;
  cin >> S >> T;
  
  for( int i = 0; i < S.size(); i++ ){
    if( S == T ){
      cout << "Yes" << endl;
      return 0;
    }
    S = S.back() + S.substr(0,S.size()-1);
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    ll n,res=1;
    string s;
    cin >> n >> s;
    for(int i = 0;i<n-1;i++){
        if(s[i]!=s[i+1]){
            res++;
        }
    }
    cout << res << endl;

}


Measured memory_bytes: 3656
#include<stdio.h>
int main(void){
    int ans;
    int i,j,k,l,m,n;
    while(1){
        int d,w;
        ans=0;
        scanf("%d%d",&d,&w);
        if(d==0 && w==0) break;
        int e[d][w];
        for(i=0; i<d; i++){
            for(j=0; j<w; j++){
                scanf("%d",&e[i][j]);
            }
        }
        for(i=0; i<d-2; i++){
            for(j=i+2; j<d; j++){
                for(k=0; k<w-2; k++){
                    for(l=k+2; l<w; l++){
                        int min=10;
                        int in=0;
                        int x=0;
                        for(m=i; m<=j; m++){
                            for(n=k; n<=l; n++){
                                if(m==i || m==j ||n==k ||n==l){
                                    if(e[m][n]<min) min=e[m][n];
                                }
                            }
                        }
                        int max=0;
                        for(m=i+1; m<j; m++){
                            for(n=k+1; n<l; n++){
                                if(e[m][n]>max) max=e[m][n];
                                in+=e[m][n];
                                x++;
                            }
                        }
                        int tmp;
                        if(min>max && (tmp=(min*x-in)) > ans){
                            ans=tmp;
                        }
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 2052
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	long long N, Ln,Ln1,ans;

	cin >> N;

	Ln = 2;
	Ln1 = 1;
	for (long long i = 1; i < N; i++) {
		ans = Ln + Ln1;
        Ln = Ln1;
		Ln1 = ans;
	}

	if (N == 0) {
		cout << 2 << endl;
	}
	else if(N == 1) {
		cout << 1 << endl;
	}else{
		cout << ans << endl;
    }

	return 0;
}

Measured memory_bytes: 256